// JavaScript Document

function setManufacturers(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('manu').innerHTML = ajaxRequest.responseText;
		}
	}
	params = '';
	ajaxRequest.open("POST", '/museum/exhibits/setmanu.php', true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(null);
}

function setYears(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('year').innerHTML = ajaxRequest.responseText;
		}
	}
	params = '';
	ajaxRequest.open("POST", '/museum/exhibits/setyear.php', true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(null);
}

//Browser Support Code
function getManu(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	var year = document.getElementById('vyear')[document.getElementById('vyear').selectedIndex].value;
	
	var params = 'year='+escape(year);
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('manu').innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("POST", '/museum/exhibits/getmanu.php', true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(params);
	
}

//Browser Support Code
function getYears(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	var manufacturer = document.getElementById('manufacturer')[document.getElementById('manufacturer').selectedIndex].value;
	
	var params = 'manufacturer='+escape(manufacturer);
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('year').innerHTML = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("POST", '/museum/exhibits/getyears.php', true);
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", params.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(params);
	
}

//Browser Support Code
function getManuFromLogo(id){
 var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = "/museum/exhibits/" ;
    var myInput = document.createElement("input") ;
	myInput.setAttribute("name", "manufacturer") ;
    myInput.setAttribute("value", id);
	var myInput2 = document.createElement("input") ;
	myInput2.setAttribute("name", "vyear") ;
    myInput2.setAttribute("value", "");
    myForm.appendChild(myInput) ;
	myForm.appendChild(myInput2) ;
  document.body.appendChild(myForm);
  myForm.submit() ;
  document.body.removeChild(myForm);	
}

function dopage($a,$b,$man,$year){
 var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = "/museum/exhibits/" ;
    var myInput = document.createElement("input") ;
	myInput.setAttribute("name", "a") ;
    myInput.setAttribute("value", $a);
	var myInput2 = document.createElement("input") ;
	myInput2.setAttribute("name", "b") ;
    myInput2.setAttribute("value", $b);
    myForm.appendChild(myInput) ;
	myForm.appendChild(myInput2) ;
	if($man == "man"){ } else {
	var myInput3 = document.createElement("input") ;
	myInput3.setAttribute("name", "manufacturer") ;
    myInput3.setAttribute("value", $man);	
	myForm.appendChild(myInput3) ;
	}
	if($year == "year"){ } else {
	var myInput4 = document.createElement("input") ;
	myInput4.setAttribute("name", "vyear") ;
    myInput4.setAttribute("value", $year);	
	myForm.appendChild(myInput4) ;
	}
  document.body.appendChild(myForm);
  myForm.submit() ;
  document.body.removeChild(myForm);	
}

function colourSwitch(id,isBack){
if (isBack == true){
document.getElementById('bike_name_id'+id).style.backgroundColor='#1a3869';
} else {
document.getElementById('bike_name_id'+id).style.backgroundColor='#5e5e5e';
}	
}
