browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3) version = "n3";
else version = "x";
if ( browserName == "Microsoft Internet Explorer" && browserVer>=4) version="IE4";


var selectOn;
var selectOf;

function Specif_Poids(poids){
	   if(poids<1024) return poids +" Ko"
	   if(poids<1024*1024) return (Math.round((poids/1024)*10)/10) +" Mo"
	   if(poids<1024*1024*1024) return (Math.round((poids/(1024*1024))*10)/10) +" Go"
}
function DownloadClick(Poids,LangueID){
	if(typeof(DownloadClick_PoidsMaxi)=="undefined"){DownloadClick_PoidsMaxi=1.5}
	var bIsGecko=(navigator.platform.toLowerCase().indexOf("gecko") != -1)
	var bIsMSIE=(navigator.platform.toLowerCase().indexOf("msie") != -1)
	var bIsMac=(navigator.platform.toLowerCase().indexOf("mac") != -1)
	var bIsPC=(navigator.platform.toLowerCase().indexOf("win") != -1)
	
	
	
	tempoTexteArray1= "¤[Enregistrer la cible sous...]¤[Save link as...]".split('¤')
	Texte= tempoTexteArray1[((LangueID>2)?2:LangueID)]

	if (bIsGecko) {
		tempoTexteArray1= "¤[Enregistrer la cible du lien sous...]¤[Save link as...]".split('¤')
		Texte= tempoTexteArray1[(LangueID>2)?2:LangueID]
	}
	
	if (bIsMSIE) {
		if (bIsMac) {
			tempoTexteArray1= "¤[Télécharger le lien sur le disque...]¤[Download link to disk...]".split('¤')
			Texte= tempoTexteArray1[((LangueID>2)?2:LangueID)]	
		}else{
			tempoTexteArray1= "¤[Enregistrer la cible sous...]¤[Save target as...]".split('¤')
			Texte= tempoTexteArray1[((LangueID>2)?2:LangueID)]	
		}
	}
	specif_DownloadOnclick=""

	if (Poids>=1024* DownloadClick_PoidsMaxi){ 
		if (Poids>1024) {
			if (bIsMac) {
				tempoTexte= "¤Ce fichier fait "+ Specif_Poids(Poids)   +"\nSur ce même bouton, faites CTRL + Clic puis "+ Texte +" pour télécharger ce fichier" +
						"¤This file weight is "+ Specif_Poids(Poids)   +"\nUsing the same button, do [CTRL + Clic] with your mouse, then click "+ Texte +" to save it on your disk"  +
						"¤Este fichero hace "+ Specif_Poids(Poids)   +"\nEn este mismo botón, haga (botón derecho) (grabar bajo...) para cargar este fichero" +
						"¤Diese Datei enthält "+ Specif_Poids(Poids)   +"\nUm diese Datei herunterzuladen: auf den gleichen Knopf mit [rechtem Mausklick] und [speichern unter...] " +
						"¤questo file pesa "+ Specif_Poids(Poids)   +"\nUsando lo stesso pulsante, fate [pulsante destro][salvare su,,,] per telecaricare questo file"
			}else{
				tempoTexte= "¤Ce fichier fait "+ Specif_Poids(Poids)   +"\nSur ce même bouton, faites [bouton droit] "+ Texte +" pour télécharger ce fichier" +
						"¤This file weight is "+ Specif_Poids(Poids)   +"\nUsing the same button, right click on your mouse, then click "+ Texte +" to save it on your disk" +
						"¤Este fichero hace "+ Specif_Poids(Poids)   +"\nEn este mismo botón, haga (botón derecho) (grabar bajo...) para cargar este fichero" +
						"¤Diese Datei enthält "+ Specif_Poids(Poids)   +"\nUm diese Datei herunterzuladen: auf den gleichen Knopf mit [rechtem Mausklick] und [speichern unter...] " +
						"¤Questo file pesa "+ Specif_Poids(Poids)   +"\nUsando lo stesso pulsante, fate [pulsante destro][salvare su,,,] per telecaricare questo file"
			}
		}else{
			if (bIsMac) {
				tempoTexte= "¤Sur ce même bouton, faites CTRL + Clic puis "+ Texte +" pour télécharger ce fichier" +
						"¤Using the same button, do [CTRL + Clic] with your mouse, then click on "+ Texte +" to save it on your disk"  +
						"¤En este mismo botón, haga (botón derecho) (grabar bajo...) para cargar este fichero" +
						"¤Um diese Datei herunterzuladen: auf den gleichen Knopf mit [rechtem Mausklick] und [speichern unter...] " +
						"¤Usando lo stesso pulsante, fate [pulsante destro][salvare su,,,] per telecaricare questo file"
			}else{
				tempoTexte= "¤Sur ce même bouton, faites [bouton droit] "+ Texte +" pour télécharger ce fichier" +
						"¤Using the same button, right click on your mouse, then Clic on "+ Texte +" to save it on your disk" +
						"¤En este mismo botón, haga (botón derecho) (grabar bajo...) para cargar este fichero" +
						"¤Um diese Datei herunterzuladen: auf den gleichen Knopf mit [rechtem Mausklick] und [speichern unter...] " +
						"¤Usando lo stesso pulsante, fate [pulsante destro][salvare su,,,] per telecaricare questo file"
			}
		
	}
		tempoTexteArray1=tempoTexte.split('¤')
		alert( tempoTexteArray1[LangueID] );
		return false;
	}

	return true;
}


function initIcones(){

	if (typeof(LangueABREVIATION)=="undefined") {LangueABREVIATION=""}
	
	if ((version == "n3") || (version == "IE4")) {
		selectOn= new Image();
		selectOn.src="/images/icones/EnleveCaddie"+LangueABREVIATION+".gif";
		selectOf= new Image();
		selectOf.src="/images/icones/AjouteCaddie"+LangueABREVIATION+".gif";
	}
}

function EtatIcone(valeur){	//V2006-04-26
	if (!valeur){return;}
	if (valeur<=0){return;}
	var nom="product";
	var n=CookieListePosition(nom,valeur);
	
	if (false){
		eval("var tempo=document.selection_"+valeur) 
		if (tempo) {
			if ( tempo.src.toLowerCase().indexOf("_on.gif")>0 || tempo.src.toLowerCase().indexOf("_off.gif")>0 ){
				etatSelection=(n!=-1)?"document.selection_"+valeur+".src.replace(/_OFF.gif/gi , '_ON.gif')":"document.selection_"+valeur+".src.replace(/_ON.gif/gi , '_OFF.gif')";
			}else{
				etatSelection=(n!=-1)?"selectOn.src":"selectOf.src";
			}
			eval("document.selection_"+valeur+".src="+etatSelection);
		}
	}else{
		 var obj=document.getElementsByName("selection_"+valeur)
		 for (var i=0; i<obj.length ; i++){
		 	
		 		if ( obj[i].src.toLowerCase().indexOf("_on.gif")>0 || obj[i].src.toLowerCase().indexOf("_off.gif")>0 ){
					etatSelection=(n!=-1)?obj[i].src.replace(/_OFF.gif/gi , '_ON.gif'):obj[i].src.replace(/_ON.gif/gi , '_OFF.gif');
				}else{
					etatSelection=(n!=-1)?selectOn.src:selectOf.src;
				}
				obj[i].src=etatSelection;
		 }
	}
}



function EtatIcone2(valeur){	//V2001-06-12
	if (!valeur){return;}
	if (valeur<=0){return;}
	nom="product";
	n=CookieListePosition(nom,valeur);
	etatSelection=(n!=-1)?"selectOn.src":"selectOf.src";
	(eval("var tempo=document.selection_"+valeur) )
	if (tempo) {
		if ( tempo.src.toLowerCase().indexOf("_on.gif")>0 ){
			eval("document.selection_"+valeur+".src=document.selection_"+valeur+".src.replace(/_ON.gif/gi , '_OFF.gif')" );
			eval("tempo2=document.selection_"+valeur+".src")
			alert(tempo2)
		}else if (tempo.src.toLowerCase().indexOf("_off.gif")>0 ){
			eval("document.selection_"+valeur+".src=document.selection_"+valeur+".src.replace(/_OFF.gif/gi , '_ON.gif')" );
			eval("tempo2=document.selection_"+valeur+".src")
			alert(tempo2)
		}else{
			eval("document.selection_"+valeur+".src="+etatSelection);
		}
	}
}

function AjoutEnleve(valeur){	//V2001-06-12

	TabVal = splitage(valeur,",");

	for (i in TabVal) {
		nom="product";
		//alert(GetCookie (nom));
		n=CookieListePosition(nom,TabVal[i]);
		( n!=-1 )?CookieEnleveListe(nom,TabVal[i]):CookieAjouteListe(nom,TabVal[i]);
		//alert(n)
		var nomPageASP="panier" + "." + "a" + "s" + "p"
		
	
		tempo=document.location+""
		if (tempo.indexOf(nomPageASP)>0){
			document.location=document.location
			if (parent && parent.parent && parent.parent.principalFrame && parent.parent.principalFrame.EtatIcone){
				parent.parent.principalFrame.EtatIcone(TabVal[i])
			}
		}
		if (parent && parent.ongletsFrameSet && parent.ongletsFrameSet.frame_1){
			tempo=(parent.ongletsFrameSet.frame_1.location)+""
			if (tempo.indexOf(nomPageASP)>0){
				//parent.ongletsFrameSet.frame_1.location.reload()
				parent.ongletsFrameSet.frame_1.location=parent.ongletsFrameSet.frame_1.location
			}
		}
		if (parent && parent.ongletsFrameSet && parent.ongletsFrameSet.frame_4){
			tempo=(parent.ongletsFrameSet.frame_4.location)+""
			if (tempo.indexOf(nomPageASP)>0){
				//parent.ongletsFrameSet.frame_4.location.reload()
				parent.ongletsFrameSet.frame_4.location=parent.ongletsFrameSet.frame_4.location
			}
		}
		
		if (parent && parent.frame_4){
			tempo=(parent.frame_4.location)+""
			if (tempo.indexOf(nomPageASP)>0){
				//parent.ongletsFrameSet.frame_4.location.reload()
				parent.frame_4.location=parent.frame_4.location
			}
		}
	
		if (parent && parent.Site){
			tempo=(parent.Site.location)+""
			//if (tempo.indexOf(nomPageASP)>0){
				//parent.ongletsFrameSet.frame_4.location.reload()
				
				parent.Site.location=parent.Site.location
			//}
		}
	
		//EtatIconeAllFrames(parent.document , TabVal[i])
		EtatIcone(TabVal[i]);
		EtatIconeAllFrames(top , TabVal[i])
		if (window && window.opener  ){
			try
			{
				self.window.onerror=erreurGestionIcones;
				EtatIconeAllFrames(window.opener.top , TabVal[i])
			}
			catch (error)
			{
			}
		}
	
		self.window.onerror=erreurGestionIcones;
		
		if (false) {
			//Code utilisé si chromless
			if (top && top.opener && top.opener.window&&top.opener.window.top){
				EtatIconeAllFrames(top.opener.window.top , TabVal[i])
		
			}
		}
		//this.blur()
	}
	
	if( (document.getElementById('dPanier')||document.getElementById('dPanier1')||document.getElementById('dPanier2')) && 'function' == typeof( window.specif_panier_maj ) ){
		specif_panier_maj()
	}
	if( (document.getElementById('dPanier')||document.getElementById('dPanier1')||document.getElementById('dPanier2')) && 'function' == typeof( window.updateMyBasketDiv ) ){
		updateMyBasketDiv()
	}
	
	
	
	
}

function erreurGestionIcones() {
	return true 
}

function EtatIconeAllFrames(Objet , valeur){
	var obj
	for (var i=0; i<Objet.frames.length;i++){
		if (Objet.frames[i].EtatIcone){Objet.frames[i].EtatIcone(valeur);}
		EtatIconeAllFrames(Objet.frames[i] , valeur)
	}
	return false
}


function CheckIfAllChecked()	//V2001-06-12
{
	var TotalBoxes = 0;
	var TotalOn = 0;
	if (document.FormRecherche && document.FormRecherche.checkAllBox){
		for (var i=0;i<document.FormRecherche.elements.length;i++)
		{
			var e = document.FormRecherche.elements[i];
			if ((e.name != 'checkAllBox') && (e.type=='checkbox'))
			{
				TotalBoxes++;
			if (e.checked)
			{
				TotalOn++;
			}
			}
		}
	
		if (TotalBoxes==TotalOn)
		{document.FormRecherche.checkAllBox.checked=true;}
		else
		{document.FormRecherche.checkAllBox.checked=false;}
	}
}


function AjouterCaddieAllSel(){	//V2002-02-04
	ID=""
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked) && (e.name.substr(0,6) == "check_")){
			if (ID!=""){ID+=","}
			ID+=e.name.substr("check_".length,e.name.length)
			CookieAjouteListe('product',e.name.substr("check_".length,e.name.length))
			EtatIcone(e.name.substr("check_".length,e.name.length))
		}
	}
	if (ID == ""){alert("Désolé, pas de fichier sélectionné ou alors qui ont pas de prix défini !")}
}

function EnleveCaddieAllSel(){	//V2002-02-04
	ID=""
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked)){
			if (ID!=""){ID+=","}
			ID+=e.name.substr("check_".length,e.name.length)
			CookieEnleveListe('product',e.name.substr("check_".length,e.name.length))
			EtatIcone(e.name.substr("check_".length,e.name.length))
		}
	}
	if (ID == ""){alert("Désolé, pas de fichier sélectionné !")}
}



function SelectAllBox()	//V2001-06-12
{
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox'))
		e.checked = document.FormRecherche.checkAllBox.checked;
	}
}
function ModifPermAllSel(){	//V2001-06-12
	ID=""
	n=0
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked)){
			if (ID!=""){ID+=","}
			ID+=e.name.substr(e.name.lastIndexOf("_")+1)
			//ID+=e.name.substr("check_".length,e.name.length)
			n++
		}
	}
	if (ID != ""){ModifPerm(ID,n+" fichiers")}else{alert("Désolé, pas de fichier sélectionné !")}
}



function DestroyAllSel(){	//V2001-06-12
	ID=""
	n=0
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked)){
			if (ID!=""){ID+=","}
			ID+=e.name.substr(e.name.lastIndexOf("_")+1)
			//ID+=e.name.substr("check_".length,e.name.length)
			n++
		}
	}

	if (ID != ""){
		if (confirm('Etes vous sûr de vouloir détruire DEFINITIVEMENT les fichiers sélectionnés ??')){
			document.FormRecherche.DeleteFile.value=ID
			document.FormRecherche.submit()
		}
	}
	else{
		alert("Désolé, pas de fichier sélectionné !")
	}
}
function Destroy(ID){	//V2001-06-12
		if (confirm('Etes vous sûr de vouloir détruire DEFINITIVEMENT CE fichier ??')){
			if ( (document.FormRecherche) && (document.FormRecherche.DeleteFile) ){
				document.FormRecherche.DeleteFile.value=ID
				document.FormRecherche.submit()
			}
			else {
				if ( (document.PermNouveauFichier) && (document.PermNouveauFichier.DeleteFile) ){
					document.PermNouveauFichier.DeleteFile.value=ID
					document.PermNouveauFichier.submit()
				}
			}
		}
}

function ModifinfosAllSel(){	//V2001-06-12
	ID=""
	n=0
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked)){
			if (ID!=""){ID+=","}
			ID+=e.name.substr(e.name.lastIndexOf("_")+1)
			//ID+=e.name.substr("check_".length,e.name.length)
			n++
		}
	}

	if (ID != ""){
		Modifier(ID)
	}
	else{
		alert("Désolé, pas de fichier sélectionné !")
	}
}

function RemoveFromNewsAllSel(){	//V2001-06-12
	ID=""
	n=0
	for (var i=0;i<document.FormRecherche.elements.length;i++)
	{
		var e = document.FormRecherche.elements[i];
		if ((e.name != 'checkAllBox') && (e.type=='checkbox') && (e.checked)){
			if (ID!=""){ID+=","}
			ID+=e.name.substr("check_".length,e.name.length)
			n++
		}
	}

	if (ID != ""){
		RemoveFromNews(ID)
	}
	else{
		alert("Désolé, pas de fichier sélectionné !")
	}	
}


var tvX = 0;
var tvY = 0;
var OLDSpan = -1;
tvDocTipsSize=200
whichEl = null;

if (navigator.appName.substring(0,3) == "Net")
{
	document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP)
	document.onmousedown = moveToAll;
	//document.onmouseup = EndDragTips;
	
}

function  ShowTips_clearbrowseredge(obj, whichedge){
	
	var dropmenuobj = obj;
	
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		
		//status="lll--"+ dropmenuobj.offsetWidth +"----"+ windowedge
		if (windowedge-dropmenuobj.x < dropmenuobj.offsetWidth)
			edgeoffset=dropmenuobj.offsetWidth-obj.offsetWidth
	}
	else{
		var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		
		if (windowedge-dropmenuobj.y < dropmenuobj.offsetWidth){ //move up?
			edgeoffset=dropmenuobj.offsetWidth+obj.offsetHeight
			if ((dropmenuobj.y-topedge)<dropmenuobj.offsetWidth) //up no good either?
				edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

var ie5=document.all
var ns6=document.getElementById&&!document.all

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ShowTips(ID) 
{
	eval("var tvDocTips = document.getElementById('doctips_"+ID+"').style;")
	eval("var tvDocTipsAlone = document.getElementById('doctips_"+ID+"');")
	if (tvDocTips) {
		if (navigator.appName.substring(0,3) == "Net") {
			document.onmousemove = moveToAll;
		} else {
			tvX = event.clientX+document.body.scrollLeft; 
			tvY = event.clientY+document.body.scrollTop;
		}
		
		if (false){
			tvDocTips.left = tvX+10;
			tvDocTips.top = tvY+5;
		}else{
			tvDocTips.left = tvX+10-ShowTips_clearbrowseredge(tvDocTipsAlone, "rightedge");
			tvDocTips.top = tvY+5-ShowTips_clearbrowseredge(tvDocTipsAlone, "bottomedge");
			//status=ShowTips_clearbrowseredge(tvDocTipsAlone, "rightedge");
			//status=tvDocTipsAlone.offsetWidth
		}
		
		tvDocTips.visibility='visible';
		tvDocTips.zIndex=ID;


		
		if(parseFloat(navigator.appVersion)>=4)	{
				WB_scr=screen;
				
				tWidth=WB_scr.width;
				tHeight=WB_scr.height;
				//window.status="infos "+ tvDocTipsWidth.width;
				//for (elt in tvDocTips){alert( elt) }
		}
		
		OLDSpan = ID;
	}
}

function moveToAll(e) 
{
      tvX = e.pageX;
      tvY = e.pageY;
}

function moveTo(pObj,pX,pY) 
{
      pObj.left = pX;
      pObj.top = pY;
}

function HideTips(ID) 
{
	eval("var tvDocTips = document.getElementById('doctips_"+ID+"');")
	if (tvDocTips) {
		tvDocTips.style.visibility='hidden';
	}
}

function HideTipsOLD() 
{
	eval("var tvDocTips = document.getElementById('doctips_"+OLDSpan+"');")
	if (tvDocTips) {
		tvDocTips.style.visibility='hidden';
	}
}

var current = null;
var dx = 0;
var dy = 0;
function StartDragTips(ID)
{
	eval("current = document.getElementById('doctips_"+ID+"').style;")
	
	if (navigator.appName.substring(0,3) == "Net") {
		//document.onmousedown = moveToAll;
	} else {
		tvX = event.clientX+document.body.scrollLeft; 
		tvY = event.clientY+document.body.scrollTop;
	}
	
	dx = tvX - parseInt(current.left);
	dy = tvY - parseInt(current.top);
	
	
	if (navigator.appName.substring(0,3) == "Net") {
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = DragTips;
	return false;
}

function DragTips(e)
{
	if (navigator.appName.substring(0,3) == "Net") {
		current.left = parseInt(e.pageX)-dx;
		current.top = parseInt(e.pageY)-dy;
	} else {
		current.left = parseInt(event.clientX)-dx;
		current.top = parseInt(event.clientY)-dy;
	}
	return false;
}

function EndDragTips(e)
{
	if (navigator.appName.substring(0,3) == "Net") {
		document.releaseEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = null;
	current = null;
}

function DisplayTips(ID) 
{
	if (NS4) 
	{
		eval("var lvLayer = document.doctips_"+ID+";")
		if (lvLayer){
			lvLayer.visibility="hide";
		}
	}
		
	if (IE4) 
	{
		if (this.document.all['doctips_'+ID]){
			tvDocTips = this.document.all['doctips_'+ID].style;
			tvDocTips.visibility="visible";
		}
	}	
}
