﻿var dbg_menu_visible = true;


var eciFloatMenuVisible = false;

var toFloatMenu;
var toOn = false;


function eci_is_child_of(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}

function eci_fixOnMouseOut(element, event, JavaScript_code) {

    //  debugger;

    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
    }

    if (!current_mouse_target)
        return;

    if (current_mouse_target.tagName == 'option')
        return;



    if ((current_mouse_target.tagName == 'UL') || (current_mouse_target.tagName == 'ul'))
        return;

    if (current_mouse_target.tagName == 'li')
        return;

    var menuDiv = $("#eci_floatMenu");

    if (!eci_is_child_of(element, current_mouse_target) && !eci_is_child_of(menuDiv[0], current_mouse_target) && element != current_mouse_target) {
        eval(JavaScript_code);
    }

}

function eci_TopMenu_arrow_onmouseout(elm) {
    while (elm.tagName != "TABLE")
        elm = elm.parentElement;
    //elm.rows[0].cells[1].firstChild.style.display = "none";
}

function eci_TopMenu_arrow_onmouseover(elm) {

    while (elm.tagName != "TABLE")
        elm = elm.parentElement;
    //elm.rows[0].cells[1].firstChild.style.display = "";
}

function eci_TopMenu__onmouseout() {
    eciFloatMenuVisible = false;
    var menu = eci_positionTopMenu();
    menu.fadeOut(400);

}


function eci_TopMenu_Solutions_onmouseout() {
    if (toOn) {
        toOn = false;
        clearTimeout(toFloatMenu);
    }


    eciFloatMenuVisible = false;
    var menu = eci_positionTopMenu();
    menu.fadeOut(400);

}

function eci_TopMenu_Solutions_onmouseover() {

    //return;

    if (eciFloatMenuVisible)
        return;
    if (toOn)
        return;

    toFloatMenu = setTimeout("eci_TopMenu_showmenu()", 500);
    toOn = true;


}

function eci_TopMenu_showmenu() {
    clearTimeout(toFloatMenu);

    toOn = false;

    if (eciFloatMenuVisible)
        return;

    var menu = eci_positionTopMenu();

    eciFloatMenuVisible = true;

    menu.fadeIn(500);

}




function eci_positionTopMenu() {
    var topRow = $("#eci_TopMenu");
    var pos = eci_findPos(topRow[0]);
    var menuDiv = $("#eci_floatMenu");
    menuDiv[0].style.left = pos[0] + 'px';
    menuDiv[0].style.top = pos[1] + topRow[0].clientHeight - 3 + 'px';
    menuDiv[0].style.width = topRow[0].clientWidth;
    return menuDiv;

}

function eci_findPos(obj) {

    var curleft = 0;
    var curtop = 0;
    while (obj.offsetParent == null) {
        obj = obj.parentNode;
    }
    if (obj.offsetParent)
        while (1) {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
            if ((!obj.offsetParent) || (obj.id == 'MSO_ContentTable') || (obj.className == 'body-wrapper'))
                break;
        }
    else if (obj.x) {
        curleft += obj.x;
        curtop += obj.y;
    }
    return [curleft, curtop];
}


function eci_TopMenu_combo_change(elm) {   
    if ($('select.selectProducts' + elm).val() != '') {
        window.location.href = $('select.selectProducts' + elm).val();
    }
}


function eci_window_onload() {
    if (dbg_menu_visible)
        $("#eci_floatMenu")[0].style.display = "";

}

function initCombo() {
  
    if ($('#selectProducts1').length == 0) {
        setTimeout("initCombo()", 50);
    }
    $('#selectProducts1').selectbox();
    $('#selectProducts2').selectbox();
}

function JQueryCombo()
{
    $('#selectProducts1').selectbox();
    $('#selectProducts2').selectbox();
}
//eci_window_onload();

function JQueryHideCombo() {
    $('#selectProducts1').hide();
    //alert($('#selectProducts1').length);
    $('#selectProducts2').hide();
}
//_spBodyOnLoadFunctionNames.push("JQueryHideCombo()"); //initCombo();

//_spBodyOnLoadFunctionNames.push("JQueryCombo()");
$(function () {
    $('#selectProducts1').hide();
    $('#selectProducts2').hide();
    $('#selectProducts1').selectbox();
    $('#selectProducts2').selectbox();
});
