﻿// JavaScript Document

var drop_menuTimer;

function drop_$(obj) {
    if (typeof (obj) == 'object') return obj;
    if (document.getElementById(obj)) return document.getElementById(obj);
}
function drop_init() {
    var i = 1;
    while (drop_$('menu_' + i)) {
        drop_$('menu_' + i).onmouseover = function() { window.clearTimeout(drop_menuTimer); drop_open(this); }
        drop_$('menu_' + i).onmouseout = function() { drop_menuTimer = window.setTimeout("drop_close()", 750); }
        i++;
    }
    i = 1;
    while (drop_$('menu_' + i + '_content')) {
        drop_$('menu_' + i + '_content').onmouseover = function() { window.clearTimeout(drop_menuTimer); }
        drop_$('menu_' + i + '_content').onmouseout = function() { drop_menuTimer = window.setTimeout("drop_close();", 750); }
        i++;
    }
}
function drop_open(menu) {
    drop_removeElementByID('drop_iFrameBack');
    menuContent = drop_$(menu.id + '_content');
    i = 1;

    while (drop_$('menu_' + i + '_content')) {


        if (drop_$('menu_' + i + '_content') != menuContent) {
            drop_$('menu_' + i + '_content').style.display = '';
        }
        i++;
    }
    //	content.style.top			=	(menu.offsetTop+menu.offsetHeight)+'px';
    //	menuContent.style.top			=	'66px';
    menuContent.style.left = menu.offsetLeft + 'px';
    menuContent.style.display = 'block';

//    if (menu.id == "menu_8") {
//        menuContent.style.left = '50px';
//    }
    iFrame = document.createElement('iframe');
    iFrame.id = 'drop_iFrameBack';
    iFrame.style.top = menuContent.offsetTop;
    iFrame.style.left = menuContent.offsetLeft;
    iFrame.style.width = menuContent.offsetWidth;
    iFrame.style.height = menuContent.offsetHeight;
    drop_$('wrapper').appendChild(iFrame);
}

function drop_close() {
    i = 1;
    while (drop_$('menu_' + i + '_content')) {
        drop_$('menu_' + i + '_content').style.display = '';
        i++;
    }
    drop_removeElementByID('drop_iFrameBack');
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }

}

function drop_removeElementByID(ID) {
    //	document.body.setAttribute('onmousedown','');
    if (typeof ID == 'string') ID = document.getElementById(ID);
    if (ID && ID.parentNode) ID.parentNode.removeChild(ID);
    return
}

//	Use this if there is nothing in the <body onload="">
//addLoadEvent(drop_init);
