function doDisabled()
{
	if (document.form1.Country.value=="155")
	  {
		document.form1.State.disabled=false;
	   	return; 	 
	  }
	 else
	 {
	 	document.form1.State.options[0].selected=true;
	 	document.form1.State.disabled=true;
	   	return; 
	 }
}

function Find(id)
{
 alert("ffff");
 var Start,End,str;
 var Tstr;
 str=new String(id.value);
 Start=0;
 End=document.form1.Country.length;
 var i,Mid;
 i=0;
 while(Start+1<End)
 {
  Mid=parseInt(Start+((End-Start)/2));
  Tstr=new String(document.form1.Country.options[Mid].value);
  Tstr=Tstr.toLowerCase();
  
  if(Tstr.substring(0,str.length)==str)
  {
   document.form1.Country.selectedIndex=Mid;
   End=Start;
  }
  else
  {
	   if(str>Tstr)
	   {
	    Start=Mid;
		//alert("UP "+Start+"-"+End);
	   }
	   else
	   {
	    End=Mid;
		//alert("Down "+Start+"-"+End);
	   }
	  // alert(Mid)
  }
  
 }
 
}



var slicer1,slicer2;
 function makeValue()
 {
 		if (document.form1.UserName.value.length > 7)
		{
		 	alert ("User name field is too Long");
			slicer1=document.form1.UserName.value.slice(0,6)
			document.form1.UserName.value = slicer1;
			document.form1.UserName.focus();
			return false;
		}
		if (document.form1.PassWord.value.length > 7)
		{
		 	alert ("Password field is too long");
			slicer2=document.form1.PassWord.value.slice(0,6)
			document.form1.PassWord.value = slicer2;
			document.form1.PassWord.focus();
			return false;
		}
 }


function check_fields(i,a,x){
if (document.form1.UserName.value=="")
  {
	alert("User name not entered");
	document.form1.UserName.focus();
   	return; 	 
  }
  if(document.form1.UserName.value.length<4){
	alert("User name must be at least 4 characters long!")
	document.form1.UserName.focus();
	return;
  }
if (document.form1.PassWord.value=="")
  {
	alert("Password not entered");
	document.form1.PassWord.focus();
    return; 	
  }
if(document.form1.PassWord.value.length<4){
	alert("User password must be at least 4 characterss long!")
	document.form1.PassWord.focus();
	return;
	}
if (document.form1.PassWordConf.value=="")
  {
	alert("Password Confirm not entered");
	document.form1.PassWordConf.focus();
    return; 	
  }

if (document.form1.PassWord.value !=document.form1.PassWordConf.value)
  {
	alert("Confirm password does not match Password,please change it");
	document.form1.PassWord.focus();
	return;
  }  

/*
  Start spliting the string that has the name of the fields and there attribute
  if they are fields that requires numbers and if they need to be field.
*/
for (j=0;j<i;j++)
{
 b=a.split(",")[j];
//************************************************************************
//----------IF THE FIELD IS REQUIRED AND HAS TO BE NUMBER-----------------
//************************************************************************
if((b.indexOf("*")!=-1)&&(b.indexOf("%")!=-1))
	{
	var f=b.length;	
	b=b.substring(0,f-2);
	var val=(document.form1[b].value);
		if(val=="")//if there is no value in current field
			{
			alert ("Must enter value in "+b+" field");
			document.form1[b].value="";
			document.form1[b].focus();
			return;
			}
    		else //**********strat of else there is a value in field.
			{
			if(isNaN(val)) // if the value in not a number, but it has to be number. 
				{  
				alert ("Must enter numbers in "+b+" field");
				document.form1[b].value="";
				document.form1[b].focus();
				return;
				}
			
			}// *************end of else there is a value in field. 
	}

//************************************************************************
//----------IF THE FIELDS HAS TO BE ENTERED WITH A VALUE-----------------
//************************************************************************
if(b.indexOf("*")!=-1)
{
var f=b.length;	
b=b.substring(0,f-1);
var val=(document.form1[b].value);
    if(val=="")//if there is no value in current field
	{
	alert ("Must enter value in "+b+" field");
	document.form1[b].value="";
	document.form1[b].focus();
	return;
	}
}
//************************************************************************
//----------IF THE THE VALUE MUST BE NUMBER-----------------
//************************************************************************
if(b.indexOf("%")!=-1){//start of if the field input must be number.
var f=b.length;	
b=b.substring(0,f-1);
var val=(document.form1[b].value);
if(isNaN(val))
	{
	alert ("You must enter number in "+b+" field");
	document.form1[b].value="";
	document.form1[b].focus();
	return;
	}
  
}//end of if the field input must be number.

}

 Email=document.form1.email.value;
 if (Email.length >0 )
 	   {
		        var ch;
				ch=0;
				var i   = Email.indexOf("@")
				var j   = Email.indexOf(".",i)
				var k   = Email.indexOf(",")
				var kk  = Email.indexOf(" ")
				var jj  = Email.lastIndexOf(".") + 1
				var len = Email.length
		
				if ((i > 0) && (j > (i + 1)) && (k == -1) && (kk == -1) && (len - jj >= 2) && (len - jj <= 3)) {
				 ch=1;
				}
		        else
				{
				alert("E-mail not valid");
		        document.form1.email.focus();
                return; 	
				}		
	}
	else
	{			
    alert("E-mail not valid");
	document.form1.email.focus();
    return; 	
	}	
document.form1.Register.value="True";
if(x=='UpDate'){
document.form1.action="../User/UpdateUser.asp";
}
else{
document.form1.action="../User/RegistrationForm.asp";
}

document.form1.submit();
return;
}



