var frontdoor = false;

function openLargeWindow(url) {
	// open a large (600 x 400) window
	if ( window.name == 'largeWindow' ) window.name = "";
	legalWindow = window.open(url, "largeWindow", "toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=600,height=420");
}

function openSmallWindow(url) {
	// open a small (340 x 320) window
	smallWindow = window.open(url,"smallWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=340,height=320");
}

// picture window
function pictPopUp(url,width,height) {
	if (width === undefined) width = '530';
	if (height === undefined) height = '604';
	winOpts = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=" + width + ",height=" + height ;
	//winOpts = "toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=" + width + ",height=" + height ;
	largeWindow = window.open(url,"largeWindow",winOpts);
	largeWindow.resizeTo(width,height) ;
	largeWindow.focus() ;
}

function returnToOpener(URLToOpen) {
	// set the main window to the new URL and send that window to the front
	if ((window.focus)&&(URLToOpen != "")&&(URLToOpen != null)) 
		window.opener.location = URLToOpen; 
	if (window.focus) 
		window.opener.focus(); 
}
	
function returnToOpenerCloseSelf(URLToOpen) {
	// set the main window to the new URL and send that window to the front and then close the calling window
	if ((window.focus)&&(URLToOpen != "")&&(URLToOpen != null)) 
		window.opener.location = URLToOpen; 
	if (window.focus) { 
		window.opener.focus(); 
		self.close();
	}
}

function setToFront() {
	// called by a window to move to the front when loaded with new content
    if( window.focus )  self.focus();
}

function openClassPage(pageName,uri) {
	winOpts = "location=0,directories=0,menubar=1,scrollbars=1,resizable=1" ;
	//winOpts = "toolbar=0,location=1,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=" + width + ",height=" + height ;
	ClassPage = window.open('/extras/pop-up-frameset.html?pageName='+pageName+'&uri='+uri,"ClassPage",winOpts);
	ClassPage.focus() ;
}


/* General Macromedia functions, pretty much take as is */

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Image Rotation Script Modification of code 
   by Sharon Paine (http://www.dyn-web.com/) 
   The initImgRotation() function and rotateImgObj.imagesPath variable are on the page 
   that uses the image rotation 
*/


rotateImgObjs = []; // holds all rotating image objects defined
// constructor 
function rotateImgObj(objectReference,speed) {
  this.speed=speed; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[objectReference]; // get reference to the image object
  this.index = rotateImgObjs.length; rotateImgObjs[this.index] = this;
  this.animString = "rotateImgObjs[" + this.index + "]";
}

rotateImgObj.prototype = {
  addImages: function() { // preloads images
    this.imgObj.imgs = [];
    for (var i=0; arguments[i]; i++) {
      this.imgObj.imgs[i] = new Image();
      this.imgObj.imgs[i].src = rotateImgObj.imagesPath + arguments[i];
    }
  },

  rotate: function() {
    if (this.ctr < this.imgObj.imgs.length-1) this.ctr++;
    else this.ctr = 0;
    this.imgObj.src = this.imgObj.imgs[this.ctr].src;
  }
}

// sets up rotation for all defined rotateImgObjs
rotateImgObj.start = function() {
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);                     
}

/* MODAL DIALOG FUNCTIONS */

function mPrompt(htmlTxt,btnArray,title,modalWidth) {
	// build content object
	d = document;
	contentObj = d.createElement("div");
	h1 = contentObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(title));

	// create a paragraph element to contain the txt argument
	msg = contentObj.appendChild(d.createElement("div"));
	msg.id = "modalText" ; 
	msg.innerHTML = htmlTxt;
	
	// build buttons 
	for (count in btnArray){
		btn = contentObj.appendChild(alertButton(btnArray[count][0],btnArray[count][1]));
	}
	
	// display the modal
	displayModal(contentObj,title,modalWidth);
}

function displayModal(contentObj,title,modalWidth) {
	if (!window.innerHeight) toggleSelectElements(true); // hide selects if IE, z-index bug
	toggleFlashVisibility(true);
	if (modalWidth == null) modalWidth = '320';
	if (title == null) title = 'Live Power Alert';	
	// shortcut reference to the document object
	d = document;
	bodyObj =  d.getElementsByTagName("body")[0];
	var windowInnerHeight = browserSafeDocHeight();

	// if the modalContainer object already exists in the DOM, bail out.
	displayPageMask() ;	
	if (!d.getElementById("modalContainer")) { 
		
		// create the modalContainer div as a child of the BODY element
		mObj = bodyObj.appendChild(d.createElement("div"));
	
		mObj.id = "modalContainer";
		 // make sure its as tall as it needs to be to overlay all the content on the page
		
		mObj.style.height = windowInnerHeight + "px";
	
		// create the DIV that will be the alert 
		modalObj = mObj.appendChild(d.createElement("div"));
		modalObj.id = "modalBox";
		// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	
		if(d.all && !window.opera) modalObj.style.top = document.documentElement.scrollTop + "px";
		modalObj.style.width = modalWidth + "px";
	
		// center the alert box
		modalObj.style.left = (d.documentElement.scrollWidth - modalWidth)/2 + "px";
		
		// attach the content object from whoever called us
		modalObj.appendChild(contentObj);
		modalObj.style.display = 'block';
	}
	setMaskSize();
	addEvent(window, 'resize', setMaskSize) ;
	d.getElementById("modalContainer").style.display = 'block';
}

function displayPageMask() { 
	if(document.getElementById("modalMask")) {
		document.getElementById("modalMask").style.display = 'block' ;
	} else {
		mMask = document.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
		mMask.id = "modalMask";
		mMask.style.height = browserSafeDocHeight() + "px";
		mMask.style.width = document.documentElement.scrollWidth + "px";
		if (!window.innerHeight) mMask.style.filter = 'alpha(opacity=60)'; // IE only 
	}
}

function resizeMask() {
	if (window.innerHeight) windowInnerHeight = window.innerHeight; // IE
	else windowInnerHeight = (document.documentElement.offsetHeight - 4); 
	document.getElementById('modalMask').style.height = windowInnerHeight + "px";
	document.getElementById('modalMask').style.width = document.documentElement.scrollWidth + "px";
	document.getElementById('modalContainer').style.height = windowInnerHeight + "px";
	document.getElementById('modalContainer').style.width = document.documentElement.scrollWidth + "px";
}


function setMaskSize() {
	document.getElementById('modalMask').style.height = browserSafeDocHeight() + "px";
	document.getElementById('modalMask').style.width = document.documentElement.scrollWidth + "px";
	document.getElementById('modalContainer').style.height = browserSafeDocHeight() + "px";
	document.getElementById('modalContainer').style.width = document.documentElement.scrollWidth + "px";
}

function hidePageMask() {
	document.getElementById("modalMask").style.display = 'none' ;
}

function mConfirm(message,action,windowTitle) {
	btnArray = new Array(new Array("OK",action),new Array("Cancel","removeCustomAlert()"));
	mPrompt(message,btnArray,windowTitle);
}

function mAlert(message,windowTitle) {
	if (typeof windowTitle == 'undefined') windowTitle = "Alert";
	btnArray = new Array(new Array("OK","removeCustomAlert()"));
	mPrompt(message,btnArray,windowTitle);
}

function alertButton(btnText, btnAction, btnID) {
	btnObject = d.createElement("div");
	btnObject.className = "textbuttonright";
	innerBtnObject = btnObject.appendChild(d.createElement("a"));
	if (btnID != null) innerBtnObject.id = btnID;
	btnText = padText(btnText);
	innerBtnObject.innerHTML = btnText;
	innerBtnObject.href = "javascript:"+btnAction;
	return btnObject;
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
	hidePageMask() ;
	removeEvent(window, 'resize', setMaskSize) ;
	if (!window.innerHeight) toggleSelectElements(false);
	toggleFlashVisibility(false);
}

function hideModal() {
	document.getElementById('modalContainer').style.display = 'none';
	document.getElementById('modalMask').style.display = 'none';
}

function showModal() {
	document.getElementById('modalContainer').style.display = 'block';
	document.getElementById('modalMask').style.display = 'block';
}

/**
* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*/

function toggleSelectElements(hide) {
	var visibilityState = (hide) ? "hidden": "visible";
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
				document.forms[i].elements[e].style.visibility = visibilityState;
			}
		}
	}
}

function toggleFlashVisibility(hide) {
	var visibilityState = (hide) ? "hidden": "visible";
	objects = document.getElementsByTagName('object');
	for(var count = 0; count < objects.length; count++) {
		objects[count].style.visibility = visibilityState;
	}
}

function browserSafeDocHeight() {
	docHeight = Math.max(document.body.scrollHeight,document.body.offsetHeight) ;
	if (window.innerHeight) {  // all except Explorer
		winHeight = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		winHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		winHeight =  document.body.clientHeight;
	}
	return Math.max(winHeight,docHeight); 
}

function padText(btnText) {
	padNum = 12;
	btnSize = btnText.length;
	if (btnSize >= padNum) return btnText;
	padBy = parseInt((padNum - btnSize - 2)/2);
	for(count = 0; count < padBy; count++) btnText = '&nbsp;'+btnText+'&nbsp;';
	return btnText;
}

// trims white space from the beginning and the end of a string
function trim(aString) {
	return String(aString).replace(/^\s*/, "").replace(/\s*$/, "") ;
}

// Event handling scripts

function addEvent(element, type, handler) {
	if (element.addEventListener) {
		element.addEventListener(type, handler, false);
	} else {
		// assign each event handler a unique ID
		if (!handler.$$guid) handler.$$guid = addEvent.guid++;
		// create a hash table of event types for the element
		if (!element.events) element.events = {};
		// create a hash table of event handlers for each element/event pair
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};
			// store the existing event handler (if there is one)
			if (element["on" + type]) {
				handlers[0] = element["on" + type];
			}
		}
		// store the event handler in the hash table
		handlers[handler.$$guid] = handler;
		// assign a global event handler to do all the work
		element["on" + type] = handleEvent;
	}
};
// a counter used to create unique IDs
addEvent.guid = 1;

function removeEvent(element, type, handler) {
	if (element.removeEventListener) {
		element.removeEventListener(type, handler, false);
	} else {
		// delete the event handler from the hash table
		if (element.events && element.events[type]) {
			delete element.events[type][handler.$$guid];
		}
	}
};

function handleEvent(event) {
	var returnValue = true;
	// grab the event object (IE uses a global event object)
	event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
	// get a reference to the hash table of event handlers
	var handlers = this.events[event.type];
	// execute each event handler
	for (var i in handlers) {
		this.$$handleEvent = handlers[i];
		if (this.$$handleEvent(event) === false) {
			returnValue = false;
		}
	}
	return returnValue;
};

function fixEvent(event) {
	// add W3C standard event methods
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
};

fixEvent.preventDefault = function() {
	this.returnValue = false;
};

fixEvent.stopPropagation = function() {
	this.cancelBubble = true;
};

/* this is here to extend the navigation bar to the bottom of the screen */

addEvent(window, 'load', drawPage) 

function drawPage() {
	if (document.getElementById('sidebar')) setElementHeightsMax() ;
	if (frontdoor != true) setMacBkgndOpacity();
	initSectionNav(); // sets rollover for section nav
}

function setMacBkgndOpacity() {
	if (navigator.platform.indexOf("Mac")  > -1) {
		document.getElementById('container').style.background = "white url(/img/page-elements/content-bkgnd-mac.png) top right no-repeat";
	}
}

function setElementHeightsMax() {
	var sideObj = document.getElementById("sidebar");
	var mainObj = document.getElementById("main");
	var sideHeight = sideObj.offsetHeight;
	var mainHeight = mainObj.offsetHeight;
	if (sideHeight < mainHeight) {
		sideObj.style.height = (mainHeight + 17) + 'px';
	} else {
		mainObj.style.height = (sideHeight - 34) + 'px';
	}
}

function initSectionNav() {
	var count = 0; // make count local
	var link_array = document.getElementById('section_nav').getElementsByTagName("a") ;
	// sets rollover for section nav
	// get objects
	for (count = 0; count < link_array.length; count++) {
		addEvent(link_array[count], 'mouseover', sectionnav_rollon);
		addEvent(link_array[count], 'mouseout', sectionnav_rolloff);
	}
}

/* Rollovers for the section nav */

function sectionnav_rollon(evt) {
	var eventObj;
	if (evt.target) eventObj = evt.target;
	else if (evt.srcElement) eventObj = evt.srcElement;
	//alert('name = '+eventObj.name + '  id= ' + eventObj.id) ;
	switchImage(eventObj,eventObj.id+"_on") ;
}

function sectionnav_rolloff(evt) {
	var eventObj;
	if (evt.target) eventObj = evt.target;
	else if (evt.srcElement) eventObj = evt.srcElement;
	//alert('name = '+eventObj.name + '  id= ' + eventObj.id) ;
	switchImage(eventObj,eventObj.id+"_off") ;
}

function switchImage(object,imageName) {
    object.src = eval(imageName + ".src");
}

function theDate() {
	var mydate=new Date() ;
	var year=mydate.getYear() ;
	var day=mydate.getDay() ;
	var month=mydate.getMonth() ;
	var daym=mydate.getDate() ;
	if (year < 1000) year += 1900 ;
	if (daym<10) daym="0"+daym;
	var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	return montharray[month] + ' ' + daym + ', ' + year ;
}

function displayTransObj(src,alt,height,width,id,opacity,bump_mac) {
	document.write('<img src="'+src+'" alt="'+alt+'" height="'+height+'" width="'+width+'" id="'+id+'" />') ;
	setOpacity(document.getElementById(id),opacity,bump_mac) ;
}

function setOpacity(obj,value,bump_mac) {
	if (bump_mac && (navigator.platform.indexOf("Mac")  > -1)) value = (value * 3);
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}

/*	AJAX Inline Contact Form with a PHP back-end */

// CONSTANTS
var cntcXMLdata = '' ;
var recipient = '';
var testDontSend = true ; // For Debug Only

function doSendMessage() {
	if ( fieldsValid('cForm', false) ) {
		sendContactEmail();
	}
}

function sendContactEmail() {
	showContactTimer() ; // quickly begin the load bar
	who_to = recipient;
	name = escape(document.getElementById('cntcName').value);
	email = escape(document.getElementById('cntcEmail').value) ;
	subject = escape(document.getElementById('cntcSubject').value) ;
	message = escape(document.getElementById('cntcMessage').value) ;
	page_URI = escape(location.pathname) ;
	agent.call("/dynamic/contact.php","sendMessage","messageReturn",who_to,name,email,subject,message,page_URI) ;
}

function messageReturn(returnData) {
    // page loaded "complete"
    if (returnData['error'] == 'true') {
		mAlert(returnData['message']);
	} else {
		hideContactTimer(returnData['message']);
	}
}

function convertEscapesToEqvs(string) {
	// convert (&, +, =) to string equivs. Needed so URL encoded POST won't choke.
	string = string.replace(/&/g,"**am**");
	string = string.replace(/=/g,"**eq**");
	string = string.replace(/\+/g,"**pl**");
	return string;
}

function showContactTimer() {
	document.getElementById('loadBar').style.display = 'block';
	document.getElementById('contactFormArea').style.display = 'none';
	//sentTimer = setTimeout("hideContactTimer()",6000);
}

function hideContactTimer(message) {
	// Hide the load bar alas! Done Loading
	if (message == undefined) message = "There was an unknown error sending your message. Please let the frontoffice know that you recieved this error." ;
	document.getElementById('loadBar').style.display = "none";
	document.getElementById('emailSuccess').innerHTML = message ;
	document.getElementById('responseMessage').style.display = "block";
	// clear the subject
	document.getElementById('cntcSubject').value = '';
	// clear the message
	document.getElementById('cntcMessage').value = '';
	// leave the name and e-mail in case of multiples. 
}

function resetModal() {
	document.getElementById('responseMessage').style.display = 'none';
	document.getElementById('contactFormArea').style.display = 'block';
}

/* BUILDING THE DIALOG */

function returnFieldObj(labelText, idName, elmLength, elmSize, validTest, remediationText ) {
	fieldObj = d.createElement("div");
	fieldObj.className = "field_element";
	labelObj = fieldObj.appendChild(d.createElement("label"));
	labelObj.setAttribute("for",idName);
	labelObj.appendChild(d.createTextNode( labelText ));
	inputObj = fieldObj.appendChild(d.createElement("input"));
	inputObj.id = idName;
	inputObj.name = idName;
	inputObj.type = "text";
	if (elmLength != '') inputObj.setAttribute('maxLength',elmLength); // maxLength must have a capital L to work in IE
	if (elmSize != '') inputObj.size = elmSize ;
	addEvent(inputObj,"focus",evt_open_field) ;
	addEvent(inputObj,"blur",evt_close_field) ;
	if (validTest) {
		inputObj.setAttribute('valid',validTest);
		fieldObj.appendChild(returnRemediationObj(idName, remediationText));
	}
	return fieldObj ;
}

function returnRemediationObj( idName, theText ) {
	remediationObj = d.createElement("div") ;
	remediationObj.id = idName+'_error' ;
	remediationObj.className = 'form_error_msg' ;
	remediationObj.appendChild(d.createTextNode(theText));
	return remediationObj;
}

function send_message(who_to) {
	recipient = who_to;
	var title = 'Send a message to '+who_to;
	// build content object
	d = document;
	if (!document.getElementById('message_form')) {
		/* dynamicly attach field handling script */
		scriptObj = d.createElement('script');
		scriptObj.src = "/tds-field-functions.js";
		scriptObj.type = "text/javascript";
		document.getElementsByTagName('head')[0].appendChild(scriptObj);
		/* start building the form */
		contentObj = d.createElement("div");
		contentObj.id = "message_form" ;
		h1 = contentObj.appendChild(d.createElement("h1"));
		/* build the hidden load bar */
		loadBar =  contentObj.appendChild(d.createElement("div"));
		loadBar.id = "loadBar";
		loadBarLineOne = loadBar.appendChild(d.createElement("p"));
		loadBarImage = loadBarLineOne.appendChild(d.createElement("img"));
		loadBarImage.src = '/img/page-elements/busy_blue.gif';
		loadBarImage.alt = "Loading...";
		loadBarImage.title = "Sending Email";
		loadBarImage.align = 'absmiddle';
		loadBarImage.hspace = "6";
		loadBarLineOne.appendChild(d.createTextNode( "Sending your message. Hold on just a sec ..." ));
		/* build the feedback message */
		responseBar = contentObj.appendChild(d.createElement("div"));
		responseBar.id = "responseMessage";
		feedback =  responseBar.appendChild(d.createElement("p"));
		feedback.id = "emailSuccess";
		feedback.appendChild(d.createTextNode( "ERROR: Script did not finish." ));
		andNext =  responseBar.appendChild(d.createElement("p"));
		btn = andNext.appendChild(alertButton("Done", "removeCustomAlert()"));
		/* build form element */
		contactDivObj =  contentObj.appendChild(d.createElement("div"));
		contactDivObj.id = "contactFormArea";
		formObj =  contactDivObj.appendChild(d.createElement("form"));
		formObj.action = "" ;
		formObj.method = "post" ;
		formObj.id = "cForm" ;
		formObj.name = "cForm" ;
		/* create Name field */
		fldOne = formObj.appendChild(returnFieldObj("Your Name:", "cntcName", 40, 30, 'not_empty', "Please tell us your full name." ));
		/* create Email field */
		fldTwo = formObj.appendChild(returnFieldObj("Your Email: (Example: name@domain.com)", "cntcEmail", 80, 30, 'is_email_required', "A valid email address is required so that we can reply to your message." ));
		/* create Regards field */
		fldThree = formObj.appendChild(returnFieldObj("Regarding:", "cntcSubject", 60, 30, 'not_empty', "Please provide a subject for your message." ));
		/* create Message text area */
		fldFour = formObj.appendChild(d.createElement("div"));
		fldFour.className = "field_element";
		labelObj = fldFour.appendChild(d.createElement("label"));
		labelObj.setAttribute("for","cntcMessage");
		labelObj.appendChild(d.createTextNode( "Message:" ));
		textAreaObj = fldFour.appendChild(d.createElement("TEXTAREA"));
		textAreaObj.id = "cntcMessage";
		textAreaObj.name = "cntcMessage";
		textAreaObj.rows = "5";
		textAreaObj.setAttribute('valid','not_empty');
		addEvent(textAreaObj,"focus",evt_open_field) ;
		addEvent(textAreaObj,"blur",evt_close_field) ;
		fldFour.appendChild(returnRemediationObj( "cntcMessage","Please enter your message in the field above." ));
	
		btnOne = formObj.appendChild(alertButton("Send Message", "doSendMessage()",'save_dialog_btn'));
		btnTwo = formObj.appendChild(alertButton("Cancel", "removeCustomAlert()"));
	} else {
		d.getElementById('loadBar').style.display = 'none';
		d.getElementById('responseMessage').style.display = 'none';
		d.getElementById('contactFormArea').style.display = 'block';
	}
	h1.innerHTML = title;
	
	// display the modal
	displayModal(contentObj,title,340);
	
	// setDialogSaveBtn();
	
	document.getElementById('cntcName').focus();
}

// Opening, Closing and Highlighting Fields

function open_field(eventObj) {
	saved_class = eventObj.className;
	eventObj.className = 'active '+ saved_class;
	return true;
}

function close_field(eventObj) {
	unhilightField(eventObj);
	if (usingAJAXbackend) save_field(eventObj);
}

function evt_open_field(evt) {
	var eventObj;
	if (evt.target) eventObj = evt.target;
	else if (evt.srcElement) eventObj = evt.srcElement;
	saved_class = eventObj.className;
	eventObj.className = 'active '+ saved_class;
	return true;
}

function evt_close_field(evt) {
	var eventObj;
	if (evt.target) eventObj = evt.target;
	else if (evt.srcElement) eventObj = evt.srcElement;
	unhilightField(eventObj);
	if (usingAJAXbackend) save_field(eventObj);
}

function unhilightField(fieldObj) {
	fieldObj.className = saved_class;
	saved_class = '';
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext) {
	if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext+'?'); 
	else
		return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) { 
	var str = '<object ';
	for (var i in objAttrs)
		str += i + '="' + objAttrs[i] + '" ';
		str += '>';
	for (var i in params)
		str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		str += '<embed ';
	for (var i in embedAttrs)
		str += i + '="' + embedAttrs[i] + '" ';
		str += ' ></embed></object>';
	document.write(str);
}

function AC_FL_RunContent() {
  var ret = AC_GetArgs( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
  var ret = AC_GetArgs( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2) {
    var currArg = args[i].toLowerCase();    
    switch (currArg) {	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//load the rollover graphics for the section nav

snav_about_tehiyah_on = new Image();
snav_about_tehiyah_on.src = "/img/page-elements/snav_about_tehiyah_on.gif";
snav_about_tehiyah_off = new Image();
snav_about_tehiyah_off.src = "/img/page-elements/snav_about_tehiyah.gif";

snav_admissions_on = new Image();
snav_admissions_on.src = "/img/page-elements/snav_admissions_on.gif";
snav_admissions_off = new Image();
snav_admissions_off.src = "/img/page-elements/snav_admissions.gif";

snav_learning_at_tehiyah_on = new Image();
snav_learning_at_tehiyah_on.src = "/img/page-elements/snav_learning_at_tehiyah_on.gif";
snav_learning_at_tehiyah_off = new Image();
snav_learning_at_tehiyah_off.src = "/img/page-elements/snav_learning_at_tehiyah.gif";

snav_community_on = new Image();
snav_community_on.src = "/img/page-elements/snav_community_on.gif";
snav_community_off = new Image();
snav_community_off.src = "/img/page-elements/snav_community.gif";

snav_supporting_tehiyah_on = new Image();
snav_supporting_tehiyah_on.src = "/img/page-elements/snav_supporting_tehiyah_on.gif";
snav_supporting_tehiyah_off = new Image();
snav_supporting_tehiyah_off.src = "/img/page-elements/snav_supporting_tehiyah.gif";
