function show(id)
{
 document.getElementById(id).className='visibleobject';
}
function hide(id)
{
 document.getElementById(id).className='invisibleobject';
}
function toggle_display(id)
{
 if (document.getElementById(id).className=='visibleobject')  
  { hide(id); }
 else
 { show(id); }
}
// JavaScript Document
	var whitespace = " \t\n\r";
// Function to check whether the value in a Text Field is Null
	function isEmpty(s)
	{  return ((s == null) || (s.length == 0))
	}
// Function to check whether the value in a Text Field is a WhiteSpace
	function isWhitespace (s)
	{  var i;
 	  // Is s empty?
 	  if (isEmpty(s)) return true;
 	   // Search through string's characters one by one
 	   // until we find a non-whitespace character.
 	   // When we do, return false; if we don't, return true.
 	   for (i = 0; i < s.length; i++)
 	   {   
 	  // Check that current character isn't whitespace.
 	  var c = s.charAt(i);
 	  if (whitespace.indexOf(c) == -1) return false;
 	   }
 	   // All characters are whitespace.
	  return true;
	}
// Function to ensure that the email address is in proper format
	function isEmail (s)
  	{
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
	  // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
    }
 function isWebsite (s)
  	{
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
    }
  function isCharsInBag (s, bag)
  {  
  var i;
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if (bag.indexOf(c) == -1)
	 return false;
  }
  return true;
  }
function validate()
{
var name= document.send_form.name.value;
 if(name=="")
 {
		alert( "Please Enter  Name");
		document.send_form.name.focus( );
		return false;
 }

  var email = document.send_form.email.value;
	if(email=="")
	{
		alert("Please enter the Email");
		document.send_form.email.focus( );
		return false;
	}
	else{
	if (!isEmail(email))
		{
			alert("Please enter the Email address in the proper Format");
			document.send_form.email.focus( );	
			return false;
		}
	}

	len=document.send_form.prefer_contact.length;
				if(!len)
				chosen = document.send_form.prefer_contact.value;	
				else
				{	
				for (i = 0; i <len; i++) {
				if (document.send_form.prefer_contact[i].checked) {
				chosen = document.send_form.prefer_contact[i].value				}
				}	
				}
		myOption = -1;
		for (i=send_form.renting_options.length-1; i > -1; i--) {
		if (send_form.renting_options[i].checked) {
		myOption = i;
		}
		}
		if (myOption == -1) {
		alert("You must select Do You want to Option");
		return false;
		}
	len2=document.send_form.renting_options.length;
				if(!len2)
				chosen2 = document.send_form.renting_options.value;	
				else
				{	
				for (i = 0; i <len2; i++) {
				if (document.send_form.renting_options[i].checked) {
				chosen2 = document.send_form.renting_options[i].value				}
				}	
				}
	getRequest('FormSubmissionAjax.php?action=query1&id=queryBox&name='+document.send_form.name.value+'&email='+document.send_form.email.value+'&phone='+document.send_form.phone.value+'&best_time='+document.send_form.best_time.value+'&prefer_contact='+chosen+'&currency='+document.send_form.currency.value+'&budget='+document.send_form.budget.value+'&amount='+document.send_form.amount1.value +'&property_type='+document.send_form.property_type.value+'&renting_options='+chosen2+'&requirements='+document.send_form.requirements.value+'&location='+document.send_form.location.value+'&entity_id='+document.send_form.entity_id.value+'&entity_level='+document.send_form.entity_level.value,'queryBox','');
}
function validatelistform()
{
var name= document.list_property_form.name.value;
 if(name=="")
 {
		alert( "Please Enter  Name");
		document.list_property_form.name.focus( );
		return false;
 }

  var email = document.list_property_form.email.value;
	if(email=="")
	{
		alert("Please enter the Email");
		document.list_property_form.email.focus( );
		return false;
	}
	else{
	if (!isEmail(email))
		{
			alert("Please enter the Email address in the proper Format");
			document.list_property_form.email.focus( );	
			return false;
		}
	}
myOption = -1;
for (i=list_property_form.list_for.length-1; i > -1; i--) {
if (list_property_form.list_for[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("You must select List For Option");
return false;
}
len=document.list_property_form.list_for.length;
if(!len)
chosen = document.list_property_form.list_for.value;	
else
{	
for (i = 0; i <len; i++) {
if (document.list_property_form.list_for[i].checked) {
chosen = document.list_property_form.list_for[i].value
				}
}	
}
 var area= document.list_property_form.area.value;
 if(area=="")
 {
		alert( "Please Enter  Area");
		document.list_property_form.area.focus( );
		return false;
 }
len1=document.list_property_form.visible_phone.length;
if(!len1)
chosen1 = document.list_property_form.visible_phone.value;	
else
{	
for (i = 0; i <len1; i++) {
if (document.list_property_form.visible_phone[i].checked) {
chosen1= document.list_property_form.visible_phone[i].value				}
}	
}
	getRequest('FormSubmissionAjax.php?action=query2&id=rentBox&short_heading='+document.list_property_form.short_heading.value+'&name='+document.list_property_form.name.value+'&rvalue='+document.list_property_form.rvalue.value+'&pvalue='+document.list_property_form.pvalue.value+'&area='+document.list_property_form.area.value+'&email='+document.list_property_form.email.value +'&phone='+document.list_property_form.phone.value+'&property_type='+document.list_property_form.property_type.value+'&location='+document.list_property_form.location.value+'&list_for='+chosen+'&visible_phone='+chosen1+'&comments='+document.list_property_form.details.value+'&image='+document.list_property_form.image.value+document.send_form.entity_id.value+'&entity_level='+document.send_form.entity_level.value,'rentBox','');
}

function validateProjectEnquiry(verifyEmail)
{
  	var EmailRegex=/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,6})$/i;
	var varFromEmail= document.getElementById(verifyEmail).value;
	//alert(varFromEmail);
	if((varFromEmail!=""  && (EmailRegex.test(varFromEmail)) != true)||(varFromEmail=="" ))
	{
		//alert("Please enter correct email format.");
		//document.getElementById(varFromEmail).focus();
		return false;
	}
	else return true;
}

function searchValidEmail()
{
	//alert('email validation requested');
	answer=false;
	for (var x=1; x<7; x++)
	{
	   	//alert(x);
		y =x;
		thisId = 'identity[' + y + ']';
		t = document.getElementById(thisId).value;
		//alert(thisId);
		//alert(t);
	   	answer = validateProjectEnquiry(thisId);
   		if (answer == true)
		{
			j = x;
			x = 100;
			//alert("Hello");
		}
	}
	if (answer == false)
	{
	   	alert("Please enter correct email format.");
		document.getElementById(thisId).focus();
		return false;
	}
	
}
	
