﻿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;
// menu style vars
var width = 155;//135
var height = 18;
var border = "#4f5a5b";//4f5a5b
var menubgOn = "#b1b2ad";//8d9497
var menubgOff = "#d6d7d6";//d6d7d6

var menuXoffset = 0;
var menuYoffset = 5;

// functionality variables
var delay = 400;
var delayStart = 250;
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 = "padding:4px 2px 4px 5px; width:" + width + "px; text-align:left; border-bottom:#4f5a5b 1px solid; border-left:#4f5a5b 1px solid; border-right:" + border + " 1px solid; background-color:" + menubgOff + "; cursor: hand;"
var menustyle2 = "padding:4px 2px 4px 5px; width:" + width + "px; text-align:left; border-bottom:#4f5a5b 1px solid; border-left:#4f5a5b 1px solid; border-right:" + border + " 1px solid; background-color:" + menubgOff 

var separator = "";

function mbj (label, url,target,level) {
	this.level = level;
	this.label = label;
	this.url = url;
	this.target = target;
	return this;
}

function renderdata () {
    menuData[catCount++] = tDa;
    tDa = 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;
}
useMask = 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("<div id=\"table" + i + "\" onMouseOver=startShow('" + i + "') onMouseOut=\"startHide(); changeStatus('');\" class=menu_border><div style='padding:0;background-image:url(images/leftnavtop.gif);'><img src=images/leftnavtop.gif></div><table cellSpacing=0 cellPadding=0 border=0 id=dropmenu>");
			for (j = 0; j < menuData[i].length; j++) {
				if (menuData[i][j].level=='1') document.write("<tr><td class=level1 Colspan=2>"); else document.write("<tr><td valign=top><img src=images/micon.gif></td><td class=level1_1>");
				if (menuData[i][j].url=='') document.write(menuData[i][j].label+"</td></tr>"); else document.write("<a href=\"" + menuData[i][j].url + "\" onMouseOver=startShow('" + i + "') onMouseOut=\"startHide(); changeStatus('');\">" + menuData[i][j].label + "</a></td></tr>");
			}
			menucount++;
			if (useMask) document.writeln("</table><div style='padding:0;background-image:url(images/leftnavbot.gif);'><img src=images/leftnavbot.gif></div></div>");
			document.writeln("</div>");
			moveMenu(i);
		}
	}
	menusWritten = true;

}

function moveMenu(num) {
	tmpMenu = "menu" + num;
	thePos = getObj("pos" + num);
	theImg = "nav" + num;
	xPos = offsetLeft(thePos) + menuXoffset;
	yPos = offsetTop(thePos) + height + menuYoffset;
	if (xPos>800) xPos=xPos-130;
	getObj(tmpMenu).style.left = xPos;
	getObj(tmpMenu).style.top = yPos;
}


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;
	if (menuData) {
		for (i = 0; i<menuData.length; i++) {
			theMenu = "menu" + i;
			var mbj = getObj(theMenu);
			if (mbj) mbj.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) {
	document.location.href = url;
}

function getObj(theId) {
	if (document.getElementById) {
		theObj = document.getElementById(theId); 
	} else if (document.all) { 
		theObj = document.all[theId];
	}
	return theObj;
}

function offsetLeft(o){
	var i = 0;
	while (o.offsetParent!=null) {i+=o.offsetLeft;o=o.offsetParent;}
	return i+o.offsetLeft;
}

function offsetTop(o){
	var i = 0;
	while (o.offsetParent!=null) {i+=o.offsetTop;o=o.offsetParent;}
	return i + o.offsetTop;
}

function changebg(id) {
	if (useDHTML) {
		var tmp = getObj(id);
		if (curItem) {
			if (tmp != curItem) {
				curItem.style.backgroundColor = menubgOff;
				tmp.style.backgroundColor = menubgOn;
			}
		} else { tmp.style.backgroundColor = menubgOn; }
		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 = null;
}

if (document.addEventListener) document.addEventListener("mouseup", mouseUp, false);
document.onmouseup = mouseUp;

function mouseUp() {
	hideAllMenus();
	return true;
}

function shfull(){
	obj=document.form1
	if (obj.search_full.value==''){
		alert('\nPlease input search string      \n');
	}
	else{
		obj.action='/asp/search.asp';
		obj.submit();
	}
}


function dfa(url){document.form1.action=url}
function daus1(){
	window.open('http://marketing.dlink.com.au','daus1')
}
function daus2(){
	window.open('http://partners.dlink.com.au/IMDF','daus2')
}
function daus3(){
	window.open('http://partners.dlink.com.au/MDF','daus3')
}
function daus4(){
	window.open('http://partners.dlink.com.au/Q3_09_Partner_Rebate_Spreadsheet.xls','daus4')
}
function pdsl(){
	window.open('Product_selector_switch.asp?CategoryType=1','pdsl')
}
function wcal(){
	window.open('PS_CAL_ind.asp','wcal')
}
function tlsl(){
	window.open('Tools/SwitchEmulator/DES-3528','tls1')
}
function tls2(){
	window.open('Tools/FirewallEmulator','tls2')
}
function changeWebSite(){
	if (document.form1.obuWebSite.options[document.form1.obuWebSite.selectedIndex].value!='0'){window.open('http://www.d'+document.form1.obuWebSite.options[document.form1.obuWebSite.selectedIndex].value,'_blank')}
}
function go_expertise(){
	window.open('go_expertise.asp','expertise')
}
function go_expertise2(){
	window.open('go_expertise2.asp','expertise')
}
document.write ("<script language=javascript src=/js/z_checkEmail.js></script>")

var count = 0;
var catCount = 0;
var tDa = new Array();
var menuData = new Array();


