//----------------------------------------------------------------------------
// 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 getCities(value) {		
		
	//alert(value);
	strURL = 'http://comp1/indiaautopoint/findcities.php?states_id='+value;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citiesdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
function carSearchForm(){
if (document.simple_car_search.car_type.selectedIndex == 0)

		{

			alert("Please Select your Type");

			document.simple_car_search.car_type.focus();

			return(false);

		}
		
		
}


function check_value_car(){
	
	
	var NumberToTest = document.search_car_form.car_id.value;
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(NumberToTest))
testresult=true
else{
alert("Please input a valid number!")
testresult=false
}
	
	return (testresult);

}


function searchByCarId(){
if (document.search_car.car_id.value == "")

		{

			alert("Please Enter Car Id.");

			document.search_car.car_id.focus();

			return(false);

		}
		
		
}
function checklogin(login){
	
	if (login.user.value == "")

		{

			alert("Please Select Username.");

			login.user.focus();

			return(false);

		}
		
		if (login.pass.value == "")

		{

			alert("Please Select Password.");

			login.pass.focus();

			return(false);

		}
if (login.user_type.selectedIndex == 0)

		{

			alert("Please Select your Type.");

			login.user_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_car(carid)
{
	var x= confirm("Are You Sure to Delete Your Car Details Completely?");
	if(x){
		window.location="listing/process_car.php?car_id="+carid+'&deletecar=deletecar';
	}else{
		return false;
	}
}

function del_car_image(car_image_id)
{
	var x= confirm("Are You Sure to Delete Your Car Image Completely?");
	if(x){
		window.location="listing/process_car.php?car_id="+car_image_id+'&deletecarimage=deletecarimage';
	}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;
				
	}	
}
function carSelection(){
	
	for(var i=0;i<document.car_select_form.car_advertise.length;i++){
		if(document.car_select_form.car_advertise[i].checked){
			var msg = document.car_select_form.car_advertise[i].value;
			
		}
		
			if(msg == 'car_sale'){
			window.location = "listing/add_car_details_sale.php";
		}else{
			window.location = "listing/add_car_details_buy.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';

	
}

