/*if ( browser.isDOM1 
    && !( browser.isMac && browser.isIE ) 
    && !( browser.isOpera && browser.versionMajor < 7 )
    && !( browser.isIE && browser.versionMajor < 5 ) ) {
		Compatible=false;
	}
*/
//if (!sOrigine) document.location.href=
function favoris() {
	window.external.addfavorite('http://www.servirecycl.fr');
	return false;
}
function view_img(src,taillew,tailleh,ref,lib)
{
	if(src==''){
		alert("Aucune image enregistrée pour ce produit");
	}
	else {
		larg=parseInt(taillew)+150;haut=parseInt(tailleh)+150;
		//alert(larg);alert(haut);
		w=open("",'popup','width='+larg+',height='+haut+',scrollbars=yes');
		w.document.write("<TITLE>Agrandissement de l\'image</TITLE>\n");
		w.document.write("<table width=100% height=10%><tr><td valign=center align=center>"+ref+"</td></tr></table>");
		w.document.write("<table width=100% height=80%><tr><td valign=center align=center><img src='"+src+"' width="+taillew+" height="+tailleh+"></td></tr></table>");
		w.document.write("<table width=100% height=10%><tr><td valign=center align=center>"+lib+"</td></tr></table>");
	}
}	
function choixImprimante(idConstr, idImpr, idGamme) {
	var scolor=document.COMMANDER.color.value;
	ac = 'LCONST';
	iac = '';
	ip = idImpr;
	sUrl="&IIMP="+ip;
	iref = '';
	igamme = idGamme;
	iId = 100;
	ic = idConstr;
	var sTmp = window.location.protocol + "//" + window.location.hostname+sSite+'commander/';
	document.location.href=sTmp+'commander.php?id='+iId+'&color='+ scolor +'&ACTION='+ ac +'&ICONST='+ic+'&IACCESS='+iac+'&IREF='+iref+'&IGAMME='+igamme+sUrl;	
}
function choixConstructeur(idconstructeur) {
	var scolor=document.COMMANDER.color.value;
	ac = 'NIMPR';
	iac = '';
	iref = '';
	igamme = '';
	sUrl = '';
	iId = 100;
	ic = idconstructeur;
	var sTmp = window.location.protocol + "//" + window.location.hostname+sSite+'commander/';
	document.location.href=sTmp+'commander.php?id='+iId+'&color='+ scolor +'&ACTION='+ ac +'&ICONST='+ic+'&IACCESS='+iac+'&IREF='+iref+'&IGAMME='+igamme+sUrl;	
}
function Recherche(sPage,sParam,iId) {
	var ac=document.COMMANDER.ACTION.value;
	var scolor=document.COMMANDER.color.value;
	var ic='';
	var iac='';
	var sUrl='';
	var ip;
	var iref='';
	var aRef=Array(4);
	var igamme='';
/*	if (sParam=='ICONST') {
		if (document.COMMANDER.IDACCESSOIRE) document.COMMANDER.IDACCESSOIRE.selectedIndex=0;
		if (document.COMMANDER.IDGAMME) document.COMMANDER.IDGAMME.selectedIndex=0;
		ac='NGAMME';
	} 
	else if (sParam=='IGAMME') {
		if (document.COMMANDER.IDACCESSOIRE) document.COMMANDER.IDACCESSOIRE.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
		ac='NIMPR';
	} 
	else if (sParam=='IACCESS') {
		if (document.COMMANDER.IDCONSTRUCTEUR) document.COMMANDER.IDCONSTRUCTEUR.selectedIndex=0;
		ac='LACCESS';
	} 
	else if (sParam=='IREF') {
		if (document.COMMANDER.IDACCESSOIRE) document.COMMANDER.IDACCESSOIRE.selectedIndex=0;
		if (document.COMMANDER.IDGAMME) document.COMMANDER.IDGAMME.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_ICOP) document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IFAX) document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IMAT) document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
		ac='LREF';
	} 
	else {
		ac='LCONST';		
	}
*/
	if (sParam=='ICONST') {
		if (document.COMMANDER.IDACCESSOIRE) document.COMMANDER.IDACCESSOIRE.selectedIndex=0;
		ac='NIMPR';
	} 
	else if (sParam=='IACCESS') {
		if (document.COMMANDER.IDCONSTRUCTEUR) document.COMMANDER.IDCONSTRUCTEUR.selectedIndex=0;
		ac='LACCESS';
	} 
	else if (sParam=='IREF') {
		if (document.COMMANDER.IDACCESSOIRE) document.COMMANDER.IDACCESSOIRE.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_ICOP) document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IFAX) document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IMAT) document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex=0;
		if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
	ac='LREF';
	} 
	else {
		ac='LCONST';		
	}
	// recupération du numero de constructeur
	if (document.COMMANDER.IDCONSTRUCTEUR) {
		if (document.COMMANDER.IDCONSTRUCTEUR.selectedIndex>0) {
			ic=document.COMMANDER.IDCONSTRUCTEUR.options[document.COMMANDER.IDCONSTRUCTEUR.selectedIndex].value;
			iId=100;		
		}
	}
	if (document.COMMANDER.IDGAMME) {
		if (document.COMMANDER.IDGAMME.selectedIndex>0) {
			igamme=document.COMMANDER.IDGAMME.options[document.COMMANDER.IDGAMME.selectedIndex].value;
			iId=100;		
		}
	}
	if (document.COMMANDER.IDCONSOMMABLE) {
		if (document.COMMANDER.IDCONSOMMABLE.selectedIndex>0) {
			iref=document.COMMANDER.IDCONSOMMABLE.options[document.COMMANDER.IDCONSOMMABLE.selectedIndex].value;
			iId=100;		
		}
	}
	if (document.COMMANDER.IDACCESSOIRE) {
		if (document.COMMANDER.IDACCESSOIRE.selectedIndex>0) {
			iac=document.COMMANDER.IDACCESSOIRE.options[document.COMMANDER.IDACCESSOIRE.selectedIndex].value;
			iId=200;		
		}
	}
/*	switch (sParam) {
		case 'IIMP' :
			if (document.COMMANDER.IDIMPRIMANTE_ICOP) document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IFAX) document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IMAT) document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex=0;
			break;		
		case 'ICOP' :
			if (document.COMMANDER.IDIMPRIMANTE_IFAX) document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IMAT) document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
			break;		
		case 'IFAX' :
			if (document.COMMANDER.IDIMPRIMANTE_ICOP) document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IMAT) document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
			break;		
		case 'IMAT' :
			if (document.COMMANDER.IDIMPRIMANTE_IFAX) document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_ICOP) document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex=0;
			if (document.COMMANDER.IDIMPRIMANTE_IIMP) document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex=0;
			break;		
	}
*/
	//alert(document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex);
	if (document.COMMANDER.IDIMPRIMANTE_IIMP)  {
		if (document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex>0) {
			ip=document.COMMANDER.IDIMPRIMANTE_IIMP.options[document.COMMANDER.IDIMPRIMANTE_IIMP.selectedIndex].value;
			sUrl="&IIMP="+ip;
		}
	} 
	
	if (document.COMMANDER.IDIMPRIMANTE_ICOP){
		if (document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex>0) {
			ip=document.COMMANDER.IDIMPRIMANTE_ICOP.options[document.COMMANDER.IDIMPRIMANTE_ICOP.selectedIndex].value;
			sUrl="&ICOP="+ip;
		}
	}
	if (document.COMMANDER.IDIMPRIMANTE_IFAX)  {
		if (document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex>0) {
			ip=document.COMMANDER.IDIMPRIMANTE_IFAX.options[document.COMMANDER.IDIMPRIMANTE_IFAX.selectedIndex].value;
			sUrl="&IFAX="+ip;
		}
	}
	if (document.COMMANDER.IDIMPRIMANTE_IMAT) {
		if (document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex>0) {
			ip=document.COMMANDER.IDIMPRIMANTE_IMAT.options[document.COMMANDER.IDIMPRIMANTE_IMAT.selectedIndex].value;
			sUrl="&IMAT="+ip;
		}
	}
					
	var sTmp =window.location.protocol + "//" + window.location.hostname+sSite+'commander/';
	document.location.href=sTmp+sPage+'.php?id='+iId+'&color='+ scolor +'&ACTION='+ ac +'&ICONST='+ic+'&IACCESS='+iac+'&IREF='+iref+'&IGAMME='+igamme+sUrl;	
}
function Path(sOrigine,sDestination) {
	var sTmp='';
	if (sOrigine=='') { 
		sTmp=sDestination+'/';
//		alert(' sOrigine '+sOrigine+'/'+ sDestination );
	}
  	else if (sDestination==sOrigine) {
		 sTmp=''
	}
	else {
	  sTmp=sDestination+'/';
//    	alert(' sOrigine '+sOrigine+'/'+ sDestination );
  	}		
	sTmp =window.location.protocol + "//" + window.location.hostname+sSite+sTmp
//	alert(sTmp);
	return  (sTmp);
}
function Menu(sOrigine,sDestination,sId,sColor) {

	var sTmp='';
	if ((sDestination=='accueil') && (sOrigine=='')) {
		sTmp='';
	}	
	else {
		if (sOrigine=='') { 
		sTmp=sDestination+'/'+sDestination+'.php';;
		}
  		else if (sDestination==sOrigine) {
			 sTmp=''
		}
		else {
	  		sTmp=sOrigine +'/'+sDestination+'.php';
  		}
		sTmp=sTmp+'?id='+sId+'&sid='+sDestination;
		
//  		sTmp=sDestination+'.php';
	}			
	sTmp='index.php'+'?id='+sId;
	//alert (window.location.hostname+sSite);
	window.location.href=window.location.protocol + "//" + window.location.hostname+sSite+sTmp;
	
	return false;
}
function SousMenu(sId,sColor) {
//	alert(iId + sColor + document.all('iSousMenu').bgcolor);
	var sInner='';
	var sPath;
	var sTmp;
	if (sId) {
		var sColSel='colsel'+sId;
		document.getElementById('colsel0').style.backgroundColor = "";
		document.getElementById('colsel0a').style.backgroundColor = "";
		document.getElementById('colsel0b').style.backgroundColor = "";
		document.getElementById('colsel1').style.backgroundColor = "";
		document.getElementById('colsel1a').style.backgroundColor = "";
		document.getElementById('colsel1b').style.backgroundColor = "";
		document.getElementById('colsel2').style.backgroundColor = "";
		document.getElementById('colsel2a').style.backgroundColor = "";
		document.getElementById('colsel2b').style.backgroundColor = "";
		document.getElementById('colsel3').style.backgroundColor = "";
		document.getElementById('colsel3a').style.backgroundColor = "";
		document.getElementById('colsel3b').style.backgroundColor = "";
		document.getElementById('colsel4').style.backgroundColor = "";
		document.getElementById('colsel4a').style.backgroundColor = "";
		document.getElementById('colsel4b').style.backgroundColor = "";
		document.getElementById('colsel5').style.backgroundColor = "";
		document.getElementById('colsel5a').style.backgroundColor = "";
		document.getElementById('colsel5b').style.backgroundColor = "";
		document.getElementById('clSousMenu').style.color= "";
		document.getElementById('clSousMenu').style.backgroundColor = "";

		if(sColor) 	{
//			document.getElementById('clSousMenu').style.backgroundColor = "#"+sColor;
//			document.getElementById('clSousMenu1').style.backgroundColor = "#"+sColor;
//			document.getElementById('footer0').style.backgroundColor = "#"+sColor;
//			document.getElementById('footer1').style.backgroundColor = "#"+sColor;
//			document.getElementById('footer2').style.backgroundColor = "#"+sColor;
		}
//		if(sColor) 	document.all('navigation').style.backgroundColor = "#"+sColor;
		if (sId.length>3) sTmp=sId.substr(0,1); else sTmp='1';
		if (sId!="10000") {
			switch (sTmp) {
				case  '0' : // commander
						document.getElementById('colsel0').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel0a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel0b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'commander');
	//					sInner='<a href="'+sPath+'constructeurs.php?id=100&color='+sColor+'&ACTION=NEWCONST"><b>RECHERCHE PAR CONSTRUCTEURS</b></a>' + sSep;				
	//					sInner=sInner +'<a href="'+sPath+'accessoires.php?id=200&color='+sColor+'&ACTION=NEWACCES"><b>COMMANDER UN ACCESSOIRE</b></a>&nbsp;&nbsp;';
						break;
				case  '1' : // occasions
						document.getElementById('colsel1').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel1a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel1b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'commander');
	//					sInner='<a href="'+sPath+'conditions_ventes.php?id=1100&color='+sColor+'"><b>Cartouches vides</b></a>' + sSep;				
	//					sInner=sInner +'<a href="'+sPath+'liste_imprimantes.php?id=1200&color='+sColor+'"><b>LISTE DES IMPRIMANTES</b></a>'+ sSep;
	//					sInner=sInner +'<a href="'+sPath+'occasions_autres.php?id=1300&color='+sColor+'"><b>AUTRES</b></a>&nbsp;&nbsp;';
						break;
				case  '2' :	// promotions
						document.getElementById('colsel2').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel2a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel2b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'promotions');
						sInner='<a href="'+sPath+'promotions_topdes10.php?id=2100&ACTION=TOP10"><b>LES 10 MEILLEURES VENTES</b></a>' + sSep;				
						sInner=sInner +'<a href="'+sPath+'promotions_toutes.php?id=2200&ACTION=PROMO"><b>TOUTES LES PROMOTIONS</b></a>&nbsp;&nbsp;';
						break;
				case  '3' :	// trucsastuces
						document.getElementById('colsel3').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel3a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel3b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'trucsastuces');
						sInner='<a href="'+sPath+'astuces_imprimantes.php?id=3100"><b>IMPRIMANTES</b></a>' + sSep;				
						sInner=sInner +'<a href="'+sPath+'astuces_consommables.php?id=3200"><b>CONSOMMABLES</b></a>&nbsp;&nbsp;';
						break;
				case  '4' : // exterieur
						document.getElementById('colsel4').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel4a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel4b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'liensutiles');
	//					sInner='<a href="'+sPath+'liens_informatiques.php?id=4100&color='+sColor+'"><b>INFORMATIQUES</b></a>' + sSep;				
	//					sInner=sInner +'<a href="'+sPath+'liens_autres.php?id=4200&color='+sColor+'"><b>AUTRES</b></a>&nbsp;&nbsp;';
						break;
				case  '5' : // PROJET TRAVAUX chantier
						document.getElementById('colsel5').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel5a').style.backgroundColor = "#"+sColor;
						document.getElementById('colsel5b').style.backgroundColor = "#"+sColor;
						sPath= Path(sOrigine,'contacts');
	//					sInner='<a href="'+sPath+'contacts.php?id=5100&color='+sColor+'"><b>CONDITIONS DE VENTES</b></a>' + sSep;				
						sInner=sInner+'<a href="#" onclick="favoris();"><b>AJOUTER AUX FAVORIS</b></a>' + sSep;				
						sInner=sInner +'<a href="'+sPath+'recommander.php?id=5200"><b>RECOMMANDER A UN AMI</b></a>&nbsp;&nbsp;';
						break;				
			}
			document.getElementById('clSousMenu').innerHTML=sInner;
		}
	}
}
function SousNavi(sId,sOrigine,sDestination) {
//	alert(sId);
	var sTmp='';
//	alert(sOrigine+' ' +sDestination);
//	var sId='';
	if (sOrigine=='') { 
		sTmp=sDestination+'/'+sDestination + '.php';
		sTmp=sTmp+'?id='+sId;
	}	 
	else {
		if (sDestination==sOrigine) {
			 sTmp=''
		}
		else {
		  	sTmp=sOrigine +'/'+sDestination+'.php';
  		}
		sTmp=sTmp+'?id='+sId+'&color=';
//		sTmp=sTmp+'?id='+sId+'&sid='+sDestination+'&color=';
	}
//	alert(window.location.protocol + "//" + window.location.hostname+sSite+sTmp);
	window.location.href=window.location.protocol + "//" + window.location.hostname+sSite+sTmp;
	
	return false;
}
function SearchPath(sPath) {
	var sTmp='';
	var i=0;
	for(i=sPath.length;i>0;i--) {
		if (sPath.substr(i,1)=='/')  
			break;
	}
	return  (sPath.substring(0,i+1));
}
