var isNav, isIE, isMac, appversion
lastLayer = null;

if (parseInt(navigator.appVersion) >=4) {
	if (navigator.appName == "Netscape") {
		isNav = true;
	} else {
		isIE = true;
	}
}

isMac = (navigator.platform.indexOf('Win') == -1);

if (isNav) {
	appVersion = parseInt(navigator.appVersion);
} else if (isIE) {
	var str = new String(navigator.appVersion);
	var index = str.indexOf('MSIE');
	var strVer = str.slice(index + 5, str.length);
	appVersion = parseInt(strVer);
}
//checks for the flash plugin
function checkFlash(reDirectURL) {
	var ok = false;
	if(isMac){
	}else if(isNav) {
		ok=(navigator.plugins&&navigator.plugins['Shockwave Flash']);
		if(!ok) {
			window.location=reDirectURL;
		}
	} else if (isIE) {
		if(!window.MM_flash) {
			window.location=reDirectURL;
		}
	}
}

//creates a new image object
function newImage(arg) {
	if(document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function superHide(aLayer) {
	theObjs[aLayer].Hide();
}

function superShow(aLayer) {
	theObjs[aLayer].Show();
}

var currTimeOut, terTimeOut;
var lastLayer = null;
var galleryLayer = "default";

function galleryShow(LayerName) {
	if(preloadFlag&&objsCreated) {
		theObjs[galleryLayer].Hide();
		theObjs[LayerName].Show();
		galleryLayer = LayerName;
	}
}

function menuShow(aLayer, bLayer, imgName) {
	if(preloadFlag&&objsCreated) {
		if (aLayer == lastLayer) {
			clearTimeout(currTimeOut);
			if (bLayer) {
				tertiaryShow(bLayer);
				swapImage(aLayer, imgName, menuImages[0]);
			}
		} else {
			if (lastLayer != null) {
				clearTimeout(currTimeOut);
				superHide(lastLayer);
				superShow(aLayer);
				lastLayer = aLayer;
			} else {
				superShow(aLayer);
				lastLayer = aLayer;	
			}
		}
	}
}

function menuHide(aLayer, bLayer, imgName) {
	if(preloadFlag&&objsCreated) {
		if (preloadFlag) {
			if (bLayer != null) {
				tertiaryHide();
				swapImage(aLayer, imgName, menuImages[5])
			}
			currTimeOut = setTimeout('superHide(lastLayer); lastLayer=null;	', 700);
		}
	}
}

var tertiaryLayer = null;

function tertiaryShow(aLayer) {
	if (aLayer == tertiaryLayer || tertiaryLayer == null) {
		if(terTimeOut!=null) {
			clearTimeout(terTimeOut);
			tertiaryLayer = aLayer;		
			superShow(aLayer);
		} else {
			tertiaryLayer = aLayer;
			superShow(aLayer);
		}
	} else {
		clearTimeout(terTimeOut);
		superHide(tertiaryLayer);
		superShow(aLayer);
		tertiaryLayer = aLayer;
	}
}

function tertiaryHide(thisLayer) {
	terTimeOut = setTimeout('superHide(tertiaryLayer);', 600);
}

//image swapper
function swapImage(layer,imgName, imgObj) {
	if (document.images) {
		if (document.layers && layer!=null) {
			eval('document.' + layer + '.document.images["' + imgName + '].src = ' + imgObj + '.src');
		} else {
			document[imgName].src = imgObj.src;
		}
	}
}

//fix nn resize problem
if (document.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize= function() {if(innerWidth!=origWidth||innerHeight!=origHeight)location.reload()}
}

// pop up window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}