/*
 * jQuery clueTip plugin
 * Version 1.0.4  (June 28, 2009)
 * @requires jQuery v1.2.6+
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
 
/*
 *
 * Full list of options/settings can be found at the bottom of this file and at http://plugins.learningjquery.com/cluetip/
 *
 * Examples can be found at http://plugins.learningjquery.com/cluetip/demo/
 *
*/

/*
 * Global defaults for clueTips. Apply to all calls to the clueTip plugin.
 *
 * @example $.cluetip.setup({
 *   insertionType: 'prependTo',
 *   insertionElement: '#container'
 * });
 * 
 * @property
 * @name $.cluetip.setup
 * @type Map
 * @cat Plugins/tooltip
 * @option String insertionType: Default is 'appendTo'. Determines the method to be used for inserting the clueTip into the DOM. Permitted values are 'appendTo', 'prependTo', 'insertBefore', and 'insertAfter'
 * @option String insertionElement: Default is 'body'. Determines which element in the DOM the plugin will reference when inserting the clueTip.
 *
 */


$(document).ready( function()
{
   PEPS.rollover.init();
    //$("#welthmanagement_image").tooltip(); 
    //$('#welthmanagement_image').cluetip({splitTitle: '|',showTitle: false,positionBy:'bottomTop'});
    //$('#investment_image').cluetip({splitTitle: '|',showTitle: false,positionBy:'bottomTop'});
    //$('#advance_planing_image').cluetip({splitTitle: '|',showTitle: false,positionBy:'bottomTop'});
    //$('#personal_image').cluetip({splitTitle: '|',showTitle: false,positionBy:'bottomTop'});    
			$('.ro').each(function () 
			{
				t=$(this).attr('title');
				$(this).removeAttr( 'title' );
				$(this).attr('title1',t);
				$('#sitemain').append('<div class="cluetip" style="display:none;position: absolute;" id="tip_'+ this.id +'"><div style="overflow: visible; position: relative; z-index: 97; height: auto;" class="cluetip-outer"><div class="cluetip-inner" id="cluetip-inner_'+ this.id +'"></div></div></div>');
			});
});

PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); 
         	$("#cluetip-inner_"+this.id).html($(this).attr( 'title1'));         	
         	var p=$("#" + this.id);         	
         	//alert(p.outerHeight());
         	$("#tip_"+ this.id).css("left",p.offset().left - p.outerWidth() - 20);
         	$("#tip_"+ this.id).css("top",p.offset().top + p.outerHeight() + 10);
         	$("#tip_"+ this.id).show();
         },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); 
         	$("#tip_"+ this.id).fadeOut("slow");
         }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_hover' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_hover\./, '.');
   }
};