// JavaScript Document

<!--
	
//	This enables or disables (clears also) the contents of a checkbox
	function disableTextbox(formname, checkboxname, textname) {
		if (document.formname.checkboxname.checked) {
			document.formname.textname.disabled=false;
		} else {
			document.formname.textname.disabled=true;
		}
	}




//	This function selects the text in a textbox when clicked in the textbox
	function selectSomeText(element){         
	  var workRange=document.selection.createRange();     
	  var allRange=element.createTextRange();     
	  workRange.setEndPoint("StartToStart",allRange);     
	  workRange.select();
	}





	function clickclear(thisfield, defaulttext) {
		if (thisfield.value == defaulttext) {
			thisfield.value = "";
		}
	}
	
	function clickrecall(thisfield, defaulttext) {
		if (thisfield.value == "") {
			thisfield.value = defaulttext;
		}
	}



	function confirmAddNewAreaItem(areaName) {
		
		// CONFIRM REQUIRES ONE ARGUMENT
		var message = "Are you certain you'd like to add a new " + areaName + "?";
	
		// CONFIRM IS BOOLEAN. THAT MEANS THAT
		// IT RETURNS TRUE IF 'OK' IS CLICKED
		// OTHERWISE IT RETURN FALSE
		var return_value = confirm(message);
	
		// TEST TO SEE IF TRUE | FALSE RETURNED
		if (return_value == true) {
			// YOUR 'OK' SCRIPT GOES HERE, IN THIS CASE JUST STAYS ON THIS PAGE
		} else {
			// YOUR 'CANCEL' SCRIPT GOES HERE
			window.opener.location=history.back(1);
		}
	}
	
//	THIS FUNCTION IS FOR THE KUED.ORG BACKEND (DBS) TO PREVENT THE UNNECESSARY ADDITION OF NEW AREA ITEMS
//	Based on... http://www.java2s.com/Code/JavaScript/Window-Browser/YesNoConfirmation.htm
	function confirmAdd(thing) {
		return confirm("Take care!  Clicking 'Ok' will create a blank " + thing + " record in the database, which will remain blank unless you enter the content information for the record.");
	//	return confirm("Are you certain you'd like to add a new " + thing + "?  Remember, as soon as you hit 'Ok', I'm going to create a blank " + thing + " record in the database so you should be sure to actually put some content in there for it.  Otherwise we'll just have have another empty record in that table, and that's no good.  Ok?  Wonderful.")
	}
	// to use, add to the <a href> tag... :  onClick=\"return confirmAdd('THING NAME')\" 




	function toggleDiv(divid) {
		if(document.getElementById(divid).style.display == 'none'){
			document.getElementById(divid).style.display = 'block';
    	} else {
    		document.getElementById(divid).style.display = 'none';
    	}
	}
	
	// For usage, see: http://www.harrymaugans.com/2007/03/05/how-to-create-a-collapsible-div-with-javascript-and-css/
	// print "<div id=\"surveyPeople\" style=\"display: none\">\n";	// Having the "style" set inline here sets the div to be hidden initially.  Get rid of the style and it'll default to be shown initially.
	
	
	
	
	

	function randomPassword(length)
		{
		   chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
		   pass = "";
		
		   for(x=0; x<length; x++)
		   {
			  i = Math.floor(Math.random() * 62);
			  pass += chars.charAt(i);
		   }
		
		   return pass;
	}
	

	function noWay() {
		self.close();
	}
	
	
	//	This will check or uncheck all checkboxes in a form, used currently on editPersonnel personnel function in /dbs
	function checkAll(f,s)
	{
		// Verified Browsers
		//  IE 6.0 / NS 4.78 / NS 6.2.1 / OP 5.12 / OP 6.03 / ES 4.85
	
		for(i=0;i<f.length;i++)if(f[i].type=='checkbox')f[i].checked=s		
	}



	function goToURL() { //v3.0
	  var i, args=goToURL.arguments; document.returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}
	
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	
	
	// Kaosweaver Calendar Settings - do not remove
	// by Paul Davis - http://www.kaosweaver.com
	// KW_lang[English]
	// KW_order[2,0,1]
	// KW_del1[-]
	// KW_del2[-]
	// KW_dd[false]
	// KW_cWidth[170]
	// KW_fd[-1]
	
	var sDate = new Array();
	var mName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	var wName = new Array("Su","Mo","Tu","We","Th","Fr","Sa")
	var cFontName = "Arial, Helvetica, sans-serif;"
	var KW_color = new Array("#000000","#ffcccc","#999999","#ffffff","#ccffcc","#cccccc","#FFFFFF","#669966")
	//var KW_color = new Array("#ffffff","#ffcccc","#999999","#ffffff","#ccffcc","#cccccc","#000000","#000000")
	var KW_cl=0;
	var KW_od=-1;
	var KW_tmo=0;
	var KW_cWidth=200;	// used to be 170
	var KW_fd=-1;
	var KW_ss=0;
	var KW_sw=0;
	var descx=-1;
	var descy=-1;
	var bwNN=(document.captureEvents)?1:0;
	function popmousemove(e){descx=(bwNN)?e.pageX:event.x;descy=(bwNN)?e.pageY:event.y}
	function KW_mouseInit(){
		if(bwNN)document.captureEvents(Event.MOUSEMOVE);document.onmousemove=popmousemove;
	}
	function m_class(m,d,y) { 
		this.month=(m<10)?"0"+m:m;if (d) this.day=(d<10)?"0"+d:d;else this.day="";this.year=y;
		this.output=this.year+"-"+this.month+"-"+this.day;	var kd=new Date();this.special=checkDates(this.month,this.day,this.year)
		this.today=((kd.getMonth()+1)==this.month && kd.getDate()==this.day && kd.getFullYear()==this.year)
		var td=new Date(this.year, (this.month-1), Number(this.day)+KW_od);this.past=(KW_od==-1)?0:(kd>td)
		var tf=new Date(kd.getFullYear(),kd.getMonth(),kd.getDate()+KW_fd);
		var d1=new Date(this.year, (this.month-1), this.day);
		this.future=(KW_fd==-1)?0:(tf<d1);this.ss=(this.special && KW_ss);
		this.display=(this.past || this.future || this.ss);
	}
	
	// Kaosweaver End of Calendar Settings - do not remove
	
	function checkDates(m1,d1,y1) { //v2.1.5
		var rStr=false;for(var i=0;i<sDate.length;i++) {var tDate=sDate[i].split(",");
			if (tDate[2]=="*" || tDate[2]==y1) {if (tDate[1]==d1 && tDate[0]==m1)	rStr=true;
			}}return rStr;
	}
	
	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 KW_doCalendar(obj,E,m,y) { //v2.6.0
	  var d=new Date();f=0;d.setDate(1);if (!m && m!=0) {m=d.getMonth();f=KW_cl}
	  if (f==1 && MM_findObj('KW_selectedMonth').value!=-1)
	  m=MM_findObj('KW_selectedMonth').value-1;d.setMonth(m);
	  if (!y) y=d.getFullYear();if (f==1 && MM_findObj('KW_selectedYear').value!=-1)
	  y=MM_findObj('KW_selectedYear').value;d.setFullYear(y);dy=d.getDay();if (!E) E=0;
	  if(E==1)dy=(dy==0)?6:dy-1;dP=new Date();dP.setDate(1);dP.setMonth(m);dP.setDate(0);
	  pStart=dP.getDate()-dy+1;dStr=new Array();for (i=pStart;i<dP.getDate()+1;i++) { tmo=(KW_tmo)?"":i;
	  tMonth=(m==0)?"12":m;tYear=(m==0)?y-1:y;dStr[dStr.length]=new m_class(tMonth,tmo,tYear);
	  }EOM=false;for (i=1;!EOM;i++){d.setDate(i);if (m!=d.getMonth()) EOM=true; else {
	  dStr[dStr.length]=new m_class((Number(m)+1),i,y);}}cnt=1;si=0;
	  if(E==1)si=(d.getDay()==0)?6:d.getDay()-1;else si=d.getDay();	for (i=si;i<7;i++) {
	  tMonth=(m==11)?"1":Number(m)+2;tYear=(m==11)?Number(y)+1:y; tmo=(KW_tmo)?"":cnt;
	  dStr[dStr.length]=new m_class(tMonth,tmo,tYear); cnt++;}pM=(m==0)?11:m-1;
	  pY=(m==0)?y-1:y;nM=(m==11)?0:Number(m)+1;nY=(m==11)?Number(y)+1:y;
	  wStr="<ht"+""+"ml><he"+""+"ad><st"+""+"yle type=\"text/css\"><!--  body { background-color: "+KW_color[6]+"}\ntd {  font-family: "+cFontName+" font-size: 14px; }\n.tblHdr { font-weight: bold; color: "+KW_color[0]+"; background-color: "+KW_color[6]+" }\n.subTbl{ color: "+KW_color[0]+"; background-color: "+KW_color[7]+";  text-align: center}-->\n</st"+""+"yle>\n<ti"+""+"tle>"+mName[m]+", "+y+"</ti"+""+"tle>\n</he"+""+"ad>\n<bo"+""+"dy  topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" onLoad=\"window.focus()\">\n<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n<tr>\n<td bgcolor=\""+KW_color[6]+"\">\n<table width=\"100%\" border=0>\n"
	  wStr+="<tr>\n<td align=center bgcolor=\""+KW_color[6]+"\" class=\"tblHdr\" colspan=\"4\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+pM+"','"+pY+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+mName[m]+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+nM+"','"+nY+"');\"  class=\"tblHdr\">&raquo</a></td>\n<td colspan=3 align=center class=\"tblHdr\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(y-1)+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+y+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(Number(y)+1)+"');\"  class=\"tblHdr\">&raquo</a></td>\n</tr>\n"
	  wStr+="<tr>\n";for(wdn=0;wdn<7;wdn++)wStr+="<td class=\"subTbl\">"+wName[wdn]+"</td>\n";wStr+="</tr>\n"
	  for (x=0;x<parseInt(dStr.length/7);x++) {	wStr+="<tr>\n";	for (y=0;y<7;y++) {
	  yT=(E==1)?5:0;bC=(y==yT||y==6)?KW_color[2]:KW_color[3];
	  if ((y==yT||y==6) && KW_sw && !dStr[x*7+y].display) dStr[x*7+y].display=true;
	  if ((Number(m)+1)!=dStr[x*7+y].month) bC=KW_color[5]; if (dStr[x*7+y].special)
	  bC=KW_color[4];if (dStr[x*7+y].today) bC=KW_color[1];
	  a0=(KW_cl!=1)?"":"window.opener.MM_findObj('KW_selectedMonth',window.opener.document).value='"+dStr[x*7+y].month+"';window.opener.MM_findObj('KW_selectedYear',window.opener.document).value='"+dStr[x*7+y].year+"'; "
	  a1=(dStr[x*7+y].display)?"":"<a href=\"javascript:window.opener.MM_findObj('"+obj+"',window.opener.document).value='"+dStr[x*7+y].output+"';"+a0+" window.close();\" >";
	  a2=(dStr[x*7+y].display)?"":"</a>";
	  wStr+="<td align=\"center\" bgcolor="+bC+">"+a1+dStr[x*7+y].day+a2+"</td>\n";
		}	wStr+="</tr>\n";}	wStr+="<tr><td colspan=7></td></tr></table></td></tr></table></bo"+""+"dy></ht"+""+"ml>";
		var screenX=(self.screenX)?self.screenX+20:window.screenLeft
		var screenY=(self.screenY)?self.screenY+70:window.screenTop
		var w =(descx==-1)?parseInt(screen.width/2-75):descx+screenX;
		var h=(descy==-1)?parseInt(screen.height/2-75):descy+screenY;
		if (isNaN(w)) w=descx+20
		if (isNaN(h)) h=descy+70
		
		//	height used to be 155, font size up above, 12px, 
		var look='width='+KW_cWidth+',height=200,left='+w+',top='+h;	popwin=window.open('','calendar',look);
		popwin.document.open();	popwin.document.write(wStr);	popwin.document.close();
	}
		
	function MM_openCrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	  if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	  }
	  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	}
	
	function popUp(wName, wFile, wWidth, wHeight, wScroll, wSize){ 
	   //alert(wFile); 
	   oString = "scrollbars="+wScroll+ ",resizable="+wSize+ ",width="+wWidth+ ",height="+wHeight+ ",top=20,left=20,toolbar=no, location=no,directories=no,status=no,menubar=no"; 
	   window.open(wFile, wName, oString) 
	}
	
	function closeWindow() {
		self.close();
	}
	
	function remote(url){
		window.opener.location=url;
	}



	function callJS(jsStr) { //v2.0
 		return eval(jsStr)
	}
	
		
	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_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_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];}
	}
		
	
	
	
	
	/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
	--------------------------------------------------------------*/
	
	//Specify affected tags. Add or remove from list:
	var tgs = new Array( 'div','td','tr');
	
	//Specify spectrum of different font sizes:
	var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
	var startSz = 2;
	
	function ts( trgt,inc ) {
		if (!document.getElementById) return
		var d = document,cEl = null,sz = startSz,i,j,cTags;
		
		sz += inc;
		if ( sz < 0 ) sz = 0;
		if ( sz > 6 ) sz = 6;
		startSz = sz;
			
		if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	
		cEl.style.fontSize = szs[ sz ];
	
		for ( i = 0 ; i < tgs.length ; i++ ) {
			cTags = cEl.getElementsByTagName( tgs[ i ] );
			for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
		}
	}


