﻿function gettableheight(idtabgen, idtablecont, idtd) {
    
    var h = window.document.getElementById(idtabgen).clientHeight;
    var h2 = window.document.getElementById(idtablecont).clientHeight;
    window.document.getElementById(idtabgen).style.height =
        window.document.getElementById(idtablecont).clientHeight;


    window.document.getElementById(idtd).style.height =
        h2 - h + 1;

}
        function MM_openBrWindow(theURL, winName, features) { 
        window.open(theURL, winName, features);
        }
        function openNewWindow(URLtoOpen, windowName, windowFeatures) {
        newWindow = window.open(URLtoOpen, windowName, windowFeatures);
        }
        function SetFocusElement(elementname) {
            
        if($get(elementname) != null)
            $get(elementname).focus();
    }
    
    var divgloballink;
    function MiseEnFormeLinking(linkingPageProduit,IDLinkGlobal) {
        
        var widthmax;
        var widthmaxNOTProduit = "600px";
        var widthmaxProduit="1002px";
        divgloballink = IDLinkGlobal;
        

        $get("divlinkInterneConteneur").style.height = $get("divLinkingInterne").offsetHeight == 0 ? 0 : $get("divLinkingInterne").offsetHeight - 5 + 'px';
        
        if (linkingPageProduit != null && linkingPageProduit == true) 
        {
            //$get("divlinkInterneHeader").style.width = $get("divlinkInterneConteneur").offsetWidth;
            $get("divlinkInterneConteneur").style.left = (1002 - $get("divlinkInterneConteneur").offsetWidth) / 2 + 'px';
            widthmax = widthmaxProduit;
            //$get("divlinkInterneHeader").style.left = $get("divlinkInterneConteneur").style.left;
        }
        else {
           
            widthmax = widthmaxNOTProduit;
            $get("divlinkInterneHeader").style.visibility = "hidden";
            $get("divlinkInterneConteneur").style.height = ($get("divlinkInterneConteneur").offsetHeight - $get("divlinkInterneHeader").offsetHeight ) + 'px';
            $get("divlinkInterneHeader").style.height = "0px";            
        }
        
        $get(IDLinkGlobal).style.maxWidth = widthmax;
        $get("divLinkingInterne").style.maxWidth = widthmax;
        $get("divlinkInterneConteneur").style.maxWidth = widthmax;

        $get(IDLinkGlobal).style.height = $get("divLinkingInterne").offsetHeight + ($get("divLinkingInterne").offsetHeight == 0 ? 0 : 5) + 'px';
        
        if ($get("ulglobal") == null) return;
        $get("ulglobal").style.height = $get("divlinkInterneConteneur").offsetHeight  + 'px';
        $get("ulglobal").style.maxWidth = widthmax;
        $get("divlinkInterneConteneur").style.visibility = "hidden";



    }


    function AffDesAffDIV(divid) {

        if ($get(divid).style.display == "none") {

            $get(divid).style.display = "inline-block";
            
        }
        else {
            $get(divid).style.display = "none";
            
        }


    }
        
        function AffDesAff(divid, forcevis) {

            if (($get(divid).style.visibility == "hidden" && forcevis == null) || forcevis) {
               
                $get(divid).style.visibility = "visible";
                $get(divgloballink).style.height = ($get("divlinkInterneConteneur").offsetHeight + $get("divlinkInterneHeader").offsetHeight + 14) + 'px';


                $get("divLinkingInterne").style.height = ($get("divlinkInterneConteneur").offsetHeight + $get("divlinkInterneHeader").offsetHeight) + 'px';
                
            }
            else {
                $get(divid).style.visibility = "hidden";
                $get(divgloballink).style.height = $get("divlinkInterneHeader").offsetHeight+14  + 'px';
                $get("divLinkingInterne").style.height = $get("divlinkInterneHeader").offsetHeight + 'px';

            }
            
            
        }
        var ObjSpan;
        var timeoutSousmenu;
        var idsousmenucurr;
        function HideSousMenuGP(idsousmenuGp) {
            //alert(idsousmenuGp);
            
            timeoutSousmenu=setTimeout(function() { HideSousMenuGPtimeout(idsousmenuGp) }, 1000);
            //jQuery('#' + idsousmenuGp).animate({  opacity: 0 }, 500);
        }

        function HideSousMenuGPtimeout(idsousmenuGp) {
            jQuery('#' + idsousmenuGp).hide().animate({ opacity: 1 }, 250);
            idsousmenucurr = "";
            
        }

        function ContinueShowSousMenuGP(idsousmenuGp) {
            clearTimeout(timeoutSousmenu);
        
        }


        function ShowSousMenuGP(idsousmenuGp, idmenuGp) {
            return;
        
        
            try {

                if (idsousmenucurr != "" && idsousmenuGp != idsousmenucurr) {
                clearTimeout(timeoutSousmenu);
                HideSousMenuGPtimeout(idsousmenucurr);
            }
            if (idsousmenuGp == idsousmenucurr) { clearTimeout(timeoutSousmenu);  return; }
            var menugpcurr = $get(idmenuGp);
            var sousmenugpcurr = $get(idsousmenuGp);

            var positionmenu = jQuery('#' + idmenuGp).position();
            
            sousmenugpcurr.style.position = 'absolute';
            var leftsousmenu = 0;
            if (positionmenu.left != null) leftsousmenu = positionmenu.left;
            if (jQuery('#' + idmenuGp).width() > jQuery('#' + idsousmenuGp).width()) sousmenugpcurr.style.width = jQuery('#' + idmenuGp).width();
            sousmenugpcurr.style.left = leftsousmenu+ 'px';
            sousmenugpcurr.style.top = '12px';
            sousmenugpcurr.style.display = 'block';
            sousmenugpcurr.style.opacity = '0';
            sousmenugpcurr.style.filter = 'alpha(opacity=0)';
            //sousmenugpcurr.style.height = '0px';
            
            idsousmenucurr = idsousmenuGp;
            jQuery('#' + sousmenugpcurr.id).show().animate({ height: jQuery('#' + idsousmenuGp).height(), opacity: 1 }, 250);
            $('#' + sousmenugpcurr.id ).mouseout(function() {
            //HideSousMenuGP(sousmenugpcurr.id);
        });

        $('#' + sousmenugpcurr.id + ' ul li').mouseover(function() {
        ShowSousMenuGP(idsousmenuGp, idmenuGp);
        });
            /*obj.style.left = 0;
            obj.style.opacity = '0';
            obj.style.width = widthspan + 'px';
            obj.style.opacity = '0';
            obj.style.filter = 'alpha(opacity=0)';
            jQuery('#' + obj.id).animate({ top: leftspan, height: widthspan, opacity: 1 }, 250);*/
        }
        catch(err){}
            
        }
        
        function showSpan(obj, leftspan, widthspan) {
            
            
            obj.style.left = 0;
            obj.style.opacity = '0';
            obj.style.width = widthspan+'px';
            obj.style.opacity = '0';
            obj.style.filter = 'alpha(opacity=0)';
            
            
            jQuery('#' + obj.id).animate({ left: leftspan, width: widthspan, opacity: 1}, 250);
       
        }
        function hideSpan(obj) {
       
            jQuery('#' + obj.id).animate({ left: 0, opacity: 0}, 500);
            
            
        }
       
        function showLiCatalogues(obj, OLDleftspan, OLDtopspan, leftspan, widthspan, topspan) {
            
            var ObjLI;
            
            obj.style.left = OLDleftspan+'px';
            obj.style.top = OLDtopspan + 'px';
            obj.style.width = 20+'px';
            obj.style.height = 20 + 'px';
            obj.style.display = 'block';
            obj.style.opacity = '0';
            
            obj.style.filter = 'alpha(opacity=0)';

            
           

            ObjLI = new Fx.Morph(obj, { duration: 500, link: 'cancel' }).start({ 'opacity': 1, 'left': leftspan + 'px', 'width': widthspan + 'px', 'height': 156 + 'px', 'top': topspan + 'px' });

        }
        function showReserveAuxPros(obj,imgcur, widthold, heightold, leftspan, topspan) {

            var ObjLI;
            imgcur.width = widthold+200;
            imgcur.height = widthold+200;
            
            
            obj.style.display = 'block';
            imgcur.style.opacity = '0';
            imgcur.style.filter = 'alpha(opacity=1)';
            //obj.style.opacity = '0';

            //obj.style.filter = 'alpha(opacity=1)';



            ObjLI = new Fx.Morph(imgcur, { duration: 500, link: 'cancel' }).start({ 'opacity': 1, 'width': widthold + 'px', 'height': heightold + 'px'});
            //ObjLI = new Fx.Morph(obj, { duration: 500, link: 'cancel' }).start({ 'opacity': 1, 'left': leftspan + 'px', 'width': widthold + 'px', 'height': heightold + 'px', 
            //'top': topspan + 'px' });

        }

        function showDivLinkGroupes(obj) {
            //obj.style.zindex=1;
            var ObjDIV;
            
            obj.style.display = 'block';
            obj.style.opacity = '0';
            obj.style.filter = 'alpha(opacity=0)';
            ObjDIV = new Fx.Morph(obj, { duration: 1000, link: 'cancel' }).start({ 'opacity': 1 });
            
        }



        function SetOpacity(elem, opacityAsInt) {
            var opacityAsDecimal = opacityAsInt;

            if (opacityAsInt > 100)
                opacityAsInt = opacityAsDecimal = 100;
            else if (opacityAsInt < 0)
                opacityAsInt = opacityAsDecimal = 0;

            opacityAsDecimal /= 100;
            if (opacityAsInt < 1)
                opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0


            elem.style.opacity = (opacityAsDecimal);
            elem.style.filter = "alpha(opacity=" + opacityAsInt + ")";
        }


        function set_opacity_100(id, timer, idTransformOnClearIntervall) {
            var op = 0;

            el = document.getElementById(id);
            el.style.display = 'block';
            if (el.style.opacity != null) {
                if (el.style.opacity != '') op = el.style.opacity;

            }

            op = parseFloat(op) + parseFloat(0.1);
            set_opacity(id, op * 100);
            if (op >= 1) {

                clearInterval(timer);
                el2 = document.getElementById(idTransformOnClearIntervall);
                if (el2 != null) {


                    //var h = 14;
                    var w = 130 + 'px';
                    
                    el2.style.display = 'block';
                    el2.style.width = 0+'px';
                    el2.style.height = 12+'px';
                    ObjSpan = new Fx.Morph(el2, { link: 'cancel' }).start({ 'width': w +'px'});
                }
                       
            }

        }
        function set_opacity(id, opacity) {
            el = document.getElementById(id);

            el.style["filter"] = "alpha(opacity=" + opacity + ")";
            el.style["-moz-opacity"] = opacity / 100;
            el.style["-khtml-opacity"] = opacity / 100;
            el.style["opacity"] = opacity / 100;
            el.style.opacity = opacity / 100;

            el.style.filter = 'alpha(opacity=' + opacity + ')';

            return true;
        }



        function rotateobj(obj) {
            var t = 0.13;
            if (t > 0.18)
                clearInterval(timer);
            t = t + 0.001;

            obj.style.filter = 'progid:DXImageTransform.Microsoft.Matrix(SizingMethod=\'auto expand\',' +
        'M11=0.9914448613738104, M12=+' + t + ', M21=-' + t + ', M22=0.9914448613738104)';

        }
