
/* Functions that swaps down images. */

/* Functions that handle preload. */
var verbose="none"; // none util ajax lists  validate checkStates calDates hours editor setSelect setSelect2 StopWatch resetOther checkParams popup stats moveBG
// popup jsformsubmit
var keepmoving=false;

function vprint(selector,wtp) {
	if (verbose == selector) 
		alert(wtp);
	}
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.0
  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 findLink(n) { //getElementbyid dont work for links!
  var p,i,x,ret_val="";  
	d=document;
	// change from Dreamweaver: add links
	for(i=0;i<d.links.length;i++) {
		if(d.links[i].name==n) {
			ret_val= d.links[i];
			break;
		}
	}
	return(ret_val);
	}
function findParentForm(somelname) { //used in validateform for some custom form objects!
  var p,i,x,ret_val="";  
	d=document;
	vprint("checkParams","findParentForm("+somelname+" )start");
	// change from Dreamweaver: add links
	for(i=0;i<d.forms.length;i++) {
		if(d.forms[i][somelname] != null)
		// look for either a single el name or an array of elements
		if(d.forms[i][somelname].name==somelname || d.forms[i][somelname].length != null) {
			ret_val= d.forms[i].name;
			vprint("checkParams","findParentForm("+somelname+") ->"+ret_val);
			break;
		}
	}
	vprint("checkParams","findParentForm("+somelname+" )end");
	return(ret_val);
	}
function findAnchor(n) { //getElementbyid dont work for links!
  var p,i,x,ret_val="";  
	d=document;
	// change from Dreamweaver: add links
	for(i=0;i<d.anchors.length;i++) {
		if(d.anchors[i].name==n) {
			ret_val= d.anchors[i];
			break;
		}
	}
	return(ret_val);
	}
// if it doesn't find it, the frame may use id and no name
function getIframe(theframe){
 var p,i,x,myframe,ret_val="no iframe found:"+theframe;  
	d=document;
	// because dreamweaver's findObj doesn't find frames in netscape
	for(i=0;i<frames.length;i++) {
		if(frames[i].name==theframe || frames[i].id==theframe) 
			myframe= frames[i];
		}
	//myframe = MM_findObj(theframe);
	//alert("getIframe is looking for frame:"+theframe+ " parent frames count:"+parent.frames.length+" this frame count:"+frames.length+ "\nfound:"+myframe+" myframe.document:"+myframe.document);
	if(myframe!=null)
		if(myframe.contentWindow !=null)
			ret_val=myframe.contentWindow.document.body.innerHTML;
		else
			ret_val=myframe.document.body.innerHTML;
	return ret_val;
	}
function getIframeObj(theframe){
 var p,i,x,ret_val="";  
	d=document;
	vprint("editor","getIframeObj, checking num frames:"+frames.length+ " for:"+theframe);
	for(i=0;i<frames.length;i++) {
		if(frames[i].name==theframe) {
			myframe= frames[i];
			vprint("editor","getIframeObj, found it!:"+theframe);
			}
		}
	return myframe;
	}
// get checked value from list of checkboxes or radio buttons
function getChecked(theEl,id){
 var p,i,x,ret_val="";  
	d=document;
	if(!isnull(theEl.selectedIndex))// looks like dropdown
		ret_val=theEl[theEl.selectedIndex].value;
	else{
		for(i=0;i<theEl.length;i++) {
			if(theEl[i].checked==true) 
				ret_val= (id==null)?theEl[i].value:theEl[i].id;
			}
		}
	return ret_val;
	}
function submitForm(theform){
 var myform,d;  
	d=document;
	myform = d.getElementById(theform);
	//alert("submitForm: text name:"+theform);
	//alert("submitForm: found object:"+myform.id+" action:"+myform.action+" method:"+myform.method);
	myform.submit();
	// if it complains "xx is not a function" you have named some element in the form "submit"
	// maybe the submit button?
}
function isnull(v){
	return (v=="" || v=="undefined" || v=="_All_" || v=="null" || v==null)?true:false;
}
function jsformsubmit(zform){
	var fl = new Object();
	stemp="";
	theurl="../../admin/en/zObjectWizard.asp?";
	if(zform.elements.length != 0) {// have an ext form
		//zform = zform.childNodes;
		zform = zform.elements;
		stemp +="ELEMENTS::";
		}
	//for(key in zform)stemp +="\nkey[<b>"+key+"</b>]->"+zform[key];
	for(ii=0; ii<zform.length;ii++){
		stemp +="\nItem[<b>"+ii+"</b>]->"+zform[ii].name+" val:"+zform[ii].value+" length:"+zform[ii].length+" checked:"+zform[ii].checked;
		//build radio buttons, if "checked" is true overwrite
		if(fl[zform[ii].name]==null)
			fl[zform[ii].name]=zform[ii].value;
		else if (zform[ii].checked == true)
			fl[zform[ii].name]=zform[ii].value;
		
		}
	// build url from collected objects
	for(key in fl)
		theurl +=key+"="+fl[key]+"&";
	stemp+="\nURL:"+theurl;
	stemp+="\nwid.id:"+win.id;
	vprint ("jsformsubmit","jsformsubmit called:"+stemp+":");
	// try and load it
	// this seemed the best place to try and catch this
	if(fl["libraryItem"]=="page") // normal load
		document.MM_returnValue=('a'=='a');
	else { // popup load
		win.load({url:theurl});
		document.MM_returnValue=(''=='a');
		}
	// return nothing return false;
	}
// adjust the pids in lastSearch to match checkboxes
function pidAdjust(){
 var myform,d;  
	d=document;
	mylink = findLink("lastSearch");
	thisOne = d.getElementById("pid");
	//alert("pidAdjust: the linkhref:"+mylink.href+"\n  pid found:"+thisOne.type+"\n checked:"+thisOne.checked+" value:"+thisOne.value);
	// if (checked)
	//   if url.IndexOf(pid=thisID) > 0) url += "&pid="+thisID;
	// else  
	//   if url.IndexOf(pid=thisID) > 0) url += url.replace("&pid="+thisID,"");
	if (thisOne.checked) {// should be there
	   if (mylink.href.indexOf('pid='+thisOne.value) > 0) mylink.href += "&pid="+thisOne.value;
		}
	else  {               // should no be there
	   if (mylink.href.indexOf('pid='+thisOne.value) > 0) { // was there remove it
			 //oldVal = new RegExp("pid="+thisOne.value,"i");
			 oldVal = "&pid="+thisOne.value;
			 mylink.href = mylink.href.replace(oldVal,"");
			 //alert ("removing pid:"+oldVal+": href now:"+mylink.href);
		 }
	}
		 
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
	}

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];}
	}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		vprint("validate","MM_findObj("+args[i]+")->name:"+val.name+" value (cant be blank):"+val.value+":");
    if (val) { nm=val.name; el=val;
			if(nm=="undefined" || nm==null) nm=args[i];
			nmNO_Q = nm.replace(/^Q/,"");
			// currently only works for text boxes, for radios, checkboxes, select boxes needs work
			// they return numitems >1
			vprint("validate","item name:"+nm+". type is:"+el.type +", selected:"+el.selected +", selectedIndex:"+el.selectedIndex+", checked:"+el.checked +", numitems:"+el.length+", val_test:"+test+", el.value:"+el.value+":");
		if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) {    // -- EMAIL
				p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) {
					if(document.myG==null)
						errors+='- '+nmNO_Q+' must contain an e-mail address.\n';
					else {
						stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
							redir: "JSON", 
							param1: "sysErrors",
							param2: "JS_EMAIL"},
							nmNO_Q);
						errors = "JSONERROR";
						}
					el.focus();
					el.bgColor="#FF0000";
				}
			// SPECIAL example: checkFWAchoice checkWorkStates
			} else if (test.indexOf('special:')!=-1) { // -- SPECIAL function, we evalit (note blank values trigger Required)
				thefunc=test.replace(/Rspecial:/,"");
				stemp = thefunc+"('"+findParentForm(nm) +"','"+nm+"')";
				vprint("validate","SPECIAL check, going to eval:"+stemp+":");
				ret_val = eval(stemp);
				vprint("validate","SPECIAL check, got back:"+ret_val+":");
				//alert("VALIDATE FORM: special check errors:"+errors+": ret_val:"+ret_val+":");
        if (ret_val !="") {
					
					if(ret_val.search(/[a-z]/) <0 && ret_val.search(/[A-Z]/)==0)
						{
						stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
							redir: "JSON", 
							param1: "sysErrors",
							param2: ret_val},
							nmNO_Q);
						errors = "JSONERROR";
						}
					else
						errors+=ret_val;
					// if a hidden el, ie6 complains: 
					//el.focus();
					//el.bgColor="#FF0000";
				}
      } else if (test=='R' && el.length>0 ) {             // -- REQUIRED and looks like dropdown or list
				// this print sometimes cause errors
				vprint("validate","item name:"+nm+": looks like dropdown or checkboxes el.value:"+el.value+", length:"+el.length+", selectedIndex?:"+el.selectedIndex+" getChecked():"+getChecked(el));
				if(el.value=="_All_" || el.value=="undefined" || el.value=="null"){ // null dropdowns go in here whereas selected dropdowns will go else clause
					if(document.myG==null)
						errors+='- '+nmNO_Q+' must choose a value.\n';
					else {
						stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
											redir: "JSON", 
											param1: "sysErrors",
							param2: "JS_CHOOSE"},
							nmNO_Q);
						errors = "JSONERROR";
						}
					//alert("found a dropdown, setting color");
					el.focus();
					el.style.backgroundColor="#FF0000";
					} 
					else { // probably an unselected list of radios, checkboxes, lists added20100804
					if(isnull(getChecked(el))){
						if(document.myG==null)
							errors+='- '+nmNO_Q+' must choose a value.\n';
						else {
							stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
												redir: "JSON", 
												param1: "sysErrors",
								param2: "JS_CHOOSE"},
								nmNO_Q);
							errors = "JSONERROR";
							}
						//  loop for all elements
						for(ee=0;ee<el.length; ee++)
							el[ee].style.backgroundColor="red";
						}
					} // end radios, checkboxes
      } else if (test!='R') {             // -- REQUIRED NUM
				vprint("validate","item name:"+nm+": looks like numeric test:"+test+ " val:"+val);
				num = parseFloat(val);
        if (isNaN(val)) {
					if(document.myG==null)
						errors+='- '+nmNO_Q+' must contain a number.\n';
					else {
						// get the error message, NOTE response is delayed!
						stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
								redir: "JSON", 
								param1: "sysErrors",
								param2: "JS_NUMBER"},
								nmNO_Q);
						//alert("VALIDATE FROM: zListProxy returned type:"+typeof(stemp)+": value:"+stemp+":");
						errors = "JSONERROR";
						}
					//stemp.replace(/TOK1/,nmNO_Q);
					
					el.focus();
					el.bgColor="#FF0000";
					}
        if (test.indexOf('inRange') != -1) { 
					p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) {
						if(document.myG==null)
							errors+='- '+nmNO_Q+' must contain a number between '+min+' and '+max+'.\n';
						else {
							stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
								redir: "JSON", 
								param1: "sysErrors",
								param2: "JS_BETWEEN"},
								nmNO_Q,
								min+","+max);
							errors = "JSONERROR";
						}
						el.focus();
						el.bgColor="#FF0000";
						}
					} 
				} 
			else  {             // -- PASSED ALL
				;//vprint("validate","item name:"+nm+": has test:"+test+ "  was OK! val:"+val+":");
				}
			}  // end NOT blank
			else if (test.charAt(0) == 'R') {   // -- REQUIRED anything
				vprint("validate","item name:"+nm+": looks like generic required test:"+test+ " val:"+val);
				if(document.myG==null)
					errors += '- '+nmNO_Q+' is required.\n';
				else{
					stemp = athena.pagecore.zListProxy("../../admin/en/zListControl.asp",{ CMD: "GETGLOBALS", 
							redir: "JSON", 
							param1: "sysErrors",
							param2: "JS_REQUIRED"},
							nmNO_Q);
						errors = "JSONERROR";
					}
				el.focus();
			el.style.background="#FF0000";
		}
		}
  } if (errors && errors!="JSONERROR") alert('The following error(s) occurred:\n'+errors);
	// uncomment to force error
	//errors += "forced error";
  document.MM_returnValue = (errors == '');
	} // end MM_validateForm

//
// CLASS calDates
// special function for DateClick
// Dateclick calls it with set date
// options:
//    dateformat - not used
//    first2nd - for date ranges, specifiy 1st or 2nd click box, otherwise leave blank
//
// DEBUG: if init value not set, make sure the spacer image is loading
function calDates(formname,elname,dateformat,first2nd){
	// remember ourself
	var myCalDate = this;
	this.myname = "CAL"+formname+"."+elname;
	this.dateformat = dateformat;
	this.thel = eval ("document."+formname+"."+elname);
	if(first2nd==null)first2nd="";
	this.first2nd = first2nd;
	this.myAnch = findAnchor(formname+"Anch"+first2nd+elname);
	vprint("calDates","calDates was initialized name:"+this.myname+", format:"+dateformat+",1st2nd:"+first2nd);
	// METHODS
	this.showCalDate = function (zdate){
		//this.myCalDate = myCalDate;
		var f1,f2,f3,stemp,usdate;
		if(zdate != null && zdate != ""){
			// standard format 20080808
			f1= zdate.substr(0,4);
			f2= zdate.substr(4,2);
			f3= zdate.substr(6,2);
			usdate = f2+"/"+f3+"/"+f1;
			vprint("calDates","showCalDate:name:"+this.myname+" zdate set as:"+usdate);
			// now set the anchor
			this.myAnch.innerHTML = usdate;
			// now set the daterange textbox (hidden el) example: 20080303,20080808
			stemp = this.thel.value;
			
			if(this.first2nd=="") // single box no commas, just replace with date
				this.thel.value = zdate;
			else if(this.first2nd=="1")
				this.thel.value = (stemp.indexOf(",") >=0)?stemp.replace(/.*,/,zdate+","):zdate+",";	
			else
				this.thel.value = (stemp.indexOf(",") >=0)?stemp.replace(/,.*/,","+zdate):","+zdate;
			} // end valid zdate
		} // end method showCalDate
	} // end class calDates
	
function showDate(myElement) {
	var darray=new Array();
	var marray=new Array();
	darray[0]="Sunday";
	darray[1]="Monday";
	darray[2]="Tuesday";
	darray[3]="Wednesday";
	darray[4]="Thursday";
	darray[5]="Friday";
	darray[6]="Saturday";
	darray[7]="Sunday";

	marray[0]="January";
	marray[1]="February";
	marray[2]="March";
	marray[3]="April";
	marray[4]="May";
	marray[5]="June";
	marray[6]="July";
	marray[7]="August";
	marray[8]="September";
	marray[9]="October";
	marray[10]="November";
	marray[11]="December";
	myDate = new Date();
	message = "";
	//message += "\nMonth is: " + myDate.getMonth();
	//message += "\nThe toString time is: " + myDate.toString();
	message += darray[myDate.getDay()] + ", " + marray[myDate.getMonth()] + " " + myDate.getDate() + ", " + myDate.getYear();
	// input box: str="document.form1." + myElement + ".value = message;"
	//	eval (str);
	document.all["dateLayer"].innerHTML='<font color="#FFFFFF" face="Arial, Helvetica, sans-serif" size="-1" weight="700">' + message +'</font>';

	temp = document.all.dateLayer.style.width;
	layerx = parseInt(temp);
	newx = document.body.clientWidth - layerx;
	document.all.dateLayer.style.left = newx;
	//alert(message);
	}


// This script and many more are available free online at --
// The JavaScript Source!! http://javascript.internet.com --

// these get reset by passed args
var swidth =180; // scroller width
var sheight=100; // scroller height
var bwidth =180; // clip window width
var bheight=155; // clip window height

//scroller's speed;
var sspeed=1;

function startSlider(zw,zh,buffer,border,direction){
	swidth  = zw;
	sheight = zh;
	bheight = zh;
	bwidth  = zh;
	startpos= 80; // offscreen/midscreen/ some percent
	if(direction==null)// default to vertical scroll
		direction="up"; 
	// 20100305 ext problems writing this out, just move it into the box template
	// 
	if (false){ //firefox
		//alert("found getElementbyid"); clip: top right bot left
		document.write('<div id="clipper" style="position:relative;overflow:hidden;color: #000000;width:'+zw+'px;height:'+zh+'px;clip:rect(0px '+zw+'px '+zh+'px 0px);padding: '+buffer+'px; border:1px solid '+border+';" onMouseover="sspeed=0;" onMouseout="sspeed=2">')
		document.write('<div id="slider" style="position:relative;width:{swidth};">')
		document.write('the div was written</div></div>')
		}
	ns6marquee(direction,startpos);
	} // end startSlider


function ns6marquee(direction,startpos){ //FFFFFFFFF firefox
	myObj = MM_findObj("slider");
	myObj.style.visibility="visible";
	ns6div=myObj;
	// 20100305 now inserting directly
	//ns6div.innerHTML=wholemessage;
	
	// set the initial positon
	if(startpos=="offscreen"){
		if(direction=="up"|| direction=="down")
			ns6div.style.top=sheight +"px";
		else
			ns6div.style.left=swidth +"px";
		}
	else if(startpos=="midscreen"){
		if(direction=="up"|| direction=="down")
			ns6div.style.top=sheight/2 +"px";
		else
			ns6div.style.left=swidth/2 +"px";
		}
	else if(String(startpos).search(/\d/) >=0){ // expecting a percentage
		if(direction=="up"|| direction=="down")
			ns6div.style.top=sheight*(100-parseInt(startpos))/100 +"px";
		else
			ns6div.style.left=swidth*(100-parseInt(startpos))/100 +"px";
		}
	else 
		;// default is to leave it where it is
	sizeup=sheight;
	sizeacross=swidth;
	//alert("slider INIT: obj.name:"+myObj.name+" startpos:"+startpos+"-> left:"+ns6div.style.left+ " top:"+ns6div.style.top+" width:"+swidth+" height:"+sheight);
	ns6slide(direction); // start repeating function
	}
// ns6slide - repeating function to move the div
function ns6slide(direction){
	//alert("firefoxslide, div id: "+ns6div.id+" top:"+ns6div.style.top+ ": left:"+ns6div.style.left+" speed:"+sspeed+": sliderheight:"+ sheight+": sizeup:"+sizeup);
	if(direction=="up"|| direction=="down"){
		if (parseInt(ns6div.style.top)>=(sizeup+bheight)*(-1)){
			ns6div.style.top=(parseInt(ns6div.style.top)-sspeed)+"px";
			// keep moving
			setTimeout('ns6slide("'+direction+'")',80)
			}
		else{
			// go back down
			ns6div.style.top=sheight + "px";
			// keep going
			ns6slide(direction)
			}
	} // end up down
	else { // left right
		if (parseInt(ns6div.style.left)>=(sizeacross+bwidth)*(-1)){
			ns6div.style.left=(parseInt(ns6div.style.left)-sspeed)+"px";
			// keep moving
			setTimeout('ns6slide("'+direction+'")',80)
			}
		else{
			// go back 
			ns6div.style.left=swidth + "px";
			// keep going
			ns6slide(direction)
			}
		}// end left right
	}
// end marquee slider

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
               

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
	}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}  
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
	}
// scroll height/width cross-browser (scrolling is still a browser mismatch)
function getScrollHeight(){
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}
function getScrollWidth(){
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
} 
// from start x,y to target x,y
// y goes zero to bottom of screen
// x goes -x to x with zero centered in screen (other wise resize is havoc)
function moveDD(nowatx,nowaty,targetx,targety,speed) {
	var winW, winH, ii, newx,newy,myObj, dx,dy,transx,transy;
	if (speed == null || speed=='')speed=43;
	winW = document.body.clientWidth;
	winH = document.body.clientHeight;
	myObj = MM_findObj("tabout");
	// omiting px causes firefox error
	// add translations here for actual graphics
	transx = winW * 0.5 ;
	transy = 0.0;
	// note the delay so we start at the given start point
	myObj.style.left = parseInt(nowatx +transx) +"px";
	myObj.style.top  = parseInt(nowaty +transy) +"px";
	//alert ("moveDD IN(curx:"+nowatx+",cury:"+nowaty + " speed:"+speed+" target("+targetx+","+targety+")" + " trans("+transx+","+transy+")"   );
	nowatx = parseInt(nowatx);
	nowaty = parseInt(nowaty);
	targetx = parseInt(targetx);
	targety = parseInt(targety);
	speed = parseInt(speed);
	dx = (targetx-nowatx)/speed;
	//targety =  winH * .5 - 85;
	dy = (targety-nowaty)/speed;
	// this dont work in netscape: document.all.tabout.style.left = newx;

	nowatx = nowatx + dx;
	nowaty = nowaty + dy;
	//alert ("moveDD(curx"+nowatx+",cury:"+nowaty + " speed:"+speed+" translated("+transx+","+transy+")" + " dxcy("+dx+","+dy+")"   );
	// now scroll out height
	if (Math.abs(targetx - nowatx) > dx || Math.abs(targety - nowaty) > dy){
		// since the target dont move, pass the in value
		window.setTimeout("moveDD("+nowatx+","+nowaty+","+targetx+","+targety+","+speed+")",10);
		}
} // end moveDD

// moveBG - move the BG image and other tagged items in a constant direction 
// direction : the angle 0 is north
// speed : the step ammount
// onecall : means to look for a cookie offset and set it once
function moveBG(direction,speed,onecall) {
	var winW, winH, ii, itemp, newx,newy,myObj, dx,dy,transx,transy;
	if (speed == null || speed=='')speed=43;
	vprint("moveBG","======moveBG START called:"+direction+":"+speed+":"+onecall+":======");
	
	// accelerate for continued movement
	speed = setVal(parseInt(speed),1,-50,50,"LIMIT");
	speed = parseFloat(speed);
	dRAD=Math.PI *parseFloat(direction)/180.0;
	
	// get current x pos
	//       document.body.style.backgroundPosition
	// these dont work:
	vprint("moveBG","the image backgroundPosition is:"+document.body.style.backgroundPosition+": image:"+document.body.style.backgroundImage);
	vprint("moveBG"," by getElement(thebody).style.backgroundPosition:"+document.getElementById("thebody").style.backgroundPosition);
	el = Ext.get("thebody");
	// IE use XY, firefox without
	stempO = el.getStyles('backgroundPosition', 'backgroundPositionX','backgroundPositionY','backgroundImage') ;
	vprint("moveBG"," by Ext.util.JSON.encode():"+Ext.util.JSON.encode(stempO));
	if(stempO.backgroundPosition != null){ // firefox
		curPosx=stempO.backgroundPosition.replace(/px.*/,"");
		curPosy=stempO.backgroundPosition.replace(/^.* /,"");
		curPosy=curPosy.replace(/px.*/,"");
		}
	else {
		curPosx=stempO.backgroundPositionX;
		curPosy=stempO.backgroundPositionY;
		}
	curPosx=parseInt(curPosx);
	curPosy=parseInt(curPosy);

	// FIRST CALL - restore remembered past position
	// we only store the bg image offsets, from this we can get a magnitude and direction
	// doing this was so we don't need to store offsets for all elements in LOOP
	if (onecall==true){// get the cookie from cookie provider
		itemp=Ext.state.Manager.getProvider().get("floorOffset");
		itemp2=athena.pagecore.cpP.get("floorOffset");
		itemp3=GetCookie("ys-floorOffset"); // Ext just isn't ready in time in IE
		vprint("moveBG"," ONECALL mode, dir:"+direction+" cookie floorOffset:"+itemp+": alternate2:"+itemp2+": alternate3:"+itemp3+":");
		if(itemp!=null && itemp!="" && itemp!="undefined"&& itemp.toString()!="undefined"){ // check Ext first
			vprint("moveBG","ONECALL DATA GOOD,offset itemp is array:"+itemp+": type:"+typeof(itemp)+ " itemp[1]y:"+itemp[1]+":");
			newbgPosx=parseInt(itemp[0]);
			newbgPosy=parseInt(itemp[1]);
			dx=parseFloat(newbgPosx-curPosx);
			dy=parseFloat(newbgPosy-curPosy);
			dRAD=Math.atan2(dx,dy);
			speed = Math.sqrt(dx*dx + dy*dy);
			//alert("reset speed:"+speed+" dRAD:"+dRAD);
		}
		else if(itemp3!=null && itemp3!="" && itemp3!="undefined"){ // check IE cookies
			// this will be hit if Ext state maanger is not fast enough
			// a:n%3A-763^n%3A40
			obj = itemp3;
			vprint("moveBG","= * = * = * IE catch BAD DATA - use ITEMP3 MODE =*=*=*=,  set defaults, before JSON array decode:"+obj+": type:"+typeof(obj)+" 0:"+obj[0]+" 1:"+obj[1]+" 2:"+obj[2]+" 3:"+obj[3]);
			// is not JSON this don't work obj = Ext.util.JSON.decode(itemp3); 
			// just set default sane values
			newbgPosx=parseInt(-763);
			newbgPosy=parseInt(40);
			dx=parseFloat(newbgPosx-curPosx);
			dy=parseFloat(newbgPosy-curPosy);
			dRAD=Math.atan2(dx,dy);
			speed = Math.sqrt(dx*dx + dy*dy);
		}
		else {
			vprint("moveBG","= * = * = * IE catch BAD DATA=*=*=*=, NOTHING SET, using sane defaults from cur pos("+curPosx+","+curPosy+") ");
			if(String(window.location).search(/JNJFAIR.en/i)>0){
				vprint("moveBG","= * = * = * IE catch BAD DATA: custom fix for:VBF NO MOVE:"+window.location);

			newbgPosx=parseInt(-763);
			newbgPosy=parseInt(40);
			dx=parseFloat(newbgPosx-curPosx);
			dy=parseFloat(newbgPosy-curPosy);
			dRAD=Math.atan2(dx,dy);
			speed = Math.sqrt(dx*dx + dy*dy);

			}
			else{

			newbgPosx=parseInt(-1);
			newbgPosy=parseInt(40);
			dx=parseFloat(newbgPosx-curPosx);
			dy=parseFloat(newbgPosy-curPosy);
			dRAD=Math.atan2(dx,dy);
			speed = Math.sqrt(dx*dx + dy*dy);
			//return;
			}
		}
	} // end FIRST CALL
	newbgPosx=parseInt(curPosx)+ parseInt(Math.round(Math.sin(dRAD)*speed ));
	newbgPosy=parseInt(curPosy)+ parseInt(Math.round(Math.cos(dRAD)*speed ));
	
	// MOVE BG
	vprint("moveBG","BACKGROUND direction:"+direction+" dRadians:"+dRAD+"(deg:"+dRAD*360/6.28+") speed:"+speed+" curPosx:"+curPosx+"->"+newbgPosx+" curPosy:"+curPosy+"-> "+newbgPosy+":");
	if(newbgPosx>0) // don't go off left edge (that is we only want neg offset
		return;
	document.body.style.backgroundPosition = newbgPosx+"px "+newbgPosy+"px";
	aparams = new Object({duration: 1,easing: 'easeIn'	});
	// MOVE OTHER
	// move all toolbars with y greater than 300 (to miss monitors and menu)
	//LOOP
	stemp="";

	
	// OLD if(tblist!="[TOOL"+"BARS]" ){ // make sure substitutions were made
	// OLD 	for(ii=0;ii<tblistA.length;ii++){
	els = Ext.query('div[id^=floorBooth]', "body");
	for (ii = 0 ; ii < els.length; ii++){
			myC = Ext.get(els[ii]);
				
			//mytb     = tblistA[ii].replace("_","-");
			//mytbcont = mytb +"-container";
			//stemp+=mytbcont+","; // debug
			// get cur pos and increment it
			//myC  =Ext.get(mytbcont);
			//myC = tblistAO[ii];

			newPosy = myC.getY() + parseInt(Math.round(Math.cos(dRAD)*speed ));
			newPosx = myC.getX() + parseInt(Math.round(Math.sin(dRAD)*speed ));
			//the initial call in IE is not getting xy coords
			//stempO = el.getStyles('left', 'top')
			//alert("Query got this id:"+myC.id+" moving:"+newPosx+", "+newPosy+" STYLES left:"+stempO.left+" top:"+stempO.top);
			//newPosy = parseInt( String(tblistAO[ii].dom.style.top).replace("px","") );
			if(ii==8 && false)
				alert("myObj.dom.style.top:"+myC.dom.style.top+" myC.getY:"+newPosy );
			if(newPosy >150 || true){
				//  firefox crawllllsssj either way using Ext or without
				myC.setX(newPosx);
				myC.setY(newPosy);
				//tblistAO[ii].dom.style.left = String(parseInt( String(tblistAO[ii].dom.style.left).replace("px","") ) + direction*speed)+"px";
				// tblistAO[ii].setLocation(newPosx,newPosy,aparams);
				}
			}

		//alert("tblist:"+tblist+" containers:"+stemp);
	if (keepmoving==true && onecall!=true){
		moveBG.defer(20,this,[direction,speed]);
		//window.setTimeout("moveBG("+direction+","+speed+")",50);
		}
}// end moveBG

function calcMonths(objName,newy,newm) { //v3.0
  var obj = MM_findObj(objName); 
  if (obj) obj.value = newy*12 +newm;
	}
function calcMinutes(dex,objName,newy,newm) { //v3.0
  var obj;
  eval("document.form2."+objName + "["+dex+"].value= "+ (parseInt(newy)*60 + parseInt(newm)));
	}

function copyOpHours(dex,objName,hopen,hclosed) { //v3.0
	objA = objName.split(/,/);
	for (ii=0; ii<objA.length; ii++){ 
		//alert("document.form2.Open"+objA[ii] + ".value");
		eval("document.form2.Open"+objA[ii] + "["+dex+"].value= hopen") ;
		eval("document.form2.Closed"+objA[ii] + "["+dex+"].value= hclosed") ;
		}
	}                                                          

// function: setSelect2 set default selections on Non-linked drop down lists
// thisSel -  the select box to change 
// deff - any default element to select (can be multi-values seperated by comma)
function setSelect2(thisSel,deff){
	var ii;
	vprint("setSelect2","setSelect2: select box: "+thisSel.name+ ", num el:"+thisSel.length+" setting defaults:"+deff +":");
	var defA=deff.split(/,\s*/);
	for(ii=0; ii<thisSel.length; ii++){			
			// vprint("setSelect","just added to list:"+thisA[ii].text);
			// look for matches with the defaults
			ztext = thisSel.options[ii].text;
			zval  = thisSel.options[ii].value;
			for(jj=0; jj<defA.length; jj++){	
				zdeff=defA[jj];
				if (zdeff != null && zdeff != ""){
					if (zdeff == zval) {
						vprint("setSelect2","SET DEFAULT listDEX:"+ii+" defDEX:"+jj+" value:"+zdeff);
						thisSel.options[ii].selected = true;
						}
					}
			} //end for jj
		} // end for ii

	vprint("setSelect2","final selected indexes:"+thisSel.selectedIndex+" out of:"+thisSel.length+":");
	} // end setSelect2
	
// function: setSelect set selections on linked drop down lists
// thisSel -  the select box to change 
// thisAtext - the Array name
// filter - the filter value we are applying
// deff - any default element to select
// note: use setSelect2 - for non-linked lists
function setSelect(thisSel,thisAtext,filter,deff){
	if (filter == "" ||filter =="--"){ // do nothing
	}
	else { // filter is OK
	// this could be a very bad variable name so do some cleanup
	betterText = thisAtext.replace(/\W/g,"");
	vprint("setSelect","setSelect: Array: "+thisAtext+ " ---> betterText:"+betterText +" FILTER:"+filter);
	thisA = eval(betterText);
	// match option length to form length
	// this seems to do the trick
	//20071019 add 1, because of the "select one"
	thisSel.length = thisA.length+1;
		
	vprint("setSelect","num elements in Array:"+thisA.length);
	realnum = 0;
	thisSel.options[realnum].text = "-- Select One --";
	thisSel.options[realnum].value = "";
	realnum++;
	
	for(ii=0; ii<thisA.length; ii++){
		if (filter == thisA[ii].filter ||filter =="ALL") {
			
			// vprint("setSelect","just added to list:"+thisA[ii].text);
			thisSel.options[realnum].text = thisA[ii].text;
			thisSel.options[realnum].value = thisA[ii].value;
			if (deff != null && deff != ""){
				if (deff == thisA[ii].value) {
					vprint("setSelect","SET DEFAULT listDEX:"+realnum+" arrayDEX:"+ii+" value:"+deff);
					thisSel.selectedIndex = realnum;
					}
				}
			//
			realnum++;
			} // end if filter OK
		} // end for
	// we rebuilt the list, reset its length
	thisSel.length = realnum;
	} // end filter OK
	vprint("setSelect","final filtered:"+realnum+" out of:"+thisA.length+" for filter:"+filter);
	} // end setSelect
	
// listObj -- used to build linked dropdowns
function listObj(fil,val,txt) {
	this.filter = fil;
	this.value = val;
	this.text = txt;
	}
// resetOther - add to a SELECTLIST
// warning: can defeat purpose of select list limiting input
function resetOther(thisSel,msg){
	if(msg==null) msg="Please enter it here:";
	var parent_object = thisSel.options;
	var selection = parent_object[parent_object.selectedIndex].value;
	if (selection == "Other" || selection == "other") {
		// prompt for a new value
		stemp = prompt(msg);
		if(stemp!=null && stemp!='' && stemp!="null" && stemp!="undefined")
			parent_object[parent_object.selectedIndex].value = stemp;
		parent_object[parent_object.selectedIndex].text=parent_object[parent_object.selectedIndex].value
		}
	selection = parent_object[parent_object.selectedIndex].value;
	}// ends resetOther
// resetOtherInput - add to a INPUT OR CHECKBOX
function resetOtherInput(thisEl,msg){
	if(msg==null) msg="Please enter it here:";
	vprint("resetOther","resetOther:el.length:"+thisEl.length+" el.name:"+thisEl.name+": msg:"+msg);
	//SINGLE value
	if (thisEl.value == "Other" || thisEl.value == "other") {
		// prompt for a new value
		stemp = prompt(msg);
		if(stemp!=null && stemp!='' && stemp!="null" && stemp!="undefined" && stemp!="Other")
			thisEl.value = stemp;
		else // uncheck it for them
			thisEl[ii].checked = false;
		}
	//ARRAY as with checkboxes
	for (ii=0; ii< thisEl.length; ii++){
		if(thisEl[ii].checked) {
			vprint("resetOther","resetOther:el:"+thisEl[ii].name+ " was checked:"+thisEl[ii].value);
			if (thisEl[ii].value == "Other" || thisEl[ii].value == "other") {
				// prompt for a new value
				stemp = prompt(msg);
				if(stemp!=null && stemp!='' && stemp!="null" && stemp!="undefined" && stemp!="Other")
				thisEl[ii].value = stemp;
				else // uncheck it for them
				thisEl[ii].checked = false;
				}
		}
	}
	}// ends resetOther

// goes with this in page:
//
//<div id="divButtons" name="divButtons">
//<a href="#" class="subNav" onClick="printPage()"><img src="../images/iconPrinter.gif" width="21" height="20" border="0">print page</a>
//</div>
function printPage() {
if(document.all) {
	document.all.divButtons.style.visibility = 'hidden';
	window.print();
	document.all.divButtons.style.visibility = 'visible';
	} 
else {
	document.getElementById('divButtons').style.visibility = 'hidden';
	window.print();
	document.getElementById('divButtons').style.visibility = 'visible';
	}
}
function mailToFriend(){
	// the editor screws this up if put in template
	href = "mailto:address?Subject=Check this out!&Body="+window.location;
	window.location = href;
}

function menuLayer() { // stub to prevent error on RSM menus (when there is no sub menu)
}
function noop() { // stub 
}
function popup(theURL,winName,features) { //v2.0
  window.open(theURL,'popupWindow','toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=400');
}    

// changeList - Increment/Decrement all numeric values in a list
function changeList(thisSel,updown,lolim,hilim,deff){
	var realnum=0,filter="ALL",ii,oldVal,curVal,sdex=0;
	// get the cur number
	// sometimes not _All_ just always start off dex 1
	//if(thisSel.options[0].value=="_All_" ||thisSel.options[0].value=="")
		sdex=1;
	tempA = thisSel.options[sdex].value.split(/-/);
	oldVal=tempA[0];
	curVal = setVal(oldVal,updown,lolim,hilim,"LOOP");
	
	if (deff != null && deff != "") {// use it to set cur val, no inc (for initializing list)
		tempA = deff.split(/-/);
		curVal=tempA[0];
		}
	
	vprint("lists","select box:"+thisSel.id+" num items:"+thisSel.length+", oldVal:"+oldVal+", curVal:"+curVal);
	for(ii=0; ii<thisSel.length; ii++){
		if (true ||filter =="ALL") {
			//alert("just set:"+thisA[ii]);
			thisSel.options[ii].text = thisSel.options[realnum].text.replace(oldVal,curVal);
			thisSel.options[ii].value = thisSel.options[realnum].value.replace(oldVal,curVal);
			if (deff != null && deff != ""){
				if (deff == thisSel.options[ii].value) {
					thisSel.selectedIndex = ii;
					}
				}
			realnum++;
			} // end if filter OK
		} // end for
	}// ends changeList
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// setVal
// inputs: val,inc,lowlim,uplim,[LIMIT/LOOP]
// output: the incremented value
function setVal(inval,inc,lolim,uplim,act){
	var val;
	inval = (isNaN(inval))?0:parseInt(inval);
	inc   = (isNaN(inc  ))?1:parseInt(inc  );
	val =  inval + inc;
	if (val > uplim){
		// overshoot ver can exceed limits!
		//val = (act == "LIMIT")? uplim: lolim+val-uplim;
		val = (act == "LIMIT")? uplim: lolim;
	} else if (val < lolim){
		//val = (act == "LIMIT")? lolim: uplim-(val-lolim);
		val = (act == "LIMIT")? lolim: uplim;
	}
	vprint("util","setVal("+inval+","+inc+","+lolim+","+uplim+","+act+")="+val);
	return (val);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// roundTo -  round a decimal number to indicated dec place
// inputs: num, numdecimal
// output: rounded number
function roundTo(inval,numdec){
	// i.e.numdec=2;  8.333333 -> 8.33
	return (Math.round(inval * Math.pow(10.0,numdec) )/Math.pow(10.0,numdec));
	
}
//
//SPECIAL funtion to get ItemID(UserID) on new registration/existing registration update
// used by VBF
//
function checkItemID(theformname,thedefault,theelname){
	var ret_val="";
	thisform = eval("document."+theformname);
	if(theelname==null)
		theelname="QUserID";
	if(thisform !=null){
		thisel = eval("document."+theformname+"."+theelname);
		// try to use the value if the form if it is there
		// if form element not there
		if(thisel ==null){ //se the default it it is there
			ret_val=thedefault;
			vprint("validate","checkItemID:form:["+theformname+"]:"+thisform.name+ " element null:"+thisel+" USING DEFAULT:["+ret_val+"]");
			}
		else {
			ret_val=thisel.value;
			vprint("validate","checkItemID:form:["+theformname+"]:"+thisform.name+ " USING el:["+theelname+"]:"+thisel.name+" is:"+thisel.value);
			}
		}
	else
		vprint("validate","checkItemID:FORM:["+theformname+"]: was NULL!:"+thisform);
	return(ret_val);
}
//
//SPECIAL funtion to set extra page template parameters on submit
// used by VBF
//
function checkParams(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);
	vprint("validate","checkParams:form:"+thisform.name+ " el:"+thisel.name);
	oneempty=false;
	myDesign = getChecked(thisform.boothdesign);
	if(myDesign=="" || myDesign=="undefined")myDesign="A";
	myColor = getChecked(thisform.boothcolor);
	if(myColor=="" || myColor=="undefined")myColor="y";
	total=0;
	outstr ="";
	errors ="";
	// make an object
	offsetO = new Object({A:-100,B:-25,C:-75,D:-50,E:-50,F:-50}); // these are in the templates but gets overwritten
	tempO = new Object();
	tempO["name"]="TMbooth";
	tempO["verticalOffset"]=offsetO[myDesign];
	vprint("validate","checkParams boothdesign length:"+thisform.boothdesign.length);
	vprint("validate","checkParams boothdesign checked:"+myDesign);
	//stemp="";
	//item1=thisform.boothdesign;
	//for(key in item1)stemp +="\nkey[<b>"+key+"</b>]->"+item1[key];
	//alert(stemp);
	tempO["boothdesign"]=myDesign;
	tempO["boothcolor"]=myColor;
	tempO2=new Object({"pageTemplate":tempO});
	// convert to JSON and store in Params
	outstr =  Ext.util.JSON.encode(tempO2);
	// the params
	thisel.value = outstr;
	// fix sTable
	thisform.sTable.value="template"+myDesign+".asp";
	// fix nTable
	thisform.nTable.value=String(thisform.nTitle.value).replace(/\W/g,'');
	
	vprint("validate","checkParams:object:"+outstr+ ":");
	if (false) // no error checking,just processing
		errors += "\n- check results!:";

	return(errors);
	} // end checkParam  

function tally(total)
	{
		var i, total;
		var y = 0; var u = 0; var n = 0;
		for (i=0; i <= total.length - 1; i++) {
			if (total[i].checked) {
				if (total[i].value == "yes") {
					y = y + 1;
				}
				if (total[i].value == "unsure") {
					u = u + 1;
				}
				if (total[i].value == "no") {
					n = n + 1;
				}	
			}
		}
		if ( y > u && y > n) {
			alert("Looks like this option works for you!");
			return true;
		}else if (y == 0 && u == 0 && n == 0) {
			return false;
		}
		else {
			alert("You might want to check out one of the other options.");
			return true;
		}
	}
//
// parseTime
// inTime: a time in formats of: 10:30am  10:30A.M. 10:30a 1030am 21:00
// Output: 24 hour clock with decimal hours 
function parseTime(inTime) // convert Access to ltform
	{
	var ret_val, message="";
	ta = new Array(3);
	theTime = String(inTime);

	if (inTime == "" || inTime == "undefined") {
		return (0);
		}
	hasPM =0;
	if (theTime.search(/P[.]*M/i) >= 0) {
		hasPM = 1;
		}
	if (theTime.search(/:/) < 0) {
		allerrors +="\nError: missing colon, the hours and minutes must be separated  by a colon, minutes must be entered even for times on the hour:" + theTime;
		// end early
		return (inTime);
		}
	// remove any am/pm
	theTime = theTime.replace(/[AP]\.*M\.*/i,"");

	// switch to colon
	ta = theTime.split(/:/);
	hh = parseInt(ta[0].replace(/^0/,"") ); // drop leading zeros, thinks its octal
	nn = parseInt(ta[1].replace(/^0/,"") );
	//ss = ta[2];
	message+="clean up am/pm" + inTime + " -> " + theTime+ " hour comp:"+hh+" min:"+nn;
	
	// look for PM (but not 12p.m.)
	// i.e. 1pm-> 13, 12pm->12
	if (hasPM && hh!= 12) {
		hh = hh + 12;
		}
	// change any 12am to 0
	if (hasPM == 0 && hh== 12) {
		hh = 0;
		}
	if (hh <0 || hh > 24) {
		allerrors += "\nthe hours must be between 0 and 24! " + hh;
		}
	if (nn <0 || nn > 60) {
		allerrors += "\nthe minuts must be between 0 and 60! " + nn;
		}
	ret_val =  hh + nn/60;
	message+="\n<b>Parse dec hours: in: " + inTime + " out: " +ret_val;
	vprint("hours",message);
	return(ret_val);
	}
// calculate totals for reqeust_modHours
// some versions ONLY use first 3 args
function CMcalculate(St,En,Set,onsite,seton,setoff,daytotal) {
	// loop for all elements
	allerrors="";
	if(St){
		numEl = St.length;
		gtot   = 0; // grand
		ontot  = 0; // onsite
		offtot = 0; // offsite
		for (ii=0; ii< numEl; ii++) {
			// parse each entry
			start = parseTime(St[ii].value);
			end = parseTime(En[ii].value);
			// ie 8pm to 1am is> 1 - 20 = -19 add 24 is 5
			tot = end - start;
			if (tot < 0) { // someone is working night shift 10 pm to 4 am
				tot += 24;
				}
			// update line total if we have one
			if(daytotal)
				daytotal[ii].value=tot;
			vprint ("hours","line" + ii + ": " + end + " - " + start + " = " +tot);
			gtot += tot;
			if(onsite){
				if (onsite[ii].value=="1") ontot += tot;
				else if (onsite[ii].value=="0") offtot += tot;
				//vprint ("hours","onnsite[" + ii + "] =" + onsite[ii].value + " ontot: " + ontot + " offtot: " +offtot);
				}
			
			} // end for all days
		Set.value = roundTo(gtot,2);
		if(seton) seton.value = roundTo(ontot,2);
		if(setoff) setoff.value = roundTo(offtot,2);
		} // end if valid element (exempt employee wont have)
	if (allerrors !="")
		alert(allerrors);
	}

function setText(dex,newText,selector) { //v3.0
  
  if(selector ==null)selector="r_";
	//alert("setting "+selector+"onSite["+dex+"] to"+newText );
	if(selector =="r_"){
		document.request.onSite[dex].value = newText;
		if (newText == -1) {
			if (document.request.r_start_t){
				document.request.r_start_t[dex].value = "";
				document.request.r_end_t[dex].value = "";
				}
			}
		}
	else 
	{
		document.request.c_onSite[dex].value = newText;
		if (newText == -1) {
			if (document.request.c_start_t){
				document.request.c_start_t[dex].value = "";
				document.request.c_end_t[dex].value = "";
				}
			}
		}
	}


function submitit(){
//alert ('submitting form NOW');
document.request.submit();
}        

//
//SPECIAL funtion to check that FWA is selected and enable other elements
// careful - used by multiple companies
// 20090706 switch to AJAX mode
//
function checkFWAchoice(theformname,theelname) {
	var ii;
	var thisform = eval("document."+theformname);
	var thisel = eval("document."+theformname+"."+theelname);
	vprint("checkStates","checkFWAchoice:form:"+thisform.name+ " el.name:"+thisel.name+": el.length:"+el.length+": parttime%:"+thisform.QPercentReduce.value+":");
	var errors="";
	//alert ('existing ret val:'+document.MM_returnValue+':');

	var onechecked=false;
	var numchecked=0;
	var foundpt=false;
	var foundOther = false;
	// go through all checkboxes
	for (ii=0; ii< thisel.length; ii++){
		if(thisel[ii].checked) {
			numchecked++;
			onechecked = true;
			vprint("checkStates","==checkFWAchoice:el:"+thisel[ii].name+ " was checked:"+thisel[ii].value);
			// special value processing
			if (thisel[ii].value == 3 || thisel[ii].value==4){ // parttime or jobshare, enable percent
				foundpt = true;
				if(thisform.QPercentReduce.value=="") {
					errors += "- You need to enter a work percentage for ";
					errors += (thisel[ii].value == 3)?"Part Time!\n":"Job Share!\n";
					if(thisel[ii].value == 3)
					errors = "JS_NO_WP_PT";
					else
					errors = "JS_NO_WP_JS";
					}
				else if (isNaN(thisform.QPercentReduce.value)) {
					errors+='- Part Time Percent must contain a number!\n';
					errors = "JS_PTP_NUMBER";
					thisform.QPercentReduce.focus();
					thisform.QPercentReduce.bgColor="#FF0000";
					} // end NaN
				} // end PT JS
			else if (thisel[ii].value == 7 ){ // other, enable FWAother
				foundOther = true;
				if(thisform.QFWAother.value=="") {
						errors+= "- You need to enter a description for Other!\n";
						errors="JS_OTHER_DESC";
						thisform.QFWAother.focus();
						thisform.QFWAother.bgColor="#FF0000";
						}
				} // end OTHER
			else {
			} // end NOT PT JS
			} // end item checked
		} // end for all items
	if (onechecked == false) {
		errors += "- You need to choose a type!\n";
		errors = "JS_NO_TYPE";
		}
	if (numchecked > 1 && foundOther==true) {
		errors += "- If Other is selected, nothing else can be selected!\n";
		errors = "JS_OTHER_ONLY";
		}
	if (foundpt == false &&thisform.QPercentReduce.value!="") {
		errors += "- You can enter a Part Time Percent only for Part Time or Job Share!\n";
		errors = "JS_NO_PTP_HERE";
		}
	if(thisform.QFWAother){ // make sure there is an OTHER or error checking fails
	if (foundOther == false &&thisform.QFWAother.value!="") {
		errors += "- You can enter a description for Other if Other is checked!\n";
		errors = "JS_OTHER_NOT_CHECKED";
		}}
	vprint("checkStates","==checkFWAchoice returning:"+errors);
	return(errors);
	}
//GENERAL function check that FWA is selected
// NOTE: now use the ordinary "required" from question properties
function checkFWA() {
	errors='';
	//alert ('existing ret val:'+document.MM_returnValue+':');
	if (document.request.FWAchoice.selectedIndex == 0) {
		errors = "You need to choose an FWA type!";
		}
	if (errors) alert('The following error(s) occurred:\n'+errors);
	if (document.MM_returnValue == true) { // we had some previous errors, dont zero out
	
		document.MM_returnValue = (errors == ''); // true = no error, false = error
		//alert ('setting ret val:'+document.MM_returnValue+':');
		}
	}
//
//SPECIAL funtion to check that workstates is properly filled in
// used by Amg
//
function checkworkStates(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);
	vprint("checkStates","checkStates:form:"+thisform.name+ " el:"+thisel.name);
	oneempty=false;
	total=0;
	outstr ="";
	errors ="";
	// go through states
	for (ii=0; ii< thisform.planned.length; ii++){
		// radio button dropped myval0 = (thisform.homestate[ii].checked == true)?"checked":"unchecked";
		// but still expecting 3 item array: checked,CA,33|...
		myval0 = "xx";
		myval1 = thisform.states[ii].value;
		myval2 = thisform.planned[ii].value;
		if(myval2 =="")myval2="0";
		outstr += myval0+","+myval1+","+parseInt(myval2);
		total  += parseInt(myval2);
		if (ii< thisform.planned.length -1) outstr +="|";
		if(myval2 =="" || myval2=="0")
			oneempty=true;
			
		}// end foreach state
	// one empty check dropped 20070614
	//if (oneempty == false) 
		//errors += "\nerror ,when specifying 4 states, the home state must have a work percentage of 0";
	if (total != 100) {
		errors += "\n- workstate percentages must total 100!, currently:"+total;
		errors = "JS_WORKSTATES";
	}
	thisel.value = outstr;
	thisform.plannedTotal.value = total;
	return(errors);
	}
//
//SPECIAL funtion to check that WIN is 8 digets
// used by MRCK
//function checkWIN(theformname,theelname){
function checkUserPassword(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);
	vprint("validate","checkWIN:form:"+thisform.name+ " el:"+thisel.name+ " el.value:"+thisel.value);
	outstr ="";
	errors ="";
	// check length is 8
	if(thisel.value.length != 8)
		errors += "\n- WIN must be 8 digets!, currently:"+thisel.value.length;
	// check is numbers
	if (isNaN(thisel.value)) 
		errors += "\n- WIN must be integer!, currently:"+thisel.value;
	return(errors);
	} // end checkWIN
//
//SPECIAL funtion to check MerckSpace is selected (because regular 'R' not working for radio buttons)
// used by MRCK
//function checkOfficeLoc(theformname,theelname){
function checkOfficeLoc(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);
	vprint("validate","checkOfficeLoc:form:"+thisform.name+ " el:"+thisel.name+ " el.value:"+thisel.value);
	outstr ="";
	errors ="";
	
	// go through all radio buttons
	somethingchecked=false;
		for(xx=0;xx<thisel.length; xx++)
			if(thisel[xx].checked==true || thisel[xx].checked=="true") somethingchecked=true;

	// check selected
	if(!somethingchecked)
		errors += "\n- MerckSpace must be selected!";
	return(errors);
	} // end checkOfficeLoc
	
//SPECIAL funtion to run when MerckSpace radio is clicked yes or no
// used by MRCK
function enableRadio(theformname,theelname,onoff){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);
	vprint("validate","enableRadio:form:"+thisform.name+ " el.name:"+thisel.name+ " el.length:"+thisel.length);
	outstr ="";
	errors ="";
	// enable bizunit radio buttons
	for(xx=0;xx<thisel.length; xx++){
		thisel[xx].disabled=((onoff=="YES")?false:true);
		if(onoff=="NO")thisel[xx].checked=false;
	}
}
//
//
//SPECIAL funtion to check IDS from popups
// 
function getUserID(theformname,theelname){
	//thisform = eval("document."+theformname);
	//thisel = eval("document."+theformname+"."+theelname);
	if(theelname==null)theelname="QUserID";
	//myVal = MM_findObj(theelname);
	myVal = eval("document."+theformname+"."+theelname);
	stemp=String(myVal.value);
	vprint("getUserID","getUserID:form:"+theformname+ "  .el("+theelname+").value:"+stemp);
	
	return(stemp);
	} // end checkimg 

//
//SPECIAL funtion to check that an image was loaded
// used by MRCK
// if no image, thi div Qimg will have text; "no images loaded"
function checkimg(theformname,theelname){
	//thisform = eval("document."+theformname);
	//thisel = eval("document."+theformname+"."+theelname);
	myDiv = MM_findObj(theelname);
	stemp=String(myDiv.innerHTML);
	vprint("validate","checkimg:myDiv:"+typeof(myDiv)+ "  myDiv("+theelname+").innerHTML:"+stemp);
	outstr ="";
	errors ="";
	// check if image loaded, this phrase is in admin/en/showFiles.asp
	if(stemp.indexOf( "No images loaded")>=0)
		errors += "\n- an upload image is required!";
	
	return(errors);
	} // end checkimg
function checkrelimg(theformname,theelname){ // other names
  return( checkimg(theformname,theelname));
}
//
// special prompt function to check for errors
// TODO move to ques params?
//
function checkReviewer2Name(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);

	outstr ="";
	errors ="";
	doublecheck= confirm('DOUBLE CHECK THE EMAIL INFORMATION YOU ENTERED. If you entered incorrectly the FWA request will NOT reach your manager.   Do you wish to submit now?');
	vprint("validate","checkReviewer2Name:form:"+thisform.name+ " el:"+thisel.name+ " confirm returned:"+doublecheck+":");
	// check length is 8
	if(!doublecheck )
		errors += "\n- Please correct and submit again";
	// check is numbers

	return(errors);
} // end checkReviewer2Name

//
// SDX special popup function to check for errors
//
function check1Comments(theformname,theelname){
	thisform = eval("document."+theformname);
	thisel = eval("document."+theformname+"."+theelname);

	outstr ="";
	errors ="";
	doublecheck= confirm('By clicking the save button you are finalizing the assessment responses. No changes can be made thereafter.  Do you wish to submit now? ');
	vprint("validate","check1Comments:form:"+thisform.name+ " el:"+thisel.name+ " confirm returned:"+doublecheck+":");
	// check length is 8
	if(!doublecheck )
		errors += "\n- To extend the session timeout CNTLclick any link on left.";
	// check is numbers

	return(errors);
} // end check1Comments


var expMinutes = 10000; // number of minutes the cookie should last (7 days)
var expweek= new Date(); 
expweek.setTime(expweek.getTime() + (expMinutes*60*1000));

var expMinutes = 10000 * 4; // number of minutes the cookie should last (7 days)
var expmonth= new Date(); 
expmonth.setTime(expmonth.getTime() + (expMinutes*60*1000));
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
	}
function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
	}
function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}

// not called directly, called by GetCookie
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}
//
// check whether to popup survey
//
function amt(){
	var popup = GetCookie('pageviews')
	if(popup == null) {
		SetCookie('pageviews','1')
		return 1
		}
	else {
		var newpopup = parseInt(popup) + 1;
		//alert("set pageviews from:" + popup + " to:" + newpopup);
		DeleteCookie('pageviews')
		// note: cookie will not expire if user returns with in month
		SetCookie('pageviews',newpopup,expmonth)
		return popup
		}
	}
function checkPopup(){
  surveyed=GetCookie('surveyed');
  if (surveyed==null)  {
	// see if visited at least 10 pages
	number =amt();
	if (number > 11) {
		// show the survey window and dont show again for a week
		SetCookie('surveyed','yes',expweek)
		MyWindow=window.open('../../clas/en/feedback.asp','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=840,height=720,left=1,top=1');window.blur();
		}
	}
	else {
		//alert("already surveyed");
	}
}
// called in body unload event :checkpopup();
//
// setheight - sets height of fwa approval popup
//
function setheight(thisel){
	if (navigator.appName == "Netscape"){
		browser="netscape";
		}
	else {
		browser="explorer";
		}
	message ="BROWSER "+browser;
	// not in i.e. 
	message += "\ndocument width height: "+ document.width + ", " + document.height;
	message += "\n clientTop:"+document.body.clientTop;
	message += "\n *offsetTop*:"+document.body.offsetTop;
	message += "\n OLD setting this *offsetHeight*:"+document.body.offsetHeight;
	message += "\n OLD minus half this *clientHeight*:"+document.body.clientHeight;
	message += "\n scrollTop:"+document.body.scrollTop;
	message += "\n scrollHeight:"+document.body.scrollHeight;
	message += "\n Now setting: getScrollHeight:"+getScrollHeight();
	// error in i.e.
	//message += "\n window.innerHeight:"+window.innerHeight);
	//alert("DATA:"+message);
	myObj = MM_findObj(thisel);
	//newy =  document.body.offsetHeight - document.body.clientHeight/2;
	newy = getScrollHeight();
	myObj.style.top = newy +"px"; 
	//alert("alert working here, values set ok, final y:"+newy);
	}
// END GLOBALS
