

// POPUP WINDOWS
function popWindowMain(winURL, winName, winWidth, winHeight, winMenu, winResize, winScroll, winToolbar, winOffset) {

	var popWinMain = null;

	//Always Centre Window
	var winPosX = (window.screen.width/2)-(winWidth/2);
	var winPosY = (window.screen.height/2)-(winHeight/2);
	
	if (winOffset) {
		//Offset window from centre
		winPosX = winPosX + 40;
		winPosY = winPosY + 40;
	}

	//Build Window Features
	var winFeatures = "height=" + winHeight
					+ ", width=" + winWidth
					+ ", innerHeight=" + winHeight
					+ ", innerWidth=" + winWidth
					+ ", channelmode=0"
					+ ", dependent=0"
					+ ", directories=0"
					+ ", fullscreen=0"
					+ ", location=0"
					+ ", menubar=" + winMenu
					+ ", resizable=" + winResize
					+ ", scrollbars=" + winScroll
					+ ", status=1"
					+ ", toolbar=" + winToolbar
					+ ", screenx=" + winPosX
					+ ", screeny=" + winPosY
					+ ", left=" + winPosX
					+ ", top=" + winPosY;
					//Only use the following attributes with a signed script:
					//-------------------------------
					//+ ", hotkeys=1"
					//+ ", alwaysLowered=0"
					//+ ", alwaysRaised=0"
					//+ ", titlebar=0"
					//+ ", z-lock=0"
					//-------------------------------

	var reWork = new RegExp('object','gi');
	try {
		//Pop the window
		popWinMain = window.open(winURL, winName, winFeatures);
		if (window.focus) { popWinMain.focus(); }
	} catch(e) { }
	if(!reWork.test(String(popWinMain))) {
		//Failed to open - killed by pop-up blocker
		alert("This window could not be opened because you have a 'Pop-Up Blocker' enabled.\n\nPlease Disable your 'Pop-Up Blocker' and try again.");
	}
}


//Forms Default Button override (when return key is pressed)
function KeyDownHandler(e, buttonID) {

	var keyCode;

	if (window.event != 'undefined') {
		//IE & Others
		keyCode = e.keyCode;
	} else if(event.which){
		//NETSCAPE & FIREFOX
		keyCode = e.which;
	} else {
		// no event, so pass through
		return true;
	}

	//RETURN KEY
	if (keyCode == 13) {
		// cancel the default submit
		e.returnValue = false;
		e.cancel = true;
		// submit the form by programmatically clicking the specified button
		if (document.getElementById(buttonID) != null) {
			document.getElementById(buttonID).focus();
			document.getElementById(buttonID).click(); 
		}
	}
}

//Open links using javascript onclick event from CELL Rollovers
function openLink(control) {
	try {
		window.location=document.getElementById(control).href;
		return false;
	} catch (ex) {
		return true;
	}
}



// Navigation Menu
function showNavigationTabMenu() {
	//display content
	document.getElementById('tblNavigationTabMenu').style.visibility = "visible";
	return false;
}
function hideNavigationTabMenu() {
	//hide content
	document.getElementById('tblNavigationTabMenu').style.visibility = "hidden";
	return false;
}



// Tabbed Tables
function TabbedTable(objName) {
	this.name = objName;
	this.aTabs = new Array();
	this.aContents = new Array();
	//Populate array with tabID's
	this.add_tab = function(tabID) {
		var i = this.aTabs.length;
		this.aTabs[i] = tabID;
	}
	//Populate array with contentID's
	this.add_content = function(contentID) {
		var i = this.aContents.length;
		this.aContents[i] = contentID;
	}
	//Tab Selected
	this.select_tab = function(tabNumber) {
		//deselect all tabs
		for (i = 0; i < this.aTabs.length; i++) {
			if (document.getElementById(this.aTabs[i]) != null) {
				document.getElementById(this.aTabs[i]).className = "TabbedTable_Tab_Off";
			}
		}
		//hide all content
		for (i = 0; i < this.aContents.length; i++) {
			if (document.getElementById(this.aContents[i]) != null) {
				document.getElementById(this.aContents[i]).className = "TabbedTable_Content_Off";
			}
		}
		//highlight tab & show content of selected tab
		if (document.getElementById(this.aTabs[tabNumber]) != null) {
			document.getElementById(this.aTabs[tabNumber]).className = "TabbedTable_Tab_On";
		}
		if (document.getElementById(this.aContents[tabNumber]) != null) {
			document.getElementById(this.aContents[tabNumber]).className = "TabbedTable_Content_On";
		}
		return false;
	}
}
















// NO LONGER USED (TO DELETE) ################################
// ###########################################################



// Toggle Checkboxs (Used in Advanced Search)
function checkboxSelector(control,boolSelect) {
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = document.Form1;
	}
	else {
		theform = document.forms["Form1"];
	}
	for (var i=0; i < theform.length; i++) {
		var curElement = theform.elements[i];
		if (curElement.type=='checkbox' && curElement.name.indexOf(control) != -1 ) {
			//Found all checkboxes relating to dlControl
			if (boolSelect) {
				curElement.checked = true;
			} else {
				curElement.checked = false;
			}
		}
	}
	return false;
}

//Redirect Opener (used in popup windows)
function redirectOpener(url) {
	var winOpener;
	var isOpen = false;
	
	try {
		winOpener = window.top.opener.top;
	} catch(ex) {
		winOpener = null;
	}
	
	if (winOpener) {
		if (!winOpener.closed) {
			isOpen = true;
		}
	}
	if (isOpen) {
		winOpener.location.href = url;
		setTimeout('window.top.close()',25);
	} else {
		window.top.location.href = url;
	}
	return false;
}
