/* Simple version detection */
var oldNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion, 10) < 5);
var newNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion, 10) >= 5);

var hilitedZoom = "none";

/* Show an object  */
function showObject(object) {
	var toshow, changeVis;
	if (newNS === true) {
		toshow = document.getElementById(object);
		toshow.style.visibility = "visible";
	}
	else {
		changeVis = ((oldNS === true) ? "document." + object + ".visibility = 'show';" : "document.all." + object + ".style.visibility = 'visible';");
		eval(changeVis);
	}
}

/* Hide an object */
function hideObject(object) {
	var toshow, changeVis;
	if (newNS === true) {
		toshow = document.getElementById(object);
		toshow.style.visibility = "hidden";
	}
	else {
		changeVis = ((oldNS === true) ? "document." + object + ".visibility = 'hide';" : "document.all." + object + ".style.visibility = 'hidden';");
		eval(changeVis);
	}
}

function hiliteZoom(objName) {
	if (hilitedZoom != ("none")) {
		if (hilitedZoom != objName) {
			hideObject(hilitedZoom);
		}
	}
	if (objName != "none") {
		showObject(objName);
	}
	hilitedZoom = objName;
}



// popup window
var windowObjectReference = null;
function showPopup(theURL, camurl, label, width, height) {
	if (width == 0) {
		width = 320;
	}
	
	winwidth = width + 40;

	if (height == 0) {
		height = 261;
	}
	
	winheight = height + 50;



	if (windowObjectReference == null || windowObjectReference.closed) {
		var popupfeatures = "width=" + winwidth + ",height=" + winheight + ",top=240,left=120,scrollbars=no,resizable=yes,toolbar=no,location=no,menubar=no";
		windowObjectReference = window.open(theURL, "WSDOTTrafficCamWindow", popupfeatures);
	}
	else {
		windowObjectReference.focus();
	};


	windowObjectReference.window.resizeTo(winwidth, winheight);
	var c = 0;
	var cam = windowObjectReference.document.getElementById("TrafficCameraImage");

	if (cam != null) {
		cam.src = camurl;
		cam.width = width;
		cam.height = height;
	}
	return false;
}


function camLoad() {
	var cam = document.getElementById("TrafficCameraImage");
	var url_param = gup("camurl");
	cam.src = url_param;
}

function gup(name) {
	name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regexS = "[\\?&]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return "";
	else
		return results[1];
}

function menuPosition(menuId) {
	var menuselection = document.getElementById(menuId);
	if (menuselection != null) {
		menuselection.className = 'menuSelected';
	}

//	do {
//		menuselection = menuselection.nextSibling;
//	} while (menuselection && menuselection.nodeType !== 1); // 1 == Node.ELEMENT_NODE
//	if (menuselection) menuselection.style.className = 'menuSelected';
}

function HighlightCamera(camdivid) {
	var camdiv = document.getElementById(camdivid);
	if (camdiv != null)
		camdiv.className = 'cameraIconSelected';
}
