// JavaScript Document

function count_fun()
{
var a=0;
a=document.link_submit.description.value.length;
a=a+1;
document.link_submit.count.value=a;
}


function check_news_form()
{
	email = window.document.getElementById('email');
	
	if(trim(email.value) == "")
	{
	  alert("Please enter your email ID.");
	  email.focus();
	  return false;
	}
	if(!isValidMail(email.value))
	{
		alert("Please enter  a valid email ID.");
		email.value='';
		email.focus();
		return false;
	}
	
	//window.location.href="./send.php?email="+email.value+"";
}

function check_form()
{
	with(window.document.reg_form)
	{
			var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|http:\/\/|\/){1}([\w]+)(.[\w]+){1,4}$/;
			
		<!-------	if(trim(url.value)=="")  ------->
		<!-------	{
		<!-------		alert("Please Enter URL."); ------->
		<!-------		url.focus(); ------->
		<!-------		return false; ------->
		<!-------	} ------->
		<!-------	if(urlRegxp.test(url.value) != true) ------->
		<!-------	{ ------->
         <!-------      alert("URL appears to be incorrect.Start with http:// or https://"); ------->
		<!-------	   url.focus(); ------->
		<!-------		return false; ------->
			<!------- } ------->
				
			
			if(pmg_type.value=='0')
			{
				alert("Please select property type.");
				pmg_type.focus();
				return false;
			}
		
				if(office_street.value=="")
			{
				alert("Please enter office street name.");
				office_street.focus();
				return false;
			}
				if(off_suburb.value=="")
			{
				alert("Please enter office suburb name.");
				off_suburb.focus();
				return false;
			}
			
			if(off_state.value=="")
			{
				alert("Please enter office state name.");
				off_state.focus();
				return false;
			}
			
			if(off_pincode.value=="")
			{
				alert("Please enter office pincode number.");
				off_pincode.focus();
				return false;
			}
			
			if(off_tel1.value=="")
			{
				alert("Please enter office telephone  state code.");
				off_tel1.focus();
				return false;
			}
			if (isNaN(off_tel1.value)) {
				alert("Enter the state code in numeric form and without any spaces.");
				off_tel1.focus();
				return false;
			}
			
			
			
			
			if(off_tel.value=="")
			{
				alert("Please enter office telephone number.");
				off_tel.focus();
				return false;
			}
			if (isNaN(off_tel.value)) {
				alert("Enter the phone number in numeric form and without any spaces.");
				off_tel.focus();
				return false;
			}
			if (isNaN(off_fax1.value)) {
				alert("Enter the state code in numeric form and without any spaces.");
				off_fax1.focus();
				return false;
			}
			if (isNaN(off_fax.value)) {
				alert("Enter the phone number in numeric form and without any spaces.");
				off_fax.focus();
				return false;
			}

			if(fname.value=="")
			{
				alert("Please enter first name");
				fname.focus();
				return false;
			}
			
				if(dir_tal1.value=="")
			{
				alert("Please enter direct telephone state code.");
				dir_tal1.focus();
				return false;
			}
			if (isNaN(dir_tal1.value)) {
				alert("Enter the direct telephone state code in numeric form and without any spaces.");
				dir_tal1.focus();
				return false;
			}
			
			
			if(dir_tal.value=="")
			{
				alert("Please enter direct telephone number.");
				dir_tal.focus();
				return false;
			}
			if (isNaN(dir_tal.value)) {
				alert("Enter the direct telephone number in numeric form and without any spacesm.");
				dir_tal.focus();
				return false;
			}
	
	
				
			if (isNaN(dir_mob.value)) {
				alert("Please fill mobile number in numeric form.");
				dir_mob.focus();
				return false;
			}
			
			
			
			if(trim(dir_email.value)=="")
			{
				alert("Please enter your email.");
				dir_email.focus();
				return false;
			}
			if(!isValidMail(dir_email.value))
			{
				alert("Please enter valid email.");
				dir_email.focus();
				return false;
			}
			
		
		  if(pwd.value=="")
			{
				alert("Please enter your  password.");
				pwd.focus();
				return false;
			}
			
			if(con_pwd.value=="")
			{
				alert("Please confirm your password.");
				con_pwd.focus();
				return false;
			}
			
			if(pwd.value!=con_pwd.value){
		
				alert("Password did not match, please enter again.");
				con_pwd.focus();
				return false;
			}
		
			if(urlRegxp.test(website.value) != false) 
			{ 
               alert("URL appears to be incorrect.Start with http:// or https://"); 
			   website.focus(); 
				return false; 
			 }
				if(how_do_you_know.value=="0")
			{
				alert("Please select how do you know about this website.");
				how_do_you_know.focus();
				return false;
			}
				if(usercap.value=="")
			{
				alert("Please enter the verification code");
				usercap.focus();
				return false;
			}
			if(document.getElementById("chk").checked==false)
			{
				alert("You must agree with Terms and Conditions.");
				chk.focus();
				return false;
			}
			
		}
	return true;
}

function login_form1()
{
	with(window.document.login_form)
	{

if(trim(username.value)=="")
			{
				alert("Please enter your email address.");
				username.focus();
				return false;
			}
			if(!isValidMail(username.value))
			{
				alert("Please enter a valid email address.");
				username.focus();
				return false;
			}
			 if(password.value=="")
			{
				alert("Please enter your password");
				password.focus();
				return false;
			}

}
	return true;
}

function login_form2()
{
	with(window.document.login_form)
	{

if(trim(username.value)=="")
			{
				alert("Please enter your email address.");
				username.focus();
				return false;
			}
			if(!isValidMail(username.value))
			{
				alert("Please enter a valid email address.");
				username.focus();
				return false;
			}
			
}
	return true;
}


function trim(s) 
{
 while (s.substring(0,1) == ' ') 
  {
    s = s.substring(1,s.length);
  }
    while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }	
  return s;
}

function isValidMail(mail)
{	
	m=new String(mail);
	var mailLength=m.length
	var totalDOT=0
	var totalROUTE=0
	var totalSPACE=0

	// Should not beging with a '.' or '@'
	if(m.charAt(0)=='@' || m.charAt(0) == '.')
	{	return false;		}

	// 
	for(ctr=1;ctr<=mailLength;ctr++)
	{	if (m.charAt(ctr)=='@')	{	totalROUTE++;	}	
		if (m.charAt(ctr)=='.')	{	totalDOT++;	}	
		if (m.charAt(ctr)==' ') {	totalSPACE++;	}
	}

	if (totalROUTE!=1)			//Checking for Multiple @
	{	return false;		}
	if(totalDOT<1)				//Checking for Route Domain
	{	return false;		}
	if(totalSPACE>0)			//No Embeded Space
	{	return false;		}
	
	//Checking for Invalid Characters

	for(ctr=0;ctr<=mailLength;ctr++)
	{	
		if (m.charAt(ctr)=='`')	return false;	
		else if (m.charAt(ctr)=='!')	return false;	
		else if (m.charAt(ctr)==' ') 	return false;	
		else if (m.charAt(ctr)=='#')	return false;	
		else if (m.charAt(ctr)=='$')	return false;	
		else if (m.charAt(ctr)=='%')	return false;	
		else if (m.charAt(ctr)=='^')	return false;	
		else if (m.charAt(ctr)=='&')	return false;	
		else if (m.charAt(ctr)=='*')	return false;	
		else if (m.charAt(ctr)=='(')	return false;	
		else if (m.charAt(ctr)==')')	return false;	
		else if (m.charAt(ctr)=='+')	return false;	
		else if (m.charAt(ctr)=='=')	return false;	
		else if (m.charAt(ctr)=='|')	return false;	
		else if (m.charAt(ctr)=='\\')	return false;	
		else if (m.charAt(ctr)=='{')	return false;	
		else if (m.charAt(ctr)=='}')	return false;	
		else if (m.charAt(ctr)=='[')	return false;	
		else if (m.charAt(ctr)==']')	return false;	
		else if (m.charAt(ctr)==':')	return false;
		else if (m.charAt(ctr)==';')	return false;	
		else if (m.charAt(ctr)=='"')	return false;	
		else if (m.charAt(ctr)=="'")	return false;	
		else if (m.charAt(ctr)=='<')	return false;	
		else if (m.charAt(ctr)=='>')	return false;	
		else if (m.charAt(ctr)==',')	return false;	
		else if (m.charAt(ctr)=='?')	return false;	
		else if (m.charAt(ctr)=='/')	return false;	
	}
	return true;
}


function CheckAlphabet(character) 
{
	var valid = 1
	character=character.toUpperCase();

	var GoodChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ."
	var i = 0
	if (character=="")
	{
	// Return false if number is empty
	 valid = 0
	}
	for (i =0; i <= character.length -1; i++) 
	{
		if (GoodChars.indexOf(character.charAt(i)) == -1) 
		{
		// Note: Remove the comments from the following line to see this
		// for loop in action.
		// alert(character.charAt(i) + " is no good.")
		valid = 0
		} // End if statement
	} // End for loop
return valid
}

function CheckDigits(TheNumber) 
{   
	var valid = 1
	var GoodChars = "0123456789-+(). "
	var i = 0
		if (TheNumber=="") {
		// Return false if number is empty
		valid = 0
		}
	for (i =0; i <= TheNumber.length -1; i++) {
			if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
			// Note: Remove the comments from the following line to see this
			// for loop in action.
			// alert(TheNumber.charAt(i) + " is no good.")
			valid = 0
			} // End if statement
		} // End for loop
return valid
}   
 