function FindQuickQuoteMakeUrl(x)
{
	var a = Makes.split(";");
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		if (b[0] == x)
			return b[2];
	}
}

function FormSubmitQuickQuote(o)
{
	var p = document.getElementById("qQType");
	var q = document.getElementById("qQMake");
	var r = document.getElementById("qQModel");
	var x = FindQuickQuoteMakeUrl(q.value);
	
	if (p.value == "0")
		document.location = "http://www.newcars.org/lease/" + x + "/" + r.value + "/";
	else if (p.value == "2")
		document.location = "http://www.newcars.org/trade-in/" + x + "/" + r.value + "/";
	else
		document.location = "http://www.newcars.org/car-price/" + x + "/" + r.value + "/";
	
	return false;
}

function IsQqUnique(x,c)
{
	var a = c.split(",");
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		if (b[0] == x)
			return false;
	}
	return true;
}

function LoadQuickQuoteMakes(Make,Model,m)
{
	var a = Makes.split(";");
	var o = document.getElementById("qQMake"); o.length = 0;
	
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		o.options[i] = new Option(b[1]);
		o.options[i].value = b[0];
		if (Make == b[1]) o.options[i].selected = true;
	}
	
	LoadQuickQuoteModels(Model,m);
}

function LoadQuickQuoteModels(Model,m)
{
	var a = Models.split(";");
	var c = "";
	var o = document.getElementById("qQModel"); o.length = 0;
	var x = document.getElementById("qQMake").value;
	
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		if (x == b[0] && IsQqUnique(b[2],c) == true)
		{
			if (c != "") c = c + ",";
			c = c + b[2] + ":" + b[3];
		}
	}
	
	c = c.split(",");
	c.sort();
	
	for (var i = 0; i < c.length; i++)
	{
		var b = c[i].split(":");
		o.options[i] = new Option((b[0].length <= m) ? b[0] : b[0].substring(0,m));
		o.options[i].title = b[0];
		o.options[i].value = b[1];
		if (Model == b[0]) o.options[i].selected = true;
	}
	
	LoadQuickQuotePhoto();
}

function LoadQuickQuotePhoto()
{
	var o = document.getElementById("qQMake");
	var p = document.getElementById("qQModel");
	var q = document.getElementById("qQPhoto");
	var u = "/photos/"
	
	var a = Makes.split(";");
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		if (o.value == b[0])
		{
			u = u + b[2] + "/";
			i = a.length;
		}
	}
	
	var a = Models.split(";");
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		if (o.value == b[0])
		{
			if (p.value == b[3])
			{
				if (q.style.height != "" && q.style.width != "")
					u = u + b[4] + "/" + b[5] + "-" + q.style.width.replace("px","") + "x" + q.style.height.replace("px","") + ".jpg";
				else
					u = u + b[4] + "/" + b[5] + "-200x100.jpg";
				i = a.length;
			}
		}
	}
	
	q.src = u;
}
