//----------------------------------------------------------------------------
// Code to delete user
//----------------------------------------------------------------------------
function getXMLHTTP() { //fuction to return the xml http object
		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 CarModels(strURL) {		
		
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('modelcardiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	function getCarVersions(str) {	

		
		var req = getXMLHTTP();
		
		if (req) {
		
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('versiondiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", str, true);
			req.send(null);
		}
				
	}
	
function checkSearchForm(form){
if (form.property_type.selectedIndex == 0)

		{

			alert("Please Select your Property Type");

			form.property_type.focus();

			return(false);

		}
}
function del(userid)
{
	var x= confirm("Are You Sure to Delete Your Profile Completely?");
	if(x){
		window.location="process.php?user_id="+userid;
	}else{
		return false;
	}
}
function del_pro(userid,type)
{
	var x= confirm("Are You Sure to Delete Your Property Completely?");
	if(x){
		window.location="listing/process_property.php?property_id="+userid+'&type='+type;
	}else{
		return false;
	}
}

function del_property_image(property_image_id,table)
{
	var x= confirm("Are You Sure to Delete Your Property Image Completely?");
	if(x){
		window.location="listing/process_property.php?property_id="+property_image_id+'&table='+table;
	}else{
		return false;
	}
}
function search_by_id(){
	var id = document.search_by_id_form.property_id.value;
	for(var i=0;i<document.search_by_id_form.type.length;i++){
		if(document.search_by_id_form.type[i].checked){
			var msg = document.search_by_id_form.type[i].value;
			
		}
		
			window.location="process_test.php?property_id="+id+'&msg='+msg;
				
	}	
}
//----------------------------------------------------------------------------
// Code to select property in dashboard
//----------------------------------------------------------------------------
function comPropSelection(){
	
	for(var i=0;i<document.com_prop_select_form.com_prop_selection.length;i++){
		if(document.com_prop_select_form.com_prop_selection[i].checked){
			var msg = document.com_prop_select_form.com_prop_selection[i].value;
			//alert("test");
		}
		if(msg == 'com_lease'){
			window.location = "listing/commercial_lease.php";
		}else{
			window.location = "listing/commercial_sale.php"	;
		}		
	}	
}



function resiPropSelection(){
	
	for(var i=0;i<document.resi_prop_select_form.resi_prop_selection.length;i++){
		if(document.resi_prop_select_form.resi_prop_selection[i].checked){
			var msg = document.resi_prop_select_form.resi_prop_selection[i].value;
			//alert("test");
		}
		if(msg == 'resi_rent'){
			window.location = "listing/residential_rent.php";
		}else{
			window.location = "listing/residential_sale.php"	;
		}		
	}	
}

function optionBuyProperty(){
	document.getElementById('min_budget_buy').style.display = 'block';
	document.getElementById('max_budget_buy').style.display = 'block';
	document.getElementById('min_budget_rent').style.display = 'none';
	document.getElementById('max_budget_rent').style.display = 'none';

}
function optionRentProperty(){
	document.getElementById('min_budget_buy').style.display = 'none';
	document.getElementById('max_budget_buy').style.display = 'none';
	document.getElementById('min_budget_rent').style.display = 'block';
	document.getElementById('max_budget_rent').style.display = 'block';

	
}