/**
 * Display and hide popup dynamically
 ******/


var image = new Image();
var imgWidth, imgHeight;
var timerID, timeoutID;

function DisplayDPopUp(imgsrc, width, height) {
	if (document.all) { // only IE
		var pane = document.all['imagepane'];
		if (pane) {		
			var xpos = event.x + document.body.scrollLeft;
			var ypos = event.y + document.body.scrollTop;
		
			pane.innerHTML = '<table border="0" width="100%" height="100%"><tr><td align="center" valign="middle">Loading image...</td></tr></table>';
			pane.style.width = '130px';
			pane.style.height = '130px';
		
			imgsrc = imgsrc.replace("130x130", "260x260");
			image.src = imgsrc;			
			imgWidth = image.width;
			imgHeight = image.height;

			if (event.y + imgHeight > document.body.clientHeight) {
				ypos -= imgWidth; 
			}
			if (event.x + imgWidth > document.body.clientWidth) {
				xpos -= imgWidth; 
			}

			pane.style.top = ypos;
			pane.style.left = xpos;
 			
			timerID = window.setInterval("LoadImage('" + imgsrc + "')", 100);
			
			document.body.onmousedown = HideDPopUp;

			pane.style.visibility = 'visible';
		}
	}
}

function LoadImage(imgsrc) {

	if (document.all) {
		if ((image.readyState == 'complete' || image.readyState == 4)) { 
			document.all['imagepane'].innerHTML = '<img src="' + imgsrc + '" width="' + image.width + '" height="' + image.height + '"></a>';
			if (timerID)
				window.clearInterval(timerID);
			timerID = null;
		}
	}
}

function HideDPopUp() {
	if (document.all) {
		if (timerID) 
			clearInterval(timerID);
		timerID = null;

		document.all['imagepane'].style.visibility = 'hidden';
		image = new Image();
		document.body.onmousedown = null;
	}
}

function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString =
strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return strReturn;
}


function setImage(obj,refimg){
    var imgName = refimg.src.replace('?h=45','');
    document[obj].src = imgName;
	var largeimg = imgName;	
		
    if (refimg.large=='true')  // 
    {
		document[obj].className='ImageLink';
		document[obj].title=imageDesc.innerText; 	
		imageDesc.style.display = 'inline';		
		largeimg = imgName.replace('.jpg','_large.jpg');	
		document[obj].large='true';
    }
     else {
		document[obj].className='productimage';
		document[obj].title='';    
		imageDesc.style.display = 'none';
		document[obj].large='false';
		largeimg = '';
    }    
	window.status = largeimg;
    try {
        var o = document.getElementById('lrgLnk');
		o.href = largeimg;		
	}
    catch(e){}
}