var bout=-1;

function alum(btn){

	for(i=1;i<5;i++){

		swapImage('btn'+i,0);

	}

	swapImage('btn'+btn,1);

	bout=-1;

	bout='btn'+btn;

}

/****** roll over *****/

function swapImage(kel,etat){

	if (kel == bout){

	}	

	else {

	obj=document.images[kel];

	finObj=obj.src.substring(obj.src.length-4,obj.src.length);

	debObj=obj.src.substring(0,obj.src.length-5);

	obj.src=''+debObj+etat+finObj;

	}

}

/****** popup ******/

function winOpen(URL,name,largeur,hauteur,scrollbars){

	window.open(URL,name,'width='+largeur+',height='+hauteur+',scrollbars='+scrollbars);

}

/******* popup mention********/

function ouvre()

{

window.open('mention.htm','mention_legale','width=300,height=300,top=350,left=400,toolbar=no,menubar=no,statusbar=no');

}

/******* impression **********/

function printit(){

self.print();

}

/******* efface le bdc ********/

function effacer()

{

	result = window.confirm('Etes vous certain de vouloir annuler cette commande ?');

	if(result == 1)

		document.location = "suivi_commande.htm"

	else

		return;

}

/****** positionnement apres cacul *******/

function calc(){

document.form_commande.calcul.value="1";

	if(document.form_commande.calcul.value == 1) {

	document.form_commande.action='#calc';

	document.form_commande.submit();

	}

}

/******* Etat des boutons de navigation gauche ********/

function onwof(rub,lien,page1,page2,page3) {
	url=window.location.href;
	if(url.indexOf(page1) > 0 || url.indexOf(page2) > 0 || url.indexOf(page3) > 0 ){
		etatbt="NavLeftOn";
	} else {
		etatbt="NavLeftOff";
	}
	document.write("<br /><div id=\""+etatbt+"\"><a href=\"../extranetPC_sima/ma_comm_fichiers/"+lien+"/\">"+rub+"</a></div>");
}


function trim(s) {
    return s.replace(/^\s+/, '').replace(/\s+$/, '');
}

function showErrorsFields(fieldName){
	try{		
		if (navigator.userAgent.indexOf("Firefox")!=-1)
			document.getElementsByName(fieldName)[0].style.backgroundColor="#ff3300"			
		else
			new Effect.Highlight(fieldName, {duration:2, fps:25, from:0.0, to:1.0, startcolor:'#ffffff', endcolor:'#ff3300', restorecolor:'#ff3300'});		
		
		//var curObject=$(fieldName);			
		document.getElementsByName(fieldName)[0].onkeydown=function(){this.style.backgroundColor="#ffffff";};	
		document.getElementsByName(fieldName)[0].onchange=function(){this.style.backgroundColor="#ffffff";};	
	}catch(err){
			alert(analyseError(err));
	}
}

function analyseError(err) {
	var myError = 'error: ' + err.name + '\nmessage: '  + err.message
	if (err.location) myError += '\nlocation' + err.location 
	
	return myError;
}


			 
			 /*
*checkLengthForTxtArea:
*Verify max length of a textArea control
*cut the control text to lenMax if control length > lenMax
*/
function checkLengthForTxtArea(field,lenMax){	
	
	if (field.value.length < lenMax){
		return true;
	}
	else{
		field.value = field.value.substr(0, lenMax);
		return false;
	}
}

function loadExpandDiv(elementName, boolProperty) {
		          if (boolProperty) {
		               expandDiv(elementName);
		          }
}
 
function expandDiv(elementName) {
//  whichElement = eval(elementName + "");
whichElement = document.getElementById(elementName);
  if (whichElement.style.display == "none") {
  	whichElement.style.display = "";
  } else {
  	whichElement.style.display = "none";
  }
}
