/* Image w/ description tooltip v2.0
* Created: April 23rd, 2010. This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/


var ddimgtooltip={

	tiparray:function(){
		var tooltips=[]
		//define each tooltip below: tooltip[inc]=['path_to_image', 'optional desc', optional_CSS_object]
		//For desc parameter, backslash any special characters inside your text such as apotrophes ('). Example: "I\'m the king of the world"
		//For CSS object, follow the syntax: {property1:"cssvalue1", property2:"cssvalue2", etc}

		tooltips[0]=["images/Stem-Kine_title.png","Stem-Kine Capsules have been clinically proven to increase circulating stem cells.  Studies have demonstrated a positive correlation between the number of circulating stem cells and health, wellness and regenerative capabilities.  Through stimulating the release of these circulating cells, Stem-Kine may heighten regenerative capabilities.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[1]=["images/C-Statin_title.png","C-Statin Capsules have been shown to support normal angiogenesis.  Recruitment of new blood vessels plays a crucial role in abnormal cell growth and survival.  A non-toxic extract isolated from bindweed, proteoglycan extract (PGM) has been shown to inhbit new blood vessel growth and abnormal cell growth.  C-Statin contains high concentrations of active PGMs.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[2]=["images/C-Statin_2_title.png","C-Statin II Capsules are an all-natural nutritional supplement intended to be used with C-Statin to help further support normal angiogenesis.  C-Statin II contains a variety of antioxidants and other ingredients that have been demonstrated to inhibit angiogenesis and inhibit abnormal cell proliferation.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[3]=["images/Imm-Kine_title.png","Imm-Kine Capsules contain a proprietary immune stimulation formula shown to boost your immune stimulation and increase athletic performance.  Imm-Kine induces a non-specific immune system response through activating macrophages, dendritic cells, and promoting the priming and differentiation of CD8+ T Cells.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[4]=["images/IVC-Max_title.png","IVC-Max is a potent vitamin C potentiator.  IVC-Max is intended to be used in conjunction with intravenous vitamin C therapy to help potentiate the health-related effects of vitamin C.  IVC-Max may be used in conjunction with C-Statin, Imm-Kine, and intravenous vitamin C therapy for a fully integrated approach.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[5]=["images/Nattokinase_title.png","Nattokinase is an enzyme derived from boiled soybeans and Bacillus natto.  Research has shown nattokinase supports the body in breaking up and dissolving unhealthy coagulation of blood.  Nattokinase also strongly supports fibrinolytic activity.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[6]=["images/Prostate-Res_title.png","Prostate-Res is a synergistic blend of high quality herbal extracts based on an ancient Chinese remedy.  Prostate-Res was based on the clinical success of PC-SPES and also contains additional ingredients shown to further support prostate health.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[7]=["images/Flitetabs_title.png","Flite Tabs are used to support deep vein health and aid in the reduction of swelling during long-term airplane flights.  Deep vein thrombosis (DVT) is a leading cause of death due to strokes in the United States.  In a randomized, controlled study of subjects on international long-haul flights, Flite Tabs significantly promoted vein health and reduction of leg swelling.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]
		tooltips[8]=["images/Veincaps_title.png","Vein Caps are an economic alternative to Flite Tabs and are used to help reduce inflammation, swelling and pain associated with deep vein thrombosis (DVT) and edema.  Vein Caps contains ingredients known to reduce inflammation and thin the blood.", {background:"#bab7b1", padding: "10px", width:"300px", height: "200px"}]

		return tooltips //do not remove/change this line
	}(),

	tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips

	//***** NO NEED TO EDIT BEYOND HERE

	tipprefix: 'imgtip', //tooltip ID prefixes

	createtip:function($, tipid, tipinfo){
		if ($('#'+tipid).length==0){ //if this tooltip doesn't exist yet
			return $('<div id="' + tipid + '" class="ddimgtooltip" />').html(
				'<div style="text-align:left; padding: 10px 10px 10px 10px;"><img src="' + tipinfo[0] + '" /></div>'
				+ ((tipinfo[1])? '<div style="text-align:left; margin: 10px 10px 10px 10px;">'+tipinfo[1]+'</div>' : '')
				)
			.css(tipinfo[2] || {})
			.appendTo(document.body)
		}
		return null
	},

	positiontooltip:function($, $tooltip, e){
		var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1]
		var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(), 
		x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(ddimgtooltip.tooltipoffsets[0]*2) : x
		y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y
		$tooltip.css({left:x, top:y})
	},
	
	showbox:function($, $tooltip, e){
		$tooltip.show()
		this.positiontooltip($, $tooltip, e)
	},

	hidebox:function($, $tooltip){
		$tooltip.hide()
	},


	init:function(targetselector){
		jQuery(document).ready(function($){
			var tiparray=ddimgtooltip.tiparray
			var $targets=$(targetselector)
			if ($targets.length==0)
				return
			var tipids=[]
			$targets.each(function(){
				var $target=$(this)
				$target.attr('rel').match(/\[(\d+)\]/) //match d of attribute rel="imgtip[d]"
				var tipsuffix=parseInt(RegExp.$1) //get d as integer
				var tipid=this._tipid=ddimgtooltip.tipprefix+tipsuffix //construct this tip's ID value and remember it
				var $tooltip=ddimgtooltip.createtip($, tipid, tiparray[tipsuffix])
				$target.mouseenter(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.showbox($, $tooltip, e)
				})
				$target.mouseleave(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.hidebox($, $tooltip)
				})
				$target.mousemove(function(e){
					var $tooltip=$("#"+this._tipid)
					ddimgtooltip.positiontooltip($, $tooltip, e)
				})
				if ($tooltip){ //add mouseenter to this tooltip (only if event hasn't already been added)
					$tooltip.mouseenter(function(){
						ddimgtooltip.hidebox($, $(this))
					})
				}
			})

		}) //end dom ready
	}
}

//ddimgtooltip.init("targetElementSelector")
ddimgtooltip.init("*[rel^=imgtip]")
