var HTTP = document.getElementById("HTTP").value;
var urlpid = document.getElementById("urlpid").value;
var urlgid = document.getElementById("urlgid").value;
var urlsid = document.getElementById("urlsid").value;
var urlcurc = document.getElementById("urlcurc").value;

var ReAjax = function(){}
ReAjax.prototype.GetHttpRequest = function()
{
	var reObj="";
	if ( window.XMLHttpRequest ){
		reObj= new XMLHttpRequest() ;
	}
	else if ( window.ActiveXObject ){	
		try{
			reObj=new ActiveXObject("MsXml2.XmlHttp") ;
		}
		catch(e){
			reObj=new 	ActiveXObject("microsoft.XmlHttp")
		}
	}
	return reObj;
}

ReAjax.prototype.LoadUrl = function( urlToCall,altDiv,valInput)
{
	var oReAjax = this ;
	var oAjaxHttp = this.GetHttpRequest() ;
	oAjaxHttp.open( "GET", urlToCall, true);
	oAjaxHttp.onreadystatechange=function()
	{
		if(oAjaxHttp.readyState==4)
		{ 
			document.getElementById(altDiv).innerHTML=oAjaxHttp.responseText;
		}
	}
	oAjaxHttp.send( null ) ;
}

function initSelect(action,objName)
{
	if(!action == "")
	{
		document.all.url.disabled=false;
					for(var i = document.getElementById(objName).options.length;i>=0;i--)
					{
						document.getElementById(objName).options[i] = null;
					}
						var opt=document.createElement("OPTION");
						opt.text="---Please select a server---";
						opt.value="";
						document.getElementById(objName).options.add(opt);
						opt.selected=true;
						
						if(action == "Alliance")
						{
							var str = document.getElementById("Alliance1").value;
							var arrayStr = str.split("|||");
							
							if(arrayStr.length-1>0)
							{
								for(i=0;i<arrayStr.length-1;i++)
								{
									var arrayName=new Array();
									arrayName=arrayStr[i].split("$$$");
									var opt=document.createElement("OPTION");
									opt.text=arrayName[1];
									opt.value=arrayName[0];
									document.getElementById(objName).options.add(opt);
								}
							}
						}
						if(action == "Horde")
						{
							var str = document.getElementById("Horde1").value;
							var arrayStr = str.split("|||");
							
							if(arrayStr.length-1>0)
							{
								for(i=0;i<arrayStr.length-1;i++)
								{
									var arrayName=new Array();
									arrayName=arrayStr[i].split("$$$");
									var opt=document.createElement("OPTION");
									opt.text=arrayName[1];
									opt.value=arrayName[0];
									document.getElementById(objName).options.add(opt);
								}
							}
						}
	}else{
		document.all.url.disabled=true;
		document.all.url.value="";
	}
}

function initSelect1(action,objName)
{
	if(!action == "")
	{
		document.all.url.disabled=false;
					for(var i = document.getElementById(objName).options.length;i>=0;i--)
					{
						document.getElementById(objName).options[i] = null;
					}
						var opt=document.createElement("OPTION");
						opt.text="---Please select a server---";
						opt.value="";
						document.getElementById(objName).options.add(opt);
						opt.selected=true;
						
						if(action == "Alliance")
						{
							var str = document.getElementById("Alliance1").value;
							var arrayStr = str.split("|||");
							
							if(arrayStr.length-1>0)
							{
								for(i=0;i<arrayStr.length-1;i++)
								{
									var arrayName=new Array();
									arrayName=arrayStr[i].split("$$$");
									var opt=document.createElement("OPTION");
									opt.text=arrayName[1];
									opt.value=arrayName[0];
									document.getElementById(objName).options.add(opt);
								}
							}
						}
						if(action == "Horde")
						{
							var str = document.getElementById("Horde1").value;
							var arrayStr = str.split("|||");
							
							if(arrayStr.length-1>0)
							{
								for(i=0;i<arrayStr.length-1;i++)
								{
									var arrayName=new Array();
									arrayName=arrayStr[i].split("$$$");
									var opt=document.createElement("OPTION");
									opt.text=arrayName[1];
									opt.value=arrayName[0];
									document.getElementById(objName).options.add(opt);
								}
							}
						}
	}else{
		document.all.url.disabled=true;
		document.all.url.value="";
	}
}

function gentitle()
{
	with(document.all.title.stytle)
	{
		display="inline";
		top=document.body.scrollTop+window.event.clientY+10;
		left=document.body.scrollLeft+window.event.clientX;
	}
}
function verify0()
{
	if(document.getElementById("selType")&&document.getElementById("selType").value=="-1"){
		alert("Please select the product!");
		return false;
	}
	document.getElementById("quantity").value = document.getElementById("quantity").value.replace(/\s/g,'');
	if(document.getElementById("quantity").value.search(/[^\-|0-9]/)!=-1)
	{
		alert("Quantity Error!");
		return false;
	}
	if((isNaN(document.getElementById("pMin").value))||document.getElementById("pMin").value==0||(isNaN(document.getElementById("pMax").value))||document.getElementById("pMax").value==0){
		alert("Sorry,Out of stock!");
		return false;
	}
	if(parseInt(document.getElementById("pMin").value)>parseInt(document.getElementById("quantity").value)||parseInt(document.getElementById("quantity").value)>parseInt(document.getElementById("pMax").value)){
		alert("Please enter a valid quantity between "+document.getElementById("pMin").value+" and "+parseInt(document.getElementById("pMax").value)+" !");
		return false;
	}

	if(document.getElementById("quantity").value==""){
		alert("Please enter the quantity!");
		return false;
	}
	
	//	֤1ԲƷĹ
	var quantity = document.getElementById("quantity").value;
	var StrUrl = "http://" + HTTP + "/ajax/checkMin.cfm?pid="+ urlpid + "&qty="+quantity;
	var result = ReLoadAjax.prototype.LoadUrl2(StrUrl); 
	 if(result > 0)
	{
		alert("Please enter a valid quantity between "+result+" and "+parseInt(document.getElementById("pMax").value)+" !");
		return false; 
	}	
	
	return true;
}
function getMinCount(val){
	if(val!="-1"){
		//alert(ReAjax.constructor);
		var result=ReLoadAjax.prototype.LoadUrl2('http://'+HTTP+'/product/product.cfm?gameid='+urlgid+'&sid='+urlsid+'&getMin='+val);
		document.getElementById("pMin").value=parseInt(result);
		result=ReLoadAjax.prototype.LoadUrl2('http://'+HTTP+'/product/product.cfm?gameid='+urlgid+'&sid='+urlsid+'&getMax='+val);
		document.getElementById("pMax").value=parseInt(result);
		if(document.getElementById("selType") && document.getElementById("selType").nodeName == "SELECT")
		{
			document.getElementById("hidType").value=document.getElementById("selType").options[document.getElementById("selType").selectedIndex].text;
		}
	}
}
var hander;
var sumPrice_pl = 0; <!---۸ȫֱ--->
<!---Ʒѡ۸--->
function SetPrice(obj,value){
	if(obj.checked){			
		sumPrice_pl += parseInt(value);
		var priceStr = document.getElementById("PowerPrice").innerHTML;
		var p1 = priceStr.split("$");			
		document.getElementById("PowerPrice").innerHTML = "USD$ "+(Math.round((parseFloat(p1[1])+parseFloat(value))*100)/100);
	}else{		
		sumPrice_pl -= parseInt(value);
		if(sumPrice_pl < 0){
			sumPrice_pl = 0;
		}				
		var priceStr = document.getElementById("PowerPrice").innerHTML;
		var p1 = priceStr.split("$");
		document.getElementById("PowerPrice").innerHTML = "USD$ "+(Math.round((parseFloat(p1[1])-parseFloat(value))*100)/100);
	}		
}
<!---END--->
function calculation(start,end){
	
	/*document.getElementById("AddFreeCartPowerLevel").disabled=true;*/
	var objrote=document.getElementById("Layer13");
	var skillType = document.getElementById("skillType").value;
	
	document.getElementById("PowerPrice").style.display="none";
	objrote.style.display="";
	objrote.innerHTML="Loading";
	hander=setInterval("ing()",100);	
	
	var url = "http://"+HTTP+"/product/product.cfm?startLevel="+start+"&endLevel="+end+"&pid="+urlpid;
	if(urlcurc != ""){url += "&curc=" + urlcurc;}
	if(skillType!=0){url += "&skillType=" + skillType;}
	//alert(url)
	ReAjax.prototype.LoadUrl(url,"Layer14");	
}

function ing(){
	var objrote=document.getElementById("Layer13");
	var objrote2=document.getElementById("Layer14");
	if(objrote2.innerHTML!=""){
		clearInterval(hander);
		var obj=objrote2.innerHTML.split("|");
		objrote2.innerHTML="";
		objrote.innerHTML="";
		objrote.style.display="none";
		document.getElementById("PowerPrice").style.display="";	
		var p1 = obj[0].split("$");
	//	document.getElementById("PowerPrice").innerHTML="USD$ "+ (Math.round((parseFloat(p1[1])+ parseFloat(sumPrice_pl))*100)/100);<!---//۸Ĵ--->
		document.getElementById("PowerPrice").innerHTML=obj[0];
		document.getElementById("PowerTime").innerHTML=obj[1];
		document.getElementById("hidPowerPrice").value=obj[2];
		document.getElementById("hidPowerTime").value=obj[3];
		document.getElementById("AddFreeCartPowerLevel").disabled=false;
	}
	switch (objrote.innerHTML){
		case "Loading":
		objrote.innerHTML="Loading.";
		break;
		case "Loading.":
		objrote.innerHTML="Loading..";
		break;
		case "Loading..":
		objrote.innerHTML="Loading...";
		break;
		case "Loading...":
		objrote.innerHTML="Loading....";
		break;
		case "Loading....":
		objrote.innerHTML="Loading.....";
		break;
		case "Loading.....":
		objrote.innerHTML="Loading......";
		break;
		case "Loading......":
		objrote.innerHTML="Loading";
		break;
		default:{
				
		}
	}
}

function verify()
{
	var objs = document.getElementsByName("checkpriceid");
	var flag = false;
	for(var i=0;i<objs.length;i++)
	{		
		if(objs[i].checked)
		{
			flag=true;
			break;
		}
	} 
	
	if(flag)
	{
		//alert( document.getElementById('ifCheckout').offsetTop)
		if(!document.getElementById('ifCheckout')) return true;
		var len =  document.getElementById('ifCheckout').offsetTop +20 ;
		var bolen = document.body.scrollTop;
		var i = 0 ;
		if( bolen < len-150 )
			i = len-150;
		for(i; i <= len ; i++){
			document.body.scrollTop = i+=100;
		}

		return true;
	}
	else
	{
		alert("Please select a product!");
		return false;
	}
}

function rep(str){
	str=str.replace(/ - /g,",");
	str=str.replace(/-/g,"_");
	str=str.replace(" ","-");
	return str;
}

function sub_rep(str)
{
	str=str.replace(/ - /g,",");
	str=str.replace(/-/g,"_");
	str=str.replace(/\s/g,"--");
	return str;	
}

<!---tip--->
var showingdscp = 0;
var canmovedscp = 1;
function showdscp(event,dscpid)
{
if (!event)
	{
		var event = window.event;
	}
var dscpobj = document.getElementById(dscpid);
if (!dscpobj)
	{
		return;
	}
var xfix = 0;
var yfix = 0;
var yall = 768;
if (document.documentElement.scrollTop || document.documentElement.scrollLeft)
	{
		xfix = document.documentElement.scrollLeft;
		yfix = document.documentElement.scrollTop;
		yall = document.documentElement.clientHeight;
	}
else if (document.body.scrollTop || document.body.scrollLeft)
	{
		xfix = document.body.scrollLeft;
		yfix = document.body.scrollTop;
		yall = document.body.clientHeight;
	}
if ((yall-event.clientY)<250)
	{
		dscpobj.style.top = event.clientY + yfix - 75 +'px';
	}
else
	{
		dscpobj.style.top = event.clientY + yfix + 16 +'px';
	}
dscpobj.style.left = event.clientX + xfix + 16 +'px';
dscpobj.style.display = 'block';
showingdscp = 1;
}
function movedscp(event,dscpid)
{
if (showingdscp == 0  || canmovedscp == 0)
	{
		return;
	}
if (!event)
	{
		var event = window.event;
	}

var dscpobj = document.getElementById(dscpid);
if (!dscpobj)
	{
		return;
	}
var xfix = 0;
var yfix = 0;
var yall = 768;
if (document.documentElement.scrollTop || document.documentElement.scrollLeft)
	{
		xfix = document.documentElement.scrollLeft;
		yfix = document.documentElement.scrollTop;
		yall = document.documentElement.clientHeight;
	}
else if (document.body.scrollTop || document.body.scrollLeft)
	{
		xfix = document.body.scrollLeft;
		yfix = document.body.scrollTop;
		yall = document.body.clientHeight;
	}
if ((yall-event.clientY)<250)
	{
		dscpobj.style.top = event.clientY + yfix - 75 +'px';
	}
else
	{
		dscpobj.style.top = event.clientY + yfix + 16 +'px';
	}
dscpobj.style.left = event.clientX + xfix + 16 +'px';
}
function hinddscp(event,dscpid)
{
if (canmovedscp == 0)
	{
		return;
	}
showingdscp = 0;
if (!event)
	{
		var event = window.event;
	}
var dscpobj = document.getElementById(dscpid);
if (!dscpobj)
	{
		return;
	}
dscpobj.style.display = 'none';
dscpobj.style.top = 0 +'px';
dscpobj.style.left = 0 +'px';
}

function delay_showdscp(event,dscpid,delay)
{
if (!event)
	{
		var event = window.event;
	}
var xfix = 0;
var yfix = 0;
if (isIE || isMZ)
	{
		if (document.documentElement.scrollTop || document.documentElement.scrollLeft)
			{
				xfix = document.documentElement.scrollLeft;
				yfix = document.documentElement.scrollTop;
			}
		else if (document.body.scrollTop || document.body.scrollLeft)
			{
				xfix = document.body.scrollLeft;
				yfix = document.body.scrollTop;
			}
	}
showingdscp = 1;
window.setTimeout("delay_showdscp_act("+(event.clientY + yfix + 16)+","+(event.clientX + xfix + 16)+",'"+dscpid+"')",delay);
}
//fe

function delay_showdscp_act(t,l,dscpid)
{
if (showingdscp == 0)
	{
		return;
	}
var dscpobj = document.getElementById(dscpid);
if (!dscpobj)
	{
		return;
	}
dscpobj.style.top = t +'px';
dscpobj.style.left = l +'px';
dscpobj.style.display = 'block';
}
//fe

function dont_move_ttip(event)
{
if (!event)
	{
		var event = window.event;
	}
if (event.keyCode == 16)
	{
		canmovedscp = 0;
	}
}
//fe

function can_move_ttip(event)
{
if (!event)
	{
		var event = window.event;
	}
if (event.keyCode == 16)
	{
		canmovedscp = 1;
	}
}
//fe

function reg_key_event()
{
document.onkeydown = dont_move_ttip;
document.onkeyup = can_move_ttip;
}
function toNewPage(pnum)
{
document.getElementById("p").value = pnum;
document.getElementById("pageform").submit();
}
<!---end--->
//show hide
var plpromotion = 0;
function show_cp()
{		
	plpromotion = 1;		
}
function hide_cp()
{
	plpromotion = 0;		
}
function show_hide_cp()
{		
	if(plpromotion == 1){			
		document.getElementById("choosepldiv").style.display = 'block';
	}
	else{
		document.getElementById("choosepldiv").style.display = 'none';
	}
}		
//λ
function checkReset(){
	var checkArray = document.getElementsByName("checkPid");	
	for(var i =0 ; i < checkArray.length; i++){			
		checkArray[i].checked = false;			
	}
	var priceStr = document.getElementById("PowerPrice").innerHTML;
	var p1 = priceStr.split("$");
	document.getElementById("PowerPrice").innerHTML = "USD$ "+(Math.round((parseFloat(p1[1])-parseFloat(sumPrice_pl))*100)/100);		
	sumPrice_pl = 0;
}
//end
//selItemcategoryװл
function switchItemCategory(GShortname,GCurrency,productName,GTemplateName){
	//һַƲӢ,÷ID,
	var strRU="";
	if(encodeURI(rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text))!=rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text)) 
		strRU=document.getElementById("url").options[document.getElementById("url").selectedIndex].value;
	else 
		strRU=rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text);		
	//END
	
	//
	var Currency = document.getElementById("scurrency").options[document.getElementById("scurrency").selectedIndex].text;		
	var StrUrl = "../../../"+GShortname+"/buy-"+GShortname+"-"+GCurrency+"-"+GTemplateName+"/"+productName+"/"+strRU+"-"+Currency+".html"
	window.location.href=StrUrl;		
}
//selItemcategoryװл
function switchPLCategory(GShortname,GCurrency,productName,GTemplateName){
	//һַƲӢ,÷ID,
	var strRU="allserver";
	//
	var Currency = document.getElementById("scurrency").options[document.getElementById("scurrency").selectedIndex].text;		
	var StrUrl = "../../../"+GShortname+"/buy-"+GShortname+"-"+GCurrency+"-"+GTemplateName+"/"+productName+"/"+strRU+"-"+Currency+".html"
	window.location.href=escape(StrUrl);		
}

function sub_switchItemCategory(obj)
{
	var strRU="";
	if(encodeURI(rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text))!=rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text)) 
		strRU=document.getElementById("url").options[document.getElementById("url").selectedIndex].value;
	else 
		strRU=rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text);		
	//END
	
	var productName = sub_rep(obj.options[obj.selectedIndex].text);
	
	var Currency = document.getElementById("scurrency").options[document.getElementById("scurrency").selectedIndex].text;	
	var StrUrl = "http://" + HTTP + "/"+productName+"-"+strRU+"-"+Currency+"/";
	location = StrUrl;
}

function changeColor(id)
{ 
	obj = document.getElementById("trCC"+id);                        
	if(obj.bgColor == "#f0f0f0")
	{
		obj.bgColor = "#999999";
	}
	else
	{
		obj.bgColor = "#f0f0f0";
	}                        
}	

function CdkSubmint(id)
{
	document.getElementById("CDK_Form_"+id).click();
}

function add2f()
{
	var Fvals = document.getElementById("addFavorite").value.split("|");
	
	var title = rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text)+" - " + Fvals[0] + " - " + Fvals[1];
	var UrlLink = "http://" + HTTP + "/" + Fvals[2];
/*	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko
	{
	 window.sidebar.addPanel(title,UrlLink,"");
	}
	else//IE
	{
	// window.external.AddFavorite(UrlLink,title);
	}*/
	try{
		 window.external.addFavorite(UrlLink,title);
	}catch(e){
		try{
	 		window.sidebar.addPanel(title,UrlLink,"");
		}catch(e){}
	}
}
function add3f()
{
	var Fvals = document.getElementById("addFavorite").value.split("|");
	
	var title = rep(document.getElementById("url").options[document.getElementById("url").selectedIndex].text)+" - " + Fvals[0] + " - " + Fvals[1];
	var UrlLink = "http://" + HTTP + "/" + Fvals[2];
	var url = window.location.href;
	if(url != ""){
		var urlList = url.split('.html');
		UrlLink = urlList[0] + "-Affi-3442.html";
	}
//	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko
//	{
//	 window.sidebar.addPanel(title,UrlLink,"");
//	}
//	else//IE
//	{
//		try{
//			 window.external.addFavorite(UrlLink,title);
//		}catch(e){
//			try{
//				window.sidebar.addPanel(title,UrlLink,"");
//			}catch(e){}
//	// window.external.AddFavorite(UrlLink,title);
//	}
	try{
		 window.external.addFavorite(UrlLink,title);
	}catch(e){
		try{
	 		window.sidebar.addPanel(title,UrlLink,"");
		}catch(e){}
	}
}
function alliance()
{
	var lis = document.getElementById("leftserverlist").getElementsByTagName("li");
	for(var i = 0;i<lis.length;i++)
	{
		lis[i].firstChild.innerHTML = lis[i].firstChild.innerHTML.replace("Horde","Alliance");
		var urlpath = lis[i].firstChild.href;
		lis[i].firstChild.href = urlpath.replace("Horde","Alliance");
	}
	document.getElementById("as").className = "this";
	document.getElementById("hs").className = "nothis";
}

function horde()
{
	var lis = document.getElementById("leftserverlist").getElementsByTagName("li");
	for(var i = 0;i<lis.length;i++)
	{
		lis[i].firstChild.innerHTML = lis[i].firstChild.innerHTML.replace("Alliance","Horde");
		var urlpath = lis[i].firstChild.href;
		lis[i].firstChild.href = urlpath.replace("Alliance","Horde");
	}
	document.getElementById("as").className = "nothis";
	document.getElementById("hs").className = "this";
}

function calculateGoldPrice()
{
	if(verify0())
	{
		var quantity = document.getElementById("quantity").value;
		var selType = document.getElementById("selType").value;	
		var hidrate = document.getElementById("hidrate").value;	
		//url = 'http://'+HTTP+'/ajax/getGoldInfo.cfm?gameid='+urlgid+'&sid='+urlsid+'&quantity='+quantity+'&selType='+selType;

		url = '../ajax/getGoldInfo.cfm?gameid='+urlgid+'&sid='+urlsid+'&rate='+hidrate+'&quantity='+quantity+'&selType='+selType+"&ts="+new Date().toString();
	
		$("#customgoldprice").html("loading...");
		$.get(url,function(data){$("#customgoldprice").html(data);})
	}
}

function customgoldcheck()
{
	if(verify0())	
	{
		document.getElementById("AddFreeCart").click();	
	}
}

function TRequire(start,end,type)
{
	var url = "/ajax/getRangeRequie.cfm?start="+start+"&end="+end+"&skillType="+type;
	var result = ReLoadAjax.prototype.LoadUrl2(url); 
	if(result!="")
	{
		var arr = result.split('|||');
		document.getElementById("viewRequire").innerHTML=arr[1];
		document.getElementById("hiddenSkillType").value=arr[0];
	}
}

function floatCDKProduct(id,b){
	var o = document.getElementById(id);
	if(o){
		if(b){
			jQuery(o).show().css("visibility","visible");
		}
		else{
			jQuery(o).hide().css("visibility","hidden");
		}
	}
}
