String.prototype.toTitleCase = function() {
var words = this.toLowerCase().split(" ");
for(var i=0;i<words.length;i++)
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
return words.join(" ");
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function getInnerText(node,ignorewhitespace)
{
 var text = "";
 // if the node has children, loop through them
 if(node.hasChildNodes())
 {
  var children = node.childNodes;
  for(var i=0; i<children.length; i++)
  {
   // if node is a text node append it
   if(children[i].nodeName == "#text")
   {
    if(ignorewhitespace)
    {
     if(!/^\s+$/.test(children[i].nodeValue))
     {
      text = text.concat(children[i].nodeValue);
     }
    }
    else
    {
     text = text.concat(children[i].nodeValue);
    }
   }
   // if node is a line break append \n
   else if(children[i].nodeName == "BR")
   {
    text = text.concat("\n");
   }
   // otherwise call this function again to get the text
   else
   {
    text = text.concat(getInnerText(children[i]));
   }
  }
 }
 // it has no children, so get the text
 else
 {
  // if node is a text node append it
  if(node.nodeName == "#text")
  {
   text = text.concat(node.nodeValue);
  }
  // if node is a line break append \n
  else if(node.nodeName == "BR")
  {
   text = text.concat("\n");
  }
 }
 return text;
}

function popupWindow(whatURL) {
	poppedWindow=window.open(whatURL,"poppedWindow","toolbar=no,width=440,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
}

function popupMapWindow(whatURL) {
	poppedMapWindow=window.open(whatURL,"poppedMapWindow","toolbar=no,width=500,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
}

function confirmBox(whatURL) {
	if (formChanged==1) {
		if (confirm("You have not saved your changes.\nHit CANCEL then SAVE INFORMATION.\nHit OK to go on without saving.")) {
			window.location=whatURL;
		}
	} else {
		window.location=whatURL;
	}
}

function popupWindowConfirmBox(whatURL) {
	if (formChanged==1) {
		if (confirm("You have not saved your changes.\nHit CANCEL then SAVE INFORMATION.\nHit OK to go on without saving.\nHit CLOSE when done.")) {
	poppedWindow=window.open(whatURL,"poppedWindow","toolbar=no,width=440,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
		}
	} else {
	poppedWindow=window.open(whatURL,"poppedWindow","toolbar=no,width=440,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
	}
}

// Disable submit when clicked.
function disableSubmit(buttonName,formName) {
	var whichForm=eval('document.' + formName);
	var whichButton=eval('document.' + formName + '.' + buttonName);
	whichButton.disabled=true;
	whichButton.className='greybutton';
	whichForm.submit();
}

// Take user here after session timed out
timedouturl = "/login/index.cfm";
function Down() { 
	sec--;      
	if (sec == -1) { 
		sec = 59; 
		min--;
	}
	window.status = "Session will time out in " + min + " minutes " + sec + " seconds.";
	if (min == 5 && sec == 0) {
		alert("Your session will time out in less than 5 minutes.\nPlease submit whatever you are updating now or navigate\nto any other page to reset your 30 minute session.");
	}
	if (min == 0 && sec == 0) {
		alert("Your session has timed out.");
		window.location.href = timedouturl;
	} else {
		down = setTimeout("Down()", 1000);
	}
}

function timeIt(useMinutes) {
	min = useMinutes;
	sec = 0;
	Down();
}

/*

// Generic rollover functions

function overImage(imgName) {
	if (document.images) {
		imgOn = eval(imgName + "on.src");
		document [imgName].src = imgOn;	
	}
}

function offImage(imgName) {
	if (document.images) {
		imgOff = eval(imgName + "off.src");
		document [imgName].src = imgOff;	
	}
}

function loadImages() {
	on = new Image();
	on.src = "/images/1.gif";
	off = new Image();
	off.src = "/images/0.gif";
}


// if (document.images) {
//	loadImages();
// }

// Returns a handle to the named layer.

function getLayer(name) {

	if (document.layers) {
		return(document.layers[name]);
	}
	else {
		layer = document.getElementById(name);
		if (layer) {
			return(layer);
		} else {
			return(null);
		}
	}
}

// Hides the named layer

function hideLayer(name) {

	var layer = getLayer(name);

	if (layer.style) {
		layer.style.visibility="hidden";	
	} else {
		layer.visibility="hide";
	}

}

// Shows the named layer

function showLayer(name) {

	var layer = getLayer(name);

	if (layer.style) {
		layer.style.visibility="visible";	
	} else {
		layer.visibility="show";
	}

}

*/