function callMultiMap()
{
	var doc = document;
	var sHTML = "";
	var xmlHttp;

	if(doc.getElementById("postcode").value != "")
	{
		doc.getElementById("your_postcode").value = doc.getElementById("postcode").value;
	}

	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
 			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.open("GET", "/asp/multimap/places.asp?pc="+doc.getElementById("postcode").value+"&dn="+doc.getElementById("dealername").value, false);
	xmlHttp.send(null);
	sHTML = xmlHttp.responseText;

	if(sHTML.substring(0,5) == "ERROR")
	{
		if(sHTML == "ERROR: No inputs specified.")
		{
			doc.getElementById("error").innerHTML = "Please enter your postcode or a dealer name.";
		}
		if(sHTML == "ERROR: Postcode not matched")
		{
			doc.getElementById("error").innerHTML = "We are sorry, but we could not find<br />a match for your postcode.";
		}
		if(sHTML != "ERROR: Postcode not matched" && sHTML != "ERROR: No inputs specified.")
		{
			doc.getElementById("error").innerHTML = sHTML
		}
		doc.getElementById("error").style.display = "inline";
	}
	else
	{
		doc.getElementById("dealer_loc_right").style.display = "none";
		doc.getElementById("mm_results").style.display = "inline";
		doc.getElementById("mm_results").innerHTML = sHTML;
		document.getElementById("searchagain").style.display = "block";
	}
}

function getDealer(sVal)
{
	var sHTML = "";
	var xmlHttp;

	document.getElementById("your_postcode").value = document.getElementById("postcode").value;
	document.getElementById("postcode").value = sVal;

	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
 			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.open("GET", "/asp/multimap/places.asp?dn="+document.getElementById("postcode").value+"&pc=", false);
	xmlHttp.send(null);
	sHTML = xmlHttp.responseText;

	document.getElementById("mm_results").innerHTML = sHTML;
	if(document.getElementById("your_postcode").value != "")
	{
		document.getElementById("your_postcode1").value = document.getElementById("your_postcode").value;
		document.getElementById("searchagain").style.display = "block";
	}
}

function getDirections(sVal)
{
	var doc = document;
	var sHTML = "";
	var xmlHttp;

	if (doc.getElementById("your_postcode").value == "" && doc.getElementById("your_postcode1").value =="")
	{
		alert("Please enter your postcode.");
		return false;
	}

	if (doc.getElementById("your_postcode").value == "")
	{
		doc.getElementById("your_postcode").value = doc.getElementById("your_postcode1").value
	}
	else
	{
		doc.getElementById("your_postcode1").value = doc.getElementById("your_postcode").value;
	}

	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
 			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.open("GET", "/asp/multimap/getdirections.asp?startpc="+doc.getElementById("your_postcode").value+"&endpc="+sVal, false);
	xmlHttp.send(null);
	sHTML = xmlHttp.responseText;

	if(sHTML.substring(0,5) == "ERROR")
	{
		if(sHTML == "ERROR: Incorrent parameters.")
		{
			doc.getElementById("div_error").innerHTML = "Start and End postcodes were not provided.";
		}
		if(sHTML == "ERROR: No directions")
		{
			doc.getElementById("div_error").innerHTML = "We are sorry, but we could not find<br />directions for this journey.";
		}
		doc.getElementById("div_error").style.display = "inline";
	}
	else
	{
		doc.getElementById("mm_dir_results").innerHTML = sHTML;
		doc.getElementById("mm_dir_results").style.display = "block";
	}
}

function doMapNav(sAction)
{
	var scale = document.getElementById("scale").value;
	var pc = document.getElementById("pc").value;
	var height = document.getElementById("height").value;
	var width = document.getElementById("width").value;
	var x = document.getElementById("x").value;
	var y = document.getElementById("y").value;
	var coordsys = document.getElementById("coordsys").value;
	var xmlHttp;
	var sHTML = "";

	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
 			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.open("GET", "/asp/multimap/places.asp?pc="+pc+"&action="+sAction+"&scale="+scale+"&height="+height+"&width="+width+"&x="+x+"&y="+y+"&coordsys="+coordsys, false);
	xmlHttp.send(null);
	sHTML = xmlHttp.responseText;

	document.getElementById("mm_results").innerHTML = sHTML;	
}

function showDiv(divNo)
{
	document.getElementById("dealerDiv"+divNo).style.display = "block";
}

function hideDiv(divNo)
{
	document.getElementById("dealerDiv"+divNo).style.display = "none";
}

function dealerMapClick(sVal)
{
	document.getElementById("postcode").value = "";
	document.getElementById("dealername").value = sVal;
	callMultiMap();
}