//sub menus
function showAboutSub()
{
	document.getElementById('menu-about-dropdown').style.display="block";
	document.getElementById('menu-aboutus').style.background="#000000 url(images/menu-triangle.png) no-repeat bottom center";
	document.getElementById('menu-aboutus').style.color="#ffffff";
	document.getElementById('sub-menu-space').style.display="block";
}
function hideAboutSub()
{
	document.getElementById('menu-about-dropdown').style.display="none";
	document.getElementById('menu-aboutus').style.background="none";
	document.getElementById('menu-aboutus').style.color="#000000";
	document.getElementById('sub-menu-space').style.display="none";
}

function showInfoSub()
{
	document.getElementById('menu-info-dropdown').style.display="block";
	document.getElementById('menu-info').style.background="#000000 url(images/menu-triangle.png) no-repeat bottom center";
	document.getElementById('menu-info').style.color="#ffffff";
	document.getElementById('sub-menu-space').style.display="block";
}
function hideInfoSub()
{
	document.getElementById('menu-info-dropdown').style.display="none";
	document.getElementById('menu-info').style.background="none";
	document.getElementById('menu-info').style.color="#000000";
	document.getElementById('sub-menu-space').style.display="none";
}

function showTechTips(page)
{
	document.getElementById('batteries').style.display="none";
	document.getElementById('lights').style.display="none";
	document.getElementById('spark-plugs').style.display="none";
	document.getElementById('horns').style.display="none";
	switch(page)
	{
	case "batteries":
		document.getElementById('batteries').style.display="block";
		break;
	case "lights":
		document.getElementById('lights').style.display="block";
		break;
	case "spark-plugs":
		document.getElementById('spark-plugs').style.display="block";
		break;
	case "horns":
		document.getElementById('horns').style.display="block";
		break;
	}
}

function showBusinessPartner(page)
{
	document.getElementById('bsn').style.display="none";
	document.getElementById('ecn').style.display="none";
	document.getElementById('bp').style.display="none";
	switch(page)
	{
	case "bsn":
		document.getElementById('bsn').style.display="block";
		break;
	case "ecn":
		document.getElementById('ecn').style.display="block";
		break;
	case "bp":
		document.getElementById('bp').style.display="block";
		break;
	}
}

//dealer locator
function showDealerList(province)
{
	hideAllProvinceDealers();
	if (province != "...")
		document.getElementById('dealer-selectdiv-'+province).style.display="block";
}

function hideAllProvinceDealers()
{
	var arrProvince = new Array("ec","fs","gt","kzn","lmp","mpl","nw","nc","wc");
	for (i=0; i<arrProvince.length;i++)
		document.getElementById('dealer-selectdiv-'+arrProvince[i]).style.display="none";
}

function textDealerList()
{
	//open dealers.xml
	if (window.XMLHttpRequest)
  	{
		xhttp=new XMLHttpRequest();
	}
	else // Internet Explorer 5/6
  	{
		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhttp.open("GET","include/dealers.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	
	//create an html string to dump everything on the page
	var html = "";

	var x = xmlDoc.getElementsByTagName("province");
	for (i=0;i<x.length;i++) //cycle through the main tags with the name "province"
	{
		provinceName = xmlDoc.getElementsByTagName("province")[i].getAttribute("name"); //get the name of the province
		html = html + "<h1>"+provinceName+"</h1>";
		html = html + "<table><tr>";
		var count = 0;
		
		var y = x[i].getElementsByTagName("dealer"); //get all the tags with the name "dealer" within the current province
		for (j=0;j<y.length;j++) //cycle through the sub tags with the name "dealer"
		{
			if (count % 3 == 0)
				html = html + "</tr><tr>";
			var name = y[j].getElementsByTagName("name")[0].childNodes[0].nodeValue;
			var tel = y[j].getElementsByTagName("tel")[0].childNodes[0].nodeValue;
			var fax = y[j].getElementsByTagName("fax")[0].childNodes[0].nodeValue;
			var skype = y[j].getElementsByTagName("skype")[0].childNodes[0].nodeValue;
			var email = y[j].getElementsByTagName("email")[0].childNodes[0].nodeValue;
			var address = y[j].getElementsByTagName("address")[0].childNodes[0].nodeValue;
			var othertext = y[j].getElementsByTagName("othertext")[0].childNodes[0].nodeValue;
			html = html + "<td width='250' valign='top'>";
			html = html + "<h2>" + name + "</h2>";
			if (tel != "empty")
				html = html + "Telephone: " + tel;
			if (fax != "empty")
				html = html + "<br>Fax: " + fax;
			if (skype != "empty")
				html = html + "<br><img src='images/skype-logo.png' align='left' />" + skype + "<br>";
			if (email != "empty")
				html = html + "<br>Email: " + email;								
			if (address != "empty")
				html = html + "<br><br>" + address;
			if (othertext !="empty")
				html = html + "<br><br>" + othertext;
			html = html + "<br><br>";
			html = html + "</td>";
			count++;
		}
		html = html + "</tr></table>";
	}
	
	//dump the html string into the page-content div
	document.getElementById("outlet-dump").innerHTML=html;
}




