function writeSpecer(tobj) {
	if (tobj == null) return;
	var iw, ih; // Set inner width and height
	if (window.innerWidth == null) {
		iw = document.body.clientWidth;
		ih=document.body.clientHeight; 
	}
	else {
		iw = window.innerWidth;
		ih = window.innerHeight;
	}
	var w = iw;
	var h = ih;
	var alt = "";
	var aln = "left";
	var pw = 640;
	var ph = 115;
	var bw = 640;
	var bh = 25;
	
	var sw = Math.round((iw - bw) * pw / 100);
	//var sh = Math.round((ih - bh) * ph / 100);
	var sh = h - ph - bh - 20 - 30;
	
	if ((w * sh) / (h * sw) < 1) sw = Math.round(w * sh / h);
	//else sh = Math.round(h * sw / w);
	
	//tobj.width=sw;
	tobj.height=sh;
}

//checkbox: select (check) all checkboxes in the e1 collection
function selectAll(e1) {
	for (var i=0;i<e1.length;i++) {
		e1[i].checked = true;
	}
}

//checkbox: clear (check) all checkboxes in the e1 collection	
function clearAll(e1) {
	for (var i=0;i<e1.length;i++) {
		e1[i].checked = false;
	}
}
	
function swap(id, newSrc) {
    var theImage = FWFindImage(document, id, 0);
    if (theImage) {
        theImage.src = newSrc;
    }
}

function FWFindImage(doc, name, j) {
    var theImage = false;
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }    
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FWFindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);
}

function swapImg(daImage, daSrc){
	var objStr,obj;
	  
	// Check to make sure that images are supported in the DOM.
	if(document.images){ // Check to see whether you are using a name, number, or object
		if (typeof(daImage) == 'string') { // This whole objStr nonesense is here solely to gain compatability with ie3 for the mac.
			objStr = 'document.' + daImage;
			obj = eval(objStr);
			obj.src = daSrc;
		} else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
			daImage.src = daSrc;
		}
	}
}


// It gets around another unfortunate bug whereby Netscape fires a resize event when the scrollbars pop up. This 
// checks to make sure that the window's available size has actually changed.
function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

// This function checks to make sure the version of Netscape in use contains the bug; if so, it records the window's 
// width and height and sets all resize events to be handled by the WM_netscapeCssFix() function.
function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

function toggleSwitch(cobj, swOn) {
	if (swOn) {
		cobj.disabled = false;
	}
	else {
		cobj.disabled = true;
	}	
}

function toggle(commonName) {
	var tbl;
	var gif;
	var iLength;
 
	if (document.layers) { // for netscape 
		gif = document.layers(commonName + "gif");
		iLength = document.layers("row" + commonName).length;
		for (var i=0; i<iLength; i++) {
			tbl = document.layers("row" + commonName)[i];
			if (tbl.style.visibility == "show") {
				tbl.style.visibility = "true";
				gif.src = HTTP_HOST + "/images/icons/plus.gif";
			}
			else {
				tbl.style.visibility = "hide";
				gif.src = HTTP_HOST + "/images/icons/minus.gif";
			}
		}
	}	

	if (document.all) {
		gif = document.all(commonName + "gif");
		iLength = document.all("row" + commonName).length;
		for (var i=0; i<iLength; i++) {
			tbl = document.all("row" + commonName)[i];
			if (tbl.style.display == "") {
				tbl.style.display = "none";
				gif.src = HTTP_HOST + "/images/icons/plus.gif";
			}
			else {
				tbl.style.display = "";
				gif.src = HTTP_HOST + "/images/icons/minus.gif";
			}
		}
	}
}

function expandAll(){
	var tables = document.all.tags("table");
	for(var i = 0; i < tables.length; i++){
		tables[i].style.display = "";
	}
}

function openNewWindow(url)	{
	var width=640;
	var height=480;
	openNewWindow(url, width, height)
}

function openNewWindow(url, width, height)	{
	if (width==null || isNaN(width)) width = 800;
	if (height==null || isNaN(height)) height = 480;
	
	// adds 18 pixels to Netscape new window height
	// so the two browsers view the quiz the same
	var browser = navigator.appName;
	if (browser.indexOf("Net") != -1){
		height += 18
	}
	// done checking browser
		
	var feature = 'toolbar=no,titlebar=no,location=no,directories=no,status=no,' + 
				  'menubar=no,resizable=yes,copyhistory=no,fullscreen=no,scrollbars=yes,' +
				  'width=' + width + ',height=' + height;

	if ( (navigator.appVersion.indexOf ("MSIE") != -1) ) {				  
		feature += ',left=' + (screenLeft+50) + ',top=' + (screenTop+30);
	}
	else {
		feature += ',screenX=' + (screenX+(outerWidth/2)-20) + ',screenY=' + (screenY+(outerHeight/2));
	}

	var Win = window.open(url,'_new', feature);	
	if(Win.opener == null) {
		alert('You must allow popups from this site \nfor certain features to work!');
	}	
	if (Win.opener == null) Win.opener = this;
}

function openHelp(url)	{
	// adds 18 pixels to Netscape new window height
	// so the two browsers view the quiz the same
	var width=800;
	var height=480;

	var browser = navigator.appName;
	if (browser.indexOf("Net") != -1){
		height += 18
	}
	// done checking browser
		
	var feature = 'toolbar=no,titlebar=no,location=no,directories=no,status=no,' + 
				  'menubar=no,resizable=yes,copyhistory=no,fullscreen=no,scrollbars=yes,' +
				  'width=' + width + ',height=' + height;

	if ( (navigator.appVersion.indexOf ("MSIE") != -1) ) {				  
		feature += ',left=' + (screenLeft+50) + ',top=' + (screenTop+30);
	}
	else {
		feature += ',screenX=' + (screenX+(outerWidth/2)-20) + ',screenY=' + (screenY+(outerHeight/2));
	}

	var Win = window.open(url,'help', feature);		
	if (Win.opener == null) Win.opener = this;
}

function openFeedbackWindow(url, width, height)	{
	if (width==null || isNaN(width)) width = 600;
	if (height==null || isNaN(height)) height = 330;
	
	// adds 18 pixels to Netscape new window height
	// so the two browsers view the quiz the same
	var browser = navigator.appName;
	if (browser.indexOf("Net") != -1){
		height += 18
	}
	// done checking browser
		
	var feature = 'toolbar=no,titlebar=no,location=no,directories=no,status=no,' + 
				  'menubar=no,resizable=no,copyhistory=no,fullscreen=no,scrollbars=yes,' +
				  'width=' + width + ',height=' + height;

	if ( (navigator.appVersion.indexOf ("MSIE") != -1) ) {				  
		feature += ',left=' + (screenLeft+50) + ',top=' + (screenTop+30);
	}
	else {
		feature += ',screenX=' + (screenX+(outerWidth/2)-20) + ',screenY=' + (screenY+(outerHeight/2));
	}

	var Win = window.open(url,'addFeedback', feature);		
	if (Win.opener == null) Win.opener = this;
}

function sort(field)	{
  alert('sort by ' + field)
}

function expandAll(){
	var tables = document.all.tags("table");
	for(var i = 0; i < tables.length; i++){
		tables[i].style.display = "";
	}
}

function goToServer (newPage) {
	location.href = changeURL(newPage); 
}

function goToNewPage (newPage) {
	location.replace(changeURL(newPage)); 
}

function reload() {
	window.location = self.location;
}


function formFocus (e) {
  if (e) {
    e.focus();
  }
}