//GENERIC DROP DOWN NAVIGATION
function goDropDown(strForm,strElement) {
	var objElement = eval('document.' + strForm + '.' + strElement);
	var objElementValue = objElement[objElement.selectedIndex].value;
	if (objElementValue != "") {
		window.location = objElementValue;
	}
}

//RETURN FROM CHILD WINDOW
function returnParent(strURL) {
	if(window.opener) {
		window.opener.location = strURL;
	}
	else if(window.parent) {
		window.parent.location = strURL;
	}
	window.close();
}

//GLOBAL POPUP
var objChildWindow;
function doChildWindow(strURL, objWin, strOptions) {
	//check for open windows and close them
	if (objChildWindow && objChildWindow.closed == false) {
		objChildWindow.close();

		objChildWindow = window.open(strURL, objWin, strOptions);
		objChildWindow.focus();
	}
	else {
		objChildWindow = window.open(strURL, objWin, strOptions);
		objChildWindow.focus();
	}
}

function openPrintPage(strURL) {
	var strOptions;
	strOptions = "toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,left=100,top=100,width=620,height=500";

	doChildWindow(strURL, 'child_window', strOptions);
	objChildWindow.focus();
}

//GLOBAL NEW WINDOW
function openNewWin(strURL, intWidth, intHeight) {
	var strOptions;
	//check for parameters and set defaults
	if ((intWidth == '') || (intHeight == '')) {
		strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=615,height=345";
	}
	else {
		intWidth += 45;
		intHeight += 45;
		strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=" + intWidth + ",height=" + intHeight;
	}
	doChildWindow(strURL, 'child_window', strOptions);
	objChildWindow.focus();
}

//VIEW LARGE IMAGE
function openNewImgWin(strImg, strTitle, intWidth, intHeight) {
	var strOptions;
	//check for parameters and set defaults
	if ((intWidth == '') || (intHeight == '')) {
		strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=400,height=400";
	}
	else {
		intWidth += 45;
		intHeight += 45;
		strOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100,width=" + intWidth + ",height=" + intHeight;
	}
	//check for browser and execute
	if (!(objBrowser.bMacNN4)) {
		doChildWindow('', 'child_window', strOptions);
		var strHTML;
		strHTML  = '<html><head><title>Bose&#174; ' + strTitle + '</title></head><body marginwidth="10" marginheight="10" leftmargin="10" topmargin="10" alink="#999999" vlink="#666666" bgcolor="#ffffff"><font face="verdana" size="1">';
		strHTML += '<div align="center"><img src="' + strImg + '" /></div>';
		strHTML += '<div align="right"><a title="Close window" href="javascript:window.close();"><font color="#000000">Close window</font></a></div></font></body></html>';
		objChildWindow.document.open();
		objChildWindow.document.write(strHTML);
		objChildWindow.document.close();
	}
	else {
		doChildWindow(strImg, 'child_window', strOptions);
	}
	//focus the new window
	objChildWindow.focus();
}

//EMAIL NEWS LETTER EMAIL VALIDATE
function checkInputEmail(theForm) {
	if ((theForm.enews.value=="") || (theForm.enews.value.indexOf("@") == -1) || (theForm.enews.value.indexOf(".") == -1)) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}

//SEARCH FIELD VALIDATE
function checkInputSearch(theForm) {
	if ((theForm.words) && (theForm.words.value=="")) {
		alert("Please enter your search criteria.");
		return false;
	}
	return true;
}

//PRINT FUNCTION
function doPrint() {
	window.print();
}

//IMAGE PRELOAD
//imgObj - the name of the object associated with the image 
//imgSrc - the source filename (url) of the image
function doPreload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj + ' = new Image()');
		eval(imgObj + '.src = "' + imgSrc + '"');
	}
}

//IMAGE EVENT FUNCTION
//layer - layer name if provided otherwise blank ''
//imgName - name or id of event image
//imgObj -  name or id of the preloaded image object
var glayer;
var gimgName;
var gimgObj;

function imgSwap(layer,imgName,imgObj) {
var layer;
var imgName;
var imgObj;
glayer = layer;
gimgName = imgName;
gimgObj = imgObj;
	if(document.images) {
		//NN 4.x DOM
		if(document.layers && layer != "") {
			eval('document.' + layer + '.document.images["' + imgName + '"].src = ' + imgObj + '.src');
		}
		//NN6 Gecko subroutine
		else if((objClient.application == "nn") && (objClient.version >= 5)) {
			//setTimeout("imgSwapTimeOut()",1);
			imgSwapTimeOut();
		}
		else {
			document.images[imgName].src = eval(imgObj + ".src");
		}
	}
}
//NN Gecko subroutine
function imgSwapTimeOut() {
	document.images[gimgName].src = eval(gimgObj + ".src");
}

//SUBMIT A FORM FUNCTION
//theForm - the name or id of the form to be submitted
//validateFunction - the name of the client side validation function to be called.
function submitForm(theForm, validateFunction) {
	document.forms[theForm].submit();
	if (validateFunction != "") {
		eval(validateFunction + '(' + theForm + ')');
	}
}

//HISTORY NAVIGATION
//i - the place in the history array ( can be a negative | positive number )
function goHistory(i) {
	var i;
	history.go(i);
}

//CONFIRM WINDOW GENERIC
//strMessage - the confirmation message to be displayed
function confirmDialogue(strMessage) {
		if (window.confirm(strMessage)) {
			return true;
		}
	return false;
}

// DISABLE SUBMIT BUTTON ON FORM SUBMISSION
// bFormSubmitted - indicates whether user has already submitted the form
var bFormSubmitted = false;

function disableSubmitButton() {
	if (bFormSubmitted) {
		return false;
	} 
	else {	
		bFormSubmitted = true;
	    return true;
	}
}

//GENERIC COOKIE CHECK
function checkForCookie(strCookieName) {
	
	//get all cookies
	var objAllCookies = document.cookie;

	//does cookie exist?
	var checkPos = objAllCookies.indexOf(strCookieName);
	
	if (checkPos != -1) {
		return true;
	}
	
	return false;
}

