function startList()
{
	if (document.all&&document.getElementById)
	{
		navRoot = document.getElementById("drop_menu");
		for (i=0; i<navRoot.childNodes.length; i++)
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI")
			{
				node.onmouseover=function()
				{
					this.className+=" hover";
  				}
  				node.onmouseout=function()
  				{
  					this.className=this.className.replace(" hover", "");
   				}
   			}
  		}
 	}
}

var xmlHttp;
function getModelSearch(make_id,pos){
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var url = "../controller/controller-get-option-search.php?make_id="+make_id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
			document.getElementById(pos).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function subscribe1(){
	name = document.getElementById('name').value;
	email = document.getElementById('email').value;
	pos="send_result";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var url = "../controller/controller-subscribe.php?name="+name+"&email="+email;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
			document.getElementById(pos).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function sendEnquiry1(car_id){
	name = document.getElementById('name').value;
	email = document.getElementById('email').value;
	phone = document.getElementById('phone').value;
	comment = document.getElementById('comment').value;
	mobile = document.getElementById('mobile').value;
	sub="no";
	if(document.getElementById('sub').checked){
		sub="yes";
	}
	pos="send_result";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var url = "../controller/controller-send-enquiry.php?car_id="+car_id+"&name="
				+name+"&email="+email+"&phone="+phone+"&comment="
				+comment+"&mobile="+mobile+"&sub="+sub;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
			document.getElementById(pos).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function sendEnquiry(){
	car_id= document.getElementById('car_id').value;
	name = document.getElementById('name').value;
	email = document.getElementById('email').value;
	phone = document.getElementById('phone').value;
	comment = document.getElementById('comment').value;
	mobile = document.getElementById('mobile').value;
	sub="no";
	span="enq_span";
	if(document.getElementById('sub').checked){
		sub="yes";
	}

	var url = "../controller/controller-send-enquiry.php?car_id="+car_id+"&name="
				+name+"&email="+email+"&phone="+phone+"&comment="
				+comment+"&mobile="+mobile+"&sub="+sub;
	url=url+"&sid="+Math.random();
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
        xmlhttp=new XMLHttpRequest();
    } else if (window.ActiveXObject) { //IE
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
    }

    // if we have created the xmlhttp object we can send the request
    if (typeof(xmlhttp)=='object') {
        xmlhttp.onreadystatechange=function xmlhttpResults() {
		    if (xmlhttp.readyState==4) {
		        if (xmlhttp.status==200) {
		            // we use a delay only for this example
		            setTimeout('loadEnqResults("enq_span","send_result")',1000);
		        }
		    }
		};
        xmlhttp.open('GET', url, true);
        xmlhttp.send(null);
        // replace the submit button image with a please wait for the results image.
       document.getElementById(span).innerHTML = '<img src="../img/loading.gif">';
    // otherwise display an error message
    } else {
        alert('Your browser is not remote scripting enabled. You can not run this example.');
    }
}

function loadEnqResults(span,result) {
    // put the results on the page
    document.getElementById(result).innerHTML = xmlhttp.responseText;
    // replace the please wait image with the results are ready image
    document.getElementById(span).innerHTML = '<img src="../img/loading.gif">';
    // delay for 2 seconds before resetting the submit image button.
	document.getElementById(span).innerHTML = '<input type="button" name="search" value="Send Enquiry" class="bt_red2"  onclick="javascript:sendEnquiry()"/></span>';
}

function subscribe() {
	name = document.getElementById('name').value;
	email = document.getElementById('email').value;
	span="sub_span";
	var url = "../controller/controller-subscribe.php?name="+name+"&email="+email;
	url=url+"&sid="+Math.random();

    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
        xmlhttp=new XMLHttpRequest();
    } else if (window.ActiveXObject) { //IE
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
    }

    // if we have created the xmlhttp object we can send the request
    if (typeof(xmlhttp)=='object') {
        xmlhttp.onreadystatechange=function xmlhttpResults() {
		    if (xmlhttp.readyState==4) {
		        if (xmlhttp.status==200) {
		            // we use a delay only for this example
		            setTimeout('loadResults("sub_span","send_result")',1000);
		        }
		    }
		};
        xmlhttp.open('GET', url, true);
        xmlhttp.send(null);
        // replace the submit button image with a please wait for the results image.
       document.getElementById(span).innerHTML = '<img src="../img/loading.gif">';
    // otherwise display an error message
    } else {
        alert('Your browser is not remote scripting enabled. You can not run this example.');
    }
}

// function to handle asynchronous call


function loadResults(span,result) {
    // put the results on the page
    document.getElementById(result).innerHTML = xmlhttp.responseText;
    // replace the please wait image with the results are ready image
    document.getElementById(span).innerHTML = '<img src="../img/loading.gif">';
    // delay for 2 seconds before resetting the submit image button.
	document.getElementById(span).innerHTML = '<a class="button_link" id="subscribe" href="javascript:subscribe()">Subscribe</a>';
}


function getMainPhoto(photo_id){
	pos="main_photo";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var url = "../controller/controller-get-photo.php?type=main&photo_id="+photo_id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
			document.getElementById(pos).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function navPhotos(car_id,nav,page){
	pos="scroll_bar";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var url = "../controller/controller-get-photo.php?page="+page+"&type="+nav+"&car_id="+car_id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
			document.getElementById(pos).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
/*-------------------------------------------------------*/
// httmRequest
function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
	  // Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
	  // Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
