// JavaScript Document

function Validator(theForm)
{
	 
 if(theForm.name.value == "")
  {
    alert("Please enter Name");
    theForm.name.focus();
    return (false);
  }
  if (theForm.tel.value == "")
  {
    alert("Please enter Phone number");
    theForm.tel.focus();
    return (false);
  }
  
  if(theForm.mobile.value == "")
  {
    alert("Please enter mobile number");
    theForm.mobile.focus();
    return (false);
  }
  
   if (theForm.email.value == "")
  {
    alert("Please enter your Email Address");
    theForm.email.focus();
    return (false);
  }
  if  (theForm.email.value != "")
  {   
	var eresult
	var str=theForm.email.value
  	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	  {
		alert("Please enter a valid Email address!")
		theForm.email.focus();
		eresult=false;
		return (eresult);
  	  }
  
  }  
  
  if (theForm.spam.value == "")
  {
    alert("Please Enter Security Code");
    theForm.spam.focus();
    return (false);
  }
  
   /* if (theForm.calculate_two.value == "")
  {
    alert("Please Calculate Calculation");
    theForm.calculate_two.focus();
    return (false);
  }
  
   if (theForm.calculate_two.value != "")
  {
      if (theForm.calculate_two.value != theForm.calculate_one.value)
     {
		 alert("Please Calculate properly");
		 theForm.calculate_two.value = "";
         theForm.calculate_two.focus();
         return (false);
	 }
  }*/
  
   if (theForm.location.value == "Select")
  {
    alert("Please Select Location");
    theForm.location.focus();
    return (false);
  }
  
  
   if (theForm.property_type.value == "Select")
  {
    alert("Please Select property type");
    theForm.property_type.focus();
    return (false);
  }
  
}


function Validator_contact(theForm)
{
	
	if(theForm.name.value == "")
  {
    alert("Please enter Name");
    theForm.name.focus();
    return (false);
  }

  if(theForm.mobile.value == "")
  {
    alert("Please enter mobile number");
    theForm.mobile.focus();
    return (false);
  }
  
   if (theForm.email.value == "")
  {
    alert("Please enter your Email Address");
    theForm.email.focus();
    return (false);
  }
  if  (theForm.email.value != "")
  {   
	var eresult
	var str=theForm.email.value
  	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	  {
		alert("Please enter a valid Email address!")
		theForm.email.focus();
		eresult=false;
		return (eresult);
  	  }
  
  }  
  
    if(theForm.message.value == "")
  {
    alert("Please enter message");
    theForm.message.focus();
    return (false);
  }
  
  
  if (theForm.spam.value == "")
  {
    alert("Please Enter Security Code");
    theForm.spam.focus();
    return (false);
  }
  
  if(theForm.frdname.value == "")
  {
    alert("Please enter Friends Name");
    theForm.frdname.focus();
    return (false);
  }
  
   if (theForm.frdemail.value == "")
  {
    alert("Please enter Friends Email Address");
    theForm.frdemail.focus();
    return (false);
  }
  if  (theForm.frdemail.value != "")
  {   
	var eresult
	var str=theForm.frdemail.value
  	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	  {
		alert("Please enter a valid Email address!")
		theForm.frdemail.focus();
		eresult=false;
		return (eresult);
  	  }
  
  }  
  
}


function getXMLHTTP() { 
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
}
	
	
	
function getCity(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
}


function miniSearch(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('minisearch').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
}


function getProperty(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					
					if (req.status == 200) {						
						document.getElementById('citydiv_two').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
			
	
			
		}
				
}






function showHideWindow(o)
{
	
 		var obj = document.getElementById(o);
        if(obj.style.display == 'block')
          obj.style.display = 'none';
        else
	     obj.style.display = 'block';
}
  
  
function hideDiv() { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideshow').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideshow.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideshow.style.visibility = 'hidden'; 
		} 
	} 
}

function showDiv() { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideshow').style.visibility = 'visible'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideshow.visibility = 'visible'; 
		} 
		else { // IE 4 
			document.all.hideshow.style.visibility = 'visible'; 
		} 
	} 
} 
