
	var timerT = false;

	function imgCancel(img) {
		clearTimeout(timerT);
	}

	function imgHover(img,accountID) {
		//clear prvious timers

		if(timerT) {
			clearTimeout(timerT);
		}
		var currentImageStr =  document.getElementById(img.id).src;
		var currentImageArr = currentImageStr.split("/");
		var currentImageLen = currentImageArr.length;
		currentImageLen  = currentImageLen - 1;
		var currentImage = currentImageArr[currentImageLen];
	

		var box = document.getElementById('catDisplay' + img.id);
		if (! box)return;

		var pop = document.getElementById('popup');

		if (! pop)return;

		var popshadow = document.getElementById('popupshadow');
		var popimage = document.getElementById('popupimage');
		var poplink = document.getElementById('popuplink');
		var infolink = document.getElementById('popupInfo');
		var cartlink = document.getElementById('popupCartLink');

		// reset any previous stuff that was set.
		pop.style.display = 'none';
		popimage.src = '/images/spacer.gif';

		var href = document.getElementById('href' + img.id);
		var cartHref = document.getElementById('cart' + img.id);

		poplink.href = href.href;
		infolink.href = href.href;
		cartlink.href = cartHref.value;

		var smallH = parseFloat(img.style.height);
		var smallW = parseFloat(img.style.width);

		// Adjust height and width based on current image
		if(smallH > smallW) {
			var medH = '270'
			var medW = parseInt((270/110) * smallW);
			var adjW = 50;

			// center the image + 20 for shading and padding
			var adjP = parseInt( (medW + 10) );
			var adjW = parseInt( (270 - adjP - 10) / 2 ) - 30;

			//alert(smallW);
			//alert(adjP);

		} else {
			var medW = '270'
			var medH = parseInt((270/110) * smallH);
			var adjP = 300;
			var adjW = 40;
		}
		var contain = document.getElementById('popupcontain');
		pop.style.width = parseFloat(img.style.width)*3;

		// and position the box
		var top = objGetRealTop(box);
		pop.style.top = (top - (smallH/2) + 5) + 'px';
		var left = objGetRealLeft(box);
		pop.style.left = (left - (smallW/2) - adjW) + 'px';

		popimage.style.width  = '300px';
		popimage.style.height = '225px';

		// set some information in the box
		var titleF = document.getElementById('title' + img.id);
		var titleT = document.getElementById('popuptitle');
		titleT.innerHTML = titleF.innerHTML;

		// pass the price to the popup
		var priceF = document.getElementById('price' + img.id);
		var priceT = document.getElementById('popupprice');
		priceT.innerHTML = priceF.innerHTML;


		// Not used right now.. 
		//var descT = document.getElementById('popupdesc');
		//descT.innerHTML = img.alt;
		popimage.src = '/clients/' + accountID + '/products/' + currentImage;
		//popimage.src = path_from_id(img.id, 'medium');

		// delay to prevent the user gettting popups while moving the mouse
		timerT = setTimeout("delayShow()", 200);

	}

	function delayShow(imgsrc) {

		// clear the timer
		clearTimeout(timerT);

		// set the image
		//var popimage = document.getElementById('popupimage');
		//popimage.src = imgsrc;

		// and show the area.
		var pop = document.getElementById('popup');
		pop.style.display = 'block';
	}

	function path_from_id(id, size) {
		var path = '/thumbs/';

		var a = new String(parseInt(id)).split('');
		if(a.length > 3 ) {
			for(var i=a.length; i>3; i--) a.pop();
			a.reverse();
			path +=  a.join('/')  + '/';
		}

		return  path +  size + '/' + id + '.jpg' ;
	}
