/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menuwidth = '200px'     //default menu width
var menubgcolor = '#FDE8DC' //menu bgcolor
var disappeardelay = 250    //menu disappear speed onMouseout (in miliseconds)

//-------------------------------------------------
/***********************************************
* AnyLink CSS Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* Modified here for a second 'drop over' level
***********************************************/

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)

/////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 subshowhide(obj, e, visible, hidden){
    if (ie5 || ns6)
        subdropmenuobj.style.left = subdropmenuobj.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 < dropmenuobj.contentmeasure)
            edgeoffset = dropmenuobj.contentmeasure - obj.offsetWidth
    }else{
        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)
            edgeoffset = dropmenuobj.contentmeasure + obj.offsetHeight
    }
    return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID, menuwidth){
    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")
        if (dropmenuID == 'menu_free'){
                dropmenuobj.style.left = dropmenuobj.x - 140 + "px"
        }else{
                dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + "px"
        }
        dropmenuobj.style.width = menuwidth
        dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + obj.offsetHeight + "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 subdynamichide(e){
    if (ie5 && !subdropmenuobj.contains(e.toElement))
        subdelayhidemenu()

    else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))
        subdelayhidemenu()
}

function delayhidemenu(){
    delayhide = setTimeout("dropmenuobj.style.visibility='hidden'", disappeardelay)
}

function subdelayhidemenu(){
    subdelayhide = setTimeout("subdropmenuobj.style.visibility='hidden'", disappeardelay)
}

function clearhidemenu(){
    if (typeof delayhide != "undefined")
        clearTimeout(delayhide)
}

function subclearhidemenu(){
    if (typeof subdelayhide != "undefined")
        clearTimeout(subdelayhide)
}

function rightmenu(obj, e, dropmenuID, menuwidth){
    if (document.all && !window.opera){
        var subObjB = '', ieStyle = document.all.tags('style')[0].innerHTML
        ieStyle = ieStyle.substr(ieStyle.indexOf('dropmenudiv a'))
        ieStyle = ieStyle.substr(ieStyle.indexOf('border-bottom'))
        ieStyle = ieStyle.substr(0, ieStyle.indexOf(';'))

        for (var i_tem = 0; i_tem < ieStyle.length; i_tem++)
            subObjB += ieStyle.charAt(i_tem).replace(/[^0-9]/, '')
        subObjB = parseInt(subObjB)
    }else if (!window.opera)
        var subObjB = parseInt(document.styleSheets[0].cssRules[1].style.borderBottomWidth)

    else
        //alert(obj.offsetHeight+' '+getposOffset(obj, "top") )
        subObjB = -6

    if (window.event)
        event.cancelBubble = true

    else if (e.stopPropagation)
        e.stopPropagation()

    if (typeof subdropmenuobj != "undefined") //hide previous menu
        subdropmenuobj.style.visibility = "hidden"
        setTimeout("dropmenuobj.style.visibility='visible'", disappeardelay)
        subclearhidemenu()

    if (ie5 || ns6){
        obj.onmouseout = subdelayhidemenu
        subdropmenuobj = document.getElementById(dropmenuID)

        if (hidemenu_onclick)
            subdropmenuobj.onclick = function(){subdropmenuobj.style.visibility = 'hidden'}
        subdropmenuobj.onmouseover = subclearhidemenu
        subdropmenuobj.onmouseout = ie5 ? function(){subdynamichide(event)}: function(event){subdynamichide(event)}
        subshowhide(subdropmenuobj.style, e, "visible", "hidden")
        if(dropmenuID == 'menu_free_beeline'){
                subdropmenuobj.style.left = obj.offsetWidth - 180 + "px"
                subdropmenuobj.style.top = 0 + "px"
                subdropmenuobj.style.clear = "left"
        }else{
                subdropmenuobj.style.left = obj.offsetWidth + "px"
                subdropmenuobj.style.top = getposOffset(obj, "top") - (dropmenuobj.y) - (obj.offsetHeight) + subObjB - 1 + "px"
        }
        subdropmenuobj.style.width = menuwidth
        }
    return clickreturnvalue()
}
