<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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];}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function printpage(){
	ht=navigator.appVersion;
	vers="5.";
	ie=0;
	var mac = (navigator.userAgent.indexOf("Mac") != -1);
	if (mac) {
		alert("Sorry, your browser doesn't support this feature. Please hit Command-P to print this page.");
	}
	else {
	<!-- Check to see if browser is IE 5 -->
	for (var i=0; i<ht.length; i++) {
		if (ht.substring(i,i+vers.length) == vers) {
		ie=1;
		}
	}
	
	bName = navigator.appName;
	if ((navigator.appName == "Netscape") || (ie==1)) {
		window.print() ;
	}
	else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 	CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
		}
	}
}

//*********************POPUP CALENDAR ****************************************
var calendarWindow = null;
var calendarColors = new Array();
calendarColors['bgColor'] = '#EBFAFE';
calendarColors['borderColor'] = '#333366';
calendarColors['headerBgColor'] = '#999999';
calendarColors['headerColor'] = '#FFFFFF';
calendarColors['dateBgColor'] = '#D1F1FB';
calendarColors['dateColor'] = '#004080';
calendarColors['dateHoverBgColor'] = '#FFFFFF';
calendarColors['dateHoverColor'] = '#8493A8';
var calendarFormat = 'm-d-y';
var calendarStartMonday = false;

function getCalendar(formField) 
{ 
    var cal_width = 200;
    var cal_height = 200;

    // IE needs less space to make this
    if ((document.all) && (navigator.userAgent.indexOf("Konqueror") == -1)) {
        cal_width = 200;
    }

    calendarTarget = formField;
    calendarWindow = window.open('../../content/global/calendar.html', 'dateSelectorPopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=0,dependent=no,width='+cal_width+',height='+cal_height);

    return false;
}

function killCalendar() 
{
    if (calendarWindow && !calendarWindow.closed) {
        calendarWindow.close();
    }
}
//functions for swapping items in listboxes ******************************	
function swap(placeFromVar,placeHereVar,removeIt) {
	// cycle through all items to see which are selected
	for (var i = 0; i < placeFromVar.length; i++) { 
		alreadyIn=false; 
		//if one is selected 
		if (placeFromVar.item(i).selected) {
			//cycle through all in destination list to make sure it is not there already 
			for (var j = 0; j < placeHereVar.length; j++) {
			placeHereVar.item(j).selected=false;
				if (placeHereVar.item(j).text==placeFromVar.item(i).text) {
					alreadyIn=true;
				}
			}
			//if it's not already in there, then put it in there 
			if (alreadyIn==false) {
				insertHere=1;
				insertHere=placeHereVar.length;
				placeHereVar.length=insertHere+1;
				placeHereVar.item(insertHere).text=placeFromVar.item(i).text;             
				placeHereVar.selectedIndex=insertHere;
				placeHereVar.selected=true; 

			}
		}
	}
	if(removeIt==true) {removeItem(placeFromVar);}
}

function removeItem(removeHereVar) {
	for (var i = 0; i < removeHereVar.length; i++) {          
		if (removeHereVar.item(i).selected) {
			removeHereVar.remove(i);   
			i=i-1;             
		}
	}
	// set focus to the list that you are removing from for the highlighting CSS effect
	removeHereVar.focus();
}
function selectall(thisobj){
numelements=thisobj.length;
  for(x=0; x<(thisobj.length); x++){
    thisobj.options[x].selected = "true";
  }
}

//*********************************************************
//toggles the selection of a list of checkboxes
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
		field[i].checked = true;}
		checkflag = "true";
}
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
	}
}


//*********************************************************
//type-to-jump-to-item textbox and listbox pair
array1 = new Array()
array2 = new Array()
array3 = new Array()
letterOn=1;
x=0;

function resetit(listboxname) {
	array1 = new Array()
	array2 = new Array()
	array3 = new Array()
	letterOn=1;
	x=0;
	listCount=listboxname.length;
	for(i=0; i<=listCount-1; i++){
		array1[i]=listboxname.item(i).text;
	}
}

function findit(listboxname, textboxname) {
	lettersEntered=textboxname.value;
	wordLength=lettersEntered.length;
	for(m=1; m<=wordLength; m++){
		for(i=0; i<=listCount-1; i++){
			if (lettersEntered.substring(letterOn-1, letterOn)==array1[i].substring(letterOn-1, letterOn)) {
				array2[x]=array1[i];
				x=x+1;	
			}
		}
		letterOn=letterOn+1;
		array1 = new Array();
		x=0;
		listCount=array2.length
		for(i=0; i<=listCount-1; i++){
			array1[i]=array2[i];
			highlight(listboxname);
			//alert (array1[i]);		
		}
		array2 = new Array();
	}
}

function highlight(listboxname) {
	found=false;
	k=0;
		while (found==false){		
			if (array1[0]==listboxname.item(k).text) {
				listboxname.item(k).selected=true;
				found=true;
			}
			k=k+1;
		}
}
//*********************************************************
//-->


//**************************SORTABLE TABLE *****************
currentCol = 0
previousCol = -1

function CompareAlpha(a, b) {
	if (a[currentCol] < b[currentCol]) { return -1; }
	if (a[currentCol] > b[currentCol]) { return 1; }
	return 0;
}

function CompareAlphaIgnore(a, b) {
	strA = a[currentCol].toLowerCase();
	strB = b[currentCol].toLowerCase();
	if (strA < strB) { return -1; }
	else {
		if (strA > strB) { return 1; }
		else { return 0; }
	}
}

function CompareDate(a, b) {
	// this one works with date formats conforming to Javascript specifications, e.g. m/d/yyyy
	datA = new Date(a[currentCol]);
	datB = new Date(b[currentCol]);
	if (datA < datB) { return -1; }
	else {
		if (datA > datB) { return 1; }
		else { return 0; }
	}
}

function CompareNumeric(a, b) {
	//window.alert ("CompareNumeric");
	numA = a[currentCol]
	numB = b[currentCol]
	if (isNaN(numA)) { return 0;}
	else {
		if (isNaN(numB)) { return 0; }
		else { return numA - numB; }
	}
}

function TableSort(myTBody, myCol, myType) {

	// Create a two-dimensional array and fill it with the table's content
	var mySource = myTBody;
	var myRows = mySource.childNodes.length;
	var myCols = mySource.childNodes.item(0).childNodes.length;
	currentCol = myCol;
	myArray = new Array(myRows);
	for (i=0; i < myRows; i++) {
		myArray[i] = new Array(myCols)
		for (j=0; j < myCols; j++) {
			myArray[i][j] = mySource.childNodes.item(i).childNodes.item(j).innerText;
			myArray[i][myCols+j+1]=mySource.childNodes.item(i).childNodes.item(j).innerHTML;
		}
	}

	if (myCol == previousCol) {
		myArray.reverse(); // clicked the same column as previously - reverse the sort
	}
	else { // clicked on a new column - sort as indicated

		switch (myType) {
			case "a":
				myArray.sort(CompareAlpha);
				break;
			case "ai":
				myArray.sort(CompareAlphaIgnore);
				break;
			case "d":
				myArray.sort(CompareDate);
				break;
			case "n":
				myArray.sort(CompareNumeric);
				break;
			default:
				myArray.sort()
		}
	}

	// Re-write the table contents
	for (i=0; i < myRows; i++) {
		for (j=0; j < myCols; j++) {
			mySource.childNodes.item(i).childNodes.item(j).innerHTML = myArray[i][myCols+j+1];
		}
	}

	previousCol = myCol; // remember the current sort column for the next pass
	return 0;
}

function toggleImage(imageObj) {
	if (imageObj.src.substring(imageObj.src.length-5, imageObj.src.length)=="n.gif") {//checking if image is sortDown
		imageObj.src="../../images/sortUp.gif"; //toggle IMG to sortUp
	} else {
		imageObj.src="../../images/sortDown.gif"; //other way around
	}	
}

//*********************************************************

//**************************EXPAND & COLLAPSE TABLE *****************
function expandCollapse(object) {
	arrow=object.firstChild.firstChild.nextSibling;
	arrowImgString=arrow.src.substring(arrow.src.length-5,arrow.src.length)
	tbodyTarget=object.parentElement.nextSibling;
	if (arrowImgString=="t.gif") {tbodyTarget.style.display='';arrow.src="../../images/arrowDown.gif" }
	else {tbodyTarget.style.display='none';	arrow.src="../../images/arrowRight.gif" }
}

//**********HIDE/SHOW SELECT FORM ELEMENTS (FOR LAYER OVERLAP PROBLEM****************
function hideSelects() {
for (var i=0; i<theForm.elements.length;i++){
	if(theForm.elements[i].type=="select-one") {
		theForm.elements[i].style.visibility="hidden";
	}
	}
}
function showSelects() {
for (var i=0; i<theForm.elements.length;i++){
	if(theForm.elements[i].type=="select-one") {
		theForm.elements[i].style.visibility="visible";
	}
}
}

function makeSelects() {
	j=0;
		for (var i=0; i<theForm.elements.length;i++){
			if(theForm.elements[i].type=="select-one") {
				selectElements[j]=theForm.elements[i]
				j=j+1;
			}
		}
}
	
function checkSelects(object) {
for (var i=0; i<selectElements.length;i++){
		if (object.getBoundingClientRect().right > selectElements[i].getBoundingClientRect().left && object.getBoundingClientRect().left < selectElements[i].getBoundingClientRect().right) {
			if (object.getBoundingClientRect().bottom > selectElements[i].getBoundingClientRect().top && object.getBoundingClientRect().top < selectElements[i].getBoundingClientRect().bottom) {
				selectElements[i].style.visibility="hidden";
			} else {
				selectElements[i].style.visibility="visible";
			}
		} else {
			selectElements[i].style.visibility="visible";
		}
	}
}
//*********************************************************
//**************************DRAGGABLE NOTES LAYER*****************
var locatorx
var locatory
var layerFocus
dragging=true;
selectElements = new Array
function handleMouseMove(object) {
	if (dragging==false) {
		checkSelects(Notes);
		document.onmousemove = null
		object.style.cursor="default"
		dragging=true;
	} else {
	//makeSelects();
	//hideSelects()
	layerFocus=object;
	locatorx=window.event.x-object.style.pixelLeft;
	locatory=window.event.y-object.style.pixelTop
	document.onmousemove = moveLayer;
	object.style.cursor="move"
	dragging=false;
	}
}

function moveLayer() {
    layerFocus.style.pixelLeft=window.event.clientX-locatorx;
	layerFocus.style.pixelTop=window.event.y-locatory;
	checkSelects(Notes);
}



//********* Confirm Popup Box

//********* Color rows with radio check

function confirmIt(alertString,destinationString) {
if (confirm(alertString) == true)
parent.location=destinationString;
else
return false;
}
//********* Confirm Popup Box


var oncell = "c0"
function chgColor(celno)
{
 var chgcell
 if (document.layers) { //browser is NN
	for (var i = 1; i < 5; i++)
	{
	chgcell = "window.document.c" + i + ".bgColor='white'";
	eval(chgcell);
	}
chgcell = "window.document."+ celno + ".bgColor='#E9C2B6'";
}
else // assume IE5
{for (var index =1; index < 5; index++)
 {
 	clrIt = "document.getElementById('c"+ index +"').bgColor='white'"; 
	eval(clrIt);
	}
chgcell = "document.getElementById('"+ celno + "').bgColor='#E9C2B6'";
}
 eval(chgcell);

}

function overm(celno)
{ var chgcell
 if (document.layers) { // browser is NN
	chgcell = "window.document."+ celno + ".bgColor='yellow'";
}
else //assume IE
{
	chgcell = "document.getElementById('"+ celno + "').bgColor='yellow'";
}
 eval(chgcell);
}

function outm(celno)
{ var chgcell
 if (document.layers) { // browser is NN
	chgcell = "window.document."+ celno + ".bgColor='white'";
}
else //assume IE
{chgcell = "document.getElementById('"+ celno + "').bgColor='white'";
}
 eval(chgcell);
}



//-->

//********* dropdown css
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
