
$(document).ready( function(){
	tooltip.init();
});


var qTipTag = "input"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 30; //This is qTip's X offset//
var qTipY = 0; //This is qTip's Y offset//


//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
		$('body').append('<div id="'+ tipContainerID +'"></div>');
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;
	
	
	$('a.product-img, a.product-list-img').each(function(idx,a){
			//sTitle = a.firstChild.getAttribute('src');
			sTitle = $(a).children('img').attr('src');
			if(sTitle) {
				a.setAttribute("tiptitle", sTitle);
				a.onmouseover = function(evt) {
					tooltip.show(this.getAttribute('tiptitle'));
					//tooltip.move();				
				};
				a.onmouseout = function() {tooltip.hide()};
				a.onclick = function() {tooltip.hide(evt)};
			}
	});
	
	
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
	
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
	
		x = evt.pageX;
		y = evt.pageY;
		
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = '<img src="' + text + '&wtooltip=242&htooltip=242" />';
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}




