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:'#fbffd0'});		
		
		//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;
}

/* Ajout de John */
function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return oDoc[divID];
}

function resizeWinTo( idOfDiv ) {
	var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
	var x = window; x.resizeTo( screen.availWidth, screen.availWidth );
	var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
	var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
	x.resizeTo( oW + 200, oH + 200 );
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
	if( window.opera && !document.childNodes ) { myW += 16; }
	//second sample, as the table may have resized
	var oH2 = getRefToDivMod( idOfDiv );
	var oW2 = oH2.clip ? oH2.clip.width : oH2.offsetWidth;
	var oH2 = oH2.clip ? oH2.clip.height : oH2.offsetHeight;
	x.resizeTo( oW2 + ( ( oW + 200 ) - myW ), oH2 + ( (oH + 200 ) - myH ) );
}

/* Fin ajout de john */