// modal codevar gmodalMask = null;var gmodalContainer = null;var gPopFrame = null;var gReturnFunc;var gmodalIsShown = false;var gHideSelects = false;var gTabIndexes = new Array();// Pre-defined list of tags we want to disable/enable tabbing intovar gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");// If using Mozilla or Firefox, use Tab-key trap.if (!document.all) {	document.onkeypress = keyDownHandler;}/** * Initializes modal code on load. */function init() {	// Add the HTML to the body	theBody = document.getElementsByTagName('BODY')[0];	popmask = document.createElement('div');	popmask.id = 'modalMask';	popcont = document.createElement('div');	popcont.id = 'modalContainer';	popcont.innerHTML = '' +		'<div id="modalInner">' +			'<div id="modalTitleBar">' +				'<div id="modalTitle"></div>' +				'<div id="modalControls">' +					'<img src="img/moo/close.png" onclick="hideModal(false);" id="popCloseBox" />' +				'</div>' +			'</div>' +			'<iframe src="js/modal.html" scrolling="auto" frameborder="0" allowtransparency="true" id="modalFrame" name="modalFrame" width="100%" height="100%"></iframe>' +		'</div>';	theBody.appendChild(popmask);	theBody.appendChild(popcont);	gmodalContainer = $("modalContainer");	gmodalMask = $("modalMask");	gPopFrame = $("modalFrame");	// check to see if this is IE version 6 or lower. hide select boxes if so	// maybe they'll fix this in version 7?	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {		gHideSelects = true;	}	// Add onclick handlers to 'a' elements of class submodal or submodal-width-height	var elms = document.getElementsByTagName('a');	for (i = 0; i < elms.length; i++) {		if (elms[i].rel.indexOf("modal") == 0) {			// var onclick = 'function (){showModal(\''+elms[i].href+'\','+width+', '+height+', null);return false;};';			// elms[i].onclick = eval(onclick);			elms[i].onclick = function(){				// default width and height				var width = 480;				var height = 510;				// Parse out optional width and height from className				params = this.rel.split(' ');				if (params.length == 3) {					width = parseInt(params[1]);					height = parseInt(params[2]);				}				showModal(this.href,width,height,null); return false;			}		}	}	if (location.search.substring(1) == "request") showModal("request.php", 480, 530,null);}Window.onDomReady(init); /**	* @argument width - int in pixels	* @argument height - int in pixels	* @argument url - url to display	* @argument returnFunc - function to call when returning true from the window.	* @argument showCloseBox - show the close box - default true	*/function showModal(url, width, height, returnFunc, showCloseBox) {	// show or hide the window close widget	if (showCloseBox == null || showCloseBox == true) {		document.getElementById("popCloseBox").style.display = "block";	} else {		document.getElementById("popCloseBox").style.display = "none";	}	gmodalIsShown = true;	disableTabIndexes();	gmodalMask.style.display = "block";	gmodalMask.onclick = function(){hideModal(false)};	gmodalContainer.style.display = "block";	// calculate where to place the window on screen	centerModal(width, height);	var titleBarHeight = parseInt(document.getElementById("modalTitleBar").offsetHeight, 10);	gmodalContainer.style.width = width + "px";	gmodalContainer.style.height = (height+titleBarHeight) + "px";	setMaskSize();	// need to set the width of the iframe to the title bar width because of the dropshadow	// some oddness was occuring and causing the frame to poke outside the border in IE6	gPopFrame.style.width = parseInt(document.getElementById("modalTitleBar").offsetWidth, 10) + "px";	gPopFrame.style.height = (height) + "px";	// set the url	window.setTimeout(function(){gPopFrame.src = url}, "1000");	gReturnFunc = returnFunc;	// for IE	if (gHideSelects == true) {		toggleSelectBoxes();	}}//var gi = 0;function centerModal(width, height) {	if (gmodalIsShown == true) {		if (width == null || isNaN(width)) {			width = gmodalContainer.offsetWidth;		}		if (height == null) {			height = gmodalContainer.offsetHeight;		}		//var theBody = document.documentElement;		var theBody = document.getElementsByTagName("BODY")[0];		theBody.style.overflow = "hidden";		var scTop = parseInt(theBody.scrollTop,10);		var scLeft = parseInt(theBody.scrollLeft,10);		gmodalMask.style.top = scTop + "px";		gmodalMask.style.left = scLeft + "px";		setMaskSize();		//window.status = gmodalMask.style.top + " " + gmodalMask.style.left + " " + gi++;		var titleBarHeight = parseInt(document.getElementById("modalTitleBar").offsetHeight, 10);		var fullHeight = getViewportHeight();		var fullWidth = getViewportWidth();		gmodalContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px";		gmodalContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";		//alert(fullWidth + " " + width + " " + gmodalContainer.style.left);	}}addEvent(window, "resize", centerModal);//addEvent(window, "scroll", centerModal);window.onscroll = centerModal;/** * Sets the size of the modal mask. * */function setMaskSize() {	var theBody = document.getElementsByTagName("BODY")[0];	var fullHeight = getViewportHeight();	var fullWidth = getViewportWidth();	// Determine what's bigger, scrollHeight or fullHeight / width	if (fullHeight > theBody.scrollHeight) {		popHeight = fullHeight;	} else {		popHeight = theBody.scrollHeight;	}	if (fullWidth > theBody.scrollWidth) {		popWidth = fullWidth;	} else {		popWidth = theBody.scrollWidth;	}	gmodalMask.style.height = popHeight + "px";	gmodalMask.style.width = popWidth + "px";}/** * @argument callReturnFunc - bool - determines if we call the return function specified * @argument returnVal - anything - return value */function hideModal(callReturnFunc) {	gmodalIsShown = false;	var theBody = document.getElementsByTagName("BODY")[0];	theBody.style.overflow = "";	restoreTabIndexes();	if (gmodalMask == null) {		return;	}	gmodalMask.style.display = "none";	gmodalContainer.style.display = "none";	if (callReturnFunc == true && gReturnFunc != null) {		gReturnFunc(window.frames["modalFrame"].returnVal);	}	gPopFrame.src = 'js/modal.html';	// display all select boxes	if (gHideSelects == true) {		toggleSelectBoxes();	}}function keyDownHandler(e) {    if (gmodalIsShown && e.keyCode == 9)  return false;}function disableTabIndexes() {	if (document.all) {		var i = 0;		for (var j = 0; j < gTabbableTags.length; j++) {			var tagElements = document.getElementsByTagName(gTabbableTags[j]);			for (var k = 0 ; k < tagElements.length; k++) {				gTabIndexes[i] = tagElements[k].tabIndex;				tagElements[k].tabIndex="-1";				i++;			}		}	}}function restoreTabIndexes() {	if (document.all) {		var i = 0;		for (var j = 0; j < gTabbableTags.length; j++) {			var tagElements = document.getElementsByTagName(gTabbableTags[j]);			for (var k = 0 ; k < tagElements.length; k++) {				tagElements[k].tabIndex = gTabIndexes[i];				tagElements[k].tabEnabled = true;				i++;			}		}	}}function toggleSelectBoxes() {	for(var i = 0; i < document.forms.length; i++) {		for(var e = 0; e < document.forms[i].length; e++){			var elem = document.forms[i].elements[e];			if(elem.tagName == "SELECT") {				elem.style.visibility = (elem.style.visibility != "hidden") ? "hidden" : "visible";			}		}	}}/** * COMMON DHTML FUNCTIONS * These are handy functions I use all the time. * * By Seth Banks (webmaster at subimage dot com) * http://www.subimage.com/ * * Up to date code can be found at http://www.subimage.com/dhtml/ * * This code is free for you to use anywhere, just keep this comment block. *//** * X-browser event handler attachment and detachment * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html * * @argument obj - the object to attach event to * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc * @argument fn - function to call */function addEvent(obj, evType, fn){ if (obj.addEventListener){    obj.addEventListener(evType, fn, false);    return true; } else if (obj.attachEvent){    var r = obj.attachEvent("on"+evType, fn);    return r; } else {    return false; }}/** * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/ * * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com) * * Gets the full width/height because it's different for most browsers. */function getViewportHeight() {	if (window.innerHeight!=window.undefined) return window.innerHeight;	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;	if (document.body) return document.body.clientHeight;	return window.undefined;}function getViewportWidth() {	if (window.innerWidth!=window.undefined) return window.innerWidth;	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;	if (document.body) return document.body.clientWidth;	return window.undefined;}