function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function ylib_Browser() {
    d = document;
    this.agt = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.dom = (d.getElementById) ? 1 : 0;
    this.ns = (d.layers);
    this.ns4up = (this.ns && this.major >= 4);
    this.ns6 = (this.dom && navigator.appName == "Netscape");
    this.op = (window.opera ? 1 : 0);
    this.ie = (d.all);
    this.ie4 = (d.all && !this.dom) ? 1 : 0;
    this.ie4up = (this.ie && this.major >= 4);
    this.ie5 = (d.all && this.dom);
    this.win = ((this.agt.indexOf("win") != -1) || (this.agt.indexOf("16bit") != -1));
    this.mac = (this.agt.indexOf("mac") != -1);
};

var oBw = new ylib_Browser();

function ylib_getH(o) { return (oBw.ns) ? ((o.height) ? o.height : o.clip.height) : ((oBw.op && typeof o.style.pixelHeight != 'undefined') ? o.style.pixelHeight : o.offsetHeight); };
function ylib_setH(o, h) { if (o.clip) o.clip.height = h; else if (oBw.op && typeof o.style.pixelHeight != 'undefined') o.style.pixelHeight = h; else o.style.height = h; };
function ylib_getW(o) { return (oBw.ns) ? ((o.width) ? o.width : o.clip.width) : ((oBw.op && typeof o.style.pixelWidth != 'undefined') ? w = o.style.pixelWidth : o.offsetWidth); };
function ylib_setW(o, w) { if (o.clip) o.clip.width = w; else if (oBw.op && typeof o.style.pixelWidth != 'undefined') o.style.pixelWidth = w; else o.style.width = w; };
function ylib_getX(o) { return (oBw.ns) ? o.left : ((o.style.pixelLeft) ? o.style.pixelLeft : o.offsetLeft); };
function ylib_setX(o, x) { if (oBw.ns) o.left = x; else if (typeof o.style.pixelLeft != 'undefined') o.style.pixelLeft = x; else o.style.left = x; };
function ylib_getY(o) { return (oBw.ns) ? o.top : ((o.style.pixelTop) ? o.style.pixelTop : o.offsetTop); };
function ylib_setY(o, y) { if (oBw.ns) o.top = y; else if (typeof o.style.pixelTop != 'undefined') o.style.pixelTop = y; else o.style.top = y; };
function ylib_getPageX(o) { var x = 0; if (oBw.ns) x = o.pageX; else { while (eval(o)) { x += o.offsetLeft; o = o.offsetParent; } } return x; };
function ylib_getPageY(o) { var y = 0; if (oBw.ns) y = o.pageY; else { while (eval(o)) { y += o.offsetTop; o = o.offsetParent; } } return y; };
function ylib_getZ(o) { return (oBw.ns) ? o.zIndex : o.style.zIndex; };
function ylib_moveTo(o, x, y) { ylib_setX(o, x); ylib_setY(o, y); };
function ylib_moveBy(o, x, y) { ylib_setX(o, ylib_getPageX(o) + x); ylib_setY(o, ylib_getPageY(o) + y); };
function ylib_setZ(o, z) { if (oBw.ns) o.zIndex = z; else o.style.zIndex = z; };
function ylib_show(o, disp) { (oBw.ns) ? '' : (!disp) ? o.style.display = "inline" : o.style.display = disp; (oBw.ns) ? o.visibility = 'show' : o.style.visibility = 'visible'; };
function ylib_hide(o, disp) { (oBw.ns) ? '' : (arguments.length != 2) ? o.style.display = "none" : o.style.display = disp; (oBw.ns) ? o.visibility = 'hide' : o.style.visibility = 'hidden'; };
function ylib_setStyle(o, s, v) { if (oBw.ie5 || oBw.dom) eval("o.style." + s + " = '" + v + "'"); };
function ylib_getStyle(o, s) { if (oBw.ie5 || oBw.dom) return eval("o.style." + s); };
function ylib_addEvt(o, e, f, c) { if (o.addEventListener) o.addEventListener(e, f, c); else if (o.attachEvent) o.attachEvent("on" + e, f); else eval("o.on" + e + "=" + f) };
function ylib_writeHTML(o, h) { if (oBw.ns) { var doc = o.document; doc.write(h); doc.close(); return false; } o.innerHTML = h; };
function ylib_insertHTML(o, h, w) { if (oBw.op) return; if (o.insertAdjacentHTML) { o.insertAdjacentHTML(w, h); return; } if (oBw.ns) { ylib_writeHTML(o, h); return; } var r = o.ownerDocument.createRange(); r.setStartBefore(o); var frag = r.createContextualFragment(h); ylib_insertObj(o, w, frag); };

gm_Items = new Array();
gm_cl = 0
gm_start = 0

function gm_clear() {
    if (!gm_start) return;
    if (gm_cl) ylib_writeHTML(gmsubs, '');
    gm_cl = 0; gm_start = 0;
}
setInterval(gm_clear, 2000);

function gm_ou(where, ttl) {
    if (!ttl) {
        where.className = 'Out';
        gm_cl = 1
    }
    else {
        where.className = 'Out_ttl';
        gm_start = 1;
        gm_cl = 1
    }
}

function gm_ov(where, ttl) {
    if (!ttl) {
        gm_start = 1;
        where.className = 'Over';
        gm_cl = 0
    }
    else {
        gm_start = 0;
        where.className = 'Over_ttl';
        gm_cl = 0
    }
}

function gm_AddItem(text, url) {
    this.ItemsText.push(text);
    this.ItemsUrl.push(url);
}

function gm_main() {
    this.ItemsText = new Array();
    this.ItemsUrl = new Array();
    this.AddItem = gm_AddItem;
    //alert(readCookie("menu"));
}

function gm_AddSub(name) {
    str = name + '=new gm_main();'
    eval(str);
    gm_Items.push(eval(name))
}

function gm_ShowSub(num) {
    var sSub = '<table border=0 width=10 cellpadding="" style="border-collapse: collapse"><tr><td width=15 nowrap onmouseout="gm_cl=1"> </td><td style="padding:0">';
    for (itm in gm_Items[num].ItemsText) {
        if (itm == 0) continue;

        href = gm_Items[num].ItemsUrl[itm]
        if (href) href = 'href="' + href + '"';

        cursor = '';
        if (href) cursor = 'cursor:hand'; else cursor = 'cursor:default;'
        sSub += '<div class="out" style="padding-right:5;background-color:#AD2A2C" onmouseover="gm_ov(this)" onmouseout="gm_ou(this)" nowrap> <img src="/images/arr.gif" align="middle" > <span id="submenu"><a style="padding-right:2pt;display:inline;width:100%;' + cursor + '" ' + href + '>' + gm_Items[num].ItemsText[itm] + '</a></span></div>'
    }
    sSub += '</td><td width=15 nowrap onmouseout="gm_cl=1"></td></tr><tr><td width=15 height=30 nowrap onmouseout="gm_cl=1"> </td><td onmouseout="gm_cl=1"> </td><td width=15 nowrap onmouseout="gm_cl=1"> </td></tr></table>';

    ylib_writeHTML(gmsubs, sSub);

    where = eval('gmmain' + num);

    ylib_setY(gmsubs, ylib_getPageY(where) + (ylib_getH(where)))
    ylib_setX(gmsubs, ylib_getPageX(where) + (ylib_getW(where) - ylib_getW(gmsubs)) + 12)
}

function gm_Display(where) {
    var inst = ''; var inst_out = '';var mainmenu_a_style = '';
    var sTtl = '<span id="menu"><span class="BGColor" id="menu" style="width:100%;paddig:0;padding-right:0" >';
    var tmp = readCookie("menu");
    if (tmp == null) createCookie("menu", 0, 10);
    for (itm in gm_Items) {
        if (readCookie("menu") == itm) {
            inst = ' class="Over" ';
            inst_out = ' ';
            mainmenu_a_style = ' class="mainmenu_a_over"  ';
        }
        else {
            inst = 'class="out_ttl"'
            inst_out = ' onmouseout="gm_ou(this,1);" ';
            mainmenu_a_style = ' class="mainmenu_a" ';
        }

        //where.className = 'Over';
        href = gm_Items[itm].ItemsUrl[0];
        if (href) href = 'href="' + href + '"';
        else href = 'href="Javascript:;"';
        cursor = '';
        if (href) cursor = 'cursor:hand'; else cursor = 'cursor:default;'
        sTtl += '<span ' + inst + ' style="width:30;z-Index:99;padding-right:0;' + cursor + '" id="gmmain' + itm + '" ' + inst_out + ' onmouseover="gm_ov(this,1);gm_ShowSub(' + itm + ')" onclick=createCookie("menu",' + itm + ',10) nowrap><span ' + mainmenu_a_style + ' id="mainmenu"><a ' + mainmenu_a_style + ' ' + href + '>&nbsp;&nbsp;&nbsp;<nobr>' + gm_Items[itm].ItemsText[0] + '&nbsp;&nbsp;&nbsp;</nobr></a></span></span>'
        //alert(sTtl);
    }
    sTtl += '</span></span>'

    ylib_writeHTML(where, sTtl);
    sTtl = '<span id="menu"> <span id="gmsubs" style="position:absolute;top:0;left:0;z-Index:100;"></span></span>'
    ylib_insertHTML(document.body, sTtl, 'afterBegin');
}