﻿// JScript File

    function showMenuFlyout(flyoutDivName, menuDiv,clickEvent) {
        doSection(flyoutDivName, clickEvent, findMyAbsoluteLeft(menuDiv) + 2, findMyAbsoluteBottom(menuDiv));
        document.getElementById(menuDiv.id).className = "MenuButtonMouseover";
        //menuDiv.className='MenuButtonMouseover';

        // Below is a hard-coded fix for Firefox zoomed in browsers. Make sure that non-active divs and buttons are reset propertly

//        var button_divs = [['functionalButton','functiondiv'], ['serviceButton','servicediv'], ['salesButton','saleslocations'], ['literatureButton','literaturediv'], ['softwareButton','softwarediv']];
//        for (var i = 0; i < button_divs.length; i++) {
//            if (flyoutDivName == button_divs[i, 1]) {
//                // do nothing
//            }
//            else {
//                document.getElementById(button_divs[i, 1]).style.display = "none";
//                document.getElementById(button_divs[i, 0]).className = "MenuButton";
//            }
        //        }

       


        var divs = ['functiondiv', 'servicediv', 'saleslocations', 'literaturediv', 'softwarediv'];
        for (var i = 0; i < divs.length; i++) {
            if (flyoutDivName == divs[i]) {
                // do nothing
            }
            else {
                document.getElementById(divs[i]).style.display = "none";
            }
        }


        //functionalButton,salesButton,serviceButton,literatureButton,softwareButton
//        var buttons = ['functionalButton', 'salesButton', 'serviceButton', 'literatureButton', 'softwareButton'];
//        for (var i = 0; i < buttons.length; i++) {
//            if (menuDiv.id == buttons[i]) {
//                  //set button to mouseover
//                //document.getElementById(menuDiv.id).className = "MenuButtonMouseover";
//            }
//            else {
//                document.getElementById(menuDiv.id).className = "MenuButton";
//            }
//        }

        
       
    }


    function hideMenuFlyout(flyoutDivName, buttonName, returnButtonToClassName, clickEvent) {

        //noSection(flyoutDivName, clickEvent);

        if (noSection(flyoutDivName, clickEvent) == true) {
            document.getElementById(buttonName).className = returnButtonToClassName;
        }

//        if (clickEvent.srcElement.id == flyoutDivName) {
//            document.getElementById(flyoutDivName).style.display = "none";
//            document.getElementById(buttonName).className = returnButtonToClassName;
        //        }


        
    }
     
    

    function findMyAbsoluteRight(thisElement) {

            var thisParent = thisElement.offsetParent;
            var absRight = thisElement.offsetLeft + thisElement.offsetWidth;

            while (thisParent.offsetLeft) {
                absRight = absRight + thisParent.offsetLeft;
                thisParent = thisParent.offsetParent;
            }

            return absRight;
        }

    function findMyAbsoluteLeft(thisElement) {
        
        var thisParent = thisElement.offsetParent;
        var absLeft = thisElement.offsetLeft;
        
        while (thisParent.offsetLeft) {
            absLeft = absLeft + thisParent.offsetLeft;
            thisParent = thisParent.offsetParent;
        }
        
        return absLeft;
        }
       

     function findMyAbsoluteBottom(thisElement) {

         var thisParent = thisElement.offsetParent;
         var absBottom = thisElement.offsetTop + thisElement.offsetHeight;

         while (thisParent.offsetTop) {
             absBottom = absBottom + thisParent.offsetTop;
             thisParent = thisParent.offsetParent;
         }

         return absBottom;
     }

     function findMyAbsoluteTop(thisElement) {

         var thisParent = thisElement.offsetParent;
         var absTop = thisElement.offsetTop;

         while (thisParent.offsetTop) {
             absTop = absTop + thisParent.offsetTop;
             thisParent = thisParent.offsetParent;
         }

         return absTop;
     }
       
    function findMyAbsoluteTopOLD(thisElement) {
        var thisParent = thisElement.offsetParent;
        var absTop = thisElement.offsetTop; 
        var tryCount = 0;
        if (thisParent.offsetTop) {
            while (tryCount < 2) {
                absTop = absTop + thisParent.offsetTop;
                thisParent = thisParent.offsetParent;
                if (thisParent.offsetTop == 0) { tryCount = tryCount + 1; }
            }
        }

         return absTop;
        } 
