﻿/* 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=[]

		tooltips[0]=["images/rolltext/br320.jpg", "Shotgun - Target - BR320 - MSRP $3,478.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[1]=["images/rolltext/S790EL.jpg", "Shotgun - Target - S790EL - MSRP $7,885.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[2]=["images/rolltext/S2000.jpg", "Shotgun - Target - S2000 - MSRP $4,613.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[3]=["images/rolltext/Vertex.jpg", "Shotgun - Target - Vertex - MSRP $2,475.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[4]=["images/rolltext/ARTEMIS-classic.jpg", "Shotgun - Field - Artemis Classic - MSRP $3,535.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[5]=["images/rolltext/ARTEMIS-delux.jpg", "Shotgun - Field - Artemis Deluxe - MSRP $6.499.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[6]=["images/rolltext/ARTEMIS-sa.jpg", "Shotgun - Field - Artemis Small Action - MSRP $4,210.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[7]=["images/rolltext/Aurum-Classic.jpg", "Shotgun - Field - Aurum Classic - MSRP $2,943.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[8]=["images/rolltext/Aurum-sa.jpg", "Shotgun - Field - Aurum Small Action - MSRP $3,407.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[9]=["images/rolltext/aurum-teutonic.jpg", "Shotgun - Field - Aurum Teutonic - MSRP $3,194.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[10]=["images/rolltext/omnium.jpg", "Shotgun - Field - Omnium - MSRP $2,048.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[11]=["images/rolltext/ROUND-BODY-EM-2.jpg", "Shotgun - Field - Inverness Round Body Standard - MSRP $4.985.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[12]=["images/rolltext/Artemis-EL.jpg", "Shotgun - Premium - Artemis EL - MSRP $18,750.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[13]=["images/rolltext/S-782-EMEL.jpg", "Shotgun - Premium - S 782 EMEL - MSRP $15,565.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[14]=["images/rolltext/S-790-EMEL.jpg", "Shotgun - Premium - S 790 EMEL - MSRP $11,875.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[15]=["images/rolltext/S-792-EMEL.jpg", "Shotgun - Premium - S 792 EMEL - MSRP $14.250.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[16]=["images/rolltext/S-780-EMEL.jpg", "Shotgun - Premium - S 780 EMEL - MSRP $14.470.00", {background:"white", font:"bold 12px Arial"}]		
		tooltips[17]=["images/rolltext/Wild-Express.jpg", "Rifles - Wild Express - MSRP $5,754.00", {background:"white", font:"bold 12px Arial"}]	
		tooltips[18]=["images/rolltext/Express-90L.jpg", "Rifles - Express 90L - MSRP $5,355.00", {background:"white", font:"bold 12px Arial"}]	
		tooltips[19]=["images/rolltext/EXPRESS-92.jpg", "Rifles - Express 92EL - MSRP $12.548.00", {background:"white", font:"bold 12px Arial"}]	
		tooltips[20]=["images/rolltext/ROUND-BODY-EL-DX.jpg", "Shotgun - Field - Inverness Round Body Deluxe - MSRP $6,078.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[21]=["images/rolltext/ROUND-BODY-EL-DX.jpg", "Shotgun - Field - Inverness Round Body Deluxe SA - MSRP $6.685.00", {background:"white", font:"bold 12px Arial"}]
		tooltips[22]=["images/rolltext/ROUND-BODY-EM-2.jpg", "Shotgun - Field - Inverness Round Body Standard SA- MSRP $5,629.00", {background:"white", font:"bold 12px Arial"}]
		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:center"><img src="' + tipinfo[0] + '" /></div>'
				+ ((tipinfo[1])? '<div style="text-align:left; margin-top:5px">'+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]")
