<!--

//look and feel for admin
var origColor = '#F5F5F5';
var newColor = '#818156';

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function display_email(user, site, label, fclass) {
	document.write('<a href=\"mailto:' + user + '@' + site + '\"');
	if (fclass.length > 0) {
		document.write(' class=\"' + fclass + '\"');	
	}	
	document.write('>');
	if (label.length == 0) {
  		document.write(user + '@' + site + '</a>');
	} else {
		document.write(label + '</a>');
	}		  
}
function padOut(number) 
{ 
// formats the time to 24 hour or any other number less then 10
	return (number < 10) ? '0' + number : number; 
}

function displayTime(intTime,strZone)
{
// displayTime(intTime,strZone)
// Input: intTime = Time Cut out from -12 to 13 hours [,] strZone = print out of EST, GMT, UTC
	var dateObj = new Date();
	var timeCut	 = intTime;
	var timeZone = strZone;
	if (timeZone == "undefined")
		timeZone = "";
	var get_GMT_Hours	 	= parseInt(dateObj.getUTCHours());
	var get_GMT_Minutes		= parseInt(dateObj.getUTCMinutes());
	var get_MyTime_Hours 	= get_GMT_Hours;
	var get_MyTime_Minutes	= get_GMT_Minutes;
	
	//My Time
	if ((get_GMT_Hours+timeCut)>=24)
		get_MyTime_Hours = (get_GMT_Hours-24)+timeCut;
	else if (get_GMT_Hours-timeCut<0)
		get_MyTime_Hours = get_GMT_Hours-timeCut+24;
	else
		get_MyTime_Hours = get_GMT_Hours+timeCut;
	// recheck if any value is over or less then what it should be
	if ((get_MyTime_Hours)>=24)
			get_MyTime_Hours = (get_MyTime_Hours-24);
	else if (get_MyTime_Hours<0)
		get_MyTime_Hours = get_MyTime_Hours+24;
		
	document.write(padOut(get_MyTime_Hours));
	document.write(":");
	document.write(padOut(get_MyTime_Minutes));
	document.write(" " + timeZone);
}

function getClientWidth(){
	var width = 0;
	var ifclause = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
		ifclause = 1;
	}
	else if( parent.document.body && parent.document.body.clientWidth ) {
		width = parent.document.body.clientWidth;
		ifclause = 2;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
		ifclause = 3;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth - 18;
		ifclause = 4;
	}
	//alert('ifclause: '+ifclause+' width: '+width);
	return width;
};

function getClientHeight() {
	var height = 0;
	var ifclause = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
		ifclause = 1;
	}
	else if( parent.document.body && parent.document.body.clientHeight ) {
		height = parent.document.body.clientHeight;
		ifclause = 2;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
		ifclause = 3;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight - 18;
		ifclause = 4;
	}
	//alert('ifclause: '+ifclause+' height: '+height);
	return height;
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus();
}

var popUpWinWH=0;
function popUpWindowWH(URLStr, w, h)
{
	if(popUpWinWH)
	{
		if(!popUpWinWH.closed) popUpWinWH.close();
	}
	var xsize = w;
	var ysize = h;
	var DocumentWidth = parseInt(getClientWidth());
	var DocumentHeight = parseInt(getClientHeight());
	var xpos = (DocumentWidth/2)-(xsize/2);
	var ypos = (DocumentHeight/2)-(ysize/2);
	//alert('xpos: '+xpos+' ypos: '+ypos);
	
	popUpWinWH = open(URLStr, 'popUpWinWH', 'toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width='+xsize+',height='+ysize+',left='+xpos+',top='+ypos);
	if (popUpWinWH.opener == null)
		popUpWinWH.opener = self;
	popUpWinWH.focus();
}

var popUpWinWHScroll=0;
// Note: function name should be diffrent then the variable name
function popUpWindowWHScroll(URLStr, w, h)
{
	if(popUpWinWHScroll)
	{
		if(!popUpWinWHScroll.closed) popUpWinWHScroll.close();
	}
	var xsize = w;
	var ysize = h;
	var DocumentWidth = parseInt(getClientWidth());
	var DocumentHeight = parseInt(getClientHeight());
	var xpos = (DocumentWidth/2)-(xsize/2);
	var ypos = (DocumentHeight/2)-(ysize/2);
	//alert('xpos: '+xpos+' ypos: '+ypos);
	
	popUpWinWHScroll = open(URLStr, 'popUpWinWHScroll', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes, width='+xsize+',height='+ysize+',left='+xpos+',top='+ypos);
	if (popUpWinWHScroll.opener == null)
		popUpWinWHScroll.opener = self;
	popUpWinWHScroll.focus();
}


/*************************************************/
// show/hide elements
function showHide(targetName) {
		if( document.getElementById ) { // NS6+
				target = document.getElementById(targetName);
		} else if( document.all ) { // IE4+
				target = document.all[targetName];
		}
		
		if( target ) {
				if( target.style.display == "none" )
					target.style.display = "inline";
				else
					target.style.display = "none";
		}//if
}//func

function showElement(targetName) {
		if ( document.getElementById ) { // NS6+
				target = document.getElementById(targetName);
		} else if( document.all ) { // IE4+
				target = document.all[targetName];
		}

		if( target ) {
			target.style.display = "inline";
		}//if
} 

function hideElement(targetName) {
		if( document.getElementById ) { // NS6+
				target = document.getElementById(targetName);
		} else if( document.all ) { // IE4+
				target = document.all[targetName];
		}
		
		if( target ) {
			target.style.display = "none";
		}//if
} 

/**********************************************************/
//form validation functions

// function isFilled(element, minLength, maxLength)
// it returns 1 on success
// it returns -1 if form element is null or empty
// It returns -2 if element is not of the minimum length required. it does not check for the minimum length required if passed value is zero. 
// It returns -3 if element exceeds the maximum length allowed. it does not check for the maximum length allowed if passed value is zero.
//usage: isFilled(firstName, 0, 20)
function isFilled(element, minLength, maxLength)
{
	if (element.value == "" || element.value == null) 
		return -1;

	if ((minLength  != 0) && (element.value.length < minLength))
		return -2;

	if ((maxLength  != 0) && (element.value.length > maxLength))
		return -3;

	return 1;
}//isFilled

// Check for drop down
// usage: isAnySelected(supervisor)
function isAnySelected(element)
{
	if (element.options[element.selectedIndex].value == "" ) 
		return false;
	else
		return true;
}//isAnySelected

/////////////////////////////////////////////////////////
function selectAllOptions(selectField)
{
	for(i=0; i<selectField.length; i++)
		selectField.options[i].selected = true;
} //selectAllOptions

// Check any of the check boxes is checked.
// usage: isAnyChecked(supervisor)
function isAnyChecked(checkboxObj)
{
	var addresses = checkboxObj;
	var address_result = 0;
	for (var a = 0; a <addresses.length; a = a + 1){
		if(addresses[a].checked)
			address_result = address_result+1;
	}
	if (address_result > 0)
		return true;
	else
		return false;
}//isAnyChecked

// Check if the check boxe is checked.
// usage: isChecked(supervisor)
function isChecked(checkboxObj)
{
	if (checkboxObj.checked)
		return true;
	else
		return false;
}//isChecked

function transferSelectedOptions(selectFrom, selectTo)
{
	var i = 0;
	while(i<selectFrom.length)
	{
		if (selectFrom.options[i].selected == true)
		{
			var newOption = new Option(selectFrom.options[i].text, selectFrom.options[i].value, false, false);
			selectTo.options[selectTo.length] = newOption;
			selectFrom.options[i] = null;
			i--;
		}//if
		i++;
  }//while
	selectFrom.selectedIndex = 0;
	selectTo.selectedIndex = 0;
} //transferSelectedOptions

function transferAllOptions(selectFrom, selectTo)
{
	while(selectFrom.length > 0)
	{
		var newOption = new Option(selectFrom.options[0].text, selectFrom.options[0].value, false, false);
		selectTo.options[selectTo.length] = newOption;
		selectFrom.options[0] = null;
   }//while
}//transferAllOptions
/////////////////////////////////////////////////////////

/*
Name: checkBrowseFileName(strFileName)
Author: Wasay (Wit Inc.)
Date: 07/13/04
Input: strFileName
Ouput: true OR false
Purpose: to check the uploading file for valid file name.
*/
function checkBrowseFileName(strFileName) {
	if (strFileName.length > 0) {
		var varFileNameString = strFileName.split("\\");
		var varFileName = varFileNameString[varFileNameString.length-1];
		var thePatternOrg = '^[a-zA-Z0-9.:_]+$';
		var thePattern = thePatternOrg;
		var myRegExp = new RegExp(thePattern);
		var strMatch = myRegExp.test(varFileName);	
		if (!strMatch) 			
			return false;  // Failed			
		else			
			return true;
	}
	else
		return true; // return true if the value is just null
}

function isEmail (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		//alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];	
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			//alert("Ths username contains invalid characters.");
			return false;
		}
	}	
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			//alert("Ths domain name contains invalid characters.");
			return false;
		}
	}	
	if (user.match(userPat)==null) {
		//alert("The username doesn't seem to be valid.");
		return false;
	}	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				//alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}	
	// Domain is symbolic name.  Check if it's valid.
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			//alert("The domain name does not seem to be valid.");
			return false;
		}
	}	
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		//alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
		//alert("This address is missing a hostname!");
		return false;
	}	
	// If we've gotten this far, everything's valid!
	return true;
}

function findDynamicIDFromURLPathName() {
	var local_pathname = location.pathname;
	var find_id=".id.";
	var find_htm=".htm";
	var the_id_location=local_pathname.indexOf(find_id);
	var the_htm_location=local_pathname.indexOf(find_htm);
	var the_id = "";
	if (the_id_location > 0 && the_htm_location > 0)
	{
		the_id_location = the_id_location + find_id.length;
		the_id = local_pathname.substring(the_id_location,the_htm_location);
	}
	else
	{
		the_id = 0;
	}	
	//alert(local_pathname);
	//alert(the_id_location);
	//alert(the_htm_location);
	//alert(the_id);
	return the_id;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// Redirects the menu links TR onClick event
var popUpWinBR=0;
function browserRedirect(URLStr,targetInt)
{
  if(!targetInt == 1)
  {
	  location = URLStr;
  }
  else
  {	  
	  popUpWinBR = open(URLStr);
	  popUpWinBR.focus();
  }
}

//-->
