var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject(){
var xmlHttp;
try{
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
var XmlHttpVersions = new Array("Microsoft.XMLHTTP",
                                    "MSXML.XMLHTTP",
                                    "Microsoft.XMLHTTP",
                                    "Msxml2.XMLHTTP.7.0",
                                    "Msxml2.XMLHTTP.6.0",
								    "Msxml2.XMLHTTP.5.0",
								    "Msxml2.XMLHTTP.4.0",
								    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP");
for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) {
try {
xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch (e) {}
}
}
if (!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}

F={
ie:(window.ActiveXObject!=null?true:false),
ie7:navigator.userAgent.indexOf('MSIE 7.0')>-1,
list:function(n,o,p){}
};
var Hot={
	set:function(o,mw,mh){
	try{
		if(!o) return;
		var d=document.getElementById("hotrect");
		if(!d){d=document.body.appendChild(document.createElement("DIV"));d.id="hotrect";}
		var t=o,lx=0,ly=0;if(!d)return;
		for (; t!=null; lx+=t.offsetLeft,ly+=t.offsetTop,t=t.offsetParent);
		if(!mw)mw=300; if(!mh)mh=300;
		var a=(mw-o.offsetWidth)/12,b=(mh-o.offsetHeight)/12;
		d.style.width=mw+"px";
		d.style.height=mh+"px";
		d.style.left=parseInt(lx-(mw-o.offsetWidth)/2)+"px";
		d.style.top=parseInt(ly-(mh-o.offsetHeight)/2)+"px";
		if(F.ie)d.filters.Alpha.opacity=100; else d.style.MozOpacity=1;
		this.cfg={fly:d,source:o,x:lx,y:ly,"a":a,"b":b,w:o.offsetWidth,h:o.offsetHeight,time:setTimeout("Hot.fly()",10)};
		d.style.display="block";
	}catch(e){}
	},
	fly:function(){
	try{
		var d=this.cfg.fly;if(!d)return;
		clearTimeout(this.cfg.time);
		if(d.offsetWidth>this.cfg.w+2||d.offsetHeight>this.cfg.h+2){
			d.style.width=parseInt(d.offsetWidth-this.cfg.a>this.cfg.w?d.offsetWidth-this.cfg.a:this.cfg.w-2)+"px";
			d.style.height=parseInt(d.offsetHeight-this.cfg.b>this.cfg.h-2?d.offsetHeight-this.cfg.b:this.cfg.h-2)+"px";
			d.style.left=parseInt(this.cfg.x-(d.offsetWidth-2-this.cfg.w)/2)+"px";
			d.style.top=parseInt(this.cfg.y-(d.offsetHeight-2-this.cfg.h)/2)+"px";
			return this.cfg.time=setTimeout("Hot.fly()",10);
		}
		if(F.ie&&d.filters.Alpha.opacity>0){d.filters.Alpha.opacity-=5;this.cfg.time=setTimeout("Hot.fly()",10);}
		else if(!F.ie&&d.style.MozOpacity>0){d.style.MozOpacity-=0.05;this.cfg.time=setTimeout("Hot.fly()",10);}
		else{d.style.display="none";d.style.left=d.style.top="0px";}
	}catch(e){}
	}
}

function getgame(){
var selectObj = document.getElementById("game");
if (selectObj.value != 0)
{
	var url = "ajax_server.php?sendtype=server&areaid=" +escape(selectObj.value);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = getgameOk;
	xmlHttp.send(null);
}
}

function getgameOk(){
var classObj = document.getElementById("serverdiv");
 if (xmlHttp.readyState != 4 || xmlHttp.status != 200){
classObj.innerHTML="<img src='images/loadinfo.gif'>";
 }
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var response = xmlHttp.responseText;
try{
classObj.innerHTML=response;

getserver();

}
catch(exception){}
}
}

function getserver(){
var selectObj = document.getElementById("server");
var url = "ajax_server.php?sendtype=quantity&serverid=" +escape(selectObj.options[selectObj.selectedIndex].value);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = getserverOk;
xmlHttp.send(null);
}
function getserverOk(){
var classObj = document.getElementById("quantitydiv");
 if (xmlHttp.readyState != 4 || xmlHttp.status != 200){
classObj.innerHTML="<img src='images/loadinfo.gif'>";
 }
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var response = xmlHttp.responseText;
try{
classObj.innerHTML=response;

getprice();

}
catch(exception){}
}
}

function getprice(){
var selectObj = document.getElementById("quantity");

var url = "ajax_server.php?sendtype=price&productsid=" +escape(selectObj.options[selectObj.selectedIndex].value);

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = getpriceOk;
xmlHttp.send(null);

}
function getpriceOk(){
var classObj = document.getElementById("price");
 if (xmlHttp.readyState != 4 || xmlHttp.status != 200){
classObj.innerHTML="<img src='images/loadinfo.gif'>";
 }
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var response = xmlHttp.responseText;
try{
classObj.innerHTML=response;
//document.body.focus();Hot.set(classObj);
}
catch(exception){}
}
}

function buy_now(products_id){

var url = "ajax_server.php?sendtype=buy_now&productsid=" +products_id;

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = buy_nowok;
xmlHttp.send(null);

}

function quick_buy_now(products_id){
var selectObj = document.getElementById("products_id");

var url = "ajax_server.php?sendtype=buy_now&productsid=" +escape(selectObj.value);

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = buy_nowok;
xmlHttp.send(null);

}

function buy_nowok(){
var classObj = document.getElementById("shopping_cart");
 if (xmlHttp.readyState != 4 || xmlHttp.status != 200){
classObj.innerHTML="<img src='images/loadinfo.gif'>";
 }
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var response = xmlHttp.responseText;
try{
classObj.innerHTML=response;
}
catch(exception){}
}
}