// JavaScript Document
//=====================================================================================================================================================================
function validateComment(prop){
	
	if(document.checkComment.name.value == ''){
		alert("Please enter name")	
		document.checkComment.name.focus()
		return false
	}else if(document.checkComment.email.value == ''){
		alert("Please enter email")	
		document.checkComment.email.focus()
		return false
	}else if(!emailCheck(document.checkComment.email.value)){
	document.checkComment.email.focus()
	return false
	}



//=============Send data through Ajax
document.getElementById("SubmitBlue").value = "Please wait.."	
xmlHttp=GetXmlHttpObject()
xmlHttp.onreadystatechange=function (){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
	//alert(xmlHttp.responseText);
	document.checkComment.reset()
	 document.getElementById("SubmitBlue").value = "Sent";
	/* document.getElementById("SubmitBlue").disabled = true*/
	 document.checkComment.onsubmit = returnfalse
	 
	 
	 
} 

}
name = document.checkComment.name.value
email = document.checkComment.email.value
phone = document.checkComment.phone.value
comments = document.checkComment.comments.value
if(document.checkComment.Sendnewsleter.checked){
send = 1
}else{
send = 0
}
//alert(prop)
xmlHttp.open("GET","savedenquiry.php?name="+name+"&email="+email+"&phone="+phone+"&comments="+comments+"&send="+send+"&prop="+prop,true)
xmlHttp.send(null)
return false;
//====END
}
//=====================================================================================================================================================================
function formsubmit(act)
{
	
	
var qry='';
var status=0;
	a=document.frm.list;
	
	if(a == undefined)
	{
	  alert("Please select At Least One Property");
	  return false;
	}
	
	if (a.length == undefined){
		//qry = qry+"&prop[]="+a.value		
		if(a.checked==true)
				{	
				status++;
				qry = qry+"&prop[]="+a.value		
				}
		if(status==0 )
			{		alert("Please select At Least One Property");		
					return false;
			}
		
		}
		
		
		
		else{
	
	for (i = 0; i < a.length; i++) 
			{
			if(a[i].checked==true)
				{	
				status++;
				qry = qry+"&prop[]="+a[i].value			
				}
			}
		if(status==0 )
			{
				if( (a.length) || ( !a.length && !a.checked))
				{
					alert("Please select At Least One Property");		
					return false;
				}
			}
		}






if(act == 'del')
{
document.frm.actions.value = act
document.frm.submit()
}else if(act == 'enq'){
	validateComment(qry)
	return false

}else if(act == 'mail')
{
validate(qry)
return false
}else if(act == 'print')
{
document.frm.action = "print.php"
document.frm.submit()
}
}


//=====================================================================================================================================================================

function validate(prop){
obj = document.friend

	
	if(document.friend.yourname.value == ''){
	alert("Please enter your name")
	document.friend.yourname.focus()
	return false
	}else if(document.friend.youremail.value == ''){
	alert("Please enter your email")
	document.friend.youremail.focus()
	return false
	}else if(!emailCheck(document.friend.youremail.value)){
	document.friend.youremail.focus()
	return false
	}else if(document.friend.friendsName.value == ''){
	alert("Please enter friends name")
	document.friend.friendsName.focus()
	return false
	}else if(document.friend.friendsEmail.value == ''){	
	alert("Please enter your friends Email")
	document.friend.friendsEmail.focus()
	return false
	}else if(!emailCheck(document.friend.friendsEmail.value)){
	document.friend.friendsEmail.focus()
	return false
	}else if(document.friend.captcha.value == '' || document.friend.captcha.value ==   'Enter Code'){	
	alert("Please enter the Code")
	document.friend.captcha.focus()
	return false
	}
	
//=============Send data through Ajax
obj.submitbtn.value = "Please wait.."
xmlHttp=GetXmlHttpObject()
xmlHttp.onreadystatechange=function (){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
	 
	 
	 if(parseInt(xmlHttp.responseText) == 100){
	 alert("Security code mismatch")
	 obj.submitbtn.value = "Send"
	 checkCaptch()

	 return false
	 }else{
		 
		 //alert(xmlHttp.responseText)
		 obj.reset()
	 obj.submitbtn.value = "Sent"
	 obj.onsubmit = returnfalse
	 }

} 

}
name = document.friend.yourname.value
myemail = document.friend.youremail.value
friendEmail = document.friend.friendsEmail.value
fname = document.friend.friendsName.value
capthcha = document.friend.captcha.value
xmlHttp.open("GET","enquiryemailFriend.php?name="+name+"&email="+myemail+"&fname="+fname+"&femail="+friendEmail+"&captcha="+capthcha+prop,true)
xmlHttp.send(null)
return false;
//====END

}
