function isDigit(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
	}


function isInteger(val){
	for(var i=0;i<val.length;i++){
		if(!isDigit(val.charAt(i))){return false;}
		}
	return true;
	}
	
function advsrch_form1()
{
   if ( document.searchbyid.srchadno.value == "" )
		{
        alert ( "Please enter an AD no to search" );
		document.searchbyid.srchadno.focus();
		return false;
		}
	if(!isInteger(document.searchbyid.srchadno.value)) 
	{
		alert("AD no can accept only numbers");
		document.searchbyid.srchadno.value="";
		document.searchbyid.srchadno.focus();
		return false;

	}
}
function advsrch_form()
{
	if ( ( document.advsearch.adtype[0].checked == false ) && ( document.advsearch.adtype[1].checked == false ) && ( document.advsearch.adtype[2].checked == false )  )
	     {
                alert ( "Please choose the adtype" );
				return false;
        }
	if ( ( document.advsearch.propertytype.selectedIndex == 0))
			{
					alert ( "Please choose your property type" );
					return false;
			}

}

function qcksrchfrm()
{
	if (( document.qksrch.adtype[0].checked == false ) && ( document.qksrch.adtype[1].checked == false ) && ( document.qksrch.adtype[2].checked == false )  )
	     {
                alert ( "Please choose the search type" );
				return false;
        }
	if ( ( document.qksrch.propertytype.selectedIndex == 0))
			{
					alert ( "Please choose your property type" );
					return false;
			}
return true;
}

function echeck(str) 
		{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(dot)==(lstr-1))
		{
		 alert("Invalid E-mail ID")
		 return false
		}
		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					
		}

function rgtfrm()
{
    valid = true;
	if (( document.register.category[0].checked == false ) && ( document.register.category[1].checked == false ))
	     {
                alert ( "Please choose the user category" );
				return false;
        }
   if ( document.register.name.value == "" )
		{
        alert ( "Please enter your name" );
		document.register.name.focus();
		return false;
		}

	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; 
    for (var i = 0; i < document.register.name.value.length; i++)
		{
                if (iChars.indexOf(document.register.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.register.name.focus();
				return false;
				 }
        }
	var inum = "1234567890"; 
    for (var i = 0; i < document.register.name.value.length; i++)
		{
                if (inum.indexOf(document.register.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.register.name.focus();
				return false;
				 }
        }
	if ( document.register.name.value.length <3)
	{
        alert ( "Minimum 3 characters required for NAME field" );
		document.register.name.focus();
		return false;
	}		
	if ( document.register.email.value == "" )
		{
        alert ( "Please enter your emailid" );
		document.register.email.focus();
		return false;
		}
	if (echeck(document.register.email.value)==false){
		document.register.email.value="";
		document.register.email.focus();
		return false;
		}
	if(!isInteger(document.register.areacode.value)) 
	{
		alert("'Areacode' can accept only numbers");
		document.register.areacode.value="";
		document.register.areacode.focus();
		return false;

	}
	if(!isInteger(document.register.homephone.value))
	{
		alert("Homephone can accept only numbers");
		document.register.homephone.value="";
		document.register.homephone.focus();
		return false;

	}
	if(!isInteger(document.register.mobile.value))
	{
		alert("Mobile can accept only numbers");
		document.register.mobile.value="";
		document.register.mobile.focus();
		return false;

	}
	if ( document.register.password.value == "" )
		{
        alert ( "Please enter your password" );
		document.register.password.focus();
		return false;
		}
	if ( document.register.password.value.length <5)
		{
        alert ( "Password should contain minimum 5 characters" );
		document.register.password.value="";
		document.register.password.focus();
		return false;
		}
		
	if ( document.register.confirmpassword.value == "" )
		{
        alert ( "Please confirm your password" );
		document.register.confirmpassword.focus();
		return false;
		}
	if ( document.register.confirmpassword.value.length <5)
		{
        alert ( "Password should contain minimum 5 characters" );
		document.register.confirmpassword.value="";
		document.register.confirmpassword.focus();
		return false;
		}
	if ( document.register.password.value!=document.register.confirmpassword.value)
		{
        alert ( "Passwords dont match, try again" );
		document.register.password.focus();
		return false;
		}
		
	if ( document.register.agreement.checked == false )
		{
        alert ( "Please accept terms and conditions" );
		return false;
		}
}

	
function advsrch_form1()
{
	if ( document.searchbyid.srchadno.value == "" )
		{
        alert ( "Please enter an AD no to search" );
		document.searchbyid.srchadno.focus();
		return false;
		}
	if(!isInteger(document.searchbyid.srchadno.value)) 
	{
		alert("AD no can accept only numbers");
		document.searchbyid.srchadno.value="";
		document.searchbyid.srchadno.focus();
		return false;
	}
}
function advsrchsignfrm()
{
	if ( ( document.advsearch.adtype[0].checked == false ) && ( document.advsearch.adtype[1].checked == false ) && ( document.advsearch.adtype[2].checked == false )&&  (document.advsearch.adtype[3].checked == false ) &&  (document.advsearch.adtype[4].checked == false ) )
	     {
                alert ( "Please choose the adtype" );
				return false;
        }
	if ( ( document.advsearch.propertytype.selectedIndex == 0))
			{
					alert ( "Please choose your property type" );
					return false;
			}

}
function advsrchsignfrm1()
{
	if ( document.searchbyid.srchadno.value == "" )
		{
        alert ( "Please enter an AD no to search" );
		document.searchbyid.srchadno.focus();
		return false;
		}
	if(!isInteger(document.searchbyid.srchadno.value)) 
	{
		alert("AD no can accept only numbers");
		document.searchbyid.srchadno.value="";
		document.searchbyid.srchadno.focus();
		return false;
	}
}

function plcad( )
{
    valid = true;

    if ( document.placead.title.value == "" )
		{
        alert ( "Please enter your property title" );
		document.placead.title.focus();
		return false;
		}
	if ( ( document.placead.adtype[0].checked == false ) && ( document.placead.adtype[1].checked == false ) && ( document.placead.adtype[2].checked == false ) && ( document.placead.adtype[3].checked == false ) && ( document.placead.adtype[4].checked == false ) )
	     {
                alert ( "Please choose the adtype" );
				return false;
        }
	if ( ( document.placead.propertytype.selectedIndex == 0))
			{
					alert ( "Please choose your property type" );
					return false;
			}
	if ( ( document.placead.areaval.value == ""))
			{
					alert ( "Please enter the built up area" );
					document.placead.areaval.focus();
					return false;
			}
	if(!isInteger(document.placead.areaval.value))
	{
		alert("'Builtup Area' textbox can accept only numbers");
		document.placead.areaval.value="";
		document.placead.areaval.focus();
		return false;
	}
	if(!isInteger(document.placead.thousand.value)) 
	{
		alert("Price textbox can accept only numbers");
		document.placead.thousand.value="";
		document.placead.thousand.focus();
		return false;
	}
	
    if ( ( document.placead.price[0].checked == false)&& ( document.placead.price[1].checked == false))
			{
					alert ( "Please enter data for the property price" );
					return false;
			}
	if ( ( document.placead.price[1].checked == true))
			{
				if(( document.placead.crore.selectedIndex == 0) && ( document.placead.lakh.selectedIndex == 0) && ( document.placead.thousand.value == ""))
				{
						alert ( "Please choose the property price,otherwise say 'contact me'" );
					return false;
				}
			}
	if ( ( document.placead.availability[0].checked == false)&& ( document.placead.availability[1].checked == false))
			{
					alert ( "Please enter the property availability" );
					return false;
			}
	if ( ( document.placead.availability[1].checked == true))
			{
				if(( document.placead.year.selectedIndex == 0))
				{
						alert ( "Please choose the property 'availability year'" );
						return false;
				}
				if(( document.placead.month.selectedIndex == 0))
				{
						alert ( "Please choose the property 'availability month'" );
						return false;
				}
				
			}
	if ( document.placead.description.value == "" )
		{
        alert ( "Please enter the description" );
		document.placead.description.focus();
		return false;
		}
		
	if ( ( document.placead.location.selectedIndex == 0))
			{
					alert ( "Please choose the location" );
					return false;
			}
	if ( document.placead.username.value == "" )
		{
        alert ( "Please enter your username" );
		document.placead.username.focus();
		return false;
		}
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; 
    for (var i = 0; i < document.placead.username.value.length; i++)
		{
                if (iChars.indexOf(document.placead.username.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.placead.username.focus();
				return false;
				 }
        }
	var inum = "1234567890"; 
    for (var i = 0; i < document.placead.username.value.length; i++)
		{
                if (inum.indexOf(document.placead.username.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.placead.username.focus();
				return false;
				 }
        }
	if ( document.placead.username.value.length <3)
	{
        alert ( "Minimum 3 characters required for NAME field" );
		document.placead.username.focus();
		return false;
	}		

	if(!isInteger(document.placead.areacode.value)) 
	{
		alert("'Areacode' can accept only numbers");
		document.placead.areacode.value="";
		document.placead.areacode.focus();
		return false;

	}
	if(!isInteger(document.placead.homephone.value))
	{
		alert("Homephone can accept only numbers");
		document.placead.homephone.value="";
		document.placead.homephone.focus();
		return false;

	}
	if(!isInteger(document.placead.mobile.value))
	{
		alert("Mobile can accept only numbers");
		document.placead.mobile.value="";
		document.placead.mobile.focus();
		return false;

	}
	
	if ( document.placead.email.value == "" )
		{
        alert ( "Please enter your email id" );
		document.placead.email.focus();
		return false;
		}
	if (echeck(document.placead.email.value)==false){
		document.placead.email.value="";
		document.placead.email.focus();
		return false;
		}
	
}

function funcfeed()
{
	   if ( document.feedbck.name.value == "" )
		{
        alert ( "Please enter your name" );
		document.feedbck.name.focus();
		return false;
		}
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; 
    for (var i = 0; i < document.feedbck.name.value.length; i++)
		{
                if (iChars.indexOf(document.feedbck.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.feedbck.name.focus();
				return false;
				 }
        }
	var inum = "1234567890";
    for (var i = 0; i < document.feedbck.name.value.length; i++)
		{
                if (inum.indexOf(document.feedbck.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.feedbck.name.focus();
				return false;
				 }
        }
	if ( document.feedbck.name.value.length <3)
	{
        alert ( "Minimum 3 characters required for NAME field" );
		document.feedbck.name.focus();
		return false;
	}		
	if ( document.feedbck.emailid.value == "" )
		{
        alert ( "Please enter your emailid" );
		document.feedbck.emailid.focus();
		return false;
		}
	if (echeck(document.feedbck.emailid.value)==false){
		document.feedbck.emailid.value="";
		document.feedbck.emailid.focus();
		return false;
		}
	if ( document.feedbck.feedbackmsg.value == "" )
		{
        alert ( "Please enter your message" );
		document.feedbck.feedbackmsg.focus();
		return false;
		}
}

function forg()
{
		if ( document.forgotpwd.email.value == "" )
		{
        alert ( "Please enter your emailid" );
		document.forgotpwd.email.focus();
		return false;
		}
		if (echeck(document.forgotpwd.email.value)==false){
		document.forgotpwd.email.value="";
		document.forgotpwd.email.focus();
		return false;
		}
}

function editaccfrm()
{
    valid = true;
	if (( document.editmyaccount.category[0].checked == false ) && ( document.editmyaccount.category[1].checked == false ))
	     {
                alert ( "Please choose the user category" );
				return false;
        }
   if ( document.editmyaccount.name.value == "" )
		{
        alert ( "Please enter your name" );
		document.editmyaccount.name.focus();
		return false;
		}

	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; 
    for (var i = 0; i < document.editmyaccount.name.value.length; i++)
		{
                if (iChars.indexOf(document.editmyaccount.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.editmyaccount.name.focus();
				return false;
				 }
        }
	var inum = "1234567890"; 
    for (var i = 0; i < document.editmyaccount.name.value.length; i++)
		{
                if (inum.indexOf(document.editmyaccount.name.value.charAt(i)) != -1) 
				{
                alert ("Your NAME should only contain alphabets.No numbers or special characters!");
				document.editmyaccount.name.focus();
				return false;
				 }
        }
	if ( document.editmyaccount.name.value.length <3)
	{
        alert ( "Minimum 3 characters required for NAME field" );
		document.editmyaccount.name.focus();
		return false;
	}		


	if(!isInteger(document.editmyaccount.areacode.value)) 
	{
		alert("'Areacode' can accept only numbers");
		document.editmyaccount.areacode.value="";
		document.editmyaccount.areacode.focus();
		return false;

	}
	if(!isInteger(document.editmyaccount.homephone.value))
	{
		alert("Homephone can accept only numbers");
		document.editmyaccount.homephone.value="";
		document.editmyaccount.homephone.focus();
		return false;

	}
	if(!isInteger(document.editmyaccount.mobile.value))
	{
		alert("Mobile can accept only numbers");
		document.editmyaccount.mobile.value="";
		document.editmyaccount.mobile.focus();
		return false;

	}
}


