function IsEmail(str)
{
	  var supported = 0;
	  if (window.RegExp) {
	    var tempStr = "a";
	    var tempReg = new RegExp(tempStr);
	    if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));

}
function CheckNumber(myform,str)
{
	string = myform.value;
	var letters="1234567890.";
	var charlength=string.length;
	for (i=0;i<charlength;i++)
	{
		var tempChar=string.charAt(i);
		if (letters.indexOf(tempChar)==-1)
		{
			alert("Please choose your Right Telphone");
			myform.focus();
			return false;
		}
	}
	return true;
}
function check_form(form_name) {
	/*
  	if (submitted == true) {
    	alert("send form,please wait...");
    	return false;
  	}*/
	_CF_this=form_name;

	
	if(_CF_this.servername.value=='Choose your Realm'){
		alert("Please choose your Realm (Server)");
		return false;
	}
	
	if(_CF_this.faction.value=='Choose Your Faction'){
		alert("Please choose your Faction");
		return false;
	}
	if(_CF_this.charactername.value==''){
		alert("Please choose In-game character");
		return false;
	}
	string = _CF_this.charactername.value;
	var letters="qwertyuioplkjhgfdsazxcvbnmMNBVCXZASDFGHJKLPOIUYTREWQ";
	var charlength=string.length;
	for (i=0;i<charlength;i++)
	{
		var tempChar=string.charAt(i);
		if (letters.indexOf(tempChar)==-1)
		{
		alert("Please choose Right In-game character");
		return false;
		}
	}
	
	if(_CF_this.customers_firstname.value==''){
		alert("Please choose your firstname");
		return false;
	}
	if(_CF_this.customers_lastname.value==''){
		alert("Please choose your lastname");
		return false;
	}

if((_CF_this.countryCode.value!='' && _CF_this.not_use_tel.value!='') || (_CF_this.usa_tel1.value!='' && _CF_this.usa_tel2.value!='' && _CF_this.usa_tel3.value!=''  )){
	}else{
		alert("Incorrect Telephone numbers! Please make sure waht you enter in the box are only numbers,do not include any other symbols");
		return false;
	}
if(_CF_this.countryCode.value!='' && _CF_this.not_use_tel.value!=''){
	if (!CheckNumber(_CF_this.countryCode,"Telphone")){return false;}
	if (!CheckNumber(_CF_this.not_use_tel,"Telphone")){return false;}
}
if(_CF_this.usa_tel1.value!='' && _CF_this.usa_tel2.value!='' && _CF_this.usa_tel3.value!=''){
	if (!CheckNumber(_CF_this.usa_tel1,"Telphone")){return false;}
	if (!CheckNumber(_CF_this.usa_tel2,"Telphone")){return false;}
	if (!CheckNumber(_CF_this.usa_tel3,"Telphone")){return false;}
}
	if(_CF_this.customers_email_address.value==''){
		alert("Please choose your Email");
		return false;
	}else{
	string = _CF_this.customers_email_address.value;
	if (IsEmail(string)){
		return true;
	}else{
	alert("Email is wrong");
	return false;
	}
	}
        
	

	
	//if(_CF_this.servername.value=='Burning Legion'&&_CF_this.faction.value=='0'){
	//	alert("Sorry, this server cannot make delivery currently.");
	//	return false;
	//}
	
	//if(_CF_this.servername.value=='Burning Legion'&&_CF_this.faction.value=='1'){
	//	alert("Sorry, this server cannot make delivery currently.");
	//	return false;
	//}

	//if(_CF_this.servername.value=='Burning Blade'&&_CF_this.faction.value=='0'){
	//	alert("Sorry, this server cannot make delivery currently.");
	//	return false;
	//}
	
	//if  (!_CF_hasValue(_CF_this.charactername, "TEXT" ))
	//{
	//	if  (!_CF_onError(_CF_this, _CF_this.charactername, _CF_this.charactername.value, "Please fill your game character name for the instant delivery."))
		//{
	//		return false;
		//}
	//} 
	//if  (!_CF_hasValue(_CF_this.customers_firstname, "TEXT" ))
	//{
	//if  (!_CF_onError(_CF_this, _CF_this.customers_firstname, _CF_this.customers_firstname.value, "Please fill your first name and the last name."))
		//{
	//		return false;
	//	}
	//}

	//if  (!_CF_hasValue(_CF_this.customers_lastname, "TEXT" ))
	//{
	//	if  (!_CF_onError(_CF_this, _CF_this.customers_lastname, _CF_this.customers_lastname.value, "Please fill your first name and the last name."))
		//{
			//return false;
		//}
	//}

	//if (!_CF_hasValue(_CF_this.customers_email_address, "TEXT" ))
	///{
	//	if  (!_CF_onError(_CF_this, _CF_this.customers_email_address, _CF_this.customers_email_address.value, "Please fill your email address."))
	//	{
	//		return false;
	////	}
//	}
	
	//if(!checkEmail(_CF_this.customers_email_address.value)){
		//alert("Invalid Email Format");
	///	return false;
	//}

	//if  (!_CF_checkphone(_CF_this.usa_tel.value))
	//{
	//	if  (!_CF_onError(_CF_this, _CF_this.usa_tel, _CF_this.usa_tel.value, "Please fill your real telephone number for the order.\nTelephone number format: XXX-XXX-XXXX"))
	//	{
		//	return false;
		//}
	//}

if( (CNumber($('usa_tel1'))&&CNumber($('usa_tel2'))&&CNumber($('usa_tel3')))||(CNumber($('not_use_tel'))&&CNumber($('countryCode')))){return true}else{alert('Incorrect Telephone numbers! Please make sure waht you enter in the box are only numbers,do not include any other symbols');return false}

    return true;
}

function CNumber(myform)
{
	string = myform.value;
	var letters="1234567890";
	var charlength=string.length;
	for (i=0;i<charlength;i++)
	{
		var tempChar=string.charAt(i);
		if (letters.indexOf(tempChar)==-1)
		{
			return false;
		}
	}
	return true;
}

function $(o){return document.getElementById(o)}


