// JavaScript Document
function for_search(id)
{
		//alert(id);
	if(id=="by_area")
	{
		if(document.getElementById(id).style.display=="none")
		{
			try
			{
				document.getElementById(id).style.display="table-row";
			}
			catch(eIE)
			{
				document.getElementById(id).style.display="inline";
			}
			document.getElementById("by_listing").style.display="none";
		}
		else
		{
			document.getElementById(id).style.display="none";	
		}
	}
	else
	{
		if(document.getElementById(id).style.display=="none")
		{
			try
			{
				document.getElementById(id).style.display="table-row";
			}
			catch(eIE)
			{
				document.getElementById(id).style.display="inline";
			}
			document.getElementById("by_area").style.display="none";
		}
		else
		{
			document.getElementById(id).style.display="none";	
		}
	}
}
function SubscriberCheck()
	{
       ///alert("test");
		if(document.frm_sav.action_all.checked)
		{
        	do_check=true;
            var j = document.frm_sav["Check_Subscriber[]"].length;
			if(j>1)
			{
            	for(i=0;i<j;i++)
				{
					document.frm_sav["Check_Subscriber[]"][i].checked=  do_check;
				}
			}
			else
				document.frm_sav["Check_Subscriber[]"].checked=  do_check;
        } 
		else
		{
        	do_check=false;
            j = document.frm_sav["Check_Subscriber[]"].length;
			if(j>1)
			{
				for(i=0;i<j;i++)
				{
				   document.frm_sav["Check_Subscriber[]"][i].checked=  do_check;
				}
			}
			else{
				document.frm_sav["Check_Subscriber[]"].checked=do_check;
				}
			
        }
}
function show_element(id)
{
	//if(document.getElementById(id))
//	{
//		//alert(id);
		if(document.getElementById(id).style.display=="none")
		{
			try
			{
				document.getElementById(id).style.display="table-row";
			}
			catch(eIE)
			{
				document.getElementById(id).style.display="inline";
			}
		}
		else
		{
			document.getElementById(id).style.display="none";	
		}
	//}
	//else
//	{
//		alert("nvn");
//	}
}
function hide_element(id)
{
	document.getElementById(id).style.display="none"	;
}
function all_delete(id,type,pageno)
{

  var stat;
  stat =  confirm("Do you want to delet this record permanently?");
  if(stat==true)
  {
	  if(id !="")
      {
		location.href="all_delete.php?id="+id+"&type="+type+"&pageno="+pageno;
	  }
  }
}
function confirm_password()
{
	var new_pass=document.getElementById('New_pass').value;
	var confirm_pass=document.getElementById('Confirm_pass').value;
	if(document.getElementById('Old_pass').value == "") 
	{
		alert("Please type your old password.");
		document.getElementById('Old_pass').focus();
		return false;
	}
	if(document.getElementById('New_pass').value == "") 
	{
		alert("Please type a new password.");
		document.getElementById('New_pass').focus();
		return false;
	}
	if(document.getElementById('Confirm_pass').value == "") 
	{
		alert("Please type confirm password.");
		document.getElementById('Confirm_pass').focus();
		return false;
	}		
	if(confirm_pass!=new_pass)
	{
		alert("Please re-type confirm password.");
		document.getElementById('Confirm_pass').value="";
		document.getElementById('Confirm_pass').focus();
		return false;	
	}
	return true;	
}
function show_comments(id)
{
	//alert(id);	
//	if(document.getElementById(id))
//	{
//		alert(id);
		if(document.getElementById(id).style.display=="none")
		{
			try
			{
				document.getElementById(id).style.display="table-row";
			}
			catch(eIE)
			{
				document.getElementById(id).style.display="inline";
			}
		}
		else
		{
			document.getElementById(id).style.display="none";	
		}
	//}
//	else
//	{
//		alert("not found");
//	}
}
function selectpack(dd)
{
//alert(dd);
	if(document.getElementById("Packages").value == "1") 
	{	
		document.getElementById('hide1').style.display = "none";
		for(var j=2; j<=6; j++)
		{
			document.getElementById(j).style.display = 'none';
		}
	} 
	else 
	{
//		document.getElementById('hide1').style.display = "visible";
		try
		{
 				document.getElementById('hide1').style.display = "table-row"; //works in FF but not in IE
		}
		catch(eIE)
		{
			    document.getElementById('hide1').style.display = 'inline'; // works in IE but not in FF
		}
		for(var i=2; i<=6; i++)
		{
			if(i==dd)
			{
			//alert("if");
				try{
 				document.getElementById(i).style.display = "table-row"; //works in FF but not in IE
				}
				catch(eIE){
				 document.getElementById(i).style.display = 'inline'; // works in IE but not in FF
				}
			
			}
			else
			{
				document.getElementById(i).style.display = 'none';
			}
		}
	}	
	
}
function chk_form()
{
	if(document.getElementById("Firstname").value == "") 
	{
		alert("Please Enter Your Name");
		document.getElementById("Firstname").focus();
		return false;
	}

	if(document.getElementById("E_mail").value == "") 
	{
		alert("Please enter the Email-Id");
		document.getElementById("E_mail").focus();
		return false;
	}
	if(!isEmail(document.getElementById("E_mail").value )) 
	{
		alert("Please Ckeck your Email format");
		document.getElementById("E_mail").focus();
		return false;
	}
	if(document.getElementById("Password").value == "") 
	{
		alert("Please Enter Password");
		document.getElementById("Password").focus();
		return false;
	}
	if(document.getElementById("Confirm_Password").value == "") 
	{
		alert("Please Enter Confirm Password");
		document.getElementById("Confirm_Password").focus();
		return false;
	}
	if(document.getElementById("Password").value != document.getElementById("Confirm_Password").value) 
	{
		alert("Password and Confirm Password must be same");
		document.getElementById("Confirm_Password").focus();
		return false;
	}
} //end of function chkk

function disablesomectrl(){
	
	if(document.getElementById("proptyp").value == "Land")
	{		
		document.getElementById("bedrooms_row").style.display = "none";	
		document.getElementById("bathrooms_row").style.display = "none";		
		document.getElementById("parktypeid_row").style.display = "none";		
		document.getElementById("furnish_row").style.display = "none";		
	}
	else if(document.getElementById("proptyp").value == "Office Space")
	{
		document.getElementById("bedrooms_row").style.display = "none";

		try{
 				document.getElementById("bathrooms_row").style.display = "table-row"; //works in FF but not in IE
				document.getElementById("parktypeid_row").style.display = "table-row"; //works in FF but not in IE
				document.getElementById("furnish_row").style.display = "table-row"; //works in FF but not in IE
				}
				catch(eIE){
				 document.getElementById("bathrooms_row").style.display = 'inline'; // works in IE but not in FF
				 document.getElementById("parktypeid_row").style.display = 'inline'; // works in IE but not in FF
				 document.getElementById("furnish_row").style.display = 'inline'; // works in IE but not in FF
				}
			
	}
	else
	{		
	try{
				document.getElementById("bedrooms_row").style.display = "table-row"; //works in FF but not in IE
 				document.getElementById("bathrooms_row").style.display = "table-row"; //works in FF but not in IE
				document.getElementById("parktypeid_row").style.display = "table-row"; //works in FF but not in IE
				document.getElementById("furnish_row").style.display = "table-row"; //works in FF but not in IE
				}
				catch(eIE){
				 document.getElementById("bedrooms_row").style.display = 'inline'; // works in IE but not in FF
				 document.getElementById("bathrooms_row").style.display = 'inline'; // works in IE but not in FF
				 document.getElementById("parktypeid_row").style.display = 'inline'; // works in IE but not in FF
				 document.getElementById("furnish_row").style.display = 'inline'; // works in IE but not in FF
				}
	}
	
}
function showbedrooms()
    {
	    if(document.AddListing.bedrooms.value!="")
		{
	   	       document.AddListing.bedrooms.value="";
               
		}
	}
	
function showbathrooms()
{
	if(document.AddListing.bathrooms.value!="")
	{
		document.AddListing.bathrooms.value="";
	}
}
function deactivate(id,category) 
{
 	var stat;
	stat =  confirm("Do you want to deactivate this account ? "); 

	if(stat==true)
  	{
  		if(id !="")
		{
			location.href="admin.php?type=member&category="+category+"&deact="+id;
		}
	}
}
function activate(id,category) 
{
 	var stat;
	stat =  confirm(" Do you want to Activate this account ? "); 

	if(stat==true)
  	{
  		if(id !="")
		{
			location.href="admin.php?type=member&category="+category+"&act="+id;
		}
	}
}
	
function fnchk()
{
        if(document.sav.sel.checked)
		{
                do_check=true;
                var j = document.sav["chk[]"].length;
                for(i=0;i<j;i++)
				{
                    document.sav["chk[]"][i].checked=  do_check;
                }
        } 
		else 
		{
                do_check=false;
                j = document.sav["chk[]"].length;
                for(i=0;i<j;i++)
				{
                        document.sav["chk[]"][i].checked=  do_check;
                }
        }
}
//for search
function chkuser()
{

var userid = '<?php if($userid != "") echo $userid; else echo ""; ?>';

if(userid != "") 
{
	return true;
} 
else 
{
	alert('Please register free to save or retrieve your search results.');
	location.replace("register.php");
	return false;
}

}
function pp()
{
j = document.sav["chk[]"].length
count=0;
for(i=0;i<j;i++)
{
if(document.sav["chk[]"][i].checked==true)
count++;
}
if(count < 1)
{
alert("Please select the Listings to save ");
return false;
}
//
var userid1 = '<?php if($userid != "") echo $userid; else echo ""; ?>';
if(userid1 != "") {
return true;
} else {
alert('Please register free to save or retrieve your search results.');
location.replace("register.php");
return false;
}
//
}	
function udelete(id) 
{
	var stat;
	stat =  confirm(" Do you want to delete this record ? ");
	if(stat==true)
	{
		if(id !="")
		{
			//alert(id);
			location.href="client_delete.php?did="+id;
		}
	}
}
function openstats()
{
	emailwindow=dhtmlmodal.open('EmailBox', 'iframe', 'statistics.php', 'Nibash statistics', 'width=300px, height=300px, center=1, resize=0, scrolling=1')

} //End "opennewsletter" function

function show_reply(id)
{
	//alert(id);	
//	if(document.getElementById(id))
//	{
//		alert(id);
		if(document.getElementById(id).style.display=="none")
		{
			try
			{
				document.getElementById(id).style.display="table-row";
			}
			catch(eIE)
			{
				document.getElementById(id).style.display="inline";
			}
		}
		else
		{
			document.getElementById(id).style.display="none";	
		}
	//}
//	else
//	{
//		alert("not found");
//	}
}
/*{function fnchk()

 if(document.sav.sel.checked)
   {
	do_check=true;
	var j = document.sav["chk[]"].length;

		for(i=0;i<j;i++)
		   {
			document.sav["chk[]"][i].checked=  do_check;
			}
	} 
		else 
		{
		 do_check=false;
		 j = document.sav["chk[]"].length;
			for(i=0;i<j;i++)
				{
				document.sav["chk[]"][i].checked=  do_check;
				}
		 }
 }
*/
//For search	