<!--

var tooltip_obj;

function open_window(url_i, width_i, height_i)
{
    window.open(url_i,'new_win', 'width=' + width_i + ',height=' + height_i + ',resizable=no,status=no,titlebar=no,scrollbars=yes');
}

function pop_tooltip(event_i, item_i)
{
    tooltip_obj = getObject(item_i + "_tip");
    
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 50;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
	//tip.style.left = 100;
	//tip.style.top = 100;
	tooltip_obj.style.visibility = "";

	if (document.captureEvents)
	{
	    document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = move_tooltip;
    }
}

function close_tooltip(event_i)
{
    //var tip = getObject(item_i + "_tip");
    if (tooltip_obj)
    {
	tooltip_obj.style.visibility = "hidden";
	tooltip_obj = null;

	if (document.releaseEvents)
	{
	    document.releaseEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = null;
    }
}

function move_tooltip(event_i)
{
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 50;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
    }
}

function pop_tooltip2(event_i, item_i)
{
    tooltip_obj = getObject(item_i + "_tip");
    
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 190;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
	//tip.style.left = 100;
	//tip.style.top = 100;
	tooltip_obj.style.visibility = "";

	if (document.captureEvents)
	{
	    document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = move_tooltip2;
    }
}

function close_tooltip2(event_i)
{
    //var tip = getObject(item_i + "_tip");
    if (tooltip_obj)
    {
	tooltip_obj.style.visibility = "hidden";
	tooltip_obj = null;

	if (document.releaseEvents)
	{
	    document.releaseEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = null;
    }
}

function move_tooltip2(event_i)
{
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 190;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
    }
}


function get_mouse_y(event_i)
{
    if (!event_i)
    {
	if (window.event)
	{
	    event_i = window.event;
	}
	else
	{
	    return;
	}
    }
    
    if (event_i.pageY)
    {
	return event_i.pageY;
    }
    else if (event_i.clientY)
    {
	return event_i.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    }
    else
    {
	return null;
    }
}

function get_mouse_x(event_i)
{
    if (!event_i)
    {
	if (window.event)
	{
	    event_i = window.event;
	}
	else
	{
	    return;
	}
    }

    if (event_i.pageX)
    {
	return event_i.pageX;
    }
    else if (event_i.clientX)
    {
	return event_i.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    }
    else
    {
	return null;
    }
}

function delete_confirm()
{
    return confirm("Are you sure you want to delete?");
}

// /////////////////////////////////////////////////////////////////////
// This function limits the input to numbers
// Input: the field, an event, a decimal
// Output: restricts the field to numbers
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	
	// Grab the key events
	if (window.event)
	{
		key = window.event.keyCode;
	}
	else if (e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	// Convert the character code to string
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
	{
		return true;
	}
	// numbers
	else if ( ( ("0123456789.-").indexOf(keychar) > -1) )
	{
		return true;
	}
	// decimal point jump
	else if ( dec && (keychar == ".") )
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
	{
		return false;
	}
}

// /////////////////////////////////////////////////////////////////////
// This function limits the field to only alphanumeric values
// Input: the field, an event, decimal(optional)
// Output: restricts to alpha numeric
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function alphanum(myfield, e, dec)
{
	var key;
	var keychar;
	
	// Grab the key events
	if (window.event)
	{
		key = window.event.keyCode;
	}
	else if (e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	// Convert from character code to string
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
	{
		return true;
	}
	// Number and letters(to lower case)
	// *NOTE* ADD to this if some characters are needed *NOTE*
	else if ( ( ("0123456789abcdefghijklmnopqrstuvwxyz-.&',/* ").indexOf(keychar.toLowerCase()) > -1) )
	{
		return true;
	}
	// decimal point jump
	else if ( dec && (keychar == ".") )
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
	{
		return false;
	}
}

// /////////////////////////////////////////////////////////////////////
// This function formats the field to a phone number (###) ### ####
// Input: the field
// Output: formats the field
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function formatPhone(myfield)
{
	var lngth = myfield.value.length;
	var temp;
	temp = myfield.value
	
	// 3 numbers are entered, so we format to have (###)
	if (lngth == 3)
	{	
		// We create an open paren
		if (temp.indexOf('(') == -1)
		{
			temp = "(" + temp;
		}
		
		// If there is no close paren
		if (temp.indexOf(')') == -1)
		{
			temp += ")";
		}

		// Put the string in the field
		myfield.value = temp;
	}
	
	// Over 3 numbers are entered, so we make sure it has (###) ### 
	if (lngth > 3)
	{
		// We are missing a closing paren
		if (temp.indexOf(')') == -1)
		{
			temp += ")";
		}
		
		// We put a space in between. Format should be (###) by now
		// We are going to make it (###) ###
		if (temp.indexOf(' ') == -1)
		{
			// Take the substring from start to the close paren, add a space and finish up
			temp = temp.substring( 0, indexOf(')') ) + " " + temp.substring(indexOf(')') + 1, temp.length);
		}
		
		// Put the string in the field
		myfield.value = temp;
	}	
	
	// Over 6 numbers entered.  By now it should have a format of (###) ###
	if (lngth > 10)
	{
		temp = temp.substring(0, 8) + " " + temp.substring(9, temp.length);
		
		// Put the string in the field
		myfield.value = temp;
	}
}	

// //////////////////////////////////////////////////////////////////
// This function checks to see if the string is empty
// Input: the string
// Output: Bool if it's empty or not
// Somebody at Some Date
// //////////////////////////////////////////////////////////////////
function isEmpty(str) 
{
	// Check whether string is empty.
	for (var intLoop = 0; intLoop < str.length; intLoop++)
	{
		if (" " != str.charAt(intLoop))
		{
			return false;
		}
	}
	return true;
}

// ////////////////////////////////////////////////////////////////
// Validate email address
// ////////////////////////////////////////////////////////////////
function CheckEmail(field)
{
 var i = 1;
 var sLength = field.length;

// Look for @
 while (( i < sLength) && (field.charAt(i) != "@")) {
  i++;
 }
 if ((i >= sLength) || field.charAt(i) != "@"){
  return false;
 }
 else {
	i += 2;
 }

// Look for .
 while ((i < sLength) && (field.charAt(i) != ".")) 
 {
  i++;
 }
// There must be at lease on character after the .
 if ((i >= sLength - 1) || (field.charAt(i) != ".")) {
  return false;
 }
 else {
  return true;
 }
}

// //////////////////////////////////////////////////////////////////
// This function checks to see if the user is sure to delete
// Input: None
// Output: Returns true if user agrees, false otherwise
// Feryl A.  Dec 23, 2004
// //////////////////////////////////////////////////////////////////
function deleteConfirm() 
{
	return confirm("Are you sure you want to delete?");
}

// //////////////////////////////////////////////////////////////////
// This function calls the proper asp page to destroy CR sessions
// Input: None
// Output: None
// Feryl A.  Jan 12, 2005
// //////////////////////////////////////////////////////////////////
function CallDestroy(val)
{
	//var test = val;
	//alert(test);
	//window.location = "clean.asp?page=" + val;
}

function getObject(obj)
{
    if (document.getElementById)
    {
	return document.getElementById(obj);
    }
    else if (document.layers)
    {
	return document.layers[obj];
    }
    else if (document.all)
    {
	return document.all[obj];
    }
   
}
//-->
