// determine what type of browser is being used as IE doesn't fully support the display attribute...would you believe!
if (navigator.userAgent.indexOf('MSIE') != -1) {
	isIE = true;
}
else {
	isIE = false;
}

if (isIE) {
	var show = "block";
}
else {
	var show = "table-row";
}




function changeDisplay(i,d) {
	if (typeof(i) != 'string') { // array keeps appearing as an object
		for(var c = 0; c < i.length; c++) {
			changeDisplay(i[c],d);
		}
	}
	else {
		e = document.getElementById(i);
		if (e) {
			e.style.display = d;
		}
		else {
			alert("unable to get id (" + i + ")");
		}
	}
}




function getManufacturer(s) {
	s_value = s.options[s.selectedIndex].value;
	s_text = s.options[s.selectedIndex].text;
	
	m = new Object; // set up an object to be used to store the various values in
	
	// if statements (as shops are implemented) to set up the oubject that will be returned
	if (s_value == "RB") {
		// 1.search prefix, 2.mfr name, 3.search url, 4.manuals url, 5.parts url
		m.prefix = s_value;
		m.name = s_text;
		m.searchurl = 'http://www.rossandbonnyman.tail-lift-parts.co.uk/cgi-bin/ss000001.pl';
		m.manualsurl = 'http://www.rossandbonnyman.tail-lift-parts.co.uk/';
		m.partsurl = 'http://www.rossandbonnyman.tail-lift-parts.co.uk/acatalog/index.html';
	}
	else if (s_value == "DH") {
		// 1.search prefix, 2.mfr name, 3.search url, 4.manuals url, 5.parts url
		m.prefix = ""; // parts numbers were too long!
		m.name = s_text;
		m.searchurl = 'http://www.dhollandia.tail-lift-parts.co.uk/cgi-bin/ss000001.pl';
		m.manualsurl = 'http://www.dhollandia.tail-lift-parts.co.uk/';
		m.partsurl = 'http://www.dhollandia.tail-lift-parts.co.uk/acatalog/index.html';
	}
	else if (s_value == "JR") {
		// 1.search prefix, 2.mfr name, 3.search url, 4.manuals url, 5.parts url
		m.prefix = s_value;
		m.name = s_text;
		m.searchurl = 'http://www.jrindustries.roller-shutter-parts.co.uk/cgi-bin/ss000001.pl';
		m.manualsurl = 'http://www.jrindustries.roller-shutter-parts.co.uk/';
		m.partsurl = 'http://www.jrindustries.roller-shutter-parts.co.uk/acatalog/index.html';
	}
	/*
	else if (s_value == "othermfr") { 
		[ other manufacturers to go here ]
	}
	*/
	// blank value 
	else if (s_value == "") {
		return false;
	}
	
	/*
	if (m.prefix != undefined) { // mfr has been found...do the business!
	*/	
		// search url
		f = document.forms['PartSearchForm'];
		if (f) {
			f.action = m.searchurl;
		}
		else {
			alert("Unable to adjust parts search form, please contact Andrew Holt on +44(0)8704466043");
			return false;
		}
		
		// 'browse mfr parts manuals' link
		var h = document.getElementById('browsemrfurl');
		if (h) {
			h.innerHTML = "Browse " + m.name + " Parts Manuals...";
			h.href = m.manualsurl;
		}
		else {
			alert("Unable to get 'browse mfr parts manuals' link, please contact Andrew Holt on +44(0)8704466043");
			return false;
		}
		
		// 'browse all parts' link
		var h = document.getElementById('browsepartsurl');
		if (h) {
			h.innerHTML = "browse our online parts lists for " + m.name + " parts here";
			h.href = m.partsurl;
		}
		else {
			alert("Unable to get 'browse all parts' url, please contact Andrew Holt on +44(0)8704466043");
			return false;
		}
		
		return m;
	/*
	}
	else {
		alert("The manufacturer chosen was not recognised by the wizard, please contact Andrew Holt on +44(0)8704466043");
		return false;
	}
	*/
}




function resetMiniForms() // resets the values of the choice forms
{
	forms = new Array('PartNumberForm','PartSearchForm','PartLookForm');
	for (var i=0; i<forms.length; i++)
	{
		var f = document.getElementById(forms[i]);
		if (f)
		{
			f.reset();
		}
		else
		{
			alert("Unable to reset form '" + forms[i] + "'");
		}
	}
}




function hfs(i) { // highlight further search information
	e = document.getElementById('furthersearch');
	if (e) {
		if (i == true) { e.className = 'tdhighlight'; }
		else { e.className = ''; }
	}
	else {
		alert("Unable to get 'further search' element, please contact Andrew Holt on +44(0)8704466043");
	}
}
