/*###########################################Function to open popup window#############################*/
var path="";
var pop='';
function openwin(nm,width,height,winName){
	var name=nm;
	if (pop && !pop.closed) {
	   pop.close();
	}
	pop=eval("window.open('"+name+"','"+winName+"','chrome[4],toolbar=no,left=5,top=5,width="+width+",height="+height+",directories=no,menubar=no,SCROLLBARS=yes,left=2,right=2')");
	if (!pop.opener) popUpWin.opener = self;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*###########################################Function to Close popup window#############################*/
function close_win(){
	window.opener.location.reload(true);
    self.close();	
}
/*###########################################Function to Check All Checkboxes##########################*/

checked = false;
function CheckAll(frm){
	var frm=eval('document.'+frm);
	var count = frm.elements.length;
	for (i=0; i < count; i++){
		if(frm.elements[i].type=="checkbox"){
			if(frm.elements[i].checked == 0){
				frm.elements[i].checked = 1;
				frm.ch.checked=1;
			} else {
				frm.elements[i].checked = 0;
				frm.ch.checked=0;
			}
		}
	}
}
/*###########################################Function to Check Checked Checkboxes##########################*/
function chkcheked(frmname){
	var count,c;
	var frm=eval('document.'+frmname);
	count=frm.elements.length;
	c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].name == 'chk[]'){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(c == 0){
		alert("Please select a record first.");
		return false;
	}
	else{
		return true;
	}
}
/*###########################################Function to Check Checked Checkboxes For Delete##########################*/
function chkdelete(frmname){
	var count,c,ms;
	var frm=eval('document.'+frmname);
	
	count=frm.elements.length;
	c=0;
	for (i=0; i < count; i++){
		if(frm.elements[i].name == 'chk[]'){
			if(frm.elements[i].checked == 1){
				c = 1;
			}
		}
	}
	if(c == 0){
		alert("Please Select Record(s) to Delete");
		return false;
	}
	else{
		return confirm('Do you really want to delete??');
	}
}
function chktrim(inputString){
	if (typeof inputString != "string") { 
		return inputString; 
	}
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ") { 
    	retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    } 
    ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") { 
    	retValue = retValue.substring(0, retValue.length-1);
        ch = retValue.substring(retValue.length-1, retValue.length);
	}
    while (retValue.indexOf("  ") != -1) { 
    	retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
    return retValue; 
}
function checkreq1(){
	var doc=document.reqfrm1;
	if(!doc.prop_purpose.value.length){
		alert("Please Select Property Pupose");
		doc.prop_purpose.focus();
		return false;
	}
	if(doc.email.value=="Email"){
		alert("Please Enter Your Email");
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.email.value.indexOf('@')==-1 || doc.email.value.indexOf('.')==-1){
		alert("Please Enter the Your Email Correctly");
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.email.value.indexOf('<')!=-1 || doc.email.value.indexOf('>')!=-1){
		alert("Please Dont Use HTML Tags In Your Email");
		doc.email.value='';
		doc.email.focus();
		return false;
	}
	if(doc.phone.value=="Phone"){
		alert("Please Enter Your Phone No.");
		doc.phone.value='';
		doc.phone.focus();
		return false;
	}
	
	if(!doc.prop_state.value.length){
		alert("Please Select Property State");
		doc.prop_state.focus();
		return false;
	}
	if(!doc.prop_state.value.length && doc.Other.value=="Other State"){
		alert("Please Select or Enter Property State");
		doc.prop_state.focus();
		return false;
	}
}
function checksearch1(){
	var doc=document.searchfrm;
	if(!doc.prop_type.value.length && !doc.prop_location.value.length && !doc.prop_purpose.value.length){
		alert("Please Set A Criteria For Searching??");
		doc.prop_type.focus();
		return false;
	}
}
function checknewsletter(){
	var doc=document.newsletter_frm;
	if(!doc.your_name.value.length){
		alert("Please Enter the Your Name");
		doc.your_name.value='';
		doc.your_name.focus();
		return false;
	}
	if(doc.your_name.value.indexOf('<')!=-1 || doc.your_name.value.indexOf('>')!=-1){
		alert("Please Dont Use HTML Tags In Your Name");
		doc.your_name.value='';
		doc.your_name.focus();
		return false;
	}
	if(parseFloat(doc.your_name.value)){
		alert("Please Enter Alphabets only in Your Name");
		doc.your_name.value="";
		doc.your_name.focus();
		return false;
	}
	if(!doc.your_email.value.length){
		alert("Please Enter the Your Email");
		doc.your_email.value='';
		doc.your_email.focus();
		return false;
	}
	if(doc.your_email.value.indexOf('@')==-1 || doc.your_email.value.indexOf('.')==-1){
		alert("Please Enter the Your Email Correctly");
		doc.your_email.value="";
		doc.your_email.focus();
		return false;
	}
	if(doc.your_email.value.indexOf('<')!=-1 || doc.your_email.value.indexOf('>')!=-1){
		alert("Please Dont Use HTML Tags In Your Email");
		doc.your_email.value='';
		doc.your_email.focus();
		return false;
	}
}
function check_feed(){
	var doc,str,s;
	doc=document.feedback;
	s=0;
	if(!doc.your_name.value.length){
		alert("Please Enter the Your Name");
		doc.your_name.focus();
		return false;
	}
	if(doc.your_name.value.indexOf('<')!=-1 || doc.your_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Name");
		doc.your_name.focus();
		return false;
	}
	if(parseFloat(doc.your_name.value)){
		alert("Please Enter Alphabets only in Your Name");
		doc.your_name.value="";
		doc.your_name.focus();
		return false;
	}
	if(doc.your_phone.value.indexOf('<')!=-1 || doc.your_phone.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Phone");
		doc.your_phone.focus();
		return false;	
	}
	if(!doc.your_email.value.length){
		alert("Please Enter the Your Email");
		doc.your_email.focus();
		return false;
	}
	if(doc.your_email.value.indexOf('@')==-1 || doc.your_email.value.indexOf('.')==-1){
		alert("Please Enter the Your Email Correctly");
		doc.your_email.value="";
		doc.your_email.focus();
	return false;
	}
	if(doc.your_email.value.indexOf('<')!=-1 || doc.your_email.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Email");
		doc.your_email.focus();
		return false;
	}
	if(!doc.message.value.length){
		alert("Please Enter the Message");
		doc.message.focus();
		return false;
	}
	if(doc.message.value.indexOf('<')!=-1 || doc.message.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Message");
		doc.message.focus();
		return false;
	}
}
function check_log(){
	var doc,str,s;
	doc=document.log_frm;
	s=0;
	if(!doc.UserName.value.length){
		alert("Please Enter the UserName");
		doc.UserName.focus();
		return false;
	}
	if(doc.UserName.value.indexOf('<')!=-1 || doc.UserName.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In UserName");
		doc.UserName.focus();
		return false;	
	}
	if(!doc.Pass.value.length){
		alert("Please Enter the Password");
		doc.Pass.focus();
		return false;
	}
	if(doc.Pass.value.indexOf('<')!=-1 || doc.Pass.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Password");
		doc.Pass.focus();
		return false;
	}
}
function checkAdd(){
	var doc,str,s;
	doc=document.add_frm;
	s=0;
	if(!doc.member_name.value.length){
		alert("Please Enter the member name");
		doc.member_name.focus();
		return false;
	}
	if(doc.member_name.value.indexOf('<')!=-1 || doc.member_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Company name");
		doc.member_name.focus();
		return false;
	}
	if(parseFloat(doc.member_name.value)){
		alert("Please Enter Alphabets only in Company name");
		doc.member_name.value="";
		doc.member_name.focus();
		return false;
	}
	if(!doc.member_user_name.value.length){
		alert("Please Enter the Member User Name");
		doc.member_user_name.focus();
		return false;
	}
	if(doc.member_user_name.value.indexOf('<')!=-1 || doc.member_user_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Member User Name");
		doc.member_user_name.focus();
		return false;
	}
	if(!doc.member_password.value.length){
		alert("Please Enter the Member Password");
		doc.member_password.focus();
		return false;
	}
	if(doc.member_password.value.indexOf('<')!=-1 || doc.member_password.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Member Password");
		doc.member_password.focus();
		return false;
	}
	if(!doc.member_password_confirmation.value.length){
		alert("Please Enter the Confirm Password");
		doc.member_password_confirmation.focus();
		return false;
	}
	if(doc.member_password_confirmation.value.indexOf('<')!=-1 || doc.member_password_confirmation.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Confirm Password");
		doc.member_password_confirmation.focus();
		return false;
	}
	if(doc.member_password_confirmation.value != doc.member_password.value){
		alert("Please Enter the Confirm Password should be same as Password");
		doc.member_password_confirmation.focus();
		return false;
	}
	
	if(!doc.member_address.value.length){
		alert("Please Enter the member address");
		doc.member_address.focus();
		return false;
	}
	if(doc.member_address.value.indexOf('<')!=-1 || doc.member_address.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In member address");
		doc.member_address.focus();
		return false;
	}
	if(!doc.prop_city.value.length){
		alert("Please Select Property City");
		doc.prop_city.focus();
		return false;
	}
	if(!doc.prop_state.value.length){
		alert("Please Select Property State");
		doc.prop_state.focus();
		return false;
	}
	if(!doc.member_country.value.length){
		alert("Please Enter the member country");
		doc.member_country.focus();
		return false;
	}
	if(doc.member_country.value.indexOf('<')!=-1 || doc.member_country.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In member country");
		doc.member_country.focus();
		return false;
	}
	if(parseFloat(doc.member_country.value)){
		alert("Please Enter Alphabets only in member country");
		doc.member_country.value="";
		doc.member_country.focus();
		return false;
	}
	if(!doc.member_phone.value.length){
		alert("Please Enter the Member Phone");
		doc.member_phone.focus();
		return false;
	}
	if(doc.member_phone.value.indexOf('<')!=-1 || doc.member_phone.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In member phone");
		doc.member_phone.focus();
		return false;
	}
	if(!doc.member_EmailID.value.length){
		alert("Please Enter the member EmailID");
		doc.member_EmailID.focus();
		return false;
	}
	if(doc.member_EmailID.value.indexOf('@')==-1 || doc.member_EmailID.value.indexOf('.')==-1){
		alert("Please Enter the member EmailID Correctly");
		doc.member_EmailID.value="";
		doc.member_EmailID.focus();
		return false;
	}
	if(doc.member_EmailID.value.indexOf('<')!=-1 || doc.member_EmailID.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In member EmailID");
		doc.member_EmailID.focus();
		return false;
	}
}
function checkpass(){
	var doc,str,s;
	doc=document.change_pass;
	s=0;
	if(!doc.old_password.value.length){
		alert("Please Enter the Old Password");
		doc.old_password.focus();
		return false;
	}
	if(doc.old_password.value.indexOf('<')!=-1 || doc.old_password.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Old Password");
		doc.old_password.focus();
		return false;
	}
	if(!doc.new_password.value.length){
		alert("Please Enter the New Password");
		doc.new_password.focus();
		return false;
	}
	if(doc.new_password.value.indexOf('<')!=-1 || doc.new_password.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In New Password");
		doc.new_password.focus();
		return false;
	}
	if(!doc.confirm_password.value.length){
		alert("Please Enter the Confirm Password");
		doc.confirm_password.focus();
		return false;
	}
	if(doc.confirm_password.value.indexOf('<')!=-1 || doc.confirm_password.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Confirm Password");
		doc.confirm_password.focus();
		return false;
	}
	if(doc.confirm_password.value != doc.new_password.value){
		alert("Please Enter the Confirm Password should be same as Password");
		doc.confirm_password.focus();
		return false;
	}
}
function checkprop(){
	var doc,str,s;
	doc=document.add_prop_frm;
	s=0;
	if(!doc.property_purpose.value.length){
		alert("Please Enter the property purpose");
		doc.property_purpose.focus();
		return false;
	}
	if(!doc.property_title.value.length){
		alert("Please Enter the property title");
		doc.property_title.focus();
		return false;
	}
	if(doc.property_title.value.indexOf('<')!=-1 || doc.property_title.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In property title");
		doc.property_title.focus();
		return false;
	}
	if(!doc.property_type.value.length){
		alert("Please select a property type");
		doc.property_type.focus();
		return false;
	}
	if(doc.property_type.value.indexOf('<')!=-1 || doc.property_type.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In property type");
		doc.property_type.focus();
		return false;
	}
	if(!doc.area.value.length){
		alert("Please Enter the area");
		doc.area.focus();
		return false;
	}
	if(doc.area.value.length <= 0 || doc.area.value.length >50){
		alert("Please Enter the area between 0 - 50");
		doc.area.focus();
		return false;
	}
	if(doc.area.value.indexOf('<')!=-1 || doc.area.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In area");
		doc.area.focus();
		return false;
	}
	if(!doc.city.value.length){
		alert("Please Enter the city");
		doc.city.focus();
		return false;
	}
	if(!doc.state.value.length){
		alert("Please Enter the state");
		doc.state.focus();
		return false;
	}
	if(doc.state.value.length <= 0 || doc.state.value.length >80){
		alert("Please Enter the state between 0 - 80");
		doc.state.focus();
		return false;
	}
	if(doc.state.value.indexOf('<')!=-1 || doc.state.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In state");
		doc.state.focus();
		return false;
	}
	if(!doc.postal_code.value.length){
		alert("Please Enter the postal code");
		doc.postal_code.focus();
		return false;
	}
	if(doc.postal_code.value.length <= 0 || doc.postal_code.value.length >10){
		alert("Please Enter the postal code between 0 - 10");
		doc.postal_code.focus();
		return false;
	}
	if(doc.postal_code.value.indexOf('<')!=-1 || doc.postal_code.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In postal code");
		doc.postal_code.focus();
		return false;
	}
	if(!doc.cost.value.length){
		alert("Please Enter Property Price");
		doc.cost.focus();
		return false;
	}
	if(doc.cost.value.indexOf('<')!=-1 || doc.cost.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Property Price");
		doc.cost.focus();
		return false;
	}
	if(!doc.description.value.length){
		alert("Please Enter the description");
		doc.description.focus();
		return false;
	}
	if(doc.description.value.indexOf('<')!=-1 || doc.description.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In description");
		doc.description.focus();
		return false;
	}
	confirm('Are you satisfied with the details??');
}
function checkrefer(){
	var doc,str,s;
	doc=document.refer;
	s=0;
	
	if(!doc.your_name.value.length){
		alert("Please Enter the Your Name");
		doc.your_name.focus();
		return false;
	}
	if(doc.your_name.value.indexOf('<')!=-1 || doc.your_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Name");
		doc.your_name.focus();
		return false;
	}
	if(parseFloat(doc.your_name.value)){
		alert("Please Enter Alphabets only in Your Name");
		doc.your_name.value="";
		doc.your_name.focus();
		return false;
	}
	if(!doc.your_email.value.length){
		alert("Please Enter the Your Email");
		doc.your_email.focus();
		return false;
	}
	if(doc.your_email.value.indexOf('@')==-1 || doc.your_email.value.indexOf('.')==-1){
		alert("Please Enter the Your Email Correctly");
		doc.your_email.value="";
		doc.your_email.focus();
		return false;
	}
	if(doc.your_email.value.indexOf('<')!=-1 || doc.your_email.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Email");
		doc.your_email.focus();
		return false;
	}
	if(!doc.friend_name.value.length){
		alert("Please Enter the Friend Name");
		doc.friend_name.focus();
		return false;
	}
	if(doc.friend_name.value.indexOf('<')!=-1 || doc.friend_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Friend Name");
		doc.friend_name.focus();
		return false;
	}
	if(parseFloat(doc.friend_name.value)){
		alert("Please Enter Alphabets only in Friend Name");
		doc.friend_name.value="";
		doc.friend_name.focus();
		return false;
	}
	if(!doc.friend_email.value.length){
		alert("Please Enter the Friend Email");
		doc.friend_email.focus();
		return false;
	}
	if(doc.friend_email.value.indexOf('@')==-1 || doc.friend_email.value.indexOf('.')==-1){
		alert("Please Enter the Friend Email Correctly");
		doc.friend_email.value="";
		doc.friend_email.focus();
		return false;
	}
	if(doc.friend_email.value.indexOf('<')!=-1 || doc.friend_email.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Friend Email");
		doc.friend_email.focus();
		return false;
	}
}
function checkpayEnq(){
	var doc,str,s;
	doc=document.pay_enq_frm;
	s=0;
	
	if(!doc.your_name.value.length){
		alert("Please Enter the Your Name");
		doc.your_name.focus();
		return false;
	}
	if(doc.your_name.value.indexOf('<')!=-1 || doc.your_name.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Your Name");
		doc.your_name.focus();
		return false;
	}
	if(parseFloat(doc.your_name.value)){
		alert("Please Enter Alphabets only in Your Name");
		doc.your_name.value="";
		doc.your_name.focus();
		return false;
	}
	if(!doc.email.value.length){
		alert("Please Enter the Email");
		doc.email.focus();
		return false;
	}
	if(doc.email.value.indexOf('@')==-1 || doc.email.value.indexOf('.')==-1){
		alert("Please Enter the Email Correctly");
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.email.value.indexOf('<')!=-1 || doc.email.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Email");
		doc.email.focus();
		return false;
	}
	if(doc.phone.value.indexOf('<')!=-1 || doc.phone.value.indexOf('>')!=-1){
		alert("Please Don't Use HTML Tags In Phone");
		doc.phone.focus();
		return false;
	}
}
