/*var ChoixVehicule = Class.create();
ChoixVehicule.prototype = {
	
	initialize: function() {	
		
		this.updateChoixVehiculeList();
	},

	updateChoixVehiculeList: function() {	
		if (!document.getElementsByTagName){ return; }
		
		var inputs = document.getElementsByTagName('input');
		for (var i=0; i<inputs.length; i++){
			var input = inputs[i];
			
			if (input.getAttribute('rel') && (input.getAttribute('rel').toLowerCase().match('choix_vehicule'))){
				input.onclick = function () {myChoixVehicule.start(this); return false;}
			}
			
			if (input.getAttribute('rel') && (input.getAttribute('rel').toLowerCase().match('reset_vehicule'))){
				input.onclick = function () {myChoixVehicule.end(); return false;}
			}
		}
		
		if(document.getElementById('choix_marque'))
		{document.getElementById('choix_marque').onchange = function () {myChoixVehicule.start(this); return false;}}
		
		if(document.getElementById('choix_modele'))
		{document.getElementById('choix_modele').onchange = function () {myChoixVehicule.start(this); return false;}}
		
		if(document.getElementById('choix_moteur'))
		{document.getElementById('choix_moteur').onchange = function () {myChoixVehicule.start(this); return false;}}
	},
	
	start: function(params) {
		var send = '';
		if(document.getElementById('choix_marque'))
		{var send = '&marque='+escape(document.getElementById('choix_marque').value);}
		
		if(document.getElementById('choix_modele'))
		{var send = '&modele='+escape(document.getElementById('choix_modele').value);}
		
		if(document.getElementById('choix_moteur'))
		{var send = '&moteur='+escape(document.getElementById('choix_moteur').value);}

		if(document.getElementById('choix_moteur'))
		{
			loadPage2('choix_vehicule','js/choix_vehicule.php',send, false, 'initChoixVehicule();','pieces/');
		}
		else
		{
			loadPage2('choix_vehicule','js/choix_vehicule.php',send, false, 'initChoixVehicule();','');
		}
	},
	
	end: function() {
		loadPage2('choix_vehicule','js/choix_vehicule.php','&reset=1', false, 'initChoixVehicule();','');
	}
}
function initChoixVehicule() { myChoixVehicule = new ChoixVehicule(); }*/

function updateChoix(marque) {
	document.getElementById('flashselect').style.visibility = 'visible';
	document.getElementById('select_marque').value=marque;
	myChoixVehicule2.updateModele(marque);
	document.getElementById('select_modele').focus();
}

var ChoixVehicule2 = Class.create();
ChoixVehicule2.prototype = {
	
	initialize: function() {	
		
		this.updateChoixVehiculeList();
	},

	updateChoixVehiculeList: function() {	
		if(document.getElementById('select_marque'))
		{
			document.getElementById('select_marque').onchange = function () {myChoixVehicule2.updateModele(this.value); return false;}
			document.getElementById('select_marque').onkeypress = function () {myChoixVehicule2.updateModele(this.value); return false;}
			
			document.getElementById('select_modele').onchange = function () {myChoixVehicule2.updateMotorisation(document.getElementById('select_marque').value,this.value); return false;}
			document.getElementById('select_modele').onkeypress = function () {myChoixVehicule2.updateMotorisation(document.getElementById('select_marque').value,this.value); return false;}
			
			document.getElementById('select_moteur').onchange = function () {myChoixVehicule2.end(this.value); return false;}
			document.getElementById('select_moteur').onkeypress = function () {myChoixVehicule2.end(this.value); return false;}
		}
	},
	
	updateModele: function(marque) {
		if(marque!='')
		{
			if(document.getElementById('select_moteur').disabled==false)
			{
				document.getElementById('choix_modele').innerHTML = '<select id="select_modele" style="width:280px;margin:6px;" disabled><option value="">Le mod&egrave;le de la voiture</option></select>';
			}
			if(document.getElementById('select_moteur').disabled==false)
			{
				document.getElementById('choix_moteur').innerHTML = '<select id="select_moteur" style="width:280px;margin:6px;" disabled><option value="">La motorisation</option></select>';
			}
			
			var send = '&action=updateModele&marque='+marque;
			loadPage2('choix_modele','js/choix_vehicule2.php',send, false, 'myChoixVehicule2.initialize();', '');
		}
	},
	
	updateMotorisation: function(marque, modele) {
		if(modele!='' && marque!='')
		{
			if(document.getElementById('select_moteur').disabled=false)
			{
				document.getElementById('choix_moteur').innerHTML = '<select id="select_moteur" style="width:280px;margin:6px;"><option value="">La motorisation</option></select>';
			}
			
			var send = '&action=updateMotorisation&modele='+modele+'&marque='+marque;
			loadPage2('choix_moteur','js/choix_vehicule2.php',send, false, 'myChoixVehicule2.initialize();', '');
		}
	},
	
	end: function(vehicule) {
		if(vehicule!='')
		{
			var send = '&action=selectMotorisation&vehicule='+vehicule;
			var url_retour = 'pieces/';
			if(window.location.href.match('pieces/'))
			{
				if(navigator.appName=='Microsoft Internet Explorer') 	{url_retour='../pieces/';}
				else													{url_retour='pieces/';}
			}
			loadPage2('','js/choix_vehicule2.php',send, false, '', url_retour);
		}
	}
}
function initChoixVehicule2() { myChoixVehicule2 = new ChoixVehicule2(); }


function loadPage2(div,file,send,rload,action,redirect)
{
	var xhr = getXhr();
	
	xhr.open("POST", file, true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send(send);

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4)
		{
            if (xhr.status == 200)
			{
				//alert(xhr.responseText);
				if(div!='')
				{
					//document.getElementById(div).innerHTML = '';
					document.getElementById(div).innerHTML = xhr.responseText;
				}
				
				if(redirect!=""){window.location.href=redirect;}
				if(rload==true){window.location.reload();}
				if(action!=""){eval(action);}
			}
		}
	}
}
