// JavaScript Document
function $(id) { return document.getElementById(id); }
function createXMLHttpRequest( ) {
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
    try { return new XMLHttpRequest( ); } catch(e) {}
    alert("XMLHttpRequest not supported");
    return null;
  }
/* general functions */
get_version_by_maker_model
function functionDatabase(url, tdid) {
	//$("status").options[0].text = "Loading...";
	//alert(url);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
		$(tdid).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(tdid).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url+'&id='+tdid, true);
	xhr.send(null);
}

function get_data(url, id, resultDiv, selected_id) {
//alert(url);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				
			}
			
		}else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url+'?id='+id+'&sel_id='+selected_id, true);
	xhr.send(null);
}
function get_modeldata(url, id, resultDiv, selected_id) {
//alert(resultDiv);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				
			}
			
		}else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url+'?maker='+id+'&sel_id='+selected_id, true);
	xhr.send(null);
}
function get_versiondata(url, id, resultDiv, selected_id) {
//alert(resultDiv);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				
			}
			
		}else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url+'?model='+id+'&sel_id='+selected_id, true);
	xhr.send(null);
}
function get_detail(ele_id, car_id, tot_ele) {
	
	for(var i=0;i<tot_ele;i++) {
		$('car_detail'+i).innerHTML ='';
		//alert($('car_detail'+i).innerHTML);
	}
//alert(ele_id);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { 
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(ele_id).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				//alert(xhr.status);
			}
			
		}else $(ele_id).innerHTML = '<table cellpadding="0" cellspacing="0" border="0" style="border:1px solid #C0C0C0;" width="100%" align="center"><tr><td style="padding-top:20px;" class="search_txt_car"><img src="image/loader.gif">&nbsp;&nbsp;<b>Loading Please Wait..</b></td></tr></table>';
	}

	xhr.open("GET", 'fetch_car_detail.php?id='+car_id, true);
	xhr.send(null);
}

// change status for ad of user particular
function user_status_change_ajax(url, id, resultDiv) {
	//alert(id+'-'+resultDiv);

	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
			$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				//$(resultDiv).innerHTML = '<img src="images/ajax-loader.gif">'
			}
			
		}else $(resultDiv).innerHTML = '<img src="images/ajax-loader.gif">';
	}

	xhr.open("GET", url+'?id='+id, true);
	xhr.send(null);
}

// Function to Add Car ad as Favourite
function make_fav(id, resultDiv, resultDiv1 ) {
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
			$(resultDiv).innerHTML = xhr.responseText;
			$(resultDiv1).innerHTML ='';
		
			} else {
				alert("Message returned with error status.");
				//$(resultDiv).innerHTML = '<img src="images/ajax-loader.gif">'
			}
			
		}else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", 'make_fav.php?id='+id, true);
	xhr.send(null);
}

// Function to Add Car ad as Favourite
function specify_navigation(resultDiv, url) {
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {
//alert(xhr.readyState);
		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
			//$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				//alert("Message returned with error status.");
				
				//$(resultDiv).innerHTML = '<img src="images/ajax-loader.gif">'
			}
			
		}//else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", 'make_session.php?page='+url, true);
	xhr.send(null);
}

function countAllVersion(url, id) {
	//$("status").options[0].text = "Loading...";
	alert(url);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
					$(id).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(id).innerHTML = '';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}

function getmodelbymaker(url, id) {
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
					$(id).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(id).innerHTML = 'working...';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}

function get_model_for_compare(url, resultid, why) {
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
					$(resultid).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(resultid).innerHTML = 'working...';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}

function get_version_for_compare(url, resultid, why) {
	
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultid).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(resultid).innerHTML = 'working...';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}


function get_cityalert(url, resultid) {
	
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultid).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(resultid).innerHTML = 'working...';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}



function get_version_by_maker_model(url, resultID) {
	//$("status").options[0].text = "Loading...";
	//alert(url);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
		$(resultID).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
			}
		}else $(resultID).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}

function model4usercar(url, resultDiv) {
//alert(url);
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {

		if (xhr.readyState==4) { // Request is finished
			if (xhr.status==200) {
				//alert(xhr.responseText);
				$(resultDiv).innerHTML = xhr.responseText;
		
			} else {
				alert("Message returned with error status.");
				
			}
			
		}else $(resultDiv).innerHTML = '<img src="image/ajax-loader.gif">';
	}

	xhr.open("GET", url, true);
	xhr.send(null);
}