function JSClock() 
{   
 var dt = new Date();
 /*
 var today = time.getDate();
 var mon = time.getMonth()+1; // months start at 0, so account for correct month
 var yr = time.getYear();
 var mydate = mon + "/" + today + "/" + yr;
 var hour = time.getHours()   
 var minute = time.getMinutes()   
 var second = time.getSeconds()   
 var temp = ""+mydate;
 temp += " " + ((hour > 12) ? hour - 12 : hour)   
 temp += ((minute < 10) ? ":0" : ":") + minute   
 temp += ((second < 10) ? ":0" : ":") + second   
 temp += (hour >= 12) ? " PM" : " AM"   
*/
 document.all['clock'].innerText = dt;
 setTimeout("JSClock()",1000);
}

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 isValidEmailFormat(email)
{		
	var AtSym    = email.indexOf('@')
	var Period   = email.lastIndexOf('.')
	var Space    = email.indexOf(' ')
	var Length   = email.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
	{
	      
	      return false;
	}
	else
	{
		return true;
	}
}

function openWin( url, w, h )
{
 win = window.open( url, '', 'width='+w+',height='+h+',status=1,personalbar=0,scrollbars=1,menubar=0,toolbar=0');
 win.focus();
}

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

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 ) {	
		window.location = self.location;
	}
	else {
		setTimeout("setTmr()",1000);
	}
}

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

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

	theBox = theForm.elements['ids[]'];
	len = theBox.length;  
	isChecked = false;
	
	if ( len > 0 )
	{
		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 isValidEmailFormat(email)
{
	var pattern = /^.+@.+\..{2,3}$/
	if (pattern.test(email))
	{
		return true; // valid email format
	}
	else
	{
		return false; // invalid email format
	}
}

function CheckEmail(form) {
	var rejectedDomain=new Array()
	var index=0;
	//rejectedDomain[index++]="hotmail"
	//rejectedDomain[index++]="rocketmail"
	//rejectedDomain[index++]="yahoo"
	//rejectedDomain[index++]="zdnetmail"

	var rejected=false
	var testresults=true
	var str=form.email.value
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(str)){
		var tempstring = str.split("@")
		tempstring = tempstring[1].split(".")
		for (i=0; i<rejectedDomain.length; i++) {
			if (tempstring[0]==rejectedDomain[i])
			rejected=true
		}
		if (rejected) {
			var message="Please input a more official email address!\n"
			message += "The following addresses are not allowed:\n"
			for (i=0; i<rejectedDomain.length; i++) {
				message += "\t" + rejectedDomain[i] + "\n"
			}
			validatePrompt(form.email, message)
			testresults=false
		}
	} else {
		message="Please input a complete and valid email address!"
		validatePrompt(form.email, message)
		testresults=false
	}
	return (testresults)
}

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

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;
	}
}
/****************************************************/
