﻿   var Win;
   
   function ShowAjouterProduitPopup(ctl) 
    { 
     var ProduitId = ctl;
     Win = window.open("Produit.aspx?p=" + ProduitId ,'AjoutWindow','height=300,width=300,toolbar=no,directories=no,status=no,limenubar=no,scrollbars=auto,resizable=no ,modal=yes,screenX=400,screenY=400,top=200,left=200,right=200');
       Win.resizeTo(500,600);
     Win.focus();
     return false;
  }     
  
   function ShowModifierProduitPopup(ctl) 
    { 
     var ProduitId = ctl;
     Win = window.open("../Admin/Modifier/ModProduit.aspx?p=" + ProduitId ,'ModifierWindow','height=600px,width=750px,toolbar=0,directories=0,status=0,limenubar=0,scrollbars=1,resizable=1,modal=1,screenX=400,screenY=400,top=200,left=200,right=200');
     Win.resizeTo(600,750);
     Win.focus();
     return false;
  }     
  
   
    
    function WindowClose(produitId)
    {
        //opener.location.reload();
        var url = opener.location;
        opener.location = "commander.aspx" + "#"+ produitId;
        window.close(); 
    }
    
     function WindowCloseAdmin(produitId)
    {
        //opener.location.reload();
        var url = opener.location;
        opener.location = "../Admin/ModifierProduit.aspx" + "#"+ produitId;
        window.close(); 
    }
    
    function DisableTextBox(formName,ddlId, tbxID)
    {
          
            var MonControlDdl = document.forms[formName].elements[ddlId];
            var MonControltbx = document.forms[formName].elements[tbxID];
        
        if (MonControlDdl.options[MonControlDdl.selectedIndex].value == 0)
            {
                MonControltbx.disabled=false;
            }
        else
            {
                MonControltbx.disabled=true;
            }    
    }

    function supprimer()
    {
    alert("Vous venez de supprimer le produit ou la catégorie que vous avez demandé!");
    }


function replaceString(sString, sReplaceThis, sWithThis) { 
    
    if (sReplaceThis != "" && sReplaceThis != sWithThis) {
      var counter = 0;
      var start = 0;
      var before = "";
      var after = "";
      while (counter<sString.length) {
        start = sString.indexOf(sReplaceThis, counter);
        if (start == -1){
         break;
         } else {
           before = sString.substr(0, start);
           after = sString.substr(start + sReplaceThis.length, sString.length);
           sString = before + sWithThis + after;
           counter = before.length + sWithThis.length;
          }
        }
      }
   return sString;
  }
  
  
  // JScript File

/*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:

*/
/**/
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if (version < 7)
{
if ((version >= 5.5)) //&& (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
}



   var Win;
   
   function ShowAjouterProduitPopup(ctl) 
    { 
     var ProduitId = ctl;
     Win = window.open("Produit.aspx?p=" + ProduitId ,'AjoutWindow','height=300,width=300,toolbar=no,directories=no,status=no,limenubar=no,scrollbars=auto,resizable=no ,modal=yes,screenX=400,screenY=400,top=200,left=200,right=200');
       Win.resizeTo(500,600);
     Win.focus();
     return false;
  }     
  
   function ShowModifierProduitPopup(ctl) 
    { 
     var ProduitId = ctl;
     Win = window.open("../Gestion/Modifier/ModProduit.aspx?p=" + ProduitId ,'ModifierWindow','height=600px,width=750px,toolbar=0,directories=0,status=0,limenubar=0,scrollbars=1,resizable=1,modal=1,screenX=400,screenY=400,top=200,left=200,right=200');
     Win.resizeTo(600,750);
     Win.focus();
     return false;
  }     
  
   
    
    function WindowClose(produitId,Div)
    {
        var divProduit = document.getElementById(Div);
        alert(divProduit);
        divProduit.style.display = "none";
       opener.location.reload();
        var url = opener.location;
       opener.location = "commander.aspx" + "#"+ produitId;
        window.close(); 
    }
    
     function WindowCloseAdmin(produitId)
    {
        //opener.location.reload();
        var url = opener.location;
        opener.location = "../Gestion/ModifierProduit.aspx" + "#"+ produitId;
        window.close(); 
    }
    
    function DisableTextBox(formName,ddlId, tbxID)
    {
          
            var MonControlDdl = document.forms[formName].elements[ddlId];
            var MonControltbx = document.forms[formName].elements[tbxID];
        
        if (MonControlDdl.options[MonControlDdl.selectedIndex].value == 0)
            {
                MonControltbx.disabled=false;
            }
        else
            {
                MonControltbx.disabled=true;
            }    
    }

    function supprimer()
    {
    alert("Vous venez de supprimer le produit ou la catégorie que vous avez demandé!");
    }


var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
var horizontaloffset=1 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+(horizontaloffset*2) //no space to the right of page? Move menu over to the left
}
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
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
edgeoffset=dropmenuobj.y
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
/******************************************************************/
function displayblock(element)
{
var d = document.getElementById('ULS' + element.id);
d.style.visibility = "visible";
d.className = 'block';
}
function hideblock(element)
{
var d = document.getElementById('ULS' + element.id);
d.style.visibility = "hidden";
d.className = 'none';
}

function SwapImage(Element,Image)
{
var d = document.getElementById(Element.id);
d.src = '/images/' + Image;
}


function showhide(targetID) {
//change target element mode
var elementmode = document.getElementById(targetID).style;
elementmode.display = (!elementmode.display) ? 'none' : '';
}

function changetext(changee,oldText,newText) {
//changes text in source element
var elementToChange = document.getElementById(changee);
//alert(elementToChange.innerHTML);
if (elementToChange.innerHTML == 'plus ...')
{elementToChange.innerHTML = 'moins ...';}
else
{elementToChange.innerHTML = 'plus ...';}
//alert('test');
//elementToChange.innerHTML = (elementToChange.innerHTML == oldText) ? newText : oldText;
}

function workforchange(targetID,sourceID,oldContent,newContent) {
showhide(targetID);
changetext(sourceID,oldContent,newContent);
}


/********************************************************************/