function getAbsolutePos(el) {
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}
function addEvent(el, evname, func) {
	if (el.attachEvent) { // IE
		el.attachEvent("on"+evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el[evname] = func;
	}
}
function removeEvent(el, evname, func) {
	if (el.detachEvent) { // IE
		el.detachEvent("on" +evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el[evname] = null;
	}
}
function removeChild(elm) {
	if ( elm.hasChildNodes() ) {
		while ( elm.childNodes.length >= 1 ) { elm.removeChild( elm.firstChild ); } 
	} 
}
function popup(name,URL,width,height,location, menubar,resizable,scrollbars,status,titlebar,toolbar){
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   if(!location) location = 0; if(!menubar)menubar=0; if(!resizable) resizable = 0; if(!scrollbars) scrollbars = 0;
   if(!status) status = 0; if(!titlebar) titlebar = 0; if(!toolbar) toolbar = 0;  
   var rwin;
   var command = "location="+location +",menubar="+menubar+",resizable="+resizable+",scrollbars="+scrollbars+",status="+status+",titlebar="+titlebar+",toolbar="+toolbar+", top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   rwin = window.open(URL,name,command);   
 	if(name=='window1')
		window.top.popupStorage = rwin;
	else if(name=='window2')
		window.top.popupStorage1 = rwin;
	else if(name=='window3')
		window.top.popupStorage2 = rwin;		
  if(window.focus)
  	rwin.focus();
} // end popup
function close_popups()
{
		if(typeof(window.top.popupStorage) !='undefined')
			window.top.popupStorage.close();
		if(typeof(window.top.popupStorage1) !='undefined')
			window.top.popupStorage1.close();
		if(typeof(window.top.popupStorage2) !='undefined')
			window.top.popupStorage2.close();
			
}
function LINK_TO_PRODUCT(itemNo)
{
	location.href = 'product_detail.php?ID='+itemNo;
}
