<!--

//look and feel for admin
var origColor = '#E1E6EA';
var newColor	=	'#F8F9FA';

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 getImagePosition(imgId, d) {

  if (document.layers) {
      x = imgId.x;
	  y = imgId.y ;
  }
  else if (document.all) {
      x = imgId.srcElement.offsetLeft;
	  y = imgId.srcElement.offsetTop ;
  }
  else if (document.getElementById) {
      imgId = getElementById(imgId);
	  x = imgId.style.top;
	  y = imgId.style.left;
  }
  return x + ',' + y;
  //alert("x = " + x + "\ny = " + y);
}

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_old(intTime,strZone)
{
//OLD Time zone script
// 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);
*/
}//displayTime_old
// Start script for display time zone

 var dateNow = new Date();      // will be used for remote time
 var dateNowL = new Date();     // local time

 // Determine if within Daylight Savings Time
 dateNow.setTime(dateNowL.getTime())
 // CST/CDT switching: 1st Sunday of April at 2am 
 //                    last Sunday of October at 2 am 
 var H = dateNow.getHours() + dateNow.getMinutes()/60 + dateNow.getSeconds()/3600
 var M = dateNow.getMonth()
 var d = dateNow.getDate()
 var D = dateNow.getDay()
 var daylight_savings_time = 0; // false 
 if((M>3 ||
     (M==3 && (d>7 || D==0 && H>2 || D==1 && d>1 || D==2 && d>2 ||
              D==3 && d>3 || D==4 && d>4 || D==5 && d>5 || D==6 && d>6)
     )) &&
    (M<9 ||
     (M==9 && (d<25 || D==0 && d>24 && H<1 || D==1 && d<26 || D==2 && d<27 ||
              D==3 && d<28 || D==4 && d<29 || D==5 && d<30 || D==6 && d<31)
     ))) daylight_savings_time = 1; // true 


 var New_York_time_zone_offset = 300; // = GMT - 5 (yes daylight savings time) +1 for DST (EDT)
 var London_time_zone_offset = 0; // = GMT (yes daylight savings time) +1 for DST (BST)
 var Tokyo_time_zone_offset = -540; // = GMT + 9 (no daylight savings time) (JST)
 if (daylight_savings_time == 1) {	 
	New_York_time_zone_offset = New_York_time_zone_offset - 60; // =240 for Detroit
	London_time_zone_offset = London_time_zone_offset - 60; //  =-60 for Detroit
 }

 // Calculate Local to UTC time zone offset (browser_time_zone_offset)
 // Detroit browser_time_zone_offset = 240 (4 hours = -5 + 1)
 // MS IE version 3 gives wrong sign of TZ
 // MSIE 4.0b2 shifts TZ by -1 hour
 // Any other problems?
 var browser_time_zone_offset = dateNowL.getTimezoneOffset(); // = what browser thinks is TZ; but
 var msie = navigator.userAgent.indexOf("MSIE")
 if(msie > -1) {
    if(navigator.userAgent.substring(msie+5,msie+6) <= 3) browser_time_zone_offset *= -1;
    else if(navigator.userAgent.indexOf("4.0b2") > -1) browser_time_zone_offset += 60;
 }

 // Calculate local time
 var local_time = new Date();
 local_time.setTime(dateNowL.getTime());

 // calculate offset between local time and New York time
 var New_York_offset = (browser_time_zone_offset - New_York_time_zone_offset) * 60000; // =0
 var New_York_time = new Date();
 New_York_time.setTime(local_time.getTime() + New_York_offset);

 // calculate offset between local time and New York time
 var London_offset = (browser_time_zone_offset - London_time_zone_offset) * 60000; 
 var London_time = new Date();
 London_time.setTime(local_time.getTime() + London_offset);

 // calculate offset between local time and Tokyo time
 var Tokyo_offset = (browser_time_zone_offset - Tokyo_time_zone_offset) * 60000;
 var Tokyo_time = new Date();
 Tokyo_time.setTime(local_time.getTime() + Tokyo_offset);

// End script for display time zone
function displayTime(intTime,strZone) {
	
	if (strZone == "EST")
	{
	//':'+padOut(New_York_time.getSeconds()) +
		document.write(padOut(New_York_time.getHours())+':'+padOut(New_York_time.getMinutes())+ " " + strZone);
	}
	else if (strZone == "GMT")
	{
		document.write(padOut(London_time.getHours())+':'+padOut(London_time.getMinutes())+ " " + strZone);
	}
	else if (strZone == "UTC")
	{
		document.write(padOut(Tokyo_time.getHours())+':'+padOut(Tokyo_time.getMinutes())+ " " + strZone);
	}
}

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;
}

function resize_window(w,h) {
	setClientWidth = w;
	setClientHeight = h;
	window.resizeTo(w, h);
	var thisClientWidth = window.document.body.clientWidth;
	var thisClientHeight = window.document.body.clientHeight;
	if (thisClientWidth < w)
		var setClientWidth = w + (w - thisClientWidth);
	if (thisClientHeight < w)
		var setClientHeight = h + (h - thisClientHeight);
	
	//alert('setClientWidth: ' + setClientWidth + ' ' + 'setClientHeight: ' + setClientHeight);
	window.resizeTo(setClientWidth, setClientHeight);
}

function resize_window_according_to_document() {
  w = getClientWidth();
  h = getClientHeight();
  resize_window(w,h);
}

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=no,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();
  }
}

function searchFocus(obj)
{
	if (obj.value == "Search")
	{
		obj.value = "";
	}	
	//return false;
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

//-->

