/******************************************/
// Tech On Tap Javascript Utilities
// Compiled 06/01/2006 ACH
/******************************************/

// Character Counter
	// This sets the maximum number of characters that can be inputed into a form text field by a user.
	 
function countChar(obj, limit){ 
	if (obj.value.length+1 > limit) { 
		alert ("You have exceeded the maximum length of " + limit + " . Please limit your comments to a maximum of " + limit + " characters.");
		obj.value=obj.value.slice(0,limit-1);
	}
} 

	
/*****************************************
Antics ToolTip2 Code _ Rollover Tool Tips
(c) 2004 Antics Onine, Inc.
Revised 1/25/06 KW -- Added bug fix for IE6 mouse coords
*****************************************/

//******************************************
// Define Global Variables
//******************************************
var gWidth = 500; // Set to same width as .tooTip style in the stylesheet
var gOffsetY = 10;	// Vertical offset for tip top position (to account for cursor)
var gDelay = .1; // Delay in seconds before tooltip appears -- defaults to half a second
var gStaysOn = 30; // How many seconds the tip stays visible

var x = 0;
var y = 0;
var gObj = null;
var gInterval = null;
var ns4 = document.layers;
var ie4 = document.all;
var nn6 = document.getElementById && !document.all;

//******************************************
// Functions /* Top, Right, Bottom, Left */
//******************************************
function tipOn(which, e) {
	clearInterval(gInterval);
	gObj = which;
	var delay = gDelay * 1000;
	gInterval = setTimeout("doShowToolTip()",delay);
	if( ns4 ) {
		x = e.pageX;
		y = e.pageY;
	}
}

function doShowToolTip() {
	clearInterval(gInterval);
	var offsetX = 0;
	var pageWidth = 0;
	
	if( ns4 )
		pageWidth = document.width;
	else
		pageWidth = document.body.clientWidth;
	
	if( !isNaN(pageWidth) ) {
		if( (x + gWidth) >= pageWidth ) {
			offsetX = gWidth - (pageWidth - x) + 20;
		}
	}
	
	if( ns4 ){		
		document[gObj].top = (y+gOffsetY);
		document[gObj].left = (x - offsetX);
	}
	else if( nn6 ) {
		document.getElementById(gObj).style.top = (y + gOffsetY) + "px";
		document.getElementById(gObj).style.left = (x - offsetX) + "px";		
	}
	else { // ie4
		document.getElementById(gObj).style.top = (y + gOffsetY) + "px";
		document.getElementById(gObj).style.left = (x - offsetX) + "px";		
	}
	
	var staysOn = gStaysOn * 1000;
	gInterval = setTimeout("tipOff()",staysOn);
}

function tipOff() {
  if( ns4 ) {
     document[gObj].left = "-5000";
  }
  else if( nn6 ) {
     document.getElementById(gObj).style.left = "-5000px";
  }
   else { // ie4
     document.getElementById(gObj).style.left = "-5000px";
  }
	clearInterval(gInterval);
}

function setMouseCoords(e) {
	if( ns4 ) {
		x = e.pageX;
		y = e.pageY;
	}
	else if( nn6 ) {
		x = e.pageX;
		y = e.pageY;
	}
	else { // ie
		if ( document.documentElement && document.documentElement.scrollTop ) {
			x = e.clientX + document.documentElement.scrollLeft;
			y = e.clientY + document.documentElement.scrollTop;
		}
		else if (document.body) {
			x = e.clientX + document.body.scrollLeft;
			y = e.clientY + document.body.scrollTop;
		}
		else {
			x = e.clientX;
			y = e.clientY;
		}
	}
}


/*****************************************
Antics Popu Up Menu Code 2
(c) 2004 Antics Onine, Inc.
Revised 1/14/06 KW -- moves styles from js file into stylesheet
Revised 1/13/06 KW - supports IE6 scrolling document.documentElement.scrollTop
Revised 6/8/05 KW - supports variable number of menu items
Revised 5/4/05 KW - Many cross platform fixes
*****************************************/

//******************************************
// Define Global Variables
//******************************************
var gWidth = 180;	// Width of the popup window in pixels (get it from stylesheet)
var gOffsetY = -10;	// Vertical offset for tip top position (to account for cursor)
var gOffsetX = 10;	// Horizontal offset for tip top position (places cursor inside popup)
var gID = 0;
var x = 0;
var y = 0;
var gObj = null;
var gVisible = false;
var gInterval = null;
var gDelay = .1;
var ns4 = document.layers;
var ie4 = document.all;
var nn6 = document.getElementById && !document.all;


//******************************************
// Functions
//******************************************
function popOn(which, e) {
	clearInterval(gInterval);
	gInterval = null;
	
	if( gVisible && gObj != which) popMenuOff();
	
	gObj = which;
	if( e != null && !gVisible ) setMouseCoords(e);
	popMenuOn();
}

function popMenuOn() {
	var offsetX = gOffsetX;
	var pageWidth = 0;
	
	if( ns4 )
		pageWidth = document.width;
	else
		pageWidth = document.body.clientWidth;
	
	if( !isNaN(pageWidth) ) {
		if( (x + gWidth) >= pageWidth ) {
			offsetX = gWidth - (pageWidth - x) + 20;
		}
	}
	
	if( ns4 ){
		document[gObj].top = (y+gOffsetY);
		document[gObj].left = (x - offsetX);
		document[gObj].visibility = "show";
	}
	else if( nn6 ) {
		document.getElementById(gObj).style.top = (y + gOffsetY) + "px";
		document.getElementById(gObj).style.left = (x - offsetX) + "px";		
		document.getElementById(gObj).style.visibility = "visible";
	}
	else { // ie4
		document.getElementById(gObj).style.top = (y + gOffsetY) + "px";
		document.getElementById(gObj).style.left = (x - offsetX) + "px";		
		document.all[gObj].style.visibility = "visible";
	}
	
	gVisible = true;
}

function popOff(who) {
	var delay = gDelay * 1000;
	gInterval = setTimeout("popMenuOff()",delay);
}

function popMenuOff() {
	if( ns4 ) {
		document[gObj].visibility = "hide";
	}
	else if( nn6 ) {
		document.getElementById(gObj).style.visibility = "hidden";
	}
	else { // ie4
		document.all[gObj].style.visibility = "hidden";
	}
	gVisible = false;
	clearInterval(gInterval);
	gInterval = null;
}


function setMouseCoords(e) {
	if( ns4 ) {
		x = e.pageX;
		y = e.pageY;
	}
	else if( nn6 ) {
		x = e.pageX;
		y = e.pageY;
	}
	else { // ie
		if ( document.documentElement && document.documentElement.scrollTop ) {
			x = e.clientX + document.documentElement.scrollLeft;
			y = e.clientY + document.documentElement.scrollTop;
		}
		else if (document.body) {
			x = e.clientX + document.body.scrollLeft;
			y = e.clientY + document.body.scrollTop;
		}
		else {
			x = e.clientX;
			y = e.clientY;
		}
	}
}


// Revised 3/1/05 to add new function to default scroll bars on


// Open the popup window to the specified URL
function openPopup(theURL, theWidth, theHeight, theName, e) {
	var positionStr ="";

	if( theName == null )
		theName = "popupWin";
		
	if( e != null ) {
		var left = e.screenX;
		var top = e.screenY - (theHeight/2);
		positionStr =  ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
	}
	
	var winProperties = "resize=no,toolbar=no,directories=no,menubar=no,status=no,noresize,scrollbars=auto,width=" + theWidth + ",height=" + theHeight + positionStr;
	var mainWin = self;
	if( window.popupWin == null )	   // If the window has never been opened
		popupWin=window.open(theURL,theName, winProperties);
	else {
		if( window.popupWin.closed )	// If the window was open but has been closed
			popupWin=window.open(theURL,theName, winProperties);
		else {								   // The window is already open
			popupWin.close();
			popupWin=window.open(theURL,theName, winProperties);
		}
	}
	popupWin.opener = mainWin;
	popupWin.focus();
}


// Open the popup window to the specified URL
function openTopLeft(theURL, theWidth, theHeight, theName, e) {
	var positionStr ="";

	if( theName == null )
		theName = "popupWin";
		
	if( e != null ) {
		var left = e.screenX - theWidth;
		var top = e.screenY - theHeight;
		positionStr =  ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
	}
	
	var winProperties = "resize=no,toolbar=no,directories=no,menubar=no,status=no,noresize,scrollbars=auto,width=" + theWidth + ",height=" + theHeight + positionStr;
	var mainWin = self;
	if( window.popupWin == null )	   // If the window has never been opened
		popupWin=window.open(theURL,theName, winProperties);
	else {
		if( window.popupWin.closed )	// If the window was open but has been closed
			popupWin=window.open(theURL,theName, winProperties);
		else {								   // The window is already open
			popupWin.close();
			popupWin=window.open(theURL,theName, winProperties);
		}
	}
	popupWin.opener = mainWin;
	popupWin.focus();
}

// Open the popup window to the specified URL
function openTopLeftScroll(theURL, theWidth, theHeight, theName, e) {
	var positionStr ="";

	if( theName == null )
		theName = "popupWin";
		
	if( e != null ) {
		var left = e.screenX - theWidth;
		var top = e.screenY - theHeight;
		positionStr =  ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
	}
	
	var winProperties = "resize=no,toolbar=no,directories=no,menubar=no,status=no,noresize,scrollbars=yes,width=" + theWidth + ",height=" + theHeight + positionStr;
	var mainWin = self;
	if( window.popupWin == null )	   // If the window has never been opened
		popupWin=window.open(theURL,theName, winProperties);
	else {
		if( window.popupWin.closed )	// If the window was open but has been closed
			popupWin=window.open(theURL,theName, winProperties);
		else {								   // The window is already open
			popupWin.close();
			popupWin=window.open(theURL,theName, winProperties);
		}
	}
	popupWin.opener = mainWin;
	popupWin.focus();
}
