﻿function fireEvent(element,event){
    if(document.createEvent){
        // dispatch for firefox + others
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);
    }
    else{
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent("on"+event,evt)
    }
}

var bAllowSectionOut = true;
function OnMenuItemMouseOut(item) {
    bAllowSectionOut = true;
    item.className = item.className.replace(new RegExp("over\\b"), "");
    var obj = item.parentNode.previousSibling;
    fireEvent(obj, "mouseout");
}

function OnMenuItemMouseOver(item) {
    bAllowSectionOut = false;
    if (null != item.className && item.className.length > 0) {
        item.className += " ";
    }
    item.className += "over";
}

function OnSectionMouseOut(img, sUrl) {
    if (bAllowSectionOut) {
        img.src = sUrl;
    }
}

function Switch(control, sUrl, bExpand)
{
    if( ! bExpand ) {
        setTimeout(function() { OnSectionMouseOut(control, sUrl) }, 100)
    }
    else
    {
        bAllowSectionOut = true;
        control.src = sUrl;
    }
}

