function chksearch(){with (document.all.searchform){if (keyword.value == ''){
alert('Please input a keyword !');keyword.focus();return false;}}}
function chklogin(){with (document.getElementById('loginform')){
if (email.value == '' || !email.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
alert('Please input your email !');email.focus();return false;}
if (password.value == ''){alert('Please input your password !');password.focus();return false;}}}
function checkorder(){with (document.PostForm){
if (firstname.value.length < 2){
alert('Please input your first name ! \n Name can contain only letters');firstname.focus();return false;}
if (lastname.value.length < 2){alert('Please input your last name ! \n Name can contain only letters');
lastname.focus();return false;}
if (email.value == '' || !email.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
alert('Please input your email address !');email.focus();return false;}
if (usaphone1.value != ''){if (usaphone1.value.length != 3 || isNaN(usaphone1.value)){
alert('Phone can contain only numbers! \n This field must contain three numbers !');
usaphone1.focus();return false;}
if (usaphone2.value.length != 3 || isNaN(usaphone2.value)){
alert('Phone can contain only numbers! \n This field must contain three numbers !');
usaphone2.focus();return false;}
if (usaphone3.value.length != 4 || isNaN(usaphone3.value)){
alert('Phone can contain only numbers! \n This field must contain four numbers !');
usaphone3.focus();return false;}}
if (etcphone.value != ''){if (etcphone.value.length <5 || etcphone.value.length >20 || isNaN(etcphone.value) ){
alert('Please input your phone number !');etcphone.focus();return false;}}
if (usaphone1.value=='' && etcphone.value==''){alert('Please input your phone number !');usaphone1.focus();return false;}
if (charname.value == '' || charname.value.length>20){alert('Please input your character name !');charname.focus();return false;}}}
function switchdic(i,obja) {document.getElementById("gamelist").style.display=(i==0)?"block":"none";document.getElementById("plist").style.display=(i==0)?"none":"block";obja.style.className = "switchfocus";}

function roundAmount(n){
	var s = "" + Math.round(n*100)/100;
	var i = s.indexOf('.');
	if (i < 0) return s + ".00";
	var t=s.substring(0,i+1) + s.substring(i+1,i+3);
	if(i + 2 == s.length) t += "0";
	return  t;
}
function setcurrency(selobj){
	var ptable = document.getElementById("prolist");
	var rows_count = ptable.rows.length;
	var currency_id = selobj.value;
	var exchangeRate;
	if (currency_id==1){currency_code='USD';exchangeRate=1;}
	if (currency_id==2){currency_code='EUR';exchangeRate=rateEur;}
	if (currency_id==3){currency_code='GBP';exchangeRate=rateGbp;}
	if (currency_id==4){currency_code='CAD';exchangeRate=rateCad;}
	if (currency_id==5){currency_code='AUD';exchangeRate=rateAud;}
	for(var i=1;i<rows_count;i++){
		var proprice = arrPrice[i-1];
		proprice = proprice / exchangeRate;
		proprice = roundAmount(proprice);
		ptable.rows[i].cells[1].innerHTML = proprice + '  ' + currency_code;
	}
	SetCookie("currencyID",currency_id);
}
var arrPrice = new Array();

function prepdt(){
	var ptable = document.getElementById("prolist");
	if (ptable==null){return}
	var rows_count = ptable.rows.length;
	for(var i=1;i<rows_count;i++){
		var priceUSD = parseFloat(ptable.rows[i].cells[1].innerHTML);
		priceUSD = roundAmount(priceUSD);
		arrPrice.push(priceUSD);
	}
	var currency_id = parseInt(getCookie("currencyID"));
	if (currency_id==0||currency_id==null){currency_id=1}
	var selobj = document.getElementById("selcurrency");
	selobj.disabled = false;
	selobj.selectedIndex = currency_id-1;
	setcurrency(selobj);
}

addLoadEvent(prepdt);