// General Toolbox Functions
// mostly by tim...

var tbJDebug = "";

//
// returns a string containing address bar info
//
function ShowQSDebug() {
	var s = "";
	s += "\nHash: "+document.location.hash;
	s += "\nHost: "+document.location.host;
	s += "\nHostName: "+document.location.hostname;
	s += "\nPathName: "+document.location.pathname;
	s += "\nPort: "+document.location.port;
	s += "\nProtocol: "+document.location.protocol;
	s += "\nSearch: "+document.location.search;
	return s;
}

//
//	Same as vbscript function
//
function isNumeric(s) {
	for (var pos = 0; pos < s.length; pos++)
		if (s.charAt(pos) < '0' || s.charAt(pos) > '9')
		return false;
	return true;
}


//
//	Toggles between 'inline' and 'none' display properties
//
function toggledisplay(el) {
	if (el.style.display == 'none'){
		el.style.display = 'inline'
	} else {
		el.style.display = 'none'
	}
}


//
//	Macromedia functions, cause everybody has them. handy-bandy stuff.
//
function MM_findObj(n, d) {
  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 tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  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_reloadPage(init) {
  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_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  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() {
  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_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

//
//	Specify 1 or more urls to go to, in format. 'framename or ref','url','framename or ref','url'
//
function goToURL() {
	var i, args=goToURL.arguments;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


//
// Similar to toggledisplay, except works with one or more string references to objects
//
function swapdisplay(){var obj,i,a=swapdisplay.arguments;
for(i=0;i<a.length;i++){if((obj=MM_findObj(a[i]))!=null){
if(obj.style.display=='inline'){obj.style.display='none'}else{obj.style.display='inline'}
}}}


//
//	Forces inline display on object
//
function forcedisplay(el) {
	el.style.display = 'inline'
}


//
//	Forces no displat on object
//
function forcehide(el) {
	el.style.display = 'none'
}


//
//	Toggle images and alt tags in forum list
//
function toggleimage(el) {
	switch (el.alt) {
	case '+':
		el.src = '/toolbox/images/minus.gif';
		el.alt = '-';
		break;
	case '-':
		el.src = '/toolbox/images/plus.gif';
		el.alt = '+';
		break;
	case ':':
		el.src = '/toolbox/images/lastminus.gif';
		el.alt = 'v';
		break;
	case 'v':
		el.src = '/toolbox/images/lastplus.gif';
		el.alt = ':';
		break;
	}
}


//
//	Force images in a forum list
//
function forceimage(el) {
	switch (el.alt) {
	case '+':
		el.src = '/toolbox/images/minus.gif';
		el.alt = '-';
		break;
	case ':':
		el.src = '/toolbox/images/lastminus.gif';
		el.alt = 'v';
		break;
	}
}


//
//	Clicks on the first <A> tag in a table cell
//
function tdClk(el) {
	if(event.srcElement.tagName=='TD')
		el.children.tags('A')[0].click();
}


//
//	Changes background colour of object (use on mouse over); cursor is 'hand'
//
function elOvr(el,clr) {
	if (!el.contains(event.fromElement)){
		el.style.cursor = 'hand';
		if (clr) el.bgColor = clr;
	}
}


//
//	Changes background colour of object (use on mouse over); cursor is 'default'
//
function elOut(el,clr) {
	if (!el.contains(event.toElement)){ 
		el.style.cursor = 'default';
		if (clr) el.bgColor = clr;
	}
}


//
//	swaps an image from src <-> lowsrc. sets window.status if it exists
//
function swap(el, t) {
	imLo = document.images[el].lowsrc;
	imHi = document.images[el].src;
	document.images[el].src = imLo;
	document.images[el].lowsrc = imHi;
	if (t) {window.status = t; return true;} else {window.status = ''; return true;}
}


//
//	Detects if flash plugin exists, redirects to different urls either way
//
function detectFlash(flash,noflash){
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
	if ((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("3.1") == -1) || (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=4)) {
		window.location=flash;
	} else {
		window.location=noflash;
	}
}


//
//	Redirects to different urls if it is IE on Mac or Windows
//
function macBrowser(macie,macns) {
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ) {
		window.location=macie;
	} else {
		window.location=macns;
	}
}


//
//	Redirects to different utls if it is Windows or Mac
//
function macOrWin(win,mac) {
	if (navigator.appVersion.indexOf("Mac") != -1 ) {
		window.location=win;
	} else {
		window.location=mac;
	}
}


//
//	Reloads specified frame name
//
function reloadFrame(x) {
		top.frames[x].location.reload();
}


//
//	Sets everything in the specified form to be blank
//
function clearform(fname, ignoretag) {
for (j=0; j<document.forms[fname].length; j++) {
	d = document.forms[fname].elements[j];
	if (d != ignoretag) {
	switch (d.type) {
		case "text" :
			d.value = "";
			break;
		case "select-one" :
			d.selectedIndex = 0;
			break;
		case "select-multiple" :
			d.selectedIndex = 0;
			d.selected = false;
			break;
		case "radio" :
			d.checked = false;
			break;
		case "checkbox" :
			d.checked = false;
			break;
		case "hidden" :
			break;
		case "submit" :
			break;
		case "reset" :
			break;
		case "button" :
			break;
		default :
			break;
	}
	}
}
}


//
//	checks to see if a value exists in the specified select box inside the specified form and selects it
//
function selectItem(frm,flt,v) {
	for (j=0; j < document.forms[frm].elements[flt].length; j++) {
		if (document.forms[frm].elements[flt].value == v) document.forms[frm].elements[flt].selectedIndex = j;
	}
}


//
//	Direct equivalent to the vbscript Trim() function
//
function Trim(szWhat) {
	return(szWhat.replace(/^\s*|\s*$/g, ""));
}


//
//	Window Opener, specify url, width, height, true/false for chrome. Opens in unique window and return window name as reference if r>0
//
function openNewWindow(fileURN,theWidth,theHeight,brChrome,r) {
	if (!brChrome) brChrome=0;
	if (r){windowName=new String(Math.round(Math.random()*100000))}else{windowName="popup"}
	var newPopWin = window.open(fileURN,windowName,"toolbar="+brChrome+",location="+brChrome+",directories="+brChrome+",status=1,menubar="+brChrome+",scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
	newPopWin.focus();
	if (r) return windowName;
}


//
//	looks for specified object in the current url/querystring and return its value
//
function parseURLfor(szWhat) {
	var re = new RegExp("[?|&]"+szWhat+"=([^&]*)","gi");
	var arr = re.exec( window.document.location.search );
	return( (arr==null)?null:arr[1]);
}


//
//	Strips spaces from start and end of string. optionally strips all spaces in string.
//
function stringclean(s,t) {
	if (!s) s = "";
	s = s.replace(/^\s*/,"");
	s = s.replace(/\s+$/,"");
	if (t) s = s.replace(/\s/g,""); "["+s+"]/g"
	return s;
}


//
//	Strips out apostophies from a string
//
function noapostrophe(s) {
	if (!s) s = "";
	return s.replace(/\'/g,""); "["+s+"]/g"
}


//
//	Strips out double quotes from a string
//
function noquotes(s) {
	if (!s) s = "";
	return s.replace(/\"/g,""); "["+s+"]/g"
}


// matches one whole string inside another and replaces all occurrences it with a third string
// o = the main string
// i = the string you want to look for in 'o'
// t = the string you want to replace in 'i's position (can be blank)
function stringreplace(o,i,t) {
	if (!t) t=null;
	r = new RegExp(i);
	r.compile(i,"g")
	re = r.valueOf();
	return o.replace(re, t);
}



//
//	Replaces all instances of char tc with char nc in string s
//
function replchar(s, tc, nc){
var rs = "";
	for(var i=0; i<s.length; i++) {
		if (s.charAt(i) == tc) 
			rs += nc
		else
			rs += s.charAt(i);
		}
	return rs;
}


//
//	Builds an "is" object. you can test is.ie or is.ie4 etc
//
function browserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new browserCheck()


//
//	pops up toolbox file browser for specified form/field
//
function doBrowse(frm,fld,flt) {
	var s = "/toolbox/utlFiles.asp?Item=" + document.forms[frm].elements[fld].value + "&Form=" + frm + "&Field=" + fld
	if (flt) s += "&Filter="+flt
	var fileWin = window.open(s,'FileDirectory',',status,alwaysRaised,resizable=yes,titlebar=no,width=600,height=450');
	fileWin.focus();
}


//
//	pops up the new miniture file browser. specify form, field & filter (e.g. doMiniBrowse("myform","textfield","csv")
//
function doMiniBrowse(frm,fld,flt) {
	var s = "/toolbox/popTBFileBrowser.asp?Browse=N&Filter="+flt+"&Frm="+frm+"&Fld="+fld;
	var fileWin = window.open(s,'TBMiniBrowser','channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=400,height=309');
	fileWin.focus();
}


//
//	pops up the dhtml editor for the form/field you specify
//
function doDHTMLEdit(frm,fld) {
	if (document.all){
		var v = document.forms[frm].elements[fld].value;
		var dhtmlEditorWin = window.open('/toolbox/dhtmledit/dhtmled.asp?String='+escape(v)+'&Form='+frm+'&Field='+fld,'DHTMLEditor','status,alwaysRaised,resizable=yes,titlebar=no,width=600,height=450');
		dhtmlEditorWin.focus();
	}
}

//
//	another popup window.. just specify url. width & height are optional.
//
function popWin(url,w,h,r) {
	if (r) {windowName="new"}else{windowName=null}
	if ((w) && (h)) {
		var fileWin = window.open(url,windowName,"status=no,resizable=no,titlebar=no,width="+w+",height="+h+",scrollbars,location=no");
	} else {
		var fileWin = window.open(url,windowName,"status,resizable,titlebar,scrollbars,location");
	}
	fileWin.focus();
}

//
//	generic object background colour (ie) routine. 'transparent' is a valid background colour
//
function SetBGColor(obj, new_color) {
	obj.style.backgroundColor=new_color
}


//
//	used 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));
}


//
//	Returns cookie value for specified name
//
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;
}


//
//	Sets cookie. Requires name & value, all else optional
//
function SetCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}


//
//	Deletes a cookie by expiring it
//
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


//
//	Moves an object to the specified x/y location
//
function moveTo(obj,x,y) {
	obj.xpos = x;
	obj.left = obj.xpos;
	obj.ypos = y;
	obj.top = obj.ypos;
}


//
//	Moves an object by the specified x/y values
//
function moveBy(obj,x,y) {
	obj.xpos += x;
	obj.left = obj.xpos;
	obj.ypos += y;
	obj.top = obj.ypos;
}


//
//	Check to see if left mouse button was clicked. Returns true or false
//
function leftClicked(e) {
	if ((is.ns && e.which!=1) || (is.ie && event.button!=1)) {return true;}else{return false;}
}


//
//	Sets vars xpos/ypos based on current mouse position (use in onmouseover or onclick). works in NS/IE
//
function setXYOnEvent(e) {
	var xpos = (is.ns)? e.pageX : event.x+document.body.scrollLeft;
	var ypos = (is.ns)? e.pageY : event.y+document.body.scrollTop;
	return true;
}


//
//	Build an empty array object of n size
//
function makearray(n) {
	this.length = n;
	for(var i = 1; i <= n; i++)
		this[i] = 0;
	return this;
}


//
// Used by hex routine
//
hexa = new makearray(16);
for(var i = 0; i < 10; i++) hexa[i] = i;
hexa[10]="A"; hexa[11]="B"; hexa[12]="C";
hexa[13]="D"; hexa[14]="E"; hexa[15]="F";


//
//	Returns hex value for a 0-255 value (use in colour routines)
//
function hex(i) {
	if (i < 0) {
		return "00";
	} else if (i > 255) {
		return "FF";
	} else {
		return "" + hexa[Math.floor(i/16)] + hexa[i%16];
	}
}


//
//	Converts a hex value to a 0-255 value (use in colour routines) .. ooh this is hard :-)
//
function dehex(i) {
	return parseInt(i,'16');
}

//
//	Checks to see if a colour string is valid in hex (eg 6 hex chars long)
//
function validHex (string) {
	var pattern=(new RegExp("^[0123456789abcdefABCDEF]{6}$"));
	return pattern.test(string);
}


//
//	Takes a colour string 'v', returns a colour string based on a percentage 'pc' of that colour 
//	useful for autocalculating shading values on table cells (e.g. courselibrary).
//
function shadeColour(v,pc) {
	var hx = Trim(v);
	if (hx.indexOf("#") == 0) {
		hx=hx.substring(1,hx.length);
	}
	if (validHex(hx)) {
		var r = dehex(hx.substring(0,2));
		var g = dehex(hx.substring(2,4));
		var b = dehex(hx.substring(4,6));
		r = parseInt(r*(pc/100));
		g = parseInt(g*(pc/100));
		b = parseInt(b*(pc/100));
		return "#"+hex(r)+hex(g)+hex(b);
	}else{
		return "";
	}
}



//
//	fills in the specified fields with the specified percent (all fields required)
//
function setshades(frm,src,hifld,lofld,pc,setstyle) {
	var s = document.forms[frm].elements[src].value;
	document.forms[frm].elements[hifld].value=shadeColour(s,100+pc);
	document.forms[frm].elements[lofld].value=shadeColour(s,100-pc);
}

// sets input background colour to match -----
function setshades1(frm,src,hifld,lofld,pc,setstyle) {
	var s = document.forms[frm].elements[src].value;
	var a = shadeColour(s,100+pc);
	var m = shadeColour(s,100-pc)
	document.forms[frm].elements[hifld].value=a;
	document.forms[frm].elements[hifld].style.backgroundColor=a;
	document.forms[frm].elements[lofld].value=m;
	document.forms[frm].elements[lofld].style.backgroundColor=m;
}

//
//	Handy-bandy function which is useful for toolbars and buttons. applies a style to an id based on the base colour and event.
//	Useful to also have default style already applied with "border=1px solid globBgColor" set.
//
function SetShadeForMouseEvent(id,ev,globBgColour) {
	switch (ev) {
	case "out":
		eval(id).style.cursor = 'auto';
		eval(id).style.borderTop = "1px solid " + globBgColour;
		eval(id).style.borderLeft = "1px solid " + globBgColour;
		eval(id).style.borderRight = "1px solid " + globBgColour;
		eval(id).style.borderBottom = "1px solid " + globBgColour;
		eval(id).style.backgroundColor = globBgColour;
		break;
	case "over":
		eval(id).style.cursor = 'hand';
		eval(id).style.borderTop = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.borderLeft = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.borderRight = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.borderBottom = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.backgroundColor = globBgColour;
		break;
	case "up":
		eval(id).style.cursor = 'hand';
		eval(id).style.borderTop = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.borderLeft = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.borderRight = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.borderBottom = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.backgroundColor = globBgColour;
		break;
	case "down":
		eval(id).style.cursor = 'hand';
		eval(id).style.borderTop = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.borderLeft = "1px solid " + shadeColour(globBgColour,60);
		eval(id).style.borderRight = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.borderBottom = "1px solid " + shadeColour(globBgColour,140);
		eval(id).style.backgroundColor = shadeColour(globBgColour,120);
		break;
	}
}


//
//	Removes all extra parameters from the querystring qs (if they exist). returns url
//	if qs isn't specified it uses the current page.
//
function QStringTrim(qs) {
	if (!qs) qs=self.location.href;
	query = qs.split('?');
	return query[0];
}


//
//	Appends/Replaces parameter p with value v to the end of the querystring qs, with the right "?" or "&" as needed. returns url
//	if qs isn't specified it uses the current page.
//
function QStringAppend(p,v,qs) {
	if (!qs) qs=self.location.href;
	q=QStringMinus(Trim(p),qs);
	query = q.split('?');
	var qsbase = query[0];
	var appendSymbol="?";
//	window.alert ('q:' + q);
	if (query.length > 1) {
		if (query[1].indexOf("=") != 0) {
			if (query[1].substring (query[1].length-1, query[1].length) == "&") {
				appendSymbol="";
				}
			else {
				appendSymbol="&"
				}
			}
	}
	var returnDoc = q+appendSymbol+p+"="+Trim(escape(v));
	return returnDoc;
}


//
//	removes all instances of parameter p from querystring qs. returns result
//	qs = this document if not specified.
//
function QStringMinus(p,qs) {
	var param=p.toLowerCase();
	var qsbase,rs="";
	if (!qs) qs=self.location.href;
	var q=qs.toLowerCase();
	if (q.indexOf(param)>0) {
		qsArgs = new Array();
		search = q.split('?');
		var qsbase = search[0];
		if (search.length > 0) {
			argList = search[1];
			argList = argList.split('&');
			for (var i=0; i<argList.length; i++) {
				newArg = argList[i].split('=');
				if (newArg[0]!=p){
					qsArgs[i] = unescape(newArg[0])+"="+unescape(newArg[1]);
				}
			}
			for (i=0;i<qsArgs.length;i++){
				if(qsArgs[i]) rs+=qsArgs[i];
				if((qsArgs[i+1])&&(i>0)) rs+="&";
			}
		}
		if (qsArgs.length >0){
			return qsbase+"?"+rs;
		} else {
			return qsbase;
		}
	} else {
		return q;
	}
}


//
// returns (as a string) the value of an element on the current querystring
// (what a pain in the arse!)
//
function getQuerystringParam(p) {
	var param=p.toLowerCase();
	var q=self.location.href.toLowerCase();
	if (q.indexOf(param)>0) {
		var s = q.split('?');
		if (s.length > 0) {
			var t = s[1].split('&');
			if (t.length > 0) {
				for (u=0;u < t.length; u++) {
					var v = t[u].split('=');
					if (v.length > 0) {
						if (v[0] == p) return unescape(v[1]);
					}
				}
			}
		}
	}
}


//
// forward/back buttons which pass back via querystring.. handy for some pages. pops everything in a small table. optional icons
//
function miniNavSystem(qsvar,pages,page,previcon,nexticon) {
	var doc=QStringMinus(qsvar.toLowerCase(),document.location.href); var i,s="";
	if (!page) page=0;
	if (!previcon) prevIcon="/toolbox/images/miniPrev.gif";
	if (!nexticon) nextIcon="/toolbox/images/miniNext.gif";
	if (doc.indexOf("?")>0) {
		docS=doc+"&"+qsvar+"=";
	} else {
		docS=doc+"?"+qsvar+"=";
	}
	s+="<table border=0 cellpadding=0 cellspacing=0><tr>"
	if (page==0) {
		s+="<td align=center valign=middle><img src='"+prevIcon+"' border=0></td>";
	} else {
		s+="<td align=center valign=middle><a href='"+docS+(page-1)+"' onmouseover=\"window.status=\'Go to page "+(page-1)+"\';return true;\" onmouseout=\"window.status=\'\';return true;\"><img src='"+prevIcon+"' border=0 alt='Previous'></a></td>";
	}
	s+="<td align=center valign=middle><font size=-1>&nbsp;"+page+" of "+pages+"&nbsp;</font></td>";
	if (page==pages) {
		s+="<td align=center valign=middle><img src='"+nextIcon+"' border=0></td>";
	} else {
		s+="<td align=center valign=middle><a href='"+docS+(page+1)+"' onmouseover=\"window.status=\'Go to page "+(page+1)+"\';return true;\" onmouseout=\"window.status=\'\';return true;\"><img src='"+nextIcon+"' border=0 alt='Next'></a></td>";
	}
	s+="</tr></table>"
	document.write(s);
}

//
//	evaluates a string as script. usage: callJS("var foo=0; s='hello';"). handy for setting variables in another frame, etc
//
function callJS(jsStr) {
  return eval(jsStr)
}
