function goregister () {
	window.location='register.asp';
}

function chkregister() {
	with (document.getElementById("PostForm")) {
		if (firstname.value.length < 2 || !firstname.value.match(/^[a-zA-Z]+$/g))
		{
			alert('Please input your first name ! \n Name can contain only letters');
			firstname.focus();
			return false;
		}
		if (lastname.value.length < 2 || !lastname.value.match(/^[a-zA-Z]+$/g))
		{
			alert('Please input your last name ! \n Name can contain only letters');
			lastname.focus();
			return false;
		}
		if (useremail.value == '' || !useremail.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig))
		{
			alert('Please input your email !');
			useremail.focus();
			return false;
		}
		if (password.value == '')
		{
			alert('Please input your password !');
			password.focus();
			return false;
		}
		if (password.value != password2.value)
		{
			alert('Password must match exactly !');
			password2.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 >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!');
			return false;
		}
		if (address1.value=='')
		{
			alert('Please input your address !');
			address1.focus();
			return false;
		}
		if (city.value=='')
		{
			alert('Please input your city !');
			city.focus();
			return false;
		}
		if (province.value=='')
		{
			alert('Please input your province/state !');
			province.focus();
			return false;
		}
		if (country.value==0)
		{
			alert('Please select your country !');
			country.focus();
			return false;
		}
		if (question.value == 0)
		{
				alert('Please select your password reset question !');
				question.focus();
				return false;
		}
		if (answer.value.length < 2)
		{
				alert('Please input your password reset answer !');
				answer.focus();
				return false;
		}

		submitbtn.disabled=true;
	}
	document.getElementById("PostForm").submit();
}

//--------end of reg form check-----------------------------------------------------

function chksearch() {
	with (document.all.searchform) {
		if (keyword.value == '')
		{
			alert('Please input a keyword !');
			keyword.focus();
			return false;
		}
	}
}
function chkLogin() {
	with (document.all.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 || !firstname.value.match(/^[a-zA-Z]+$/g))
		{
			alert('Please input your first name ! \n Name can contain only letters');
			firstname.focus();
			return false;
		}
		if (lastname.value.length < 2 || !lastname.value.match(/^[a-zA-Z]+$/g))
		{
			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 setCurrency(a) {
	if (a == 'usd')
	{
		window.top.hiddenfrm.location='/setCurrency.asp?ucurrency=usd';
		setTimeout("window.location.reload()",2000);
	}
	if (a == 'eur')
	{
		window.top.hiddenfrm.location='/setCurrency.asp?ucurrency=eur';
		setTimeout("window.location.reload()",2000);
	}
	if (a == 'gbp')
	{
		window.top.hiddenfrm.location='/setCurrency.asp?ucurrency=gbp';
		setTimeout("window.location.reload()",2000);
	}
}


/*hack the css input:hover,input:focus for IE*/
window.onload = function(){ 
for(var i = 0; i < document.forms.length; i++){ 
var form = document.forms[i]; 
for(var t = 0; t < form.elements.length; t++){ 
form.elements[t].onfocus = function(){ this.className += " focus"; } 
form.elements[t].onblur = function(){ this.className = this.className.replace(/\bfocus\b/, ""); } 
form.elements[t].onmouseover = function(){ this.className += " hover"; } 
form.elements[t].onmouseout = function(){ this.className = this.className.replace(/\bhover\b/, ""); } 
} 
} 
}



function regInput(obj, reg, inputStr) {
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}


function isIE(){ //ie?
if (window.navigator.userAgent.indexOf("MSIE")>=1)
return true;
else
return false;
}



if(!isIE()){ //firefox innerText define ,xurun
HTMLElement.prototype.__defineGetter__
(
"innerText",
function ()
{
var anyString = "";

var childS = this.childNodes;
for(var i=0; i<childS.length; i++)
{
if(childS[i].nodeType==1)
anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
}