/**********************************************************
 LETRUCKSTOP.com
 FONCTIONS JAVASCRIPTS POUR MOTEUR DE RECHERCHE AVANCÉE
 Créé le 26 juin 2006 par Simon Racine-Chevalier
 Dernière modification : 26 juin 2006, Simon Racine-Chevalier
**********************************************************/

///////////////////////////////////////////////////////////////////////////////////	
/*	Element.prototype.setEvent = function(e,code){
		this.setAttribute(e,code);
		if(document.all) this[e] = function(){eval(code);};
	}
*/
///////////////////////////////////////////////////////////////////////////////////	
//_ INITIALISATION DU FORMULAIRE
//_ Références globales
	var myForm = 			new Object();
	var myTables = 			new Array();
	var champsIndex = 		new Array();
	var iTextClassName =	new String();
	var iCheckClass =		new String();
	var lang = 				new String();
	var errorMsg = 			new String();

///////////////////////////////////////////////////////////	
//_ Méthodes
	function validerRecherche(){
		var f = 		myForm;
		var inputs = 	f.elements;
		var l =			inputs.length;
		while(l--){
			s = inputs[l];
			if(s.type=='text') if(s.value!='') break;
			if(l==0){
				alert(errorMsg);
				set_focus($('ch_tous'));
				return;
			}
		}
		l = inputs.length;
		
		if($('ch_tous').value=='' && $('ch_exact').value=='' && $('ch_aumoins').value==''){
			alert(errorMsg);
			set_focus($('ch_tous'));
			return;
		}
		
		while(l--){
			s = inputs[l];
			if(s.type=='checkbox'){
				if(s.disabled) s.disabled = false;
				if(s.className.indexOf('instruments')>-1)
					if(s.checked) break;
			}
			if(l==0){
				alert(errorCheck);
				return;
			}
		}		
		l = inputs.length;
		
		if($('cbox_isfonds').checked){
			var fonds = getElementsByClass('cbox_fonds');
			var fonds_l = fonds.length;
			while(fonds_l--){
				s = fonds[fonds_l];
				if(s.checked) break;
				if(fonds_l==0){
					alert(errorFonds);
					return;
				}
			}
		}
		
		f.submit();
	}
	function validerChRecherche(){
		var f = 		myForm;
		var inputs = 	f.elements;
		for(var i=0;i<inputs.length;i++){
			s = inputs[i];
			if(s.type=='text')
				if(s.value!='') break;
			if(i==inputs.length-1){
				alert(errorMsg);
				set_focus($('ch_rechercher'));
				return;
			}			
		}
		
		f.submit();
	}
	function setTablesWidth(){
		var width = myTables['ref'].clientWidth;
		for(var i=0;i<myTables.length;i++)
			myTables[i].style.width = width+'px';
	}
	function setInputsStyle(){
		var f = 		myForm;
		var c =			iTextClassName;
		var inputs = 	f.elements;
		var focusAction = 	'this.style.borderColor = "#e7601d"';
		var blurAction = 	'this.style.borderColor = "#CCC"';
		var overAction = 	'this.style.backgroundColor = "#FFFFCC"';
		var outAction = 	'this.style.backgroundColor = "white"';		
		var s;
		for(var i=0;i<inputs.length;i++){
			s = inputs[i];
			if(s.type=='text'){
				_setAttribute(s,'class',c);
				setEvent(s,'onfocus',		focusAction);
				setEvent(s,'onblur',		blurAction);
				setEvent(s,'onmouseover',	overAction);
				setEvent(s,'onmouseout',	outAction);
			}//else if(s.type=='checkbox') s.setAttribute('class',iCheckClass);
		}
	}
	function setLabelsRollOver(){
		var labels = 		document.getElementsByTagName('label');
		var overAction = 	'this.style.color = "#999"';
		var outAction = 	'this.style.color = "black"';
		var s;
		for(var i=0;i<labels.length;i++){
			s = labels[i];
			if(s.form!=null && s.form.name!=myForm.name) continue;
			setEvent(s,'onmouseover',overAction);
			setEvent(s,'onmouseout',outAction);
		}
	}
	function showForm(){
		loadingMsg.style.display = 'none';
		myForm.style.display = 'block';
	}
	function overrideResize(){
		$('centreint').style.height = 'auto';
	}
///////////////////////////////////////////////////////////////////////////////////	
