// JavaScript Document
//sex下拉
function slt_sex(sex)
{
  $('sex').length=0;
  var sex=sex;
  var arr_sex=new Array('Mr.','Ms.','Mrs.','Dr.');
  $('sex').options[$('sex').length]=new Option(arr_sex[0],arr_sex[0]);

	var k=0;
  for(i=1;i<arr_sex.length;i++)
  {
    if(arr_sex[i]==sex)
    {
      $('sex').options[$('sex').length]=new Option(arr_sex[i],arr_sex[i]);
			k=i;
    }
    else
    {
      $('sex').options[$('sex').length]=new Option(arr_sex[i],arr_sex[i]);
    }
  }
	$('sex').options[k].selected=true;
}

function trim(str)
{ 
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
} 

function $(id)
{
	return document.getElementById(id);
}
//表单验证
function checkForm()
{
	if(trim($('txtName_1').value)==""){	
		$('txtName_1').style.backgroundColor='#000000';
		$('txtName_1').focus();
		return false;
	}
	else{
		$('txtName_1').style.backgroundColor='#FFCC99';
	}
	
	if(trim($('txtName_2').value)==""){	
		$('txtName_2').style.backgroundColor='#000000';
		$('txtName_2').focus();
		return false;
	}
	else{
		$('txtName_2').style.backgroundColor='#FFCC99';
	}	
	
	if(trim($('txtCompany').value)=="")	{	
		$('txtCompany').style.backgroundColor='#000000';
		$('txtCompany').focus();
		return false;
	}
	else	{
		$('txtCompany').style.backgroundColor='#FFCC99';
	}
		
	if(trim($('txtJob_Title').value)=="")	{	
		$('txtJob_Title').style.backgroundColor='#000000';
		$('txtJob_Title').focus();
		return false;
	}	
	else	{
		$('txtJob_Title').style.backgroundColor='#FFCC99';
	}
	
	if(trim($('txtMail').value)=="")
	{	
		$('txtMail').style.backgroundColor='#000000';
		$('txtMail').focus();		
		return false;
	}
	else
	{
		$('txtMail').style.backgroundColor='#FFCC99';
	}
		
	var testRegExp=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!testRegExp.test(trim($('txtMail').value)))
	{
		alert("Wrong email!");
		$('txtMail').focus();		
		return false;
	}
			
	if(trim($('txtReMail').value)!=trim($('txtMail').value))
	{	
		$('txtReMail').style.backgroundColor='#000000';
		$('txtReMail').focus();				
		return false;
	}	
	else
	{
		$('txtReMail').style.backgroundColor='#FFCC99';
	}
		
	if(trim($('txtPwd').value)=="")
	{	
		$('txtPwd').style.backgroundColor='#000000';
		$('txtPwd').focus();
		return false;
	}
	else
	{
		$('txtPwd').style.backgroundColor='#FFCC99';
	}
		
	if($('txtRePwd').value!=$('txtPwd').value)
	{	
		$('txtRePwd').style.backgroundColor='#000000';
		$('txtRePwd').focus();		
		return false;
	}	
	else
	{
		$('txtRePwd').style.backgroundColor='#FFCC99';
	}

	if(trim($('txtTel_1').value)=="")	{	
		$('txtTel_1').style.backgroundColor='#000000';
		$('txtTel_1').focus();
		return false;
	}
	else	{
		$('txtTel_1').style.backgroundColor='#FFCC99';
	}
	
	if(trim($('txtTel_2').value)=="")	{	
		$('txtTel_2').style.backgroundColor='#000000';
		$('txtTel_2').focus();
		return false;
	}
	else	{
		$('txtTel_2').style.backgroundColor='#FFCC99';
	}	
	
	if(trim($('txtTel_3').value)=="")	{	
		$('txtTel_3').style.backgroundColor='#000000';
		$('txtTel_3').focus();
		return false;
	}
	else	{
		$('txtTel_3').style.backgroundColor='#FFCC99';
	}	
	
	if(isNaN($('txtTel_1').value) || isNaN($('txtTel_2').value) || isNaN($('txtTel_3').value))
	{
		alert('The telephone number must be a digit !');
		return false;
	}
	
	if(trim($('sltCountry').value)=="")	{	
		alert('Please select the country');
		return false;
	}			
			
	if(trim($('txtAdd_1').value)=="")	{	
		$('txtAdd_1').style.backgroundColor='#000000';
		$('txtAdd_1').focus();
		return false;
	}
	else	{
		$('txtAdd_1').style.backgroundColor='#FFCC99';
	}
				
	if(trim($('txtAdd_2').value)=="")	{	
		$('txtAdd_2').style.backgroundColor='#000000';
		$('txtAdd_2').focus();
		return false;
	}
	else	{
		$('txtAdd_2').style.backgroundColor='#FFCC99';
	}
	
	if(trim($('txtZip').value)=="")	{	
		$('txtZip').style.backgroundColor='#000000';
		$('txtZip').focus();
		return false;
	}
	else	{
		$('txtZip').style.backgroundColor='#FFCC99';
	}	

	return true;
}
