var utMenu_defaultColor = '#FFFFFF'
var utMenu_mOverColor = '#EEEEEE';
var utMenu_clickColor = '#FFFFCC';
var hlColor = '#EEEEEE';

var days = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var months = Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');


function openCal(formName,fieldName)
{	
	w = 250;
	h = 230;
	
	calWin = window.open('phpcal.php?formName='+formName+'&fieldName='+fieldName,'','width='+w+',height='+h+',status=0');	
	
	calWin.moveTo(screen.availWidth/2-(w/2),screen.availHeight/2-(h/2));
}


function selectAll(theForm,state)
{ 
	for (i=0,n=theForm.elements.length;i<n;i++) {
		if (theForm.elements[i].name.indexOf('ids') !=-1) {
			theForm.elements[i].checked = state;
		}
	}
}

function IsEmailValid(theForm,ElemName)
{
	var EmailOk  = true
	var Temp     = document.forms[theForm].elements[ElemName]
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // '@' cannot be in first position
	    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
	    (Period == Length ) ||             // Must be atleast one valid char after '.'
	    (Space  != -1))                    // No empty spaces permitted
	{
	      EmailOk = false
	      alert('Please enter a valid e-mail address!')
	      Temp.focus()
	}
	return EmailOk
}

function openWin( url, w, h )
{
 var newWin = window.open( url, '', 'width='+w+',height='+h+',scrollbars=auto,personalbar=0,menubar=0,toolbar=0,resizable=0');
}

function openWin2( url, w, h )
{
 var newWin = window.open( url, '', 'width='+w+',height='+h+',scrollbars=1,personalbar=0,menubar=0,toolbar=0,resizable=1');
}

function setTmr(loc)
{
	/* A timer with built in page refresh */
	tx = document.all.tmr.innerText;
	tm = '' + (parseInt(tx) - 1);
	document.all.tmr.innerText = tm;
	if ( tm == 0 ) {	
		if ( eval(paused) == 0 )
			window.location = self.location;
	}
	else {
		if ( eval(paused) == 0 )
			setTimeout("setTmr()",1000);
	}
}

function bookmark(url,title)
{
	window.external.AddFavorite(url,title);
}

function deleteClick(theForm)
{ 
	if ( ! theForm.elements['ids[]'] ) {
		alert('There is nothing to delete at this time.');
		return;
	}

	theBox = theForm.elements['ids[]'];
	len = theBox.length;  
	isChecked = false;
	
	if ( len )
	{
		for(i=0; i<len; i++) {
			if ( theBox[i].checked ) {
				isChecked = true;
				break;
			}
		}
	}
	else if ( theForm.elements['ids[]'].value != '' )
	{
		//alert( theForm.elements['ids[]'].value ); //debug
		isChecked = true;
	}

	if ( isChecked )
	{
		if ( confirm( 'Are you sure you want to permanently delete the selected item(s)? Click \'OK\' for yes or \'Cancel\' to terminate this action.') )
		{
			theForm.func.value = 'delete';
			theForm.submit();
		}
	} 
	else {
		alert('You have not selected any items for deletion');
	}
}


/****************************************************/


function getDateTime()
{
	/*
		returns the current date & time
	*/
	
	
	dt = new Date();
	
	mon = dt.getMonth();
	d = dt.getDate();
	dow = dt.getDay();
	Y = dt.getYear();
	
	g = dt.getHours();
	i = dt.getMinutes();
	s = dt.getSeconds();
	
	if ( g < 12 ) {
		if(g==0) g = 12;
		T = 'AM';
	}
	else  {
		if( g > 12 ) {
			g -= 12;
		}
		
		T = 'PM';
	}

	//if ( g<10 ) g = '0' + g;
	if ( i<10 ) i = '0' + i;
	if ( s<10 ) s = '0' + s;
	
	D = days[dow];
	M = months[mon];
	
	// D M d, Y g:i T
	
	newDate = D + ' ' + M + ' ' + d + ', ' + Y + ' ' + g + ':' + i + ':' + s + ' ' + T;
	return newDate;
	
}

/* A real-time Clock */
function setJSClock()
{	
	if(document.all){
		obj = document.all['theClock'];
	}
	else {
		obj = document.getElementById("theClock");			
	}
	
	obj.innerText = getDateTime();		//new Date();
	setTimeout("setJSClock()",1000); // 1000 ms = 1 second			
}

/****************************************************/

function mOver (obj,hlColor,clickColor) {
	if ( obj.style.backgroundColor.toUpperCase() != clickColor.toUpperCase() ) {
		obj.style.backgroundColor = hlColor;
	}
}

function mOut (obj,defaultColor,clickColor) 
{
	if ( obj.style.backgroundColor.toUpperCase() != clickColor.toUpperCase() ) {
		obj.style.backgroundColor = defaultColor;
	}
}

function mClick (obj,clickColor,hlColor) 
{
	if ( obj.style.backgroundColor.toUpperCase() != clickColor.toUpperCase() ) {
		obj.style.backgroundColor = clickColor;
	}
	else {
		obj.style.backgroundColor = hlColor;
	}
}
/****************************************************/

var rowState = true;
function showRow(elemID) { 
	
	rowState = !rowState;
	
	//alert( rowState );
	
	//if ( document.all ) { 
	//	document.getElementById(elemID).style.visibility= (rowState) ? "visible" : "hidden"; 
	//} else { 
		document.getElementById(elemID).style.display= (rowState) ? "table-row" :"none"; 
	//} 
} 

var tableVisible = true;

function toggleFilters(elemID) 
{
	var temp = document.getElementById(elemID);
	
	if (tableVisible) {		
		
		//if true, table is visible so hide it
		
		tableVisible = false;
		temp.style.position = 'absolute';
		temp.style.visibility = 'hidden';
		
		hideSelects(); // a function found in the menu javascript menu_ie4.js / menu_ie5.js
	} else {				
		
		//table is not visible, so expand it.
		
		tableVisible = true;
		temp.style.position = 'relative';
		temp.style.visibility = 'visible';
		
		showSelects(); // a function found in the menu javascript menu_ie4.js / menu_ie5.js
	}
}


