// JavaScript Document
var x=1,y=0;
var mycookie = document.cookie;

function addme(){ 
var nome_sito = "levelvip"; 
var url_sito = "http://www.levelvip.com";
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt
	(navigator.appVersion) >= 4))
	window.external.AddFavorite(url_sito, nome_sito);
else if (navigator.appName == "Netscape")
	window.sidebar.addPanel(nome_sito, url_sito, '');
else
	alert("Sorry! Cann't Add this site to your favorite! Please use IE or Firefox");
}

function SetHome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("This action was refused by firefox£¡\n Please enter¡°about:config¡±and press enter \n Change the value of [signed.applets.codebase_principal_support],\n Let it becames to 'true',Double click it,All done!");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}

function checkspace(checkstr) { 
	var str = ''; 
	for(i = 0; i < checkstr.length; i++) { 
	str = str + ' '; 
	} 
	return (str == checkstr);
}



function load_cookie(name)
{
	var start1 = mycookie.indexOf(name + "=");
	if (start1== -1)
	document.getElementById("a1").className="ax";
	else
	{
		start=mycookie.indexOf("=",start1)+1; 
		var end = mycookie.indexOf(";",start);
		if (end==-1)
		{
 			end=mycookie.length;
		}
		var value=unescape(mycookie.substring(start,end));
 		if (value==null)
 		{
			document.getElementById("a1").className="ax";
		}
 		else
 		{
	 		window.x=value;
	 		document.getElementById("a"+window.x).className="ax";
		 }
	 }
}

function setTab(m){
	window.y=window.x;
	window.x=m;
	document.getElementById("a"+window.y).className="";
	document.getElementById("a"+window.x).className="ax";
	document.cookie="x="+window.x+";"
	
}


function $(id) {
	return document.getElementById(id);
}

function changediv(divid,type){
switch(type){
case 0:document.getElementById(divid).style.display="none";break;
case 1:document.getElementById(divid).style.display="block";break;
}
}

function changeclass(divid,classname){
document.getElementById(divid).className=classname;
}


function showtabs(par,tabid,no){
for(var i=1;i<=no;i++){
	changediv(par+'tab'+i,0);
	changeclass(par+'taba'+i,"");
}
changeclass(par+'taba'+tabid,"select");
changediv(par+'tab'+tabid,1);
}

function move(elementID,final_x,final_y){
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  elem.style.left = final_x + "px";
  elem.style.top = final_y + "px";
}

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x  &&  ypos == final_y) {
  return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/20);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/20);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/20);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/20);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}

function hideorderid(a)
{
	a=replace(a,right(a,3),"***");
	return a;
}

function getXMLRequester( )
{ var xmlhttp_request = false;
try
{ if( window.ActiveXObject )
{ for( var i = 5; i; i-- ){
try{
if( i == 2 )
{ xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" ); }
else
{ xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
xmlhttp_request.setRequestHeader("Content-Type","text/xml");
xmlhttp_request.setRequestHeader("Content-Type","utf8"); }
break;}
catch(e){ xmlhttp_request = false; } } }
else if( window.XMLHttpRequest )
{ xmlhttp_request = new XMLHttpRequest();
if (xmlhttp_request.overrideMimeType)
{ xmlhttp_request.overrideMimeType('text/xml'); } } }
catch(e){ xmlhttp_request = false; }
return xmlhttp_request ; }

function showatoz(a){
	for(var i=0;i<26;i++){
		$('atoz_'+String.fromCharCode(65+i)).style.display = 'none';
		$('aatoz_'+String.fromCharCode(65+i)).className = 'atoz';
	}
	$('atoz_'+a).style.display = '';
	$('aatoz_'+a).className = 'satoz';
}

function showlist(a,obj){
var ssa;
var ssb;
var sa = new Array();
var sb = new Array();
var dw;
var str;
var price;
str='';
$('servernamediv').innerHTML=obj.innerHTML;	
ssa=document.goldorder.count_str.value;
sa=ssa.split('|');
dw=sa[sa.length-1];
	for(var i=0;i < sa.length-1;i++)
	{
	ssb=sa[i];
	sb=ssb.split(':');
	price=sb[0]*sb[1]*a;
	price=price.toFixed(2);
	str=str + '<li>' + sb[0] + ' ' + dw + '</li><li>$ ' + price + '</li> <li><a href="#" onclick="buygold(' + price + ',' + sb[0] + ')"><img src="/images/buy_gold.gif"  border="0" /></a></li>'
	}
$('plist').innerHTML=str;
}

function buygold(price,count){
document.goldorder.servername.value=$('servernamediv').innerHTML;
document.goldorder.price.value=price;
document.goldorder.count.value=count;
document.goldorder.submit();
}


function fastordersubmit(){
var str;
var gp;
if(document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value==0){
	alert('please select your game');
}
else
{
		if(document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].value==0){
			alert('please select your server');
		}
		else
		{
				gp=document.fastorder.s_pl.value;
				if(gp =='' ){
					alert('please input your amount');
				}
				else
					{
						pr=document.fastorder.s_price.value;
						if(pr == ''){
							alert('please click the <calc price> button!');
						}
						else{
								document.fastorder.game_id.value=document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value;
								document.fastorder.servername.value=document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].text;
								document.fastorder.price.value=document.fastorder.s_price.value;
								document.fastorder.submit();
						}
					}
						
		}	
}	
}


function buygoldcheck(){
var str;
str='';
if(document.buygoldform.fullname.value==''){
str='please input your Full Name\n';
}
if(document.buygoldform.email.value==''){
str=str+'please input your E-mail\n';
}
else
{
patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (!patrn.test(document.buygoldform.email.value)){
str=str+'your E-mail addr format error\n';
}
}

if(document.buygoldform.phone.value==''){
str=str+'please input your phone\n';

}
if(document.buygoldform.character.value==''){
str=str+'please input your character name\n';
}

if(str!=''){
	str='Warning:\n---------------------------------\n\n'+str;
	alert(str);
	}
else
{
document.buygoldform.submit();	
}
}



function buycdkeycheck(){
var str;
str='';
if(document.cdkeyform.fullname.value==''){
str='please input your Full Name\n';
}
if(document.cdkeyform.email.value==''){
str=str+'please input your E-mail\n';
}
else
{
patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (!patrn.test(document.cdkeyform.email.value)){
str=str+'your E-mail addr format error\n';
}
}

if(document.cdkeyform.phone.value==''){
str=str+'please input your phone\n';

}
if(str!=''){
	str='Warning:\n---------------------------------\n\n'+str;
	alert(str);
	}
else
{
document.cdkeyform.submit();	
}
}



function lpcheck()
{
	var str;
	str='';
	if(document.lpform.servername.value=='')
	{
		str+='please select a server\n';
	}
	if(document.lpform.first_name.value=='')
	{
		str+='please input your First Name \n';
	}
	if(document.lpform.last_name.value=='')
	{
		str+='please input your Last Name \n';
	}
	if(document.lpform.account.value=='')
	{
		str+='please input your Account \n';
	}
	if(document.lpform.character.value=='')
	{
		str+='please input your Password for Account \n';
	}
	if(document.lpform.pswd.value=='')
	{
		str+='please input your Password for Account \n';
	}
	if(document.lpform.character.value=='')
	{
		str+='please input your Character Name \n';
	}
	if(document.lpform.class1.value=='')
	{
		str+='please input your Character Class \n';
	}
	if(document.lpform.email.value=='')
	{
		str=str+'please input your E-mail \n';
	}
	else
	{
		patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		if (!patrn.test(document.lpform.email.value))
		{
			str=str+'your E-mail addr format error \n';
		}
	}

	if(document.lpform.phone.value=='')
	{
		str=str+'please input your phone \n';

	}

	
	if(str!='')
	{
		str='Warning:\n---------------------------------\n\n'+str;
		return alert(str);
	}
	else
	{
	return document.lpform.submit();	
	}
}



function pl_product_form_submit()
{
	return document.pl_product_form.submit()
}

function changeid(changed,id)
{
	changed=id;
//	location.reload();
}


function js_select(obj,itemvalue){
	
for(var i=0;i<document.getElementById(obj).options.length;i++)
{
 if(document.getElementById(obj).options[i].value == itemvalue)
 {
	 document.getElementById(obj).options[i].selected = true;
	 break;
 }
}
}


function signup_check(){
var str;
var sexn = document.getElementsByName("sex");
var sexz=0;
for(var i=0;i<sexn.length;i++)
	if(sexn[i].checked) sexz=1;
str='';
if(sexz==0) str=str+'*Please select your gender\n';
if(document.signup.firstname.value=='') str=str+'*Please input your First Name\n';
if(document.signup.lastname.value=='') str=str+'*Please input your Last Name\n';
if(document.signup.b_month.options[document.signup.b_month.selectedIndex].value=="") str=str+'*Please select your Birth Month\n';
if(document.signup.b_day.options[document.signup.b_day.selectedIndex].value=="") str=str+'*Please select your Birth Day\n';
if(document.signup.b_year.options[document.signup.b_year.selectedIndex].value=="") str=str+'*Please select your Birth Year\n';
if(document.signup.email.value=='') str=str+'*Please input your E-mail Address\n';
if(document.signup.email.value==''){str=str+'please input your E-mail\n';}
else{patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;if (!patrn.test(document.signup.email.value))
{str=str+'your E-mail addr format error\n';}}

if(document.signup.street.value=='') str=str+'*Please input your Street Address\n';
if(document.signup.postcode.value=='') str=str+'*Please input Post Code\n';
if(document.signup.city.value=='') str=str+'*Please input City\n';
if(document.signup.country.options[document.signup.country.selectedIndex].value=="") str=str+'*Please select your Country\n';
if(document.signup.state.value=='') str=str+'*Please input State/Province\n';
if(document.signup.tele.value=='') str=str+'*Please input Your Telephone Number\n';
if(document.signup.password.value=='') str=str+'*Please input Your Password\n';
if(document.signup.password1.value=='') str=str+'*Please input Confirm Password\n';
if((document.signup.password.value!='')&&(document.signup.password1.value!='')){
if(document.signup.password.value!=document.signup.password1.value)str=str+'*The password confirmation must match your password\n';
}
if(str!=''){
str='Please input all Required Information, Error:              \n\n'+str;
alert(str);
return false;
}
}


function infoedit_check(){
var str;
var sexn = document.getElementsByName("sex");
var sexz=0;
for(var i=0;i<sexn.length;i++)
	if(sexn[i].checked) sexz=1;
str='';
if(sexz==0) str=str+'*Please select your gender\n';
if(document.changeinfo.firstname.value=='') str=str+'*Please input your First Name\n';
if(document.changeinfo.lastname.value=='') str=str+'*Please input your Last Name\n';
if (document.changeinfo.b_month.options[document.changeinfo.b_month.selectedIndex].value=="") str=str+'*Please select your Birth Month\n';
if (document.changeinfo.b_day.options[document.changeinfo.b_day.selectedIndex].value=="") str=str+'*Please select your Birth Day\n';
if (document.changeinfo.b_year.options[document.changeinfo.b_year.selectedIndex].value=="") str=str+'*Please select your Birth Year\n';

if(document.changeinfo.street.value=='') str=str+'*Please input your Street Address\n';
if(document.changeinfo.postcode.value=='') str=str+'*Please input Post Code\n';
if(document.changeinfo.city.value=='') str=str+'*Please input City\n';
if (document.changeinfo.country.options[document.changeinfo.country.selectedIndex].value=="") str=str+'*Please select your Country\n';
if(document.changeinfo.state.value=='') str=str+'*Please input State/Province\n';
if(document.changeinfo.tele.value=='') str=str+'*Please input Your Telephone Number\n';

if(str!=''){
str='Please input all Required Information, Error:              \n\n'+str;
alert(str);
return false;
}
}

function repswd_check(){
var str;
var sexn = document.getElementsByName("sex");
var sexz=0;
for(var i=0;i<sexn.length;i++)
	if(sexn[i].checked) sexz=1;
str='';
if(document.changepassword.ps1.value=='') str=str+'*Please input Your currently Password\n';
if(document.changepassword.ps2.value=='') str=str+'*Please input Your new Password\n';
if(document.changepassword.ps3.value=='') str=str+'*Please input Your confirm new Password\n';
if((document.changepassword.ps2.value!='')&&(document.changepassword.ps3.value!='')){
if(document.changepassword.ps2.value!=document.changepassword.ps3.value)str=str+'*The new password confirmation must match your new password\n';
}
if(str!=''){
str='Please input all Required Information, Error:              \n\n'+str;
alert(str);
return false;
}
}

function calcdes(goldcount){
var minicount;
var thecountstr=0;
thecountstr=document.fastorder.count_str.value;
if (checkspace(thecountstr)) {
alert ("you must choose server!");
minicount=800;
}
else{
sa=thecountstr.split('|');
dw=sa[sa.length-1];
minicount=800;
}

if (isNaN(goldcount)){
alert ("not numeric!");
return 0 ;
}
else{
	if((goldcount-minicount)<=0){
    goldcount=minicount;
    des=1;    
    }
    else
    {
    	if(goldcount*1<1000){
    	des=1;
    	}
    	else{
        	if(goldcount*1<3000){
            des=0.9856;
            }
            else{
            	if(goldcount*1<7000){
                des=0.9634;
                }
                else{
                	if(goldcount*1<10000){
                    des=0.9455;
                    }
                    else{
                    	if(goldcount*1<20000){
                        des=0.932;
                        }
                        else{
                        	if(goldcount*1<25000){
                            des=0.925;
                            }
                            else{
                            	if(goldcount*1<30000){
                                des=0.92;
                                }
                                else{
                                	if(goldcount*1<40000){
                                    des=0.912;
                                    }
                                    else{
                                    des=0.9;
                                    }
                                }
                            }
                         
                        }
                    }
                }
            }
        }
        	
    }
return(goldcount+':'+des+'|'+dw); 
}
}


function RemoveHTML( strText )
{
var regEx = /<[^>]*>/g;
return strText.replace(regEx, "");
}