<!--
/* 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 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,ret_val="";  
	d=document;
	// because dreamweaver's findObj doesn't find frames in netscape
	for(i=0;i<frames.length;i++) {
		if(frames[i].name==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);
	return myframe.document.body.innerHTML;
	}
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;
	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 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]);
    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)) {
					errors+='- '+nmNO_Q+' must contain an e-mail address.\n';
					el.focus();
					el.bgColor="#FF0000";
				}
			// 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+":");
        if (ret_val !="") {
					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
				vprint("validate","item name:"+nm+": looks like dropdown or checkboxes selected:"+el[el.selectedIndex].value);
				if(el.value=="_All_" || el.value=="undefined" || el.value=="null"){
					errors+='- '+nmNO_Q+' must choose a value.\n';
					el.focus();
					el.bgColor="#FF0000";
					}
      } else if (test!='R') {             // -- REQUIRED NUM
				num = parseFloat(val);
        if (isNaN(val)) {
					errors+='- '+nmNO_Q+' must contain a number.\n';
					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) {
						errors+='- '+nmNO_Q+' must contain a number between '+min+' and '+max+'.\n';
						el.focus();
						el.bgColor="#FF0000";
					}
					} 
				} 
			}  // end NOT blank
			else if (test.charAt(0) == 'R') {   // -- REQUIRED anything
				errors += '- '+nmNO_Q+' is required.\n';
				el.focus();
			el.style.background="#FF0000";
		}
		}
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
	}

//
// 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 bwidth=180;// clip window width
var sheight=100;//scroller height
var bheight=155; // clip window height

//scroller's speed;
var sspeed=1;

function startSlider(zw,zh,buffer,border,direction){
	swidth=zw;
	bwidth=zh;
	sheight=zh;
	bheight = zh;
	if(direction==null)direction="up";
	/* 20090312 remove ie version
	if (document.all){
		//alert("found document.all");
		document.writeln('<marquee id="ieslider" scrollAmount=2 width='+zw+' height='+zh+' direction='+direction+'  style="padding:'+buffer+'px; border:1 solid '+border+'">')
		document.writeln(wholemessage)
		ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
		ieslider.onmouseout=new Function("if (document.readyState=='complete') ieslider.scrollAmount=2")
		document.write('</marquee>')
		}
		*/
	if (true){ //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>')
		}
	startSliderMotion(direction);
	} // end startSlider
	
function startSliderMotion(direction){

if (true){ //FFFFFFFFFF firefox
	myObj = MM_findObj("slider");
	//myObj.style.top = sheight +"px";
	//alert ("firefox, starting slider: "+myObj.id + ": cur top:"+myObj.style.top +": Ext.top:"+Ext.get("slider").dom.style.top) ;
	myObj.style.visibility="visible";
	ns6marquee(myObj,direction);
	}

}// end startSliderMotion


function ns6marquee(whichdiv,direction){ //FFFFFFFFF firefox
	//ns6div=eval(whichdiv);
	ns6div=whichdiv;
	ns6div.innerHTML=wholemessage;
	//alert("slider: past set text");
	if(direction=="up"|| direction=="down")
		ns6div.style.top=sheight +"px";
	else
		ns6div.style.left=swidth +"px";
	sizeup=sheight;
	sizeacross=swidth;
	ns6slide(direction);
	}
function ns6slide(direction){
	//alert("firefoxslide, div id: "+ns6div.id+" top currently at:"+ns6div.style.top+ ": 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+'")',100)
		}
	else{
		// go back down
		ns6div.style.top=sheight + "px";
		// keep going
		ns6slide(direction)
		}
} // end up down
else {
	if (parseInt(ns6div.style.left)>=(sizeacross+bwidth)*(-1)){
		ns6div.style.left=(parseInt(ns6div.style.left)-sspeed)+"px";
		// keep moving
		setTimeout('ns6slide("'+direction+'")',100)
		}
	else{
		// go back down
		ns6div.style.left=swidth + "px";
		// keep going
		ns6slide(direction)
		}
	}// end left right
}

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;
//alert("moveBG 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:
	//alert("the image is:"+document.body.style.backgroundPosition+": image:"+document.body.style.backgroundImage);
	//alert(" by getElement:"+document.getElementById("thebody").style.backgroundPosition);
	el = Ext.get("thebody");
	// IE use XY, firefox without
	stempO = el.getStyles('backgroundPosition', 'backgroundPositionX','backgroundPositionY','backgroundImage') ;
	//alert(" by Ext.getStyles:"+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
		//alert("moveBG FIRSTCALL, dir:"+direction+" cookie offset:"+itemp+": alternate2:"+itemp2+": alternate3:"+itemp3+":");
		if(itemp!=null && itemp!="" && itemp!="undefined"){ // check Ext first
			//alert("moveBG FIRSTCALL,offset:"+itemp+": type:"+typeof(itemp)+ " itemp[1]:"+itemp[1]+":");
			newbgPosx=parseInt(itemp[0]);
			newbgPosy=parseInt(itemp[1]);
			dx=parseFloat(newbgPosx-curPosx);
			dy=parseFloat(newbgPosy-curPosy);
			dRAD=Math.atan(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
			speed=parseInt(itemp3.replace(/n:/,"") ); // this was abandoned
		else
			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
	//alert("BACKGROUND direction:"+direction+" dRAD:"+dRAD+" 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 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
//
// Cookie utility functions
//
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;
	} // end getCookie
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" : "");
	} // end setCookie
function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	} // end DeleteCookie

// 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));
	} // end getCookieVal
//
// call this function to 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();

// 
// arg1 the count time in sec
// arg2 the mode count UP or DOWN
// called with startTimer(PARAMS) passed in as string "counter=10 inc=-1 formName=TABNAME elName=RNAME mode=recordShow/recordHide/Show"
function startTimer(PARAMS){
	PARAMS=PARAMS.replace(/\s/g,";");
	PARAMS=PARAMS+";";
	// one-time hide show of elements
	vprint("StopWatch"," START:"+PARAMS);
	var browser="IE";
	if (!document.all && document.getElementById) {
		// we have a DOM browser
		vprint("StopWatch","DOM browser found");
		browser="DOM";
		}
	junk = eval(PARAMS+";");
	var myDocEl=eval("document."+formName+"."+elName);
	//alert("the element type="+myDocEl.type);
	if(mode=="recordShow")
		;// nothing
	else if(mode=="recordHide")
		myDocEl.type="hidden";// hidden form element
	else{ // disable
		// IE won't let you change type dynamically 
		if(browser=="DOM")
			myDocEl.type="hidden";
		else{
			myDocEl.height=0;myDocEl.width=0;
			}
		myDocEl.disabled=true;
		}
	//alert("startTimer called, counter:"+counter+", inc:"+inc);
	window.setTimeout("testTimer('"+PARAMS+"');",1000); 
	}
function testTimer(PARAMS) {
	vprint("StopWatch","testTimer going with params:"+PARAMS);
	junk = eval(PARAMS);
	counter =parseInt(counter) +parseInt(inc);
	// convert to MM:SS
	counterMS = seconds2minutes(counter);
	if(mode=="Show"){
		myAnch = findAnchor(formName+"Anch"+elName);
		myAnch.innerHTML=counterMS;
		}
	else {
		myEl = eval("document."+formName+"."+elName);
		myEl.value = counterMS;
		}

	if (inc <0) {// DOWN
		// see if at end
		if(counter<=0) // submit form
			eval("document."+formName).submit();
		}
 	// recursive call ** UP or DOWN **
	if(counter>0) {
		PARAMS = 'counter="'+counter+'"; inc="'+inc+'";formName="'+formName+'"; elName="'+elName+'"';
		window.setTimeout("testTimer('"+PARAMS+"');",1000); 
		}
	}
function seconds2minutes(inval){
	inval = parseInt(inval);
	if(inval <= 60)
		ret_val = "0:"+ leadingzero(inval,2);
	else
		ret_val = parseInt(inval/60) +":"+ leadingzero(inval%60,2) ;
	return (ret_val);
	}
function leadingzero(inval,num){
	inval = inval.toString();
	ret_val=inval;
	for(ii=inval.length;ii<num; ii++)
		ret_val = "0"+ret_val;
	return(ret_val);
	}
	
// END GLOBALS
-->

