// JavaScript Document
var popUp;
var inPopUp=0;
var xxx = 0; var yyy = 0;
var oH=0;
var abody='';
var ahead='';
var personlAccess=0;
var ieDOM = 0, nsDOM = 0; 
var secrets;
var MAY_EDIT_ITEM=4;
var MAY_ADD_MENUS=8;
// these next few lines resolve the broswer type and hence the object model
// their only use is in the objectStructure function
var stdDOM = document.getElementById; // firefox, safari
var isIE = document.all ? true : false; // additional check needed for decoding event logic
var EVinfo=new Object();
if (!stdDOM) 
{
	if (!isIE)
	{
		var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
			&& (parseInt(navigator.appVersion) ==4)); 
	}
}	
function passWordInput(rawEvent,mode)
{
	/* notes
		onkeypress will report control keys in firefox, but not in ie
		onkeydown does not cancel the input, even with a return(false)
		in ie, moving to a new focus before edning the event leaves the new value in the new element - 
		whereas firefox correctly sets the value of the current element then moves the focus.
	*/
	resolveEventByDOM(rawEvent); // set EVinfo
	var k=EVinfo.keyCode||EVinfo.charCode;
	//var k=EVinfo.keyCode?EVinfo.keyCode :EVinfo.charCode;
	switch(k)
	{
		case 35: // end\
		case 36: // home
		case 37: 
		case 123: // mac
		case 38:
		case 124:
		case 39:
		case 125: // mac
		case 32: // space
		case 40:
		case 126: 
		case 46: // insert
//		case 9: // tab
		case 27: // escape
		case 45: // delete
		case 33: // pageup
		case 34: // pagedown
			return (false);
	}
	if(k==9)return(true);
	if(mode==2)
	{
		switch(k)
		{
		case 8: // backspace
			x=document.a.thePassword.value.length;
			if(x)
			{
				document.a.thePassword.value=document.a.thePassword.value.substring(0,x-1);
				document.a.fakePassword.value=document.a.fakePassword.value.substring(0,x-1);
				//alert(x+"=x v="+document.a.thePassword.value);
			}
			return(false);
		case 35: // end\
		case 36: // home
		case 37:
		case 123: // mac
		case 38:
		case 124:
		case 39:
		case 125: // mac
		case 32: // space
		case 40:
		case 126: 
		case 46: // insert
		//case 9: // tab
		case 27: // escape
		case 45: // delete
		case 33: // pageup
		case 34: // pagedown
			return (false);
		}
		return(true);
	}
	if(k<32 || k>127)return(false);
	//if(k>96)k=k-48; // convert keypad raw codes
	newchar=String.fromCharCode(k);
	document.a.thePassword.value=document.a.thePassword.value+newchar;
	document.a.fakePassword.value=document.a.fakePassword.value+'*';
	//alert(document.a.thePassword.value+" k="+k+", n="+newchar+".");
	return(false);
}
var passwordcount;
function requirePassword(cnt)
{
	if(!cnt)
	{
		document.a.thePassword.value='';
		return true;
	}
	if(!passwordcount)
	{
		alert("re-enter your password");
		document.a.thePassword.value="";
		passwordcount=1;
		return false;
	}
}
function submitMe(theName)
{
	// create a form element with the same name as the submit button it replaces
    simButton = addElem(theName,'hidden');
    document.a.appendChild(simButton);    
	// then create a real submit subbton ...
	simButton=addElem("simB",'submit');
    document.a.appendChild(simButton); 
	// ...which we will click
	document.a.simB.click();
	// because the following line does not necesarily execute an 'onbumit' associated with the containing form
   // document.a.submit();
}
function addElem(theName,btype) 
{
	var elm = null;
	try {
		// for IE
		elm=document.createElement('<input type="'+btype+'" name="'+theName+'" value="simulated button" style="display:none">');
		}
	catch(e) {
		// for everybody else
		elm = document.createElement('input');
		elm.setAttribute('type', btype);
		elm.setAttribute('style','display:none');
		elm.name=theName;
		elm.value='simulated button';
		}
	return elm;
}
function moveToAnchor(thispos){window.location.hash=thispos;}
function writeFontCookie(SFS,catx)
{
	// SFS=startingFontSize
	var k=readFontCookie('new_font_size');
	var today = new Date();
	var the_date = new Date("December 31, 2023");
	var the_cookie_date = the_date.toGMTString();
	var bw=getBrowserWidth();			
	var newfontsize=Math.round((12/80)*bw)/10;		// font size to one decimal place
	var screenProportion=bw/1024;
	if(bw<750)newfontsize=SFS*(8/12);
	else if(bw<890)newfontsize=SFS;
	else if(bw<990)newfontsize=SFS*(13.5/12);
	else if(bw<1090)newfontsize=SFS*(16/12);
	else if(bw<1190)newfontsize=SFS*(19/12);
	else if(bw<1300)newfontsize=SFS*(20/12);
	else newfontsize=SFS*(23/12);
	newfontsize=Math.round(newfontsize); // some browsers force integer base font size
	if(newfontsize<8)newfontsize=8;
	var the_cookie = "new_font_size="+ newfontsize;
	var the_cookie = the_cookie + ";expires=" + the_cookie_date;   
	document.cookie=the_cookie;
	if(k!=newfontsize)
	{
		location.href="?Catid="+catx;
	}
}
function readFontCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function getBrowserWidth()
{
	if (document.documentElement && document.documentElement.clientWidth != 0)
	{
		return document.documentElement.clientWidth;
	}
	if (window.innerWidth)
	{
		return window.innerWidth;
	}
	else if (document.body) // internet explorer
	{
		return document.body.clientWidth;
	}			
	return 0;
}
function initContextMenus()
{
	// N.B. 'contextmenu' is a synonym for 'right click'
	d=document.body;
	if (d.addEventListener) 
	{
		d.addEventListener("contextmenu", showContextMenu, true);
	} 
	else 
	{
		// IE event model
		d.oncontextmenu = showContextMenu;
	}
}
function doMouseOver(rawEvent)
{
	theEvent=resolveEventByDOM(rawEvent)
	var itemx = theEvent.target;
	if(itemx.isLink=="link")itemx.className=itemx.holdClass+" linkhover";
	if(itemx.isLink=="linkpic")itemx.className=itemx.holdClass+" picturehover";
}
function doMouseOut(rawEvent)
{
	theEvent=resolveEventByDOM(rawEvent)
	var itemx = theEvent.target;
	if(itemx.isLink=="link")itemx.className=itemx.holdClass;
	if(itemx.isLink=="linkpic")itemx.className=itemx.holdClass;
}
function moveSudokuFocus(newID)
{
	var id=parseFloat(EVinfo.target.id);
	// id's are numeric cna correspond witht he cell positions from 0 to 80
	id=id+newID;
	if(id<0)id+=81;
	else if(id>80)id-=81;
	objectStructure(id).focus();
	OID.select();
	return(true);
}
function generalizeObjects(thing)
{
	if(isIE) // ie
	{
		window.innerWidth=document.body.clientWidth;
		window.innerHeight=document.body.clientHeight;
		window.pageXOffset=document.body.scrollLeft;
		window.pageYOffset=document.body.scrollTop;
		window.screenX=window.screenLeft;
		window.screenY=window.screenTop;
	}
	else if(!stdDOM)
	{
		window.innerWidth=0
		window.innerHeight=0
		window.pageXOffset=0 
		window.pageYOffset=0
		window.screenX=0
		window.screenY=0
	}
	var allElements = document.getElementsByTagName('*');
	for(var m=0;m<allElements.length;m++)
	{
		oneElem=allElements[m]; 
		if(oneElem.title=="link" || oneElem.title=="linkpic") 
		{
			oneElem.holdClass=oneElem.className;
			oneElem.isLink=oneElem.title;
			oneElem.title='';
		}
		if(oneElem.clip) // make IE objects emulate stadard DOM
		{
			oneElem.offsetWidth=oneElem.clip.width;
			oneElem.offsetHeight=oneElem.clip.height;
		}
	}
	initLinkMenus();
	focus2(); 
	el=objectStructure(thing);
	el.style.display='block';
}
function initLinkMenus()
{
	d=document.body;
	if (d.addEventListener) 
	{
		d.addEventListener("mouseover", doMouseOver, true);
		d.addEventListener("mouseout", doMouseOut, true);
	} 
	else 
	{
		// IE event model
		d.onmouseover = doMouseOver;
		d.onmouseout = doMouseOut;
	}
/*{
	//var allElements=document.forms[0].elements; 
	var allElements = document.getElementsByTagName('*');
	for(var m=0;m<allElements.length;m++)
	{
		if(allElements[m].isLink=="link" || allElements[m].isLink=="linkpic") 
		{
			allElements[m].holdClass=allElements[m].className;
		}
	}
}
*/
	/* also
		window.screen.availWidth;
		window.screen.availHeight;
		window.screen.height;
		wnidow.screen.width;;
	*/
	return;
}
function resolveEventByDOM(rawEvent)
{
	// 'event' is a global set in IE when an event occurs. rawEvent is an event code passed by the function
	// for non-ie DOMs.  if both rawEvent and event are null then there was no event
	EVinfo= (rawEvent) ? rawEvent : ((event) ? event : null);
	if(isIE)
	{
		var b=EVinfo.button;
		// read-only property on next line
		//EVinfo.button=(b==1)?0:((b==4)?0:2); // 0=left, 1=middle, 2=right
		EVinfo.charCode=EVinfo.keyCode;
		EVinfo.target=EVinfo.srcElement;
		EVinfo.relatedTarget=(EVinfo.fromElement)?EVinfo.fromElement:EVinfo.toElement;
		EVinfo.pageY=EVinfo.clientY+document.body.scrollTop;
		EVinfo.pageX=EVinfo.clientX+document.body.scrollLeft;
	}
	return EVinfo;
	
}
function sudokuInput(rawEvent)
{
	/* notes
		onkeypress will report control keys in firefox, but not in ie
		onkeydown does not cancel the input, even with a return(false)
		in ie, moving to a new focus before edning the event leaves the new value in the new element - 
		whereas firefox correctly sets the value of the current element then moves the focus.
	*/
	resolveEventByDOM(rawEvent); // set EVinfo
	var k=EVinfo.keyCode||EVinfo.charCode;
	var id=parseFloat(EVinfo.target.id);
	switch(k)
	{
	case 35: // end
		moveSudokuFocus(80-id);
		return(true);
	case 36: // home
		moveSudokuFocus(-id);
		return (true);
	case 37:
	case 123: // mac
		moveSudokuFocus(-1);  // left arrow
		return (true);
	case 38:
	case 124:
		moveSudokuFocus(-9); // up arrow
		return (true);
	case 39:
	case 125: // mac
	case 32: // space
		moveSudokuFocus(+1);  // right arrow
		return (true);
	case 40:
	case 126: 
		moveSudokuFocus(+9); // down arrow
		return (true);
	case 46: // insert
		return (false);
	case 9: // tab
	case 27: // escape
	case 45: // delete
	case 33: // pageup
	case 34: // pagedown
		return(true);
	}
	if((k<48 || k>57)&&(k<97||k>105)) // latter is numbers on keypad
	{
		//alert(k);
		return(false);
	}
	if(k>96)k=k-48; // convert keypad raw codes
	EVinfo.target.value=String.fromCharCode(k);
	if(id==80)id=0;
	else id++;
	objectStructure(id).focus();
	OID.select();
	return(false);
}


// get the structure, regardles of browser , of a form element where id='objectid'
function objectStructure(objectId) 
{
	var os;
	if (stdDOM) os= document.getElementById(objectId);
	else if (isIE) os= document.all[objectId];
	else if (nsDOM) os =document.layers[objectId];
	else alert("Object model not recognized");
	return os;
}
function noDefault(theEvent)
{
	if (theEvent.preventDefault) theEvent.preventDefault();
	theEvent.returnValue = false;
}
function trim(s) 
{
	while (s.substring(0,1) == ' ') 
	{
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') 
	{
		s = s.substring(0,s.length-1);
	}
	return s;
}
function toggleAll(state) 
{ 
	var boxes = document.getElementsByTagName('input');
	var box, i=0; 
	while(box=boxes[i++]) 
	{
		if(box.className == 'cbox')
		{ 
			box.checked = state; 
		} 
	}
} 
function toggleAllID(theLeft,theRight,state) 
{ 
	/*
		 can toggle checkboxes to on or off  using a substring of the id string.
		 it imagines a 2D array of cheboxes in which all of a row or all of a
		 column will be turned on or off.  the first 3 characters of the id are the
		 name of a row, the next up to 5 are the name of a column..
		 So a checkbox like this <input type=checkbox id="rrrc">
		 could be turned on with toggallD('rrr','',1) or with toggleAllD('','c',1)
	*/
	var boxes = document.getElementsByTagName('input');
	var box, i=0; 
	while(box=boxes[i++]) 
	{
		if(box.className == 'cbox')
		{ 
			if(box.id.substring(0,3)==theLeft)box.checked = state; 
			if(box.id.substring(4,5)==theRight)box.checked = state; 
		} 
	}
} 
function loadcomplete(thing)
{
	el=objectStructure(thing);
	el.style.display='block';
}
function reveal(drop,family)
{
	dr=drop; //objectStructure(drop,0);
	el=objectStructure(family);
	elStyle=el.style;
	el.className='';
	if(dr.value=='any')	elStyle.display='none';
	else 	elStyle.display='';
	dr.style.display='none';
}
function revealThis(toShow)
{
	el=objectStructure(toShow);
	elStyle=el.style;
	elStyle.display='block';
}
function kThru(val)
{
	window.location='?CatId='+val;
}
function passCatId(val)
{
	window.location='?CatId='+val;
}
// designed to display various spans based on radio button alternatives
function altRad(family,limit,which)
{
	for(i=1;i<=limit;i++)
	{
		j=family+i;
		el=objectStructure(j);// document.getElementById(j);
		elStyle=el.style;
		if(which==1)
		{
			el.className='';
//			elStyle.visibility='';
			elStyle.display='';
//			elStyle.position='relative';
		}
		else
		{
			//el.className='secret';
			//elStyle.visibility='hidden';
			el.className='';
			elStyle.display='none';
			//elStyle.position='absolute';
		}	
	}
}
var lastTog=-1;
function toggleMe(myid,which)
{
	// works only if toggleMe is called in only one place on a form (because of  lastTog ambiguity)
	j=myid;
	el=objectStructure(j);// document.getElementById(j);
	elStyle=el.style;
	if(lastTog!=-1)which=1-lastTog;
	lastTog=which;
	if(which==1)
	{
		el.className='';
		elStyle.display='';
	}
	else
	{
		el.className='';
		elStyle.display='none';
	}	
}
function clickIt(what,evt)
{
	el=objectStructure(what);
	el.click();
	return;
}
function hide()
{
	inPopUp=0;
	popUp.style.display='none';
}
function mayhide()
{
	window.status="hide";
	popUp.timeoff=setTimeout("hide()",100);
}
function keep()
{
	window.status="keep";
	clearTimeout(popUp.timeoff);
}

function addMenuItem(tx,ndx,opt)
{
return( "\n<tr><td>" +
"<a href=\"?MenuItem="+ndx+"&"+"MenuOpt="+opt+"\">" +tx +
"</a></td></tr>");
}
 
function showContextMenu(rawEvent)
{
	var ahead='';
	var abody='';
	theEvent=resolveEventByDOM(rawEvent)
	var itemUnderClick = theEvent.target;
	Llup=0;
	while(itemUnderClick.id.length<1) // in case we clicked on a child of the thing
	{
		itemUnderClick=itemUnderClick.parentNode;
		Llup++;
		if((itemUnderClick.nodeName=='#document')||(Llup>20))
		{
			noDefault(theEvent); // no context menu available
			return;
		}
	}
	// example of itemID:	"MP62S30" for left-side items
	//                                     		"DAX166S" for content-side items
	//											"C527S" for a flag item
	//											"ED1224655200" for a calendar entry
	var itemID=trim(itemUnderClick.id);
	var lio=itemID.lastIndexOf("S"); // custom security matrix follows
	if(lio>0)
	{
		var personlAccess=itemID.substr(lio+1);
		itemID=itemID.substr(0,lio);
	}
	var generalKindOfItem=itemID.substr(0,1);
	var contentSideSubType=itemID.substr(1,1); // c=child p=parent a=article r=archive
	var menuSideSubType=itemID.substr(2,1); // see below for meaning
	var itemNumber=itemID.substr(2); // for two-letter ids, this is the numeric
	switch(generalKindOfItem)
	{
	case "M":
		smType="Menu Item";
		switch(menuSideSubType)
		{
		case "2": //	linkType="Archive";
			abody=addMenuItem('Add another file to archive',itemID,9);
			break;
		case "8": //	linkType="Photo";
			abody=addMenuItem('Add another photo to album',itemID,9);
			break;
		case "6": //	linkType="Divider";
			abody=addMenuItem('Manage this divider',itemID,2);//+		
//			addMenuItem('Delete this divider ',itemID,1)+
//			addMenuItem('Change permission','SZZ'+itemID.substr(3),25);
			break;
		case "5": //		linkType="Blog"; 
			abody=addMenuItem('Start a new conversation',itemID,10);
			break;
		case "7": //		linkType="URL";
			break;
		case "4": //		linktype="executable";
			abody=addMenuItem('Add an article',itemID,9);
			break;
		case "1": //		linkType="Article";
			abody=addMenuItem('Add an article',itemID,9);
			break;
		default:
			alert("Unexpected link type "+itemID+" "+menuSideSubType);
		}
		break;
	case "D": // content-side context menu for archives and articles
		switch(contentSideSubType)
		{
		case "R": //			smType="Archive";
			abody=addMenuItem('Add another file to archive' ,itemID,4)+	
			addMenuItem('Edit info for this file in archive ',itemID,2)+
			addMenuItem('Delete this file from archive ',itemID,1);
			break;
		case "P": //			smType="Photo";
			abody=addMenuItem('Add another photo to album' ,itemID,4)+	
			addMenuItem('Edit info for this photo ',itemID,2)+
			addMenuItem('Delete this photo from album ',itemID,1);
			break;
		case "A": //			smType="Article";					
			abody=addMenuItem('Add new article',itemID,4)+	
			addMenuItem('Manage this article',itemID,2); //+
			//addMenuItem('Delete this article',itemID,1);
			break;
		default:
			alert("Unexpected value in article context menu "+itemID+" "+contentSideSubType);
		}
		break;
	case "E": // content-side context menus for calendar 		smType="Event";
		if(contentSideSubType=="D") // whole-day context menu
		{		
			abody='<tr><td><a href="?task=add">Add NEW Event</a></td></tr>';
			if(typeof pasteE!='undefined')abody=abody+pasteE;
			if(typeof pasteD!='undefined')abody=abody+pasteD;
			abody=abody+'\n<tr><td><a href="?wholeday=1">Copy Day</a></td></tr>';
			abody=abody+'\n<tr><td><a href="?task=deleteDay">Delete Entire Day</a></td></tr>';
		}
		else if(contentSideSubType=="V")// one-event context menu
		{
			abody='<tr><td><a href="?task=edit&evid='+itemNumber+'">Edit Event</a></td></tr>';
			abody=abody+'<tr><td><a href="?task=delete&evid='+itemNumber+'">Delete Event</a></td></tr>';
			abody=abody+'<tr><td><a href="?copyid='+itemNumber+'">Copy Event</a></td></tr>';
		}
		else alert("Unexpected value in calendar context menu");		
		break;
	case "C": //		smType="Can Do";		
		abody='<tr><td><a href="?flagOperation[addFlag]=1&whichFlag='+itemID+'">Add NEW Flag</a></td></tr>';
		if(itemNumber>0) // not just add mode
		{
			abody=abody+'<tr><td><a href="?flagOperation[editFlag]=1&whichFlag='+itemID+'">Edit Flag</a></td></tr>';
			abody=abody+'<tr><td><a href="?flagOperation[deleteCanDo]=1&whichFlag='+itemID+'">Delete Flag</a></td></tr>';
		}	
		break;
	case "X": // management options in upper left corner
		abody=addMenuItem("Management Option 1",itemID,21)+
		addMenuItem("Management Option 2",itemID,22)+
		addMenuItem("Management Option 3",itemID,23);
		break;
	default:
		return;
		alert("Unexpected context menu value for ["+itemID+"]");
	}
	ahead="<table class=\"devmen\" >" +
	"\n<tr class=\"devmenhead\"><td>"+" Options</td></tr>" ;
	if(generalKindOfItem=="M" && menuSideSubType!="6") 
	{
		if((personlAccess & MAY_ADD_MENUS)==MAY_ADD_MENUS)
		{
			abody=abody+ 		
			addMenuItem('Add New Menu Item',itemID,4);
		}
		if((personlAccess & MAY_EDIT_ITEM)==MAY_EDIT_ITEM)
		{
			abody=abody+ 
			addMenuItem('Manage This Menu Item',itemID,2);
			if((menuSideSubType=="1" ||  menuSideSubType=="8" ||menuSideSubType=="2"))
			{
				abody=abody+addMenuItem('Add Child Menu Item',itemID,7);
			}
		}
	}
	os=objectStructure("conMen");
	os.innerHTML=ahead+abody+	"</table>";
	//display_menu(itemUnderClick,'conMen');
	noDefault(theEvent);
	show("conMen",theEvent,2);
}
function show(popu, theEvent, typ)
{
	/* type: 			0= tool tip 			2=context menu		*/
	if(inPopUp)return;
	popUp=objectStructure(popu);
	/* 
		popUp is now a JS object.  We can add properties to the object just by
		assigning them values.  We will do this to avoid a proliferation of independent
		variables
			mouseY, mouseX
	*/
		popUp.mouseY=theEvent.pageY; //mouseY(rawEvent);
		popUp.mouseX=1+theEvent.pageX; //mouseX(rawEvent);
		clearTimeout(popUp.popDelay);
		popStyle=popUp.style; // value by address
		if(typ!=0)
		{
			popUp.onmouseout=mayhide;
			popUp.onmouseover=keep;
		}
		else
		{
			popUp.parentNode.onmouseout=hide;
		}
		if(typ==0) //tool tip
		{
			popStyle.display='block';
			popStyle.top=(popUp.mouseY+10)+'px';
			popStyle.left=(popUp.mouseX+10)+'px';
		}
		else // context menu
		{
			popStyle.display='';
			oH=popUp.offsetHeight;
			oW=popUp.offsetWidth;
			topOfScreen=window.pageYOffset;
			bottomOfScreen=window.innerHeight+topOfScreen;
			// if popup height plus mouse position would put popup off bottom ...
			if((popUp.mouseY+oH)>bottomOfScreen)
			{
				// ... then make sure popup bottom is on screen
				z=bottomOfScreen-oH;
			}
			// otherwise put vert center of popup at mouse pos
			else z=popUp.mouseY-(oH/2); 
			// unless that would move part of it off the top
			if(z<topOfScreen)z=topOfScreen;
			popStyle.top=z+'px';
			leftOfScreen=window.pageXOffset;
			rightOfScreen=leftOfScreen+window.innerWidth
//			alert("los "+leftOfScreen+" ow "+oW+ " ros "+rightOfScreen+" mx "+popUp.mouseX);
			if((popUp.mouseX+oW)>rightOfScreen)
			{ 
				z=(popUp.mouseX-oW)+1;
			}
			else z=popUp.mouseX-1;
			popStyle.left=z+'px';
		}
		if(typ!=0)inPopUp=1;
}
function makeEditable(thisrte) 
{
	document.getElementById(thisrte).contentDocument.designMode="on";
}
function formEmail(which,p1,p2,p3)
{
	// unwinds screen-scraper protection done in PHP by toEmail  and makeEmailLink
	which.href="mailto:"+p1+"@"+p2+"."+p3;
}
function focus2()
{
	// finds a form element whose id is initialfocuswillbe and moves the focus to the element named as the value of that element. also reorders the tab indexes of all fields  so that they follow that focus field
	//var targ=objectStructure("initialfocuswillbe");
	//if(targ.is_null
	if(targ=objectStructure("initialfocuswillbe"))
	{
		if(targ.value)
		{
			targ=targ.value;
			if(targ.length>0)
			{				//  find targ - the name of the element that should be in the first tab position
				var allElements=document.forms[0].elements;
				for(var m=0;m<allElements.length;m++)
				{
					if(allElements[m].name==targ) 
					{
						// we've got the id
						var ti=allElements[m].tabindex; // get its current tab index
						for(var n=0;n<allElements.length;n++) // reshuffle tab inbdices: lesser get high, higher gut scruncehd together
						{
							if(allElements[n].tabindex>ti)allElements[n].tabindex-=(ti-1); // starts at 2
							else if(allElements[n].tabindex<ti)allElements[n].tabindex+=1000;
						}
						allElements[m].tabindex=1;
						allElements[m].focus();
						// trick IE into moving cursor to end of field
						allElements[m].value=allElements[m].value;
						//allElements[m].select(); // just to remember!
						return true;
					}
				}
			}
		}
	}
	return true;
}
/*
function objexists(obj) 
{
	alert(obj);
	return (typeof obj != 'undefined');
}
// JavaScript Document
function focus2old()
{
	// keeping this because it shows how to loop through all elements of all forms in a document
	for (var i=0; i<document.forms.length;i++)
	{
		var alldfe=document.forms[i].elements;
		for(var j=0;j<alldfe.length;j++)
		{
			onedfe=alldfe[j];
			if(onedfe.name=="initialfocuswillbe")
			{
				var targ=onedfe.value;
				for(var m=0;m<alldfe.length;m++)
				{
					if(alldfe[m].name==targ)
					{
						var ti=alldfe[m].tabindex;
						for(var n=0;n<alldfe.length;n++)
						{
							if(alldfe[n].tabindex>ti)alldfe[n].tabindex-=(ti-1); // starts at 2
							else if(alldfe[n].tabindex<ti)alldfe[n].tabindex+=1000;
						}
						alldfe[m].tabindex=1;
						alldfe[m].focus();
						// trick IE into moving cursor to end of field
						alldfe[m].value=alldfe[m].value;
						//alldfe[m].select(); // just to remember!
						return true;
					}
				}
			}		
		}
	}
	return true;
}
function focusif()
{
	// finds a form element with an attribute called 'onfocus' and moves the focus to the element named in that attribute. also reorders the tab indexes of all fields  so that they follow that focus field
	for (var i=0; i<document.forms.length;i++)
	{
		var dfe=document.forms[i].elements;
		for(var j=0;j<dfe.length;j++) // get each element
		{
			dfea=dfe[j].attributes;
			for(var k=0;k<dfea.length;k++) // get each attribute of that element
			{
				if(dfea[k].name=="onfocus") // if the name of that attribute is 'onfocus' ...
				{
					var targs=dfea[k].value.split(".");
					var targ=targs[0];
					for(var m=0;m<dfe.length;m++)
					{
						if(dfe[m].name==targ)
						{
							var ti=dfe[m].tabindex
							for(var n=0;n<dfe.length;n++)
							{
								if(dfe[n].tabindex>ti)dfe[n].tabindex-=ti;
								else if(dfe[n].tabindex<ti)dfe[n].tabindex+=1000;
							}
							dfe[m].tabindex=1;
							dfe[m].focus();
							return true;
						}
					}
				}
			}
			
			if(false) //(dfe[j].name=="starthere")
			{
				dfe[j].focus();
				return true;
			}
		}
	}
	return true;
	// alternatively (requires knowing name of form)
	if(objexists(document.a))
	{
		if(objexists(document.a.starthere))document.a.starthere.focus();
	}
}
*/
/*
var theEvent,eventSource; //  eDOM appears not to use the event stuff
function eDOM(objectId,evt)
{
	theEvent=resolveEventByDOM(evt);
	eventSource=getEventSource(theEvent);
	return(objectStructure(objectId));
}
function getEventSource(evt)
{
	xevt=resolveEventByDOM(evt)
	return xevt.target;
}
function showMore(what,evt,state) // called by PHP jsEvnt function. appears never to be used
{
	alert("showMore appears never to be used");
	el=(what,0);
	elStyle=el.style;
	evt = resolveEventByDOM(evt);
	evnt=getEventSource(evt);
	truestate=(state==true)?true:false;
	if(evnt.checked==truestate)
	{
//		elStyle.visibility='visible';
		elStyle.display='block';
		//elStyle.position='relative';
	}
	else
	{
		//elStyle.visibility='hidden';
		//elStyle.position='absolute';
		elStyle.display='none';
	}
}
*/