<!--
// Browser detection
if (navigator.userAgent.indexOf('Opera')>=0) var opera = true;
if (opera && parseInt(navigator.appVersion) < 6) var opera5 = true;

function GoListe(obj) {	
	if (obj.value != '') {
		obj.form.submit();
	}
	return 0;
} // end of GoListe

function Aide(url) {
	win=window.open(url,"newWindow","width=720, height=380, scrollbars=yes, resizable=yes").focus();
} // end of Aide

function AideCata(url) {
	win=window.open(url,"newWindow","width=485, height=370, scrollbars=yes, resizable=yes").focus();
} // end of Aide

function change_site() {
	var site = document.menu.select.selectedIndex;
	if (site != '') {
		self.location.href = document.menu.select.options[site].value;
	}
} // end of change_site

function ChangeOptionTriA(Tab, isSearchResultsPage) {
  if (!isSearchResultsPage) {
      if (Tab == 1) {
        var site = document.forms["ChOption1"].ReOrdreTriA1.selectedIndex;
        self.location.href = document.forms["ChOption1"].ReOrdreTriA1.options[site].value;
      }
      if (Tab == 2) {
        var site = document.forms["ChOption2"].ReOrdreTriA2.selectedIndex;
        self.location.href = document.forms["ChOption2"].ReOrdreTriA2.options[site].value;
      }
  }
} // end of function ChangeOptionTri

function ChangeOptionTriB(Tab) {
  if (Tab == 1) {
	var site = document.forms["ChOption1"].ReOrdreTriB1.selectedIndex;
	if (site != '') {
		self.location.href = document.forms["ChOption1"].ReOrdreTriB1.options[site].value;
	}
  }
  if (Tab == 2) {
	var site = document.forms["ChOption2"].ReOrdreTriB2.selectedIndex;
	if (site != '') {
		self.location.href = document.forms["ChOption2"].ReOrdreTriB2.options[site].value;
	}
  }
} // end of function ChangeOptionTri

function submitNbArticlesParPage(select, isSearchResultsPage) {
    if (!isSearchResultsPage) {
        select.form.submit();
    }
}

$(function() {
    $("#resultats-recherche .page-precedente,#resultats-recherche .page-suivante").click(function() {
		$('#queryASF-N').val(parseInt($("#choix-page-1").val(), 10) + ($(this).hasClass("page-precedente") ? -1 : 1));
		$("#affineSearchForm input[@type=checkbox][@checked]").attr("checked","");
		$("#affineSearchForm input[@type=radio][@checked]").attr("checked","");
		$('#affineSearchForm').submit();
	});

    $("#choix-page-1,#choix-page-2").change( function() {
        $('#queryASF-N').val($(this).val());
        $("#affineSearchForm input[@type=checkbox][@checked]").attr("checked","");
        $("#affineSearchForm input[@type=radio][@checked]").attr("checked","");
        $('#affineSearchForm').submit();
    });

    $("#choix-tri").change(function() {
        $('#queryASF-SORT_ORDER').val($(this).val());
        $("#affineSearchForm input[@type=checkbox][@checked]").attr("checked","");
        $("#affineSearchForm input[@type=radio][@checked]").attr("checked","");
        $('#affineSearchForm').submit();
    });

    $("#choix-nbpages").change( function() {

        $('#queryASF-NB_REPLY').val($(this).val().replace(/[^\d]+/, ""));
        $("#affineSearchForm input[@type=checkbox][@checked]").attr("checked","");
        $("#affineSearchForm input[@type=radio][@checked]").attr("checked","");

        $('#queryASF-N').val('1');//force l'affichage de la page 1
        $('#affineSearchForm').submit();
    });
});

function change_site_target() {
	var site = document.menu.select.selectedIndex;
	if (site!="") {
		win=window.open(document.menu.select.options[site].value,"newWindow","width=600, height=420").focus();
	}
} // end of change_site_target

function change_pays_target() {
	var site = document.getElementsByName('select').item(0).selectedIndex;
	if (site!="") {
		win=window.open(document.getElementsByName('select').item(0).options[site].value,"newWindow","scrollbars=yes, width=600, height=420").focus();
	}	
} // end of change_pays_target

function launch(url, name, w, h, x, y, scroll) {
	name=window.open(url, name,'width='+w+',height='+h+',left='+x+',top='+y+',toolbar=no,menubar=no,status=no,resizable=no,scrollbars='+scroll).focus();
} // end of launch

function MM_openBrWindow(theURL,winName,features) { //v2.0
	var win = window.open(theURL,winName,features).focus();
	return win;
} // end of MM_openBrWindow

function PopProduit(MyFile,MyName) {	
    var xMax, yMax, xOffset, yOffset;
    var MyWidth	= 780;
    var MyHeight= 580;

    var n4	= window.Event ? true : false; // NN4 ou plus 
    var ns4	= document.layers
    var ie4	= document.all
    var ns6	= document.getElementById&&!document.all

    if (ie4 || ns6) {
        xMax = screen.width;
        yMax = screen.height;
    } else if (ns4) {
        xMax = window.outerWidth;
        yMax = window.outerHeight;
    } else {
        xMax = 780;
        yMax = 580;
    }

    xOffset = (xMax - MyWidth)/2;
    yOffset = (yMax - MyHeight)/2;

  	MyName = window.open(MyFile,MyName,'width='+MyWidth +',height='+MyHeight +',screenX='+xOffset +',screenY='+yOffset +',top='+yOffset +',left='+xOffset +',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
  	MyName.focus();
  if (MyName.blur) MyName.focus();
} // end of function PopProduit

function ChangeLangue(lg) {
	document.forms["ChLg"].lang.value=lg;
	document.forms["ChLg"].action=document.location;
	document.forms["ChLg"].submit();
} // end of ChangeLangue

// Display the layer container
// @param whichLayer  le layer a afficher (container)
function show(whichLayer) {
    if (document.getElementById) { // MSIE 5.x, Opera 4.x, Mozilla m17, Netscape 6PR2
		layerName = document.getElementById(whichLayer);
		layerName.style.visibility = 'visible';
    }
    else if (document.all) { // MSIE 4.x
		layerName = eval(whichLayer);
		layerName.style.visibility = 'visible';
    }
} // end of function show

// Hidden the layer container
// @param whichLayer  le layer a afficher (container)
function hide(whichLayer) {
    if (document.getElementById) { // MSIE 5.x, Opera 4.x, Mozilla m17, Netscape 6PR2
		layerName = document.getElementById(whichLayer);
		layerName.style.visibility = 'hidden';
    }
    else if (document.all) { // MSIE 4.x
		layerName = eval(whichLayer);
		layerName.style.visibility = 'hidden';
    }
} // end of function hide

// Permet d'afficher en dislay none ou inline un block div
// @param whichLayer  le layer a afficher (container)
// @param whatStyle   inline - none - block
function DisplayChoice(whichLayer,whatStyle) {
  var element_style = null;
  if (document.getElementById && document.getElementById(whichLayer)) {
    element_style=document.getElementById(whichLayer);
  } else if (document.all && document.all[whichLayer]) {
    element_style=document.all[whichLayer];
  } else {
    element_style = null;
  }
  if (element_style) {
     element_style = element_style.style;
  	 if (whatStyle=='inline') 	element_style.display='inline';
     if (whatStyle=='none')   	element_style.display='none';
     if (whatStyle=='block')  	element_style.display='block';
     if (whatStyle=='')  		element_style.display='';
  }
} // end of DisplayChoice

// Verifie si le layer id existe
// @param whichLayer  le layer a afficher (container)
function IfexistObject(whichLayer) {
  var layerExist = null;
    if (document.getElementById) layerExist = document.getElementById(whichLayer);
    else if (document.all)       layerExist = eval(whichLayer);
    else                         layerExist = null;
return layerExist;
} // end of function show

// Display the layer
function table(thisform) {
    var result = document.getElementById(thisform).style.display;
	if (result == 'none') {
		DisplayChoice(thisform,'inline');
	} else {
		DisplayChoice(thisform,'none');
	}
}

// pour les menus select
function SearchDispoProd(CurrentForm,CurrentValue) {

	// Le cas dit "normal"
	var recup_dispo = CurrentValue.split('|');              
	if (recup_dispo && recup_dispo[1] == 2) {
		DisplayChoice('DispoMoment','block');                           
		DisplayChoice('DispoStop','none'); 
	hide('DispoOk');
	}
	else if (recup_dispo && recup_dispo[1] == 3) {
		DisplayChoice('DispoStop','block');                     
		DisplayChoice('DispoMoment','none'); 
	hide('DispoOk');
	}
	else {
		show('DispoOk');
		DisplayChoice('DispoMoment','none'); 
		DisplayChoice('DispoStop','none'); 
	}
}

// Fonction pour la page de paiement
function table_cd(thisform) {
    var result = document.getElementById(thisform).style.display;
	if (result == 'none') {
		DisplayChoice(thisform,'inline');   	   	   	
	}
}

function table_hid(thisform) {
    var result = document.getElementById(thisform).style.display;
		DisplayChoice(thisform,'none'); 
}

//****************************************************************************************
//                    AFFICHAGE - DESAFFICHAGE D'ELEMENTS - * D'AFFICHAGE
//                                 Benjamin - 14/09/2004
//****************************************************************************************

function switch_affichage(id) {
	if(document.getElementById(id).style.display == "block")
		DisplayChoice(id,'none');
	else if(document.getElementById(id).style.display == "none")
		DisplayChoice(id,'block');
	else alert('erreur');
}

/* Redirige à la page 'page' selon la valeur et le nom de l'objet en paramètre */
function redirige_param(objet,page)
{
	//alert(page+setParams(objet.name, objet.value));
	window.location.href = page+setParams(objet.name, objet.value);
}

/* Redirige à la page 'page' selon la valeur et le nom des objets en paramètre */
function redirige_paramTab(objets,page)
{
	names	= '';
	values	= '';
	for (i=0;i<objets.length;i++) {
		if (i == 0) {
			names	= names+objets[i].name;
			values	= values+objets[i].value;
		}
		else {
			names	= names+';'+objets[i].name;
			values	= values+';'+objets[i].value;
		}
	}
	window.location.href = page+setParamsTab(names, values);
}

/* Méthode qui retourne un tableau contenant tous les paramètres */
function getParams(){
	if(window.location.search.length > 1)
	{
		var parms = window.location.search.substring(1).split("&");
		var parmList = new Array();	
		for(var i = 0; i < parms.length; i++)
		{
			parmList[i] = new Object;
			parmList[i].name = parms[i].substring(0,parms[i].indexOf("="));
			parmList[i].value = parms[i].substring(parms[i].indexOf("=")+1);
		}
		return parmList;
	}	
	else return null;
}

/* Méthode initialisant un menu déroulant ou autre selon les paramètres */
function init_selection(sel, param)
{
	var params = getParams();
	var bool = true;
	is_selected	= false;
	if(params != null && sel != null) {	
		var val;
		var i;
		for(i=0;(i<params.length)&&(bool);i++)
		{
			if(params[i].name == param)
			{
				val = params[i].value;
				for(i=0;i<sel.length;i++)
				{
					if(sel[i].value == val && is_selected == false) {
						sel[i].selected = true;
						is_selected = true;
					}
					else	sel[i].selected = false;
				}
				bool = false;
			}
		}
	}
}

/*
 *   Fonction permettant de renvoyé les paramètres de la page
 *  sous forme de string                                       
 */
function setParams(param, newval)
{
	var params = getParams();
	var bool = true;
	var res = "";
	if(params != null)
	{
		var i;
		for(i=0;i<params.length;i++)
		{
			if(i == 0)
				res = res+"?";
			else res = res+"&";
			res = res+params[i].name+"=";
			if(params[i].name == param)
			{
				res = res+newval;
				bool = false;
			}
			else res = res+params[i].value;
		}
		if(bool)
			res = res + "&"+param+"="+newval;
	}
	else res = "?"+param+"="+newval;
	
	return res;
}

/*
 *   Fonction permettant de renvoyé les paramètres de la page
 *  sous forme de string
 * @param param tableau Tableau des paramètres à modifier
 * @param param tableau Tableau des valeurs des paramètres
 */
function setParamsTab(param2, newval2)
{
	var params = getParams();
	var param = param2.split(";");
	var newval = newval2.split(";");
	var bool2 = false;
	var res = "";
	if(params != null)
	{
		var i;
		for(i=0;i<params.length;i++)
		{
			bool2 = false;
			if(i == 0)
				res = res+"?";
			else res = res+"&";
			for(j=0;(j<param.length) && (!bool2);j++)
			{
				if(params[i].name == param[j])
				{
					res = res+params[i].name+"="+newval[j];
					param[j] = "toto";
					bool2 = true;
				}	
			}
			if(!bool2)
				res = res+params[i].name+"="+params[i].value;
		}
		for(j=0;j<param.length;j++)
		{
			if(param[j] !=  "toto" )
				res = res + "&"+param[j]+"="+newval[j];
		}
	}
	else
	{
		res = res + "&"+param[0]+"="+newval[0];
		for(j=1;j<param.length;j++)
			res = res + "?"+param[j]+"="+newval[j];
	}
	
	return res;
}

function eclaircirImgListe(id) {
	var monId = 'listeimg'+id;
  if (document.getElementById(monId).className == 'ImgListeRond') {
    document.getElementById(monId).className	= 'ImgListeRondOver';
  } else {
    document.getElementById(monId).className	= 'ImgListeOver';
  }
	
}

function foncerImgListe(id) {
	var monId = 'listeimg'+id;
  if (document.getElementById(monId).className == 'ImgListeRondOver') {
    document.getElementById(monId).className	= 'ImgListeRond';
  } else {
    document.getElementById(monId).className	= 'ImgListe';
  }
}

function FocusText(BoxName) {
  if (BoxName.value == BoxName.defaultValue) {
   BoxName.value = '';
  }
}

function BlurText(BoxName) {
  if (BoxName.value == '') {
    BoxName.value = BoxName.defaultValue;
  }
}

function getBaseStoreFromCurrentUrl() {
    return document.location.protocol+"//"+document.location.host+document.location.pathname.replace(/^(\/[a-z]{2}\/[^\/]+\/).*$/, "$1");
}

function rechercheActeur(select, addComfrom) {
	valeur	= select.options[select.selectedIndex].value;
	document.location.href=getBaseStoreFromCurrentUrl()+"liste.php?P1Idx=1&MotCle="+valeur+""+addComfrom;
}
function rechercheActeur2(id, addComfrom) {
	valeur	= document.getElementById(id).value;
	document.location.href=getBaseStoreFromCurrentUrl()+"liste.php?P1Idx=1&MotCle="+valeur+""+addComfrom;
}

// Supprime les espaces inutiles en début et fin de la chaîne passée en paramètre.
function trim(stringToTrim,carToTrim) {
	if(typeof(carToTrim)=="undefined") carToTrim = "\\s";
	if(new String(typeof(stringToTrim)).toLowerCase() != "string"){
		return stringToTrim ;
	}
	else{
		return rtrim(ltrim(stringToTrim,carToTrim),carToTrim);
	}
}
function ltrim(stringToTrim,carToTrim) {
	if(typeof(carToTrim)=="undefined") carToTrim = "\\s";
	var reg = new RegExp("^"+carToTrim+"+","g");
	return stringToTrim.replace(reg,"");
}
function rtrim(stringToTrim,carToTrim) {
	if(typeof(carToTrim)=="undefined") carToTrim = "\\s";
	var reg = new RegExp(carToTrim+"+$","g");
	return stringToTrim.replace(reg,"");
}

// retourne le parent le plus proche desiré
function getParent(element, parentTagName, niveaux){
	if(typeof(niveaux)==="undefined") niveaux = 0;
	if(!element)
		return null;
	else if ( element.nodeType == 1 && element.tagName.toLowerCase() == parentTagName.toLowerCase() )
		if(niveaux > 0) return getParent(element.parentNode, parentTagName, niveaux-1);
		else			return element;
	else
		return getParent(element.parentNode, parentTagName, niveaux);
}

// TETIERE
/*
var tetiereIsOver	= Array();
function tetiereOver(num) {
	if ($(document.getElementById('onglet_l_'+num)).attr("src") != "../images/store/gabarit/onglet_bkd_over.gif") {
		$(document.getElementById('onglet_l_'+num)).attr("src", "../images/store/gabarit/onglet_l_over.gif");
		$(document.getElementById('onglet_bkd_'+num)).attr("background", "../images/store/gabarit/onglet_bkd_over.gif");
		$(document.getElementById('onglet_bkd_'+num)).attr("class", "tetiereonglet_over");
		$(document.getElementById('onglet_r_'+num)).attr("src", "../images/store/gabarit/onglet_r_over.gif");
	}
	tetiereIsOver[num]	= true;
}

function tetiereOut(num) {
	window.setTimeout("tetiereOutReel("+num+")", 300);
	tetiereIsOver[num]	= false;
}

function tetiereOutReel(num) {
	if ($(document.getElementById('onglet_l_'+num)).attr("src") != "../images/store/gabarit/onglet_bkd.gif" && tetiereIsOver[num] == false) {
		$(document.getElementById('onglet_l_'+num)).attr("src", "../images/store/gabarit/onglet_l.gif");
		$(document.getElementById('onglet_bkd_'+num)).attr("background", "../images/store/gabarit/onglet_bkd.gif");
		$(document.getElementById('onglet_bkd_'+num)).attr("class", "tetiereonglet");
		$(document.getElementById('onglet_r_'+num)).attr("src", "../images/store/gabarit/onglet_r.gif");
	}
}
*/
//-->

//functions d'ouverture d'un div absolute
function fermer_div(iddiv){
	ouvrir_div(iddiv,null,0);
}
function ouvrir_div(iddiv,even,action,x,y,couche,langue,centre,docColor,fermable,fixe){
	//alert("ouvrir_div("+iddiv+","+even+","+action+","+x+","+y+","+couche+","+langue+","+centre+")");
	var pan;
	var elem;
  
	if(typeof(even)=="undefined")                       even=null;
  if(typeof(action)=="undefined" || action==null)     action=1;
  if(typeof(x)=="undefined" || isNaN(x))              x=10;
  if(typeof(y)=="undefined" || isNaN(y))              y=10;
	if(typeof(couche)=="undefined" || couche==null)     couche="";
  if(typeof(langue)=="undefined" || langue==null)     langue="L0";
	if(typeof(centre)=="undefined" || centre==null)     centre=false; // le div ne doit pas sortir au centre de l'ecran
	if(typeof(docColor)=="undefined" || docColor==null) docColor=false; // le div ne doit pas sortir avec un fond fixe qui bloque le document
  if(typeof(fermable)=="undefined" || fermable==null) fermable=true;
  if(typeof(fixe)=="undefined" || fixe==null){
      fixe = ((centre) ? false : true);
  }

  if(couche!="" && couche.substr(couche.length-1,1)!='.'){ couche=couche+"."; }
	eval("elem="+couche+"document.getElementById('"+iddiv+"')");
  
	if(elem){
		pan=elem;
		pan.style.position="absolute";
		DisplayChoice(pan.id,"");
    pan.style.visibility="hidden";
		var htmlToAdd = "";
		var firstDiv = pan.getElementsByTagName("div")[0];
		if(!firstDiv || !firstDiv.getAttribute('name') || firstDiv.getAttribute('name').substring(0,5)!="auto_"){
			if(typeof(langue)==="undefined"){ langue="L0"; }
      if(fermable){
        htmlToAdd += "<div name=\"auto_close_pan\" style=\"padding-bottom:5px; cursor:pointer;\" class=\"opacity50\" onclick=\"ouvrir_div('"+pan.id+"',event,0);\" onmouseover=\"this.className='opacity100'\" onmouseout=\"this.className='opacity50'\">";
        htmlToAdd += "<img src='../images/help_close.png' id='auto_img_close'><img id='auto_img_close_txt' alt='' src='../images/sexyavenue/"+langue+"/store/fermer.gif'>";
        htmlToAdd += "</div>";
      }
			htmlToAdd += "<div name=\"auto_ombreTop\" style='position:absolute; left:-14px; top:-14px;' class='ombreTop'>&nbsp;</div>";
			htmlToAdd += "<div name=\"auto_ombreLeft\" style='position:absolute; left:-14px; top:0px;' class='ombreLeft'>&nbsp;</div>";
		}
		$(pan).prepend(htmlToAdd);
		pan.style.border = "1px solid #CCCCCC";
		if(!pan.style.backgroundColor) pan.style.backgroundColor = "#F6F6F6";
		pan.style.padding = "5px";
		// gestion de la position du bloc
		NouvLeft=0;
		NouvTop=0;
		if(isNaN(action)){
			action=1;
		}
		if(action==1){ // ouverture
			pan.style.zIndex='1000';
			//creation du fond
      var docColorDiv;
      if($('#docColorDiv').length == 0){
        docColorDiv = ajouterElementDocument('div','docColorDiv');
        docColorDiv.name = "auto_fixe";
        docColorDiv.className = "fond_fixed";
      }
      else{
        docColorDiv=document.getElementById('docColorDiv');
      }
      docColorDiv.style.zIndex = pan.style.zIndex-1;
      if(docColor){
        docColorDiv.style.backgroundColor = docColor;
				DisplayChoice('docColorDiv',"");
			}
      else{
        DisplayChoice('docColorDiv','none');
      }
      //puis on affiche
      var fonctionReplacer = "repositionneDiv('"+pan.id+"',null,"+x+","+y+","+centre+",'"+docColorDiv.id+"',"+fixe+")";
      pan = repositionneDiv(pan.id,even,x,y,centre,docColorDiv.id,false); // pour le premier appel on ne fixe pas la fenetre
      pan.style.visibility="visible";
      
                timeo = window.setTimeout(fonctionReplacer,10);
			window.onscroll = function(){
				timeo = window.setTimeout(fonctionReplacer,10);
			}
			window.onresize = function(){
				timeo = window.setTimeout(fonctionReplacer,10);
			}
		}
		else{
			DisplayChoice(pan.id,"none");
			DisplayChoice('docColorDiv',"none");
			window.onscroll = function(){};
			window.onresize = function(){};
    }
		//puis on associe le socle au div affiché
		var divSocle = iddiv;
		if(document.getElementById('docColorDiv') && document.getElementById('docColorDiv').style.display!='none'){
      divSocle = 'docColorDiv';
    }
		PositionSocle(divSocle,action,couche);
	}
}
function repositionneDiv(panId,even,x,y,centre,fondId,fixe){
  if(!document.getElementById(panId)) return null;
  var pan = document.getElementById(panId);
  //on test si un parent (div) n'est pas deja positionné
  parentTest=pan;
  xDepart=0;
  yDepart=0;
  while(parentTest.parentNode){
    if(parentTest.parentNode.style){
      if(parentTest.parentNode.style.position!=""){
        xDepart+=parentTest.parentNode.offsetLeft;
        yDepart+=parentTest.parentNode.offsetTop;
      }
    }
    parentTest=parentTest.parentNode;
  }
  //position de l'ecran
  var largEcran;
  var hautEcran;
  var largPan = pan.offsetWidth;
  var hautPan = pan.offsetHeight;
  largEcran = ((window.innerWidth)?   window.innerWidth 	: screen.availWidth);
  hautEcran = ((window.innerHeight)? 	window.innerHeight	: screen.availHeight);
  //gestion de la largeur du pan
  if(!pan.style.width){
    if(largPan < 500) largPan = 500;
    if(largPan > 600) largPan = 600;
  }
  else{
    largPan = floatval(pan.style.width);
  }
  if(largPan > largEcran-60 && !fixe) largPan = largEcran-60;
  //gestion de la hateur
  if(!pan.style.height){
    if(hautPan < 300) hautPan = 300;
    if(hautPan > 500) hautPan = 500;
  }
  else{
    hautPan = floatval(pan.style.height);
  }
  if(hautPan > hautEcran-60 && !fixe) hautPan = hautEcran-60;
  pan.style.width = largPan+"px";
  pan.style.height = hautPan+"px";
  // gestion du div enfant
  var children = pan.getElementsByTagName("div");
  if(children.length>0){
    var contenu = new Array();
    for(var i=0; i<children.length; i++){
      var name = children[i].getAttribute('name');
      if(!name || name.substring(0,5)!="auto_"){ // ne prend pas les auto_ parce que ajoutés automatiquements
        contenu[contenu.length] = children[i];
      }
    }
    if(contenu.length==1 && contenu[0]!=""){
      contenu = contenu[0];
      contenu.style.top="0px";
      contenu.style.left="0px";
      var topToPan = floatval(contenu.offsetTop);
      var bottomToPan = floatval($(pan).css('paddingBottom'));
      var hautContenu = floatval(hautPan-(topToPan+bottomToPan));
      contenu.style.height 	= hautContenu+"px";
    }
  }
  if(!centre){
    //position de la souris
    if(even){
      mouse=position(even);
      nouvX=mouse["x"];
      nouvY=mouse["y"];
    }
    else{
      nouvX=pan.style.left;
      nouvY=pan.style.top;
    }
    if(isNaN(y) || y==0){
      y=10;
    }
    if(isNaN(x) || x==0){
      x=10;
    }
    eval("x="+x);
    eval("y="+y);
    if(nouvX+x+pan.offsetWidth>largEcran){
      nouvX=nouvX-pan.offsetWidth;
      x=(-1)*x;
      nouvLeft=nouvX+x;
      if(nouvLeft<document.documentElement.scrollLeft){
        nouvX=nouvX+pan.offsetWidth;
        x=(-1)*x;
      }
    }
    if(nouvY+y+pan.offsetHeight>hautEcran){
      nouvY=nouvY-pan.offsetHeight;
      y=(-1)*y;
      nouvTop=nouvY+y;
      if(nouvTop<document.documentElement.scrollTop){
        nouvY=nouvY+pan.offsetHeight;
        y=(-1)*y;
      }
    }
    nouvLeft=(nouvX-xDepart)+x;
    nouvTop=(nouvY-yDepart)+y;
  }
  else{
    nouvTop=hautEcran/2-pan.offsetHeight/2+document.documentElement.scrollTop;
    nouvLeft=largEcran/2-pan.offsetWidth/2+document.documentElement.scrollLeft;
  }
  if(nouvTop<document.documentElement.scrollTop) nouvTop=document.documentElement.scrollTop;
  if( !fixe ){
    pan.style.top=nouvTop+"px";
    pan.style.left=nouvLeft+"px";
  }
  if(document.getElementById(fondId)){
    var docColorDiv = document.getElementById(fondId);
    docColorDiv.style.top = document.documentElement.scrollTop+"px";
    docColorDiv.style.left = document.documentElement.scrollLeft+"px";
    docColorDiv.style.width = "100%";
    docColorDiv.style.height = screen.availHeight+"px";
  }
  return pan;
}
function PositionSocle(iddiv,action,couche){
	if(isNaN(action)){
		action=1;
	}
	if(!couche){ couche=""; }
	if(couche!="" && couche.substr(couche.length-1,1)!='.'){ couche=couche+"."; }
	if(!document.getElementById('iframe_div')){
		ajouterElementDocument('iframe','iframe_div');
	}
	eval("socle="+couche+"document.getElementById('iframe_div')"); // ce socle permet de cacher le select sous le div
	eval("pan="+couche+"document.getElementById('"+iddiv+"')");
	if(socle){
		$(socle).css("position","absolute");
		$(socle).css("z-index",$(pan).css("z-index")-1);
		socle.style.display="none";
		socle.className="opacity0";
		socle.style.border="0px";
		if(action==1){
			//on test si un parent (div) n'est pas deja positionné
			var parentTest;
			var xDepart;
			var yDepart;
			var x;
			var y;
			//si le panneau est diplay:none -> on l'affiche
			if($(pan).css("display")=="none"){ $(pan).css("display",""); }
			parentTest=pan;
			xDepart=0;
			yDepart=0;
			if(pan.style && pan.style.position!="" && trim(pan.style.left)==""){
				xDepart+=pan.offsetLeft;
				yDepart+=pan.offsetTop;
			}
			while(parentTest.parentNode){
				if(parentTest.parentNode.style){
					if(parentTest.parentNode.style.position!=""){
						xDepart+=parentTest.parentNode.offsetLeft;
						yDepart+=parentTest.parentNode.offsetTop;
					}
				}
				parentTest=parentTest.parentNode;
			}
			x=(pan.style.left.replace("px","")*1)+xDepart;
			y=(pan.style.top.replace("px","")*1)+yDepart;
			socle.style.display='';
			socle.style.top=y+"px";
			socle.style.left=x+"px";
			socle.style.width=pan.offsetWidth+"px";
			socle.style.height=pan.offsetHeight+"px";
      socle.style.border='1px solid red';
		}
		else{
			socle.style.top="0px";
			socle.style.left="0px";
			socle.style.width="0px";
			socle.style.height="0px";
			socle.style.display="none";
		}
	}
}
function position(e){
	var DocRef;    // Variable pour IE uniquement
	var mouse;
	// L'évènement est passée à la fonction
	// donc tous sauf IE
	mouse=new Array;
	var Mouse_X = 0;
	var Mouse_Y = 0;
	if(typeof(e)!=='undefinded' && e!=null){
		if(e.pageX){                     // Dans ce cas on obtient directement la position dans la page
	    	Mouse_X = e.pageX;
	    	Mouse_Y = e.pageY;
	  	}
	 	else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
	    	Mouse_X = e.clientX;
	    	Mouse_Y = e.clientY;
			//-- Il faut traiter le CAS des DOCTYPE sous IE
			if(document.documentElement && document.documentElement.clientWidth){ // Donc DOCTYPE
				DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est référence
			}
			else{
				DocRef = document.body;                    // Dans ce cas c'est body qui est référence
			}
			//-- On rajoute la position liée aux ScrollBars
			Mouse_X += DocRef.scrollLeft;
			Mouse_Y += DocRef.scrollTop;
		}
	}
	mouse["x"]=Mouse_X;
	mouse["y"]=Mouse_Y;
	return mouse;
}

//function d'ajout d'un  element pour le document
function ajouterElementDocument(type,iddiv,couche){
  if(!couche) couche = document.getElementsByTagName("body")[0];
	var elem = document.createElement(type);
  if(type=='iframe') elem.src = 'javascript:false;';
  $(couche).append(elem);
	$(elem).attr('id',iddiv);
	return elem;
}

//function d'extraction de la querystring depuis un formulaire
function getQueryStringForm(nomForm){
	var strParams = "";
	var formulaire = null;
	var toQuery = true;
	if(document.forms[nomForm]) formulaire = document.forms[nomForm];
	if(formulaire!=null){
		var inputs = new Array();
		var str = "";
		for(i=0; i<formulaire.elements.length; i++){ 
			str="";
			toQuery = true;
			switch(formulaire.elements[i].type){
				case "text":
				case "textarea":
				case "hidden":
					str = formulaire.elements[i].value;
					str = encodeURIComponent(str);
					break;
				case "checkbox":
				case "radio":
					if(formulaire.elements[i].checked) str = formulaire.elements[i].value;
					if(trim(str)=="") toQuery=false;
					break;
				case "select-one":
					//str = formulaire.elements[i].options[formulaire.elements[i].selectedIndex].text;
					str = formulaire.elements[i].value;
					break;
				case "password":
					str = formulaire.elements[i].value;
					if(typeof(hex_md5)=="function") str=hex_md5(str);
					str = encodeURIComponent(str);
					break;
			}
			//alert(formulaire.elements[i].name+"="+formulaire.elements[i].type)
			if(toQuery) strParams += "&"+formulaire.elements[i].name+"="+str;
		}
	}
	strParams = trim(strParams,"&");
	return strParams;
}

//function permettant de changer le disable d'un formulaire
function enableForm(nomForm){
	disableForm(nomForm,false);
}
function disableForm(nomForm,disableValue){
	if(typeof(disableValue)=="undefined") disableValue = true;
	var formulaire = null;
	if(document.forms[nomForm]) formulaire = document.forms[nomForm];
	var tabTypes = new Array("input","select","textarea");
	if(formulaire!=null){
		var inputs = new Array();
		for(var j=0; j<tabTypes.length; j++){
			inputs=formulaire.getElementsByTagName(tabTypes[j]);
			for (var i=0; i<inputs.length; i++){
				inputs[i].disabled = disableValue;
			}
		}
	}
}

//functions d'ouverture d'un div lors d'un traitement ajax
function ouvrirDivTraitementAjax(message){
  if($('#divTraitementAjax').length == 0){
    $('body').eq(0).append('<div id="divTraitementAjax" style="position:relative;display:none">'+message+'<br><img src="/images/ajax/indicator_web20_working.gif" style="position:absolute;bottom:20%;left:185px"></div>');
    var hauteur = '250px';
    var largeur = '416px';
    $('#divTraitementAjax').css('background-image','url(/images/store/panier/fenetre_modif.gif)');
    $('#divTraitementAjax').css('background-position','0px -35px');
    $('#divTraitementAjax').css('text-align','center');
    $('#divTraitementAjax').css('height',hauteur);
    $('#divTraitementAjax').css('line-height',hauteur);
    $('#divTraitementAjax').css('font-weight','bold');
    $('#divTraitementAjax').css('color','#333333');
    $('#divTraitementAjax').css('width',largeur);
  }
  ouvrir_div('divTraitementAjax', null, 1, 0, 0, null, 'L0', true, '#000000', false);
}
function fermerDivTraitementAjax(){
  fermer_div('divTraitementAjax');
}

//function a appeler lors d'un traitement ajax avec fenetre
function appelAjax(nomForm,message){
  if(arguments.length==1) message = 'Please wait...';
  ouvrirDivTraitementAjax(message);
  disableForm(nomForm);
}
function retourAjax(nomForm){
  enableForm(nomForm);
  fermerDivTraitementAjax();
}

//function str_replace
function str_replace(find,replace,subject){
  if(typeof(find)!=='string')   find=new String(find);
  if(typeof(replace)!=='string')replace=new String(replace);
  if(typeof(subject)!=='string')subject=new String(subject);
  var i=0;
  while(subject.indexOf(find,i)>=0){
    i=subject.indexOf(find,i)+replace.length;
    subject = subject.replace(find,replace);
  }
  return subject;
}

//function permettant de convertir une querystring en string pour posts de la function jquery .load()
function queryStringToPost(querystring){
  querystring = str_replace('?','',querystring);
  var tabElems = querystring.split('&');
  var posts = "";
  var elem = "";
  for(var i=0; i<tabElems.length; i++){
    elem = tabElems[i].split('=');
    if(trim(elem[1])=="" || isNaN(elem[1])) elem[1] = "'"+elem[1]+"'";
    posts += ","+elem[0]+":"+elem[1];
  }
  posts = posts.substring(1);
  posts = "{"+posts+"}";
  return posts;
}

// function rmplacant les retour a la ligne php en retours js
String.prototype.br2nl =
function() {
  return this.replace(/<br\s*\/?>/mg,"\n");
};

//function retournant le floatVal d'une variable
function floatval(mixed_var){
  return (parseFloat(mixed_var) || 0);
}

/* 16/03/2011 Code JS statique en provenance du fichier haut.tpl */

/*
jQuery drop down plugin
Copyright (C) 2009 Schwartz Pierre
*/
(function($) {
    //Définition du plugin de liste déroulante (sélection langues)
    $.fn.imgDropDown = function(options) {

        // définition des paramètres par défaut
        var defaults = {
            imgSelected: "",
            title: "",
            selectEvent: null
        };
        // mélange des paramètres fournis et des paramètres par défaut
        var opts = $.extend(defaults, options);

        // création d'une liste
        function createList(f){
            // créer la première zone, affichant l'option sélectionnée

            var cell = $('<div class="dropdownCell">'+ /* <!-- */ '<img style="float:left;" src="'+opts.imgSelected+'" />'+ /* --> */ '<span class="flecheLangue"></span></div>');

            // créer la seconde zone, affichant toutes les options
            var dropdown = $('<div class="dropdownPanel"></div>');

            $(this).find("li").each(function(){
                dropdown.append($('<div class="dropdownOpt"></div>')
                    .attr("value", $(this).attr("value"))
                    .append($(this).html())
                    .hover(function(){$(this).addClass("dropdownOptSelected");},
                           function(){$(this).removeClass("dropdownOptSelected");})
                );
            });

            // on masque la zone déroulante
            dropdown.css('display', 'none');
            $.data(cell, "visible", false);

            // on remplace la balise ul par notre liste personnalisée
            $(this).after(dropdown);
            $(this).after(cell);
            $(this).remove();

            // on positionne l'évènement de déroulage de la liste
            cell.click(function(){
                // si la liste est déroulée
                if ($.data(cell, "visible")){
                    dropdown.slideUp("fast");
                    $.data(cell, "visible", false);
                }else{
                    dropdown.slideDown("fast");
                    $.data(cell, "visible", true);
                }
            });

            // fonction appelée à chaque sélection d'un élément
            function onSelect(){
                cell.html($(this).html());
                cell.attr("value", $(this).attr("value"));
                dropdown.slideUp("fast");

                $.data(cell, "visible", false);

                // appel d'une fonction personnalisée
                if (opts.selectEvent)
                    opts.selectEvent($(this));
            }
        }

        // création d'une liste déroulante personnalisée pour tous les éléments de l'objet jQuery
        $(this).each(createList);

        // interface fluide
        return $(this);
    };
})(jQuery);


function masquer_select(){
    $('#P1Menu>.catego_content').hide();
    if (jQuery.browser.msie){
    	//$("select").css("visibility","hidden");
    }
}

function afficher_select(){
    $('#P1Menu>.catego_content').hide();
     if (jQuery.browser.msie){
    	//$("select").css("visibility","visible");
    }
}

var effect={
tempo:false,
setX:function (element){
  var x=$(element).offset();
  effect.left=x.left;
  return Math.abs(x.left)+"px";
},

setWidth:function(element){
   var maxRight=$(element).offset();
   maxRight=(maxRight.left-effect.left);
   maxRight =maxRight>=200?maxRight:500;//bug opera
   return maxRight+"px";
},
setHeight:function(element){
  var maxHeight=$(element).height();
  return  maxHeight;
},

setTempo:function (){
    window.clearTimeout(effect.tempoactif);
    effect.tempo=false;
    effect.tempoactif=window.setTimeout('effect.masquerEnfant()',100);
},

afficherEnfant:function (element){
    if (jQuery.browser.msie){
        if(parseInt(jQuery.browser.version) <= 6) {
            return false;
        }

    }
	$("#P1Menu>.currentTemp").removeClass("currentTemp");
    if ($(element).hasClass("current")==false){
        $(element).addClass("currentTemp");
    }
    this.catego="#catego_"+parseInt($(element).attr("id"));
	var widthContenu=parseInt($(this.catego +" div:first").css("width"));
	effect.tempo=true;
    window.clearTimeout(effect.tempoactif);
    if (!isNaN(widthContenu)){
          //	$(this.catego+" div:first").css("width",effect.setWidth($("#1_tetiere")));
			//$(this.catego).css("left","0px");
			$(this.catego).show("",masquer_select());
	}else{
        window.clearTimeout(effect.tempoactif);
        afficher_select();
       }
    },

masquerEnfant:function (){
    if (effect.tempo==false){
         afficher_select();
         $("#P1Menu>.currentTemp").removeClass("currentTemp");
       }
    }
}



/* 16/03/2011 FIN Code JS statique en provenance du fichier haut.tpl */


