// JavaScript Document
function callActionPage()
{
var total_array=0;
       if(document.frm.state.length)
       {
               total = document.frm.state.length;
               for (i=1;i<total;i++)
               {
                       if (document.frm.state[i].selected)
                       {
                            total_array++;
                       }
               }
       }
return  total_array;
}

function validate()
{	
	
	var first =document.frm.reg_fname;
	if(first.value=='')
	{		
		alert("First Name Should Not Be Blank ");
		first.focus();
		return false;
	}
	var last=document.frm.reg_lname;
	if (last.value=='') 
	{
		alert("Surname Should Not Be Blank");
		last.focus();
		return false;
	}
	var last=document.frm.reg_email;
	if (last.value=='') 
	{
		alert("Email Should Not Be Blank");
		last.focus();
		return false;
	}
	var last=document.frm.reg_user_password;
	if ((last.value=='') || (last.value.length <6))
	{
		alert("Password Should Not Be Blank Or Less Than 6");
		last.focus();
		return false;
	}
	
	var Phone=document.frm.reg_phoneno_r;
	if (Phone.value==''){
		alert("Please Enter Phone Number");
		Phone.focus();
		return false;
	}
	if (document.frm.reg_city.value=='')
	{
		alert("Website Should Not Be Blank");
		document.frm.reg_city.focus();
		return false;
	}
	var middle=document.frm.country ;
	if (middle.value=='')
	{	alert("Please select the state");
		middle.focus();
		return false;
	}
	var sel=callActionPage();
	if(sel == 0) {
	   alert('Please select suburbs');
	   document.frm.state.focus();
	   return false;
	}
	else if (sel > 3)
	{
	   alert('You can select no more than 3 suburbs');
	   document.frm.state.focus();
	   return false;
	}
	if(document.frm.number.value==0)
		{
		alert("Please enter Verification Code");
		document.frm.number.focus();
		return false;
	}
	
	
	
}

	

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	

