/* homepage.js */
var nsDiv = "navDefault";

function swapImage() {
	if (document.images) {
		for(var i=0;i<arguments.length;i++) {
			if (isNS4) {
				divLayer = document.layers[nsDiv];
				divLayer.document.images[arguments[i]].src = arguments[i+1];
			} else {
				document.images[arguments[i]].src = arguments[i+1];
			}
			++i;
		}
	}
}

zMax = 1;

function showSubNav(id) {
	if (typeof section=="undefined") {
		hideAllHomeSubNav();
	}
	var obj = (isDOM)?document.getElementById(id):(isIE4)?document.all[id]:(isNS4)?document.layers[id]:null;
	if (obj != null) {
		if (isNS4) obj.style = obj;
		obj.style.zIndex = zMax++;
		obj.style.visibility = (isNS4)?"show":"visible";
	}
}

function hideSubNav(id) {
	var obj = (isDOM)?document.getElementById(id):(isIE4)?document.all[id]:(isNS4)?document.layers[id]:null;
	if (obj != null) {
		if (isNS4) obj.style = obj;
		obj.style.visibility = (isNS4)?"hide":"hidden";
	}
}

function hideAllHomeSubNav() {
	hideSubNav("navAbout");
	hideSubNav("navProducts");
	hideSubNav("navManufacturing");
	hideSubNav("navNews");
	hideSubNav("navCareers");
}

if (isNS4) document.captureEvents(Event.MOUSEMOVE);
if (typeof section=="undefined") {
	document.onmousemove = checkHomeNavZone;
}

function checkHomeNavZone(arg) {
	e = (arg)?arg:event;
	mX = (e.pageX)?e.pageX:e.clientX;
	mY = (e.pageY)?e.pageY:e.clientY;
	var navL = 0;
	var navR = 260;
	var navB = 332;
	var navT = 135;
	if ((mX<navL)||(mX>navR)||(mY>navB)||(mY<navT)) {
		showSubNav("navDefault");
	}
	if ((isIE)&&(mX<10)) {
		st = setTimeout("showSubNav('navDefault')",3000);
	}
}

// fixes a resize/DHTML issue with Netscape 4.x browsers
if (document.layers) {
	origWinWidth = window.innerWidth;
	origWinHeight = window.innerHeight;
	
	window.onresize = function() {
		currWinWidth = window.innerWidth;
		currWinHeight = window.innerHeight;
		if((origWinWidth != currWinWidth) || (origWinHeight != currWinHeight)) location.reload();
	}
}

function reloadPage() {
	setTimeout("window.location.reload(0)",500);
}

minFlashVer = 4;

// catch for ActiveX control
if (isIE) {
	document.write(
	'<SCR'+'IPT language=VBScript\>'+'\n'+
	'Function checkFlashActiveX()'+'\n'+
		'Dim flashEnabled, currentFlashVer'+'\n'+
		'flashEnabled = false'+'\n'+
		'currentFlashVer = 10'+'\n'+
		'Do While currentFlashVer >= minFlashVer'+'\n'+
			'On Error Resume Next'+'\n'+
			'flashEnabled = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & currentFlashVer & \"\")))'+'\n'+
			'If flashEnabled = true Then Exit Do'+'\n'+
			'currentFlashVer = currentFlashVer - 1'+'\n'+
		'Loop'+'\n'+
		'checkFlashActiveX = flashEnabled'+'\n'+
	'End Function'+'\n'+
	'<\/SCR'+'IPT\>'
	);
}

// catch for NS plugin
function checkFlashPlugin() {
	var plugin = ((navigator.mimeTypes) && (navigator.mimeTypes["application/x-shockwave-flash"]))?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
	if (plugin) {
		var pluginDesc = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin.description;
		var currentFlashVer = parseInt(pluginDesc.charAt(pluginDesc.indexOf(".")-1));
		if (currentFlashVer >= minFlashVer) return true;
	}
	return false;
}

function detectFlash() {
	var flashCapable = false;
	if (isNS4||isNS6) {
		flashCapable = checkFlashPlugin();
	}
	if ((isIE) && (navigator.appVersion.indexOf("Windows") != -1)) {
		flashCapable = checkFlashActiveX();
	}
	if ((isIE) && (navigator.appVersion.indexOf("Mac") != -1)) {
		var browserVer = parseFloat(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE") + 4));
		if (browserVer>=5) {
			flashCapable = checkFlashPlugin();
		} else {
			flashCapable = true;
		}
	}
	return flashCapable;
}
