// SEO - suppression des frames incluant le site
if (parent.frames.length > 0)
{
	window.top.location.href = location.href;
}

    function getQueryVariableJci(variable) {
    	var find = false;
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      }
      
      if (find==false){
    	return "";
      }
    }


		function isEmail(str)
		{
		  // are regular expressions supported?
		  var supported = 0;
		  if (window.RegExp) 
		  {
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		  }
		  if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
			var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			var r2 = new
			RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			return (!r1.test(str) && r2.test(str));
		}
    
        function validation(form)
        {
            if (form.societe.value == "")
            {
                alert("Veuillez saisir le nom de votre société");
                form.societe.focus();
				return false;
            }
            if (form.metier.value == "-")
            {
                alert("Veuillez sélectionnner votre métier");
                form.metier.focus();
                return false;
            }
            if (form.activite.value == "-")
            {
                alert("Veuillez sélectionnner votre activité");
                form.activite.focus();
                return false;
            }
			if (form.civilite.value == "")
			{
				alert("Veuillez saisir votre civilité.")
				form.civilite.focus();
				return false;
			}
			if (form.nom.value == "")
			{
				alert("Veuillez saisir votre nom.")
				form.nom.focus();
				return false;
			}
			if (form.prenom.value == "")
			{
				alert("Veuillez saisir votre prénom.")
				form.prenom.focus();
				return false;
			}

			if (!isEmail(form.email.value))
		  	{
				alert("Veuillez saisir votre email.")
				form.email.focus();
				return false;
			}	
			
			return true;
		}

       function validation2(form)
        {
			if (form.civilite.value == "")
			{
				alert("Veuillez saisir votre civilité.")
				form.civilite.focus();
				return false;
			}
			if (form.nom.value == "")
			{
				alert("Veuillez saisir votre nom.")
				form.nom.focus();
				return false;
			}
			if (form.prenom.value == "")
			{
				alert("Veuillez saisir votre prénom.")
				form.prenom.focus();
				return false;
			}

			if (!isEmail(form.email.value))
		  	{
				alert("Veuillez saisir votre email.")
				form.email.focus();
				return false;
			}	
			if (form.adresse1.value == "")
			{
				alert("Veuillez saisir votre adresse 1.")
				form.adresse1.focus();
				return false;
			}
			if (form.cp.value == "")
			{
				alert("Veuillez saisir votre code postal.")
				form.cp.focus();
				return false;
			}
			if (form.ville.value == "")
			{
				alert("Veuillez saisir votre ville.")
				form.ville.focus();
				return false;
			}

			
			return true;
		}		
		
        function hasOptions(obj)
        {
	        if(obj!=null && obj.options!=null)
	        {
		        return true;
	        }
	        return false;
        }
    	
        function addOption(obj,text,value,selected)
        {
	        if(obj!=null && obj.options!=null)
	        {
		        obj.options[obj.options.length] = new Option(text, value, false, selected);
	        }
        }
		
        function removeAllOptions(from)
        {
	        if(!hasOptions(from))
	        {
		        return;
	        }
	        for(var i=(from.options.length-1);i>=0;i--)
	        {
		        from.options[i] = null;
	        }
	        from.selectedIndex = -1;
        }

		function majActivites(index)
		{
		    var myDest = document.getElementById("activites");
		    if (index != 0)
		    {
		        var myTab = eval("tab" + index);
		        removeAllOptions(myDest);
		        addOption(myDest,"-","-", true);
		        for (var i=0; i<myTab.length;i++)
		        {
		            addOption(myDest,myTab[i],myTab[i],false);
		        }
		    }
		    else
		    {
		        removeAllOptions(myDest);
		        addOption(myDest,"-","-", true);
		    }
		}

        //Administration
        var tab1 = new Array;
        tab1[0] = "Public";

        //Architecte
        var tab2 = new Array ();
        tab2[0] = "Constructeur";
        tab2[1] = "Généraliste";
        tab2[2] = "Intérieur";

        //Banque assurance
        var tab3 = new Array ();
        tab3[0] = "Service technique";

        //Bureau Etude
        var tab4 = new Array ();
        tab4[0] = "Acoustique";
        tab4[1] = "Electricité";
        tab4[2] = "Ingénierie";
        tab4[3] = "Thermique";

        //Constructeur
        var tab5 = new Array ();
        tab5[0] = "Maison individuelle";

        //Consultant
        var tab6 = new Array ();
        tab6[0] = "Consultant";

        //Distributeur
        var tab7 = new Array ();
        tab7[0] = "Alimentaire";
        tab7[1] = "Bricolage";
        tab7[2] = "Climatisation";
        tab7[3] = "Correspondance";
        tab7[4] = "Divers";
        tab7[5] = "Electricité";
        tab7[6] = "Entreprise générale";
        tab7[7] = "Généraliste";
        tab7[8] = "Matériaux";
        tab7[9] = "Plomberie";
        tab7[10] = "Quincaillerie détail";
        tab7[11] = "Quincaillerie gros";
        tab7[12] = "Sanitaire chauffage";
        tab7[13] = "Tôlier";

        //Economiste
        var tab8 = new Array ();
        tab8[0] = "Economiste";

        //Entreprise générale
        var tab9 = new Array ();
        tab9[0] = "Divers";

        //Fabricant
        var tab10 = new Array ();
        tab10[0] = "Acoustique";
        tab10[1] = "Climatisation";
        tab10[2] = "Divers";
        tab10[3] = "Menuiserie";
        tab10[4] = "Protection incendie";
        tab10[5] = "Sanitaire chauffage";

        //Fournisseur
        var tab11 = new Array ();
        tab11[0] = "Electricité";
        tab11[1] = "Gaz";

        //Incorporateur
        var tab12 = new Array ();
        tab12[0] = "Divers";

        //Installateur
        var tab13 = new Array ();
        tab13[0] = "Aéraulique";
        tab13[1] = "Climatisation";
        tab13[2] = "Divers";
        tab13[3] = "Electricité";
        tab13[4] = "Entreprise Générale";
        tab13[5] = "Généraliste";
        tab13[6] = "Maintenancier";
        tab13[7] = "Menuiserie";
        tab13[8] = "Pieuvriste";
        tab13[9] = "Plomberie";
        tab13[10] = "Poseur";
        tab13[11] = "Sanitaire chauffage";

        //Maître d'ouvrage
        var tab14 = new Array ();
        tab14[0] = "Communes";
        tab14[1] = "Conseil Général";
        tab14[2] = "Conseil Régional";
        tab14[3] = "Divers";
        tab14[4] = "Maître d'ouvrage privé";
        tab14[5] = "Maître d'ouvrage public (autres)";
        tab14[6] = "Maître d'ouvrage social";
        tab14[7] = "Service technique Hospitalier";

        //Organisme de controle
        var tab15 = new Array ();
        tab15[0] = "Organisme de controle";

        //Pompier
        var tab16 = new Array ();
        tab16[0] = "Public";

        //Service
        var tab17 = new Array ();
        tab17[0] = "Hôtellerie";

        //Syndics
        var tab18 = new Array ();
        tab18[0] = "Syndics";


		
function download(titre)
{
	tb_show("Demande de téléchargement", "../html/form_telechargement.asp?titre=" + encodeURIComponent(titre) + "&height=600&width=800",false);
}		
		
function dl(url, nom)
{
  	pageTracker._trackPageview("telechargements/" + nom);
    window.location.href = url;
}		
		
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

function displayProd(sListe)
{
	$("#liensProd").css("display", "none");
	$("#liensProd").html("");
	aList = sListe.split("/");
	myList = aList[aList.length - 1];
	aList = myList.split(",");
	var sHTML = "";
	var nbLiens = 0;
	
	for (i=0; i<aList.length; i++)
	{
		var sLien = "";
		sItem = aList[i];
		sId = Right(sItem, sItem.length-2);
		
		$.ajax({
			type: "post",
			url: "../html/getLienProd.asp",
			data: "type=" + Left(sItem, 1) + "&id=" + sId + "&result=link",
			error: function(msg)
			{
				//alert(msg.responseText);
				return false;
			},
			success: function(msg)
			{
				sHTML += "<div class=\"lienProd\"><div class=\"lienProdContenu\">" + msg + "</div></div>";
				$("#liensProd").html(sHTML);
			}
		});
		
		if (i==0) 
		{
			sHTML = "<div class=\"menuDeroulantHaut\"></div>" + sHTML;
			$("#liensProd").html(sHTML);
		}
	}
	if (i==0) 
	{
		sHTML += "<div class=\"menuDeroulantBas\"></div>";
		$("#liensProd").html(sHTML);
	}
	
	nbLiens = aList.length;
	
	if (nbLiens == 0)
	{
		//alert("pas de lien");
	}

	if (nbLiens == 1)
	{
		// on recupere juste l'url pour redirection
		$.ajax({
			type: "post",
			url: "../html/getLienProd.asp",
			data: "type=" + Left(sItem, 1) + "&id=" + sId + "&result=url",
			error: function(msg)
			{
				//alert(msg.responseText);
				return false;
			},
			success: function(msg)
			{
				window.location.href = msg;
			}
		});
	}
	
	if (nbLiens > 1)
	{
	
		jQuery.fn.extend({
		   findPos : function() {
		       obj = jQuery(this).get(0);
		       var curleft = obj.offsetLeft || 0;
		       var curtop = obj.offsetTop || 0;
		       while (obj = obj.offsetParent) {
		                curleft += obj.offsetLeft
		                curtop += obj.offsetTop
		       }
		       return {x:curleft,y:curtop};
		   }
		});
		pos = $("#contenu").findPos();
		posX = posX - pos.x + 250;
		
		
		$("#liensProd").css("left", posX + "px");
		$("#liensProd").css("top", posY + "px");
		$("#liensProd").css("z-index", "200");
		sHtml = $("#liensProd").html();
		sHtml = "" + sHtml + "<div class=\"menuDeroulantBas\">&nbsp;</div>";
		$("#liensProd").html(sHtml);
		$("#liensProd").css("display", "block");
	
	}
	
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
	
function loadOngletSysteme(num)
{
	var numEq = (num - 1);
	$(".ongletSystemeContenu").css("display", "none");
	$(".ongletSystemeContenu2").css("display", "none");
	$("#onglet" + num).css("display", "block");
	$("#liensProd").css("display", "none");
	
	$("#onglet1btn").css("background-image", "url(../images/ongsys1.jpg)");
	$("#onglet2btn").css("background-image", "url(../images/ongsys2.jpg)");
	$("#onglet3btn").css("background-image", "url(../images/ongsys3.jpg)");
	
	$("#onglet" + num + "btn").css("background-image", "url(../images/ongsys" + num + "-over.jpg)");
}

function loadContact()
{
	var url = $("#select-contact").val();
	if (url != "")
	{
		window.location.href = "aldes-contact-" + url + ".htm";
	}
}

function favoris() 
{
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    { 
        window.sidebar.addPanel("Aldes - Espace professionnels","http://www.aldes.fr",""); 
    }
    else 
    { 
        window.external.AddFavorite("http://www.aldes.fr","Aldes - Espace professionnels"); 
    } 
}

/*
function initMenu(idLi)
{
    $(".niveau3").css("display", "none");
    $("#" + idLi).parent("ul").css("display", "block");
	$("#" + idLi).children("a").css("color", "#bdd72f");
	$("#" + idLi).children("a").css("font-weight", "bold");
	$("#" + idLi).children("ul").css("display", "block");
    
	$("#" + idLi).parent("ul").parent("li").parent("ul").css("display", "block");
    $("#" + idLi).parent("ul").parent("li").children("a").css("color", "#022D80");
	$("#" + idLi).parent("ul").parent("li").children("a").css("font-weight", "bold");
	
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").css("display", "block");
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("a").css("color", "#022D80");
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("a").css("font-weight", "bold");
		
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").parent("ul").css("display", "block");
    $("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").children("a").css("color", "#022D80");
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").children("a").css("font-weight", "bold");
	
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").parent("ul").css("display", "block");
    $("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").children("a").css("color", "#022D80");
	$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").children("a").css("font-weight", "bold");
    
    //$('#paneMenuGauche').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
}
*/

function initMenu(idLi)
{
	// on allume le menu du haut
	var texte = $("span.rubrique").html();
	texte = texte.replace("<BR>", "");
	texte = texte.replace("<br>", "");
	
	$("#menu li a").each(function(i){
		if ($(this).html() == texte) 
		{
			$(this).css("background-color", "#bdd72f");
			$(this).css("color", "#213e99");
		}
	});


	// on allume le menu de gauche
	var typeTab = $(".niveau2").attr("id");
	var sNiveau = $("#" + idLi).parent("ul").attr("class");

	if (typeTab != "tabdoc")$(".niveau3").css("display", "none");
	
	if (sNiveau == "niveau2")
	{
		// on allume le niveau 2
		$("#" + idLi).css("background-color", "#cbd1e8");
		$("#" + idLi).css("background-image", "url(../images/puce-menu-2.png)");
		$("#" + idLi).css("font-weight", "bold");
		$("#" + idLi).children("ul").css("display", "block");
		$("#" + idLi).children("ul").css("font-weight", "normal");
	}
	
	if (sNiveau == "niveau3")
	{
		// on allume le niveau 2
		$("#" + idLi).parent("ul").parent("li").css("background-color", "#cbd1e8");
		$("#" + idLi).parent("ul").parent("li").css("background-image", "url(../images/puce-menu-2.png)");
		$("#" + idLi).parent("ul").parent("li").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").children("ul").css("font-weight", "normal");
		
		// on affiche le niveau3
		$("#" + idLi).parent("ul").css("display", "block");
		
		$("#" + idLi).children("a").css("font-weight", "bold");
		$("#" + idLi).children("a").css("color", "#b7d226");
		$("#" + idLi).children("ul").css("display", "block");
		
	}
	
	if (sNiveau == "niveau4")
	{
		// on allume le niveau 2
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").css("background-color", "#cbd1e8");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").css("background-image", "url(../images/puce-menu-2.png)");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("ul").css("font-weight", "normal");
		
		// on affiche le niveau3
		$("#" + idLi).parent("ul").parent("li").parent("ul").css("display", "block");
		
		$("#" + idLi).parent("ul").parent("li").children("a").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").children("a").css("color", "#b7d226");
		$("#" + idLi).parent("ul").parent("li").children("ul").css("display", "block");

		$("#" + idLi).children("a").css("font-weight", "bold");
		$("#" + idLi).children("a").css("color", "#b7d226");
		$("#" + idLi).children("ul").css("display", "block");

	}
	
	if (sNiveau == "niveau5")
	{
		// on allume le niveau 2
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").css("background-color", "#cbd1e8");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").css("background-image", "url(../images/puce-menu-2.png)");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").parent("li").children("ul").css("font-weight", "normal");
		
		// on affiche le niveau3
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").parent("ul").css("display", "block");
		
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("a").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("a").css("color", "#b7d226");
		$("#" + idLi).parent("ul").parent("li").parent("ul").parent("li").children("ul").css("display", "block");

		// on affiche le niveau4
		$("#" + idLi).parent("ul").parent("li").parent("ul").css("display", "block");
		
		$("#" + idLi).parent("ul").parent("li").children("a").css("font-weight", "bold");
		$("#" + idLi).parent("ul").parent("li").children("a").css("color", "#b7d226");
		$("#" + idLi).parent("ul").parent("li").children("ul").css("display", "block");


		$("#" + idLi).children("a").css("font-weight", "bold");
		$("#" + idLi).children("a").css("color", "#b7d226");
		$("#" + idLi).children("ul").css("display", "block");

	}	
	
	if($.browser.msie){
		if(parseInt($.browser.version) == 7) {					
			$("#menuGauche").css("border-bottom-width", "2px");
		}
	}	
	
}



//identification espace prive
function logged()
{
    //deja loggué ?
    $.ajax({
        type: "post",
        url: "logged.asp",
        data: "",
        error: function(msg)
        {
            return false;
        },
        success: function(msg)
        {
			     if (msg != "ok")
           {
  				 $("#infoprive").css("display", "none");
  				 $("#login").html("ESPACE PRIVE");
  				 $("#login").unbind();
  				 $("#login").click(function(){ 
  					 login();
  				  });
           }
           else
           {
				    $("#login").html("ESPACE PRIVE");
				    $("#infoprive").css("display", "block");
           }
        }
    });
}

function submitForm(idform)
{
	$("#" + idform).submit();
}

function login()
{
	 $("#loginForm").css("display", "block");
}

function cacheLogin()
{
	$("#loginForm").css("display", "none");
}

function importWindevis()
{
	tb_show("","../html/upload.htm?height=480&width=640",false);
}

function login2()
{
    $.ajax({
        type: "post",
        url: "login.asp",
		    data: "login=" + encodeURIComponent($("#loginId").val()) + "&pw=" + encodeURIComponent($("#loginPw").val()),
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
    			if (msg != "ok")
    			{
    				//alert(msg);
    			}
    			else
    			{
    				$("#loginForm").css("display", "none");
    				logged();
    				panierListe();
    			  if(document.getElementById("fragment-5"))
            {
              initCAO();
            }
    			}
        }
    });
 }

function loginAccueil()
{
	
	$.ajax({
        type: "post",
        url: "login.asp",
		    data: "login=" + encodeURIComponent($("#login_accueil").val()) + "&pw=" + encodeURIComponent($("#password_accueil").val()),
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
			if (msg != "ok")
			{
				//alert(msg);
			}
			else
			{
				$("#loginForm").css("display", "none");
				logged();
				$("#ajoutSel").css("display", "block");
				$("#login_accueil").val("");
				$("#password_accueil").val("");
				
			}
        }
    });
 }
function logout()
{
    //deja loggué ?
    $.ajax({
        type: "post",
        url: "logout.asp",
        data: "",
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
			logged();
			$("#selection").css("display", "none");
			$("#ajoutSel").css("display", "none");
			
        }
    });
}

// recherche 'trouver en un click"

function trouver()
{
	var sKey = $("#trouverChp").val();

    //deja loggué ?
    $.ajax({
        type: "post",
        url: "search.asp",
		data: "key=" + encodeURIComponent(sKey),
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
			$("#resultats").html(msg);
			$("#contenu").css("display", "none");
			$("#divResultats").css("display", "block");
        }
    });	
}

function trouverAccueil()
{
	var sKey = $("#search_txt").val();

    //deja loggué ?
    $.ajax({
        type: "post",
        url: "search.asp",
		data: "key=" + encodeURIComponent(sKey),
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
			$("#result_accueil").html(msg);
			tb_show("ffffff","#TB_inline?height=600&width=800&inlineId=result_accueil",false);			
        }
    });	
}

function cacheResultats()
{
	$("#divResultats").css("display", "none");
	$("#contenu").css("display", "block");
}

function initCAO(idSatin)
{

    //deja loggué ?
    $.ajax({
        type: "post",
        url: "logged.asp",
        data:"",
        error: function(msg)
        {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg)
        {
			if (msg != "ok")
            {
      				//PAS LOGGUE
      				$("#fragment-5").html("Veuillez vous identifier pour accèder aux schemas CAO.");
      				login();
    				}
            else
            {
      				//LOGGUE
      				$("#fragment-5").html("Accès autorisé aux schemas CAO.<br /><br /><br /><center><img src='../images/loading.gif' />&nbsp;Chargement en cours</center>");
      				
      				// on va chercher les schemas CAO pour le doc
              $.ajax({
                  type: "get",
                  url: "docCAO.asp",
                  data: "idProduit=" + idSatin,
                  error: function(msg)
                  {
                      alert(msg.responseText);
                      return false;
                  },
                  success: function(msg)
                  {
                    $("#fragment-5").html(msg + "<br />-");
                    $("#fragment-5").show();
                    $(".tablesorter").tablesorter();
                  }
              });

            }
        }
    });
}

var displayDoc = "liste";
var typeDoc = "";
function getListeDoc(lbRubrique, rubrique, displayDoc) 
{
    if ($("#listeAffichages").val() != "") displayDoc = $("#listeAffichages").val();
	if ($("#filtre_type_doc").val() != "") typeDoc = $("#filtre_type_doc").val();
	$.ajax({
		type: "get",
		url: "documents.asp",
		//data: "lbRubrique=" + encodeURIComponent(lbRubrique) + "&rubrique=" + encodeURIComponent(rubrique) + "&display=" + encodeURIComponent(displayDoc) + "&typeDoc=" + encodeURIComponent(typeDoc),
		data: "lbRubrique=" + encodeURIComponent(lbRubrique) + "&rubrique=" + encodeURIComponent(rubrique) + "&display=" + encodeURIComponent(displayDoc) + "&typeDoc=" + encodeURIComponent(typeDoc),
		error: function(msg)
		{
			//alert(msg.responseText);
			return false;
		},
		success: function(msg)
		{
			$("#rubriquesDoc").html(msg);
			$(".tablesorter").ready(function() {
				$(".tablesorter").tablesorter();
			});
			$("#savLbRubrique").val(lbRubrique);
			$("#savRubrique").val(rubrique);
			if (displayDoc == "liste") $("#listeAffichages").attr("selectedIndex", 0);
			if (displayDoc == "vignettes") $("#listeAffichages").attr("selectedIndex", 1);
			document.getElementById('txt_recherche_doc').value = "";
		}
	});
}

function getRechercheListeDocProd(sSql) 
{
	if ($("#listeAffichages").val() != "") displayDoc = $("#listeAffichages").val();
	$.ajax({
		type: "post",
		url: "documentsProd.asp",
		data: "sql=" + encodeURIComponent(sSql) + "&display=" + encodeURIComponent(displayDoc),
		error: function(msg) {
			alert(msg.responseText);
			return false;
		},
		success: function(msg) {
			//alert(msg);
			$("#rubriquesDoc").html(msg);
			$(".tablesorter").ready(function() {
				$(".tablesorter").tablesorter();
			});
			if (displayDoc == "liste") $("#listeAffichages").attr("selectedIndex", 0);
			if (displayDoc == "vignettes") $("#listeAffichages").attr("selectedIndex", 1);
		}
	});
}

function getRechercheListeDoc() 
{
	var texte = $("#txt_recherche_doc").val();
    if ($("#listeAffichages").val() != "") displayDoc = $("#listeAffichages").val();
	if ($("#filtre_type_doc").val() != "") typeDoc = $("#filtre_type_doc").val();

	lbRubrique = $("#savLbRubrique").val();
	rubrique = $("#savRubrique").val();	

	$.ajax({
		type: "get",
		url: "documents.asp",
		data: "lbRubrique=" + encodeURIComponent(lbRubrique) + "&rubrique=" + encodeURIComponent(rubrique) + "&texte=" + encodeURIComponent(texte) + "&display=" + encodeURIComponent(displayDoc) + "&typeDoc=" + encodeURIComponent(typeDoc),
		error: function(msg) {
			//alert(msg.responseText);
			return false;
		},
		success: function(msg) {
			$("#rubriquesDoc").html(msg);
			$(".tablesorter").ready(function() {
				$(".tablesorter").tablesorter();
			});
			if (displayDoc == "liste") $("#listeAffichages").attr("selectedIndex", 0);
			if (displayDoc == "vignettes") $("#listeAffichages").attr("selectedIndex", 1);
		}
	});
}

function changeVue(nouvelleVue) 
{
    getListeDoc($("#savLbRubrique").val(), $("#savRubrique").val(), nouvelleVue);
    displayDoc = nouvelleVue;
}

function changeGallerie(source) 
{
    var idSource = source.id;
    initMenu(idSource);
    var idParent = source.parentNode.parentNode.id;
    $.ajax({
        type: "get",
        url: "../xml/" + idSource + ".htm",
        error: function(msg) {
            //alert(msg.responseText);
            return false;
        },
        success: function(msg) {
            if (idParent == "myImageFlow") {
                idDest = "myImageFlow3";
            }
            if (idParent == "myImageFlow3") {
                idDest = "myImageFlow4";
            }
            if (idParent == "myImageFlow4") {
                idDest = "myImageFlow5";
            }
            if (idParent == "myImageFlow5") {
                idDest = "myImageFlow6";
            }

            if (msg.length != 0) {
                $("#" + idDest).html(msg);
                setTimeout("", 500);

                if (idParent == "myImageFlow") {
                    $("#myImageFlow3").css("display", "block");
                    $("#myImageFlow4").html("");
                    $("#myImageFlow4").css("display", "none");
                    $("#myImageFlow5").html("");
                    $("#myImageFlow5").css("display", "none");
                    $("#myImageFlow6").html("");
                    $("#myImageFlow6").css("display", "none");

                }
                if (idParent == "myImageFlow3") {
                    $("#myImageFlow3").css("display", "block");
                    $("#myImageFlow4").css("display", "block");
                    $("#myImageFlow5").html("");
                    $("#myImageFlow5").css("display", "none");
                    $("#myImageFlow6").html("");
                    $("#myImageFlow6").css("display", "none");
                }
                if (idParent == "myImageFlow4") {
                    $("#myImageFlow3").css("display", "block");
                    $("#myImageFlow4").css("display", "block");
                    $("#myImageFlow5").css("display", "block");
                    $("#myImageFlow6").html("");
                    $("#myImageFlow6").css("display", "none");
                }
                if (idParent == "myImageFlow5") {
                    $("#myImageFlow3").css("display", "block");
                    $("#myImageFlow4").css("display", "block");
                    $("#myImageFlow5").css("display", "block");
                    $("#myImageFlow6").css("display", "block");
                }

                var newInstance = new ImageFlow();
                newInstance.init({ ImageFlowID: idDest });
                
            }
            else {
                $("#" + idDest).html("");
            }
        }
    });
}