// JavaScript Document

var imageLoc = 'images/';
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var is_opera = (agt.indexOf("opera") != -1);
var iePos  = appVer.indexOf('msie');
var is_mac_ie = false;
if (iePos !=-1) {
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
   is_major = parseInt(is_minor);
}
var is_ie = ((iePos!=-1) && (!is_opera));
if (is_mac && is_ie) {
	is_mac_ie = true;
}
var is_ie5up = (is_ie && is_minor >= 5);
var is_ie5_5up =(is_ie && is_minor >= 5.5);
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var nn4 = false;
if (document.layers) {
	nn4 = true;
}

function turnOnMyStore(imgName,imgPath) {
    document[imgName].src = imgPath;
}


// menu style vars
var width = 165;
var height = 25;
var border = "#A9A7A7";
var menubgOn = "#C50503";
var menubgOff = "#FFFFFF";

var menuXoffset = -347;
var menuYoffset = -25;

// functionality variables
var delay = 500;
var delayStart = 50;
var useMask = false;
var useDHTML = false;
var hideSels = false;
var start;
var hideFlag;
var hideTimer;
var showTimer;
var curMenu;
var curItem;
var curNav;
var activeMenu;
var theMenu;
var theImg;
var thePos;
var theDiv;
var theCont;
var theTable;
var theMask;
var onMenu = false;
var menusWritten = false;

// menu building variables;
var menucount = 0;

var menustyle = "width:" + width + "px; text-align:left; border-left:" + border + " 1px solid; border-right:" + border + " 1px solid; background-color:" + menubgOff + "; cursor: pointer;"

var separator = "<div style=\"background-image:url('"+imageLoc+"menudot.gif'); \"><img src=\""+imageLoc+"spacer.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\"></div>";

function menuobject (label, url) {
    this.label = label;
    this.url = url;
    return this;
}

function renderdata () {
    menuData[catCount++] = tmpData;
    tmpData = new Array();
    count = 0;
}

// Turn iFrame mask on for IE 5.5+ / PC only
if (is_ie && !is_mac_ie) {
    if (is_ie5_5up) {
        //useMask = true;
    }
    else {
        hideSels = true;
    }
}

// Turn on DHTML for 5+ browsers only
if (is_ie && !is_ie5up) {
    useDHTML = false;
} else if(!nn4) { useDHTML = true; }

function writeMenus() {
    if(useDHTML) {
        for (i = 0; i < menuData.length; i++) {
            document.writeln("<div id=\"menu" + i + "\" style=\"position:absolute; z-index:100; top:0px; left:0px; visibility:hidden;\">");
            if (useMask) {
                document.writeln("<table id=\"table" + i + "\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td>");
            }
            for (j = 0; j < menuData[i].length; j++) {
				if ((j == 0) && (menuData[i].length == 1)) {
					document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"padding:5px 0px 5px 5px;cursor:pointer;" + menustyle + "border-top:" + border + " 1px solid; border-bottom:" + border + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink\">" + menuData[i][j].label + "</a></div>" + separator + "</div>");
				}
				else {
					if (j == 0) {
						document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"padding:5px 0px 5px 5px;cursor:pointer;" + menustyle + "border-top:" + border + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink\">" + menuData[i][j].label + "</a></div>" + separator + "</div>");
					}
					else if (j < menuData[i].length - 1) {
						document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"padding:5px 0px 5px 5px;cursor:pointer;" + menustyle + "\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink\">" + menuData[i][j].label + "</a></div>" + separator + "</div>");
					}
					else {
						document.write("<div id=\"menuitem" + menucount + "\" onMouseOver=\"startShow('" + i + "'); changebg('menuitem" + menucount + "'); changeStatus('" + menuData[i][j].url + "');\" onMouseOut=\"startHide(); changeStatus('');\" onClick=\"goTo('" + menuData[i][j].url + "');\" style=\"padding:5px 0px 5px 5px;cursor:pointer;" + menustyle + "border-bottom:" + border + " 1px solid;\"><div class=\"dhtml_menuitem\"><a href=\"" + menuData[i][j].url + "\" class=\"dhtml_menulink\">" + menuData[i][j].label + "</a></div></div>");
					}
				}
                menucount++;
            }
            if (useMask) {
                document.writeln("</td></tr></table>");
            }
            document.writeln("</div>");
            moveMenu(i);
        }
    }
    menusWritten = true;
}

function moveMenu(num) {
    tmpMenu = "menu" + num;
    thePos = getotherframeObj("pos" + num);
    theImg = "nav" + num;
    xPos = offsetLeft(thePos) + menuXoffset;
    yPos = offsetTop(thePos) + height + menuYoffset;
    
    if (num == (menuData.length - 2)) {
        xPos -= 30;
    }
	
    getObj(tmpMenu).style.left = xPos + "px";
    getObj(tmpMenu).style.top = yPos + "px";
}

function showMenus() {
    unfocus();
    if (hideSels) {
        hideSelect();
    }
    onMenu = true;
    theMenu = "menu" + curMenu;
    activeMenu = theMenu;
    moveMenu(curMenu);
    if (useMask) {
        theMask = getObj("iMask");
        theTable = "table" + curMenu;
        theMask.style.left = xPos;
        theMask.style.top = yPos;
        theMask.style.width = getObj(theTable).offsetWidth;
        theMask.style.height = getObj(theTable).offsetHeight;
    }
    getObj(theMenu).style.visibility = "visible";
}

function startShow(menu) {


    curNav = menu;
    if (menusWritten && !nn4) {
        curMenu = menu;
        if (activeMenu) {
            getObj(activeMenu).style.visibility = "hidden";
        }
        clearTimer();
        if (!onMenu) {
            if (curItem) {
                curItem.style.backgroundColor = menubgOff;
            }
            showTimer = setTimeout("showMenus()", delayStart);
        }
        else {
            showMenus();
        }
    }
    else {
        return false;
    }
}

function startHide() {
    if (!onMenu) {
        if (curNav) {
            curNav = null;
        }
    }
    if (menusWritten && !nn4) {
        if (showTimer) clearTimeout(showTimer);
        start = new Date();
        hideFlag = true;
        hideTimer = setTimeout("hideMenus()", delay);
    }
    else {
        return false;
    }
}

function clearTimer() {
    if (hideTimer) clearTimeout(hideTimer);
    hideTimer = null;
    hideFlag = false;
}

function hideMenus() {
    if (!hideFlag) return;
    var elapsed = new Date() - start;
    if (elapsed < delay) {
        hideTimer = setTimeout("hideMenus()", delay - elapsed);
        return;
    }
    hideFlag = false;
    hideAllMenus();
    if (hideSels) {
        showSelect();
    }
}

function hideAllMenus() {
    changeStatus('');
    if (curNav) {
        curNav = null;
    }
    for (i = 0; i<menuData.length; i++) {
        theMenu = "menu" + i;
        getObj(theMenu).style.visibility = "hidden";
    }
    if (useMask) {
        if (theMask) {
            theMask.style.left = -300;
            theMask.style.top = -300;
        }
    }
    if (curItem) {
        curItem.style.backgroundColor = menubgOff;
    }
    onMenu = false;
}

function goTo(url) {
	if (is_ie) {
		if (parent.document.all("top_frame").all("middle_vert_frame").all("middle_hor_frame").cols == "350,*") {
			top.leftframe.location = "leftframe2.html";
			parent.document.all("top_frame").all("middle_vert_frame").all("middle_hor_frame").cols = "268,*";
		}
	}
	else {
		if (parent.document.getElementById("middle_hor_frame").cols == "350,*") {
			top.leftframe.location = "leftframe2.html";
			parent.document.getElementById("middle_hor_frame").cols = "268,*";
		}
	}
    document.location.href = url;
}


function goHome() {
	if (is_ie) {
		if (parent.document.all("top_frame").all("middle_vert_frame").all("middle_hor_frame").cols == "268,*") {
			top.leftframe.location = "leftframe.htm";
			parent.document.all("top_frame").all("middle_vert_frame").all("middle_hor_frame").cols = "350,*";
		}
	}
	else {
		if (parent.document.getElementById("middle_hor_frame").cols == "268,*") {
			top.leftframe.location = "leftframe.htm";
			parent.document.getElementById("middle_hor_frame").cols = "350,*";
		}
	}
    document.location.href = "content.htm";
}

//return [object]
function getObj(theId) {
    if (document.getElementById) {
        theObj = document.getElementById(theId); 
    } else if (document.all) { 
        theObj = document.all[theId];
    }
    return theObj;
}

//return [object]
function getotherframeObj(theId) {
    if (parent.menuframe.document.getElementById) {
        theObj = parent.menuframe.document.getElementById(theId); 
    } else if (parent.menuframe.document.all) { 
        theObj = parent.menuframe.document.all[theId];
    }
    return theObj;
}

//return [img] object NS4 fix
function getImg(imgName, divName) {
    if (nn4) {
        imgObj = eval("document." + divName + ".document.images." + imgName);
    }
    else {
        imgObj = eval("document.images." + imgName);
    }
    return imgObj;
}

//Mac IE offset fix
function offsetLeft(o){
    var i = 0;
	while (o && o.offsetParent != null) {
		i += o.offsetLeft;
		o = o.offsetParent;
	}
	return i;
}
function offsetTop(o){
   var i = 0;
	while (o && o.offsetParent!=null) {
		i += o.offsetTop;
		o = o.offsetParent;
	}
	
	i += document.documentElement['scrollTop'] ? document.documentElement['scrollTop'] : document.body['scrollTop'];
	
	return i;
}

function changebg(id) {
    if (useDHTML) {
        var tmp = getObj(id);
        if (curItem) {
            if (tmp != curItem) {
                curItem.style.backgroundColor = menubgOff;
				curItem.getElementsByTagName('a')[0].style.color = "#C50503";
				
                tmp.style.backgroundColor = menubgOn;
				tmp.getElementsByTagName('a')[0].style.color = "#EFEFEF";
            }
        } else { 
			tmp.style.backgroundColor = menubgOn;
			tmp.getElementsByTagName('a')[0].style.color = "#EFEFEF";
		}
        curItem = tmp;
    }
}

function unfocus() {
    for (x = 0; x < document.forms.length; x++) {
        for (y = 0; y < document.forms[x].elements.length; y++) {
            if (document.forms[x].elements[y].type == "text") {
                document.forms[x].elements[y].blur();
            }
        }
    }
}

function hideSelect() {
    var f = document.forms;
    for(var i=0;i<f.length;i++) {
        for (var j=0; j<f[i].elements.length; j++) {
            if (f[i].elements[j].type == 'select-one') {
                f[i].elements[j].style.visibility = 'hidden';
            }
        }
    }
}

function showSelect() {
    var f = document.forms;
    for(var i=0;i<f.length;i++) {
        for (var j=0; j<f[i].elements.length; j++) {
            if (f[i].elements[j].type == 'select-one') {
                f[i].elements[j].style.visibility = 'visible';
            }
        }
    }
}

function changeStatus(text) {
    window.status = text;
}

function clearbg() {
    if (curItem) {
        curItem.style.backgroundColor = menubgOff;
		curItem.getElementsByTagName('a')[0].style.color = "#C50503";
    }
    curItem = null;
}

if (document.addEventListener) {
    document.addEventListener("mouseup", mouseUp, false);
}

document.onmouseup = mouseUp;

function mouseUp() {
    hideAllMenus();
    return true;
}

var count = 0;
var catCount = 0;
var menuData = new Array();
var tmpData = new Array();

// About Us
tmpData[count++] = new menuobject("About Us","main.php?SCREEN=about");
tmpData[count++] = new menuobject("Company Profile","main.php?SCREEN=profile");
tmpData[count++] = new menuobject("Company History","main.php?SCREEN=history");
tmpData[count++] = new menuobject("Eagle Certifications","main.php?SCREEN=certifications");

renderdata();

// Sales
tmpData[count++] = new menuobject("Heli-Sales","main.php?SCREEN=helisales");

renderdata();

// Leasing
tmpData[count++] = new menuobject("Heli-Leasing","main.php?SCREEN=helileasing");

renderdata();

// Services
tmpData[count++] = new menuobject("Maintenance","main.php?SCREEN=maintenance");
tmpData[count++] = new menuobject("Component","main.php?SCREEN=component");
tmpData[count++] = new menuobject("Turbine Engine","main.php?SCREEN=turbineengine");
tmpData[count++] = new menuobject("Fuel Control","main.php?SCREEN=fuelcontrol");
tmpData[count++] = new menuobject("Structures","main.php?SCREEN=structures");
tmpData[count++] = new menuobject("Avionics","main.php?SCREEN=avionics");

renderdata();

// Parts
tmpData[count++] = new menuobject("Request for Quote","main.php?SCREEN=quoterequest");
tmpData[count++] = new menuobject("Dart Aerospace","main.php?SCREEN=dartaerospace");

renderdata();

// Contact Us
tmpData[count++] = new menuobject("Contact Information","main.php?SCREEN=contact");
tmpData[count++] = new menuobject("Monthly Report","main.php?SCREEN=monthlyreport");
tmpData[count++] = new menuobject("Employment Opportunities","main.php?SCREEN=employment");

renderdata();


<!--
	if (useDHTML) {
		writeMenus();
	}
//-->