function fixAnchors() {
    var nodes = document.getElementsByTagName("A");
    var url = new String(document.location);
    if (url.indexOf('#') !== -1)
    {
        url = url.substr(0, url.indexOf('#'));
    }
    for (var i in nodes) {
        var node = nodes[i];
        if (!node || !node.getAttribute) {
            continue;
        }
        var href = node.getAttribute("href");
        if (href && href.indexOf('#') !== -1) {
            var pos = href.indexOf('#');            
            node.href = url + href.substr(pos);
        }
    }
}

function getTarget(event){
    if (!event) {
        return null;
    }
    return event.target ? event.target : event.srcElement;
}

function setCookie(name, value, days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 3600000));
        expires = "; expires=" + date.toGMTString();
    }
    document.cookie = name + "=" + escape(value) + expires + "; path=/";
}
 
function getCookie(name) {
    var nameEQ = name + "=";
    var parts = document.cookie.split(';');
    var l = parts.length;
    for (var i = 0; i < l; i++) {
        var part = parts[i];
        while (part.charAt(0)==' ') {
            part = part.substring(1, part.length);
        }
        if (part.indexOf(nameEQ) == 0) {
            return unescape(part.substring(nameEQ.length, part.length));
        }
    }
    return null;
}
 
function removeCookie(name) {
    setCookie(name, "", -1);
}

function onClickMenu(id, name) {
    if (!name) {
        name = '__menu_item_active';
    }
    setCookie(name, id);
}

__dumpContainer__ = null;

function dump(value) {
    var first = false;
    if (__dumpContainer__ === null) {
        first = true;
        __dumpContainer__ = document.body.appendChild(document.createElement("DIV"));
        __dumpContainer__.style.border = "solid 1px #5B6D85";
        __dumpContainer__.style.position = "absolute";
        __dumpContainer__.style.margin = "1px";
        __dumpContainer__.style.width = "75%";
        __dumpContainer__.style.backgroundColor = "#D5D5D5";
        var node = __dumpContainer__.appendChild(document.createElement("DIV"));
        node.style.padding = "2px";
        node.style.color = "#FFFFFF";
        node.style.fontSize = "10px";
        node.style.fontFamily = "Tahoma";
        node.style.backgroundColor = "#5B6D85";
        var nodeLink = node.appendChild(document.createElement("A"));
        node.appendChild(document.createTextNode(" | JavaScript dump"));
        nodeLink.href = "#";
        nodeLink.onclick = function() {
            var show = __dumpContainer__.style.display === "none";
            __dumpContainer__.style.display = show ? "" : "none";
            this.innerHTML = show ? "Hide" : "Show";
        };
        nodeLink.style.fontWeight = "bold";
        nodeLink.style.color = "#FFFFFF";
        nodeLink.innerHTML = "Hide";
        __dumpContainer__ = __dumpContainer__.appendChild(document.createElement("DIV"));
    }
    var nodeDiv = __dumpContainer__.appendChild(document.createElement("DIV"));
    nodeDiv.style.whiteSpace = "pre";
    nodeDiv.style.padding = "1px";
    if (!first) {
        nodeDiv.style.borderTop = "solid 1px #5B6D85";
    }
    nodeDiv.style.margin = "2px";
    nodeDiv.appendChild(document.createTextNode(__prepareToDump(value)));
	
}

function __prepareToDump(val, level) {
    var content = "";
    var valuePadding = "";
    var typeOfValue = typeof(val);
    if (!level) {
        level = 0;
    }
    for (var j = 0; j < level; j++) {
        valuePadding += "\t";
    }
    if (typeOfValue == "object") {
        for (var name in val) {
            var value = val[name];
            if (typeof(value) === "object") {
                content += valuePadding + "\"" + name + "\" => {\n";
                content += __prepareToDump(value, level + 1);
                content += valuePadding + "}\n";
            } else {
                content += valuePadding + "\"" + name + "\" => " + __prepareToDump(value) + "\n";
            }
        }
    } else {
        content = '"' + val + "\" (" + typeOfValue + ")";
    }
    return content;
}

function NewWindow(mypage, myname, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no ,resizable=no'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}

function NewImageWindow(mypage, myimage, myname) {
    function getWidthAndHeight() {
        alert("'" + this.name + "' is " + this.width + " by " + this.height + " pixels in size.");
        return true;
    }
    function loadFailure() {
        alert("'" + this.name + "' failed to load.");
        return true;
    }
    function openWindow() {
        var winl = (screen.availWidth - this.width) / 2;
        var wint = (screen.availHeight - this.height) / 2;
        winprops = 'height='+this.height+',width='+this.width+',top='+wint+',left='+winl+',scrollbars=no,resizable=no'
        win = window.open(mypage, '', winprops);
        if (parseInt(navigator.appVersion) >= 4) {
            win.window.focus();
        }
        return true;
    }

    var myImage = new Image();
    myImage.name = myimage;
    myImage.onload = openWindow;
    myImage.onerror = loadFailure;
    myImage.src = myimage;
}


function setSubActive(id){
   
}

$(document).ready(function(){
    $(".main_menu_item").mouseenter(function () {
        $(this).children("table").css("display","block");
    });
   $(".main_menu_item").mouseleave(function () {
        $(this).children("table").css("display","none");
    });

});




function gotoOtherSite(url){
window.location = url;
}


