// JavaScript Document
//m.budi.s@hotmail.com
var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
var scrollbarwidth= 16;
function centerDiv(divobj){ //Centers a div element on the page
var curposx,curposy;
var ie=document.all && !window.opera;
var dom=document.getElementById;
var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
var docwidth=(ie)? standardbody.clientWidth : window.innerWidth-scrollbarwidth;
var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
var docheightcomplete=(standardbody.offsetHeight>standardbody.scrollHeight)? standardbody.offsetHeight : standardbody.scrollHeight; //Full scroll height of document
var objwidth=divobj.offsetWidth ;//width of div element
var objheight=divobj.offsetHeight; //height of div element
var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px"; //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
curposx = docwidth/2-objwidth/2;
curposy = Math.floor(parseInt(topposition));
//if(curposx > 10){
//divobj.style.left=docwidth/2-objwidth/2+"px"; //Center div element horizontally
//}else{
if(window.event){
	if(window.event.x  < curposx)
	{
		curposx = window.event.x + objwidth/4;
	//divobj.style.left=  (window.event.x + objwidth/2 + "px";
	}else{
		//divobj.style.left=  window.event.x - objwidth/2 + "px";
		curposx = window.event.x - objwidth - 20;
	}
	divobj.style.left= curposx + "px";
}else{
divobj.style.left= docwidth/2-objwidth/2 + "px";	
}
//}
//if(curposy > 10){
//divobj.style.top=Math.floor(parseInt(topposition))+"px";
//}else{
if(window.event){	
	if((window.event.y+objheight) > screen.height)
	{
		curposy = window.event.y + objheight;
	//divobj.style.top= (window.event.y + 300) + "px";
	}else{
		curposy = window.event.y - objheight;
		//divobj.style.top= (window.event.y - 300) + "px";
	}
	if(curposy < 10){
		curposy = 10;
	}
	divobj.style.top = curposy + "px";
}else
{
divobj.style.top=Math.floor(parseInt(topposition))+"px";	
}
//}
divobj.style.visibility="visible";
}
var xmlHttp
function showProduct(url)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }else{
	centerDiv(document.getElementById("imgloading"));
  }
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{
//display product
document.getElementById("imgloading").style.visibility="hidden";
document.getElementById("shprod").innerHTML = xmlHttp.responseText;
centerDiv(document.getElementById("shprod"));

//document.write("xmlHttp.responseText");
//document.write("<div style='visibility:visible;z-index:2; background:#666666'>" + xmlHttp.responseText + "</div>");
}

}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
function hideproduct()
{
	document.getElementById("imgloading").style.visibility="hidden";
	document.getElementById("shprod").style.visibility="hidden";
}
