function checkConfirm(confirm_what) {
	if (confirm_what == "cancel") {
		if (window.confirm("Are you sure you want to cancel?")) {
			window.back();
		}
	}
	if (confirm_what == "reset") {
		if (window.confirm("Are you sure you want to clear the form?")) {
			this.form.reset();
			this.form.elements[0].focus();
		}
	}
}
function confirmation(message, yesAction, noAction) {
var answer = confirm(message)
if (answer){
alert("yes action")
yesAction;
}
else {
alert("no action");
noAction;
}
}


function viewPic(URL,winName,features) {
	 window.open(URL,winName,features);
	}
	
function viewMovie(URL) {
	viewpic=window.open(URL,"screenshot","toolbar=no,width=415,height=400,status=no,scrollbars=yes,resize=no,menubar=no");
	}
	
function checkform(form) {
	if (isFilled(form.NAME) == false) 
	{
	alert ("Please enter your name.");
	form.NAME.focus();
	return false;
	}
	if (isFilled(form.TITLE) == false) 
	{
	alert ("Please enter your job title.");
	form.TITLE.focus();
	return false;
	}
	if (isFilled(form.COMPANY) == false) 
	{
	alert ("Please enter your company name.");
	form.COMPANY.focus();
	return false;
	}
	if (isFilled(form.ADDR1) == false) 
	{
	alert ("Please enter your address.");
	form.ADDR1.focus();
	return false;
	}
	if (isFilled(form.CITY) == false) 
	{
	alert ("Please enter your city.");
	form.CITY.focus();
	return false;
	}
	if (isFilled(form.STATE) == false) 
	{
	alert ("Please enter your state.");
	form.STATE.focus();
	return false;
	}
	if (isFilled(form.ZIP) == false) 
	{
	alert ("Please enter your zip code.");
	form.ZIP.focus();
	return false;
	}
	if (isFilled(form.EMAIL) == false) 
		{
		alert ("Please enter your e-mail address.");
		form.EMAIL.focus();
		return false;
		}	
	if (isChecked(form.OtherRequest) == true && isFilled(form.OtherReqExplanation) == false)
		{
		alert ("Please explain your selection of Other.");
		form.OtherRequest.focus();
		return false;
		}
	if (isChecked(form.Demo) == false 
		&& isChecked(form.OtherRequest) == false 
		&& isChecked(form.EMSOF) == false
		&& isChecked(form.EMSDP) == false
		&& isChecked(form.EMSIR) == false
		&& isChecked(form.TDP) == false
		&& isFilled(form.Comments) == false) 
		{
		alert("You have not told us what information you are interested in receiving.");
		form.Demo.focus();
		return false;
		}
	return true
}
	
function isChecked(form){
	if (form.checked == false)
		return false;
		else return true;
	}
			
function isFilled(elm) {
	if (elm.value == ""||
		elm.value == null)
	return false;
	else return true;
	}
function openfocus(form) {
	form.NAME.focus();
	}
	
// Cross-browse event handling from Professional Javascript for Web Developers 1st Ed. pg 292
var EventUtils = new Object; 

EventUtils.addEventHandler = function(oTarget, sEventType, fnHandler) {
	if (oTarget.addEventListener) { // DOM Compatible browsers (like firefox)
		oTarget.addEventListener(sEventType, fnHandler, false);
	} else if (oTarget.attachEvent) {  // for IE 
		oTarget.attachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget.attachEvent("on" + sEventType) = fnHandler;
	} 
}

EventUtils.removeEventHandler = function(oTarget, sEventType, fnHandler) {
	if (oTarget.removeEventListener) {
		oTarget.removeEventListener(sEventType, fnHandler, false);
	} else if (oTarget.detachEvent) {
		oTarget.detachEvent("on" + sEventType, fnHandler);
	}
}

EventUtils.getEvent = function() {
	if (window.event) { //for IE
		return this.formatEvent(window.event);
	} else {
		return EventUtils.getEvent.caller.arguments[0];
	}
}

EventUtils.formatEvent = function(oEvent) {
	
	if (window.event) {
		oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
		oEvent.eventPhase = 2
		oEvent.isChar = (oEvent.charCode > 0);
		oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
		oEvent.pageY = oEvent.clientY + document.body.scrollTop;
		oEvent.preventDefault = function () {
			this.returnValue = false;
		}
		
		if (oEvent.type == "mouseout") {
			oEvent.relatedTarget = oEvent.toElement;
		} else if (oEvent.type == "mouseover") {
			oEvent.relatedTarget = oEvent.fromelement;
		}
		
		oEvent.stopPropagation = function () {
			this.cancelBubble = true;
		}
		
		oEvent.target = oEvent.srcElement
		oEvent.timeStamp = (new Date()).getTime();
	
	}
	return(oEvent);
}

// This function overloads the String class to add a much needed trim method
String.prototype.trim = function() {
	var regexExtraSpace = /^\s*(.*?)\s*$/;
	return this.replace(regexExtraSpace , "$1");
}

function isVisible(o){
	if (o.className.indexOf("hidden") >= 0) {
		return false;
	} else {
		return true;
	}
}
function toggle(o){
	function hide(o){
		o.className += " hidden ";
	}
	function show(o){
		o.className = o.className.replace("hidden", "").trim();
	}
	if (isVisible(o) == true) {
		hide(o);
	} else {
		show(o);
	}
}

function collapsibleUL(oUL){
	var oLink = oUL.parentNode.getElementsByTagName("a")[0];
	EventUtils.addEventHandler(oLink, 'click', function(){
		toggle(oUL);
		var oEvent = EventUtils.getEvent();
		oEvent.stopPropagation();
		oEvent.preventDefault();
  	});
}

function initNavigationUL () {
	var oULArray = document.getElementsByTagName("ul");
	for (var i = 0; i < oULArray.length; i++) {
		var oUL = oULArray[i];
		if (oUL.className.indexOf("collapsible") >= 0) {
			if (isVisible(oUL) == true) {
				toggle(oUL);
			}
			for (var j = 0; j < oUL.childNodes.length; j++) {
				var li = oUL.childNodes[j];
				if ((window.location.pathname.length > 1) &&
					(li.firstChild != null) &&
					(li.firstChild.href.indexOf(window.location.hostname + window.location.pathname + window.location.search) >= 0)) {
					toggle(oUL);
					break;
				}
			}
			collapsibleUL(oUL);
		}
	}
}

EventUtils.addEventHandler(window, 'load', initNavigationUL);