function SelectHomeModelSelected()
{
	var ModelList = document.getElementById("selectHomeModel");

	//Getting the selected country from country combo box.
	var selectedModel = ModelList.options[ModelList.selectedIndex].value;
	//alert(selectedModel);
	var tmpModel = selectedModel.split('*/*');
	//alert(tmpModel[2]);
	window.location = tmpModel[2];
	
	
}


//Global XMLHTTP Request object
var XmlHttp;

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

//Gets called when country combo box selection changes
function SelectHomeMakeSelected() 
{
	
	var MakeList = document.getElementById("selectHomeMake");

	//Getting the selected country from country combo box.
	var selectedMake = MakeList.options[MakeList.selectedIndex].value;
	
	// URL to get states for a given country
	var requestUrl = "ajaxGetModels.aspx" + "?Make=" + selectedMake;
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}


//Called when response comes back from server
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			//ClearAndSetYearListItems(XmlHttp.responseXML.documentElement);
			SetSelectHomeModelList(XmlHttp.responseText );			
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

function SetSelectHomeModelList(strIn)
{
    var ModelList = document.getElementById("selectHomeModel");

	for (var count = ModelList.options.length-1; count >-1; count--)
	{
		ModelList.options[count] = null;
	}
	
	var textValue; 
	var optionItem;
	var maxLength;
	maxLength = 0;
	

		optionItem = new Option( textValue, textValue,  false, false);

		ModelList.disabled=false;
		optionItem = new Option('Select Model', '',  false, false);
		ModelList.options[ModelList.length] = optionItem;
		ModelList.options[ModelList.length-1].style.backgroundColor='#eeeeee';
		
		var lastType;
				
		var addModel = strIn.split('|');		
		for(i=0; i!=addModel.length; i++)
			{
				if(addModel[i] != '') {
				
					var tmpStr = addModel[i].split('*/*');						
					
					optionItem = new Option(tmpStr[0], addModel[i], false, false);
					ModelList.options[ModelList.length] = optionItem;
					
					
					}
			}

}


// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
