tick = function() { } 

function Init()
{
	LoadLocation();
	
	if (DoSelChange)
		DoSelChange(null);
}

function LoadLocation()
{
	try {
		document.menuFindCentre.searchHome.value = GetCookie("homelocation");
	}
	catch (e)
	{
	}
}

function GetCookie(name)
{
	var res = "";
	var index = 0;

	if (document.cookie)
		index = document.cookie.indexOf(name + "=");
	else
		index = -1;

	if (index < 0)
		res = "";
	else
	{
		var countbegin = (document.cookie.indexOf("=", index) + 1);
		if (0 < countbegin)
		{
			var countend = document.cookie.indexOf(";", countbegin);
			if (countend < 0)
				countend = document.cookie.length;
			res = document.cookie.substring(countbegin, countend);
		}
		else
			res = "";
	}
	
	return res;
}

function ShowNotBuyingOther()
{
	var sel = document.getElementById("notBuyingSelect");
	var otherReason = document.getElementById("notBuyingOtherReason");
	var otherReasonDiv = document.getElementById("notBuyingOtherReasonDiv");
	
	if (sel == null || otherReason == null || otherReasonDiv == null)
		return;
		
	if (sel.options[sel.selectedIndex].value == "Other")
	{
		otherReasonDiv.style.display = "";
		otherReason.focus();
	}
	else
		otherReasonDiv.style.display = "none";
}

////////////////////////////////////////////////////////////////////////////////
//
// Make/Model lookup support
//
var REQUEST = null;
var CONTROL = null;

function CreateRequestObject()
{
	if (typeof XMLHttpRequest != 'undefined') 
	{
		try 
		{
			REQUEST = new XMLHttpRequest();
		} 
		catch (e) 
		{
			REQUEST = null;
		}
	}
	else
	{
		REQUEST = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function SubmitQueryDR(query)
{
	CreateRequestObject();

	if (query == "")
		REQUEST.open("GET", "/includes/makesDR.xml", false);
	else
		REQUEST.open("GET", "/ts/search/GetModels.ashx" + query, false);
	
	REQUEST.send(null);
	ExtractDR();
}

function ExtractDR()
{
	if (CONTROL == null)
		return;
		
	var tags = REQUEST.responseXML.getElementsByTagName(CONTROL.id);

	CONTROL.options[0] = new Option("Select...", "");
	
	for (var i = 0; i < tags.length; i++)
	{
		var item = tags[i].firstChild.nodeValue;
		
		var parts = item.split("@|@");
		
		CONTROL.options[i + 1] = new Option(parts[1],parts[0]);
	}
	
	CONTROL.options[0].selected = true;
	CONTROL.disabled = false;
}

function GetSelectValue(control)
{
	if (control == null || control.selectedIndex < 0)
		return "";
	else
		return control.options[control.selectedIndex].value;
}

function ClearSel(ctrl1, ctrl2, ctrl3, ctrl4, ctrl5)
{
	if (ctrl1)
	{
		ctrl1.options.length = 0;
		ctrl1.disabled = true;
	}

	if (ctrl2)
	{
		ctrl2.options.length = 0;
		ctrl2.disabled = true;
	}

	if (ctrl3)
	{
		ctrl3.options.length = 0;
		ctrl3.disabled = true;
	}

	if (ctrl4)
	{
		ctrl4.options.length = 0;
		ctrl4.disabled = true;
	}

	if (ctrl5)
	{
		ctrl5.options.length = 0;
		ctrl5.disabled = true;
	}
}

function DoSelChange()
{
	// Should be overriden in pages that need it
}
