var xVersion='3.15.4',xNN4,xOp7,xOp5or6,xIE4Up,xIE4,xIE5,xUA=navigator.userAgent.toLowerCase();
if (window.opera){
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if (document.all && xUA.indexOf('msie')!=-1) {
  xIE4Up=parseInt(navigator.appVersion)>=4;
  xIE4=xUA.indexOf('msie 4')!=-1;
  xIE5=xUA.indexOf('msie 5')!=-1;
}
else if (document.layers) {xNN4=true;}
xMoz=xUA.indexOf('gecko')!=-1;
xMac=xUA.indexOf('mac')!=-1;

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function submitForm (formName) {
	var form = xGetElementById(formName);
	form.submit();
}

function updateHidden (fieldName,newValue) {
	var field = xGetElementById(fieldName);
	field.value = newValue;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xStr() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
function xNum() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
  return true;
}
function xParent(e,bNode){
  if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  return p;
}

function xDisplay(e, sProp)
{
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.display)) {
    if (xStr(sProp)) e.style.display = sProp;
    return e.style.display;
  }
  return null; // or return an empty string ???
}

function xBackground(e,sColor,sImage) {
  if(!(e=xGetElementById(e))) return '';
  var bg='';
  if(e.style) {
    if(xStr(sColor)) {
      if(!xOp5or6) e.style.backgroundColor=sColor;
      else e.style.background=sColor;
    }
    if(xStr(sImage)) e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
    if(!xOp5or6) bg=e.style.backgroundColor;
    else bg=e.style.background;
  }
  return bg;
}


      
      function attachDoc( orderID ) {
        addr = "/Popups/Popup_AttachDoc.php?orderID="+ orderID;
        window.open (addr,'popup',config='height=800,width=700,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes');
      }


// THIS CODE was mutated, modified, and re-done by the K10k» semi-bald posse
// THIS CODE was done in 1997-2001
//
// ----------------------------------------------------------------------
//
// NOTE1: IE4 fucks up if you try to "compress" js statements, like this:
// if (!document.getElementById) { browserNew = false; That's why all
// the lines have been written out in full.
//
// ----------------------------------------------------------------------




// CHECK CLIENT BROWSER & PLATFORM
// original code from http://developer.apple.com/internet/_javascript/
//
// USAGE:	browserNaming();
// NOTES:	call it from within an external JS document
// RESULT:	browserNew = true/false
//			browserName = IE/NS/Opera
//			browserNameLong = IE5/etc
//			Macintosh = true/false
// WORKS:	everything

	var its;
	var browserName;
	var browserNameLong;
	var browserNew;
	var preloadFlag = false;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0;

	function its() {
		var n = navigator;
		var ua = ' ' + n.userAgent.toLowerCase();
		var pl = n.platform.toLowerCase();
		var an = n.appName.toLowerCase();

		// browser version
		this.version = n.appVersion;
		this.nn = ua.indexOf('mozilla') > 0;

		// 'compatible' versions of mozilla aren't navigator
		if(ua.indexOf('compatible') > 0) {
			this.nn = false;
		}

		this.opera = ua.indexOf('opera') > 0;
		this.ie = ua.indexOf('msie') > 0;
		this.major = parseInt( this.version );
		this.minor = parseFloat( this.version );

		// platform
		this.mac = ua.indexOf('mac') > 0;
		this.win = ua.indexOf('win') > 0;

		// workaround for IE5 which reports itself as version 4.0
		if(this.ie) {
			if(ua.indexOf("msie 5") > 1) {
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
			}
		}

		return this;
	}

	function browserNaming() {
		its = new its();

		// is it a DOM-enabled browser?
		if (!document.getElementById) {
			browserNew = false;
		}
		else {
			browserNew = true;
		}

		// need the name, too
		if (its.opera) {
			browserName = "Opera";
		}
		else if (its.ie) {
			browserName = "IE";
		}
		else {
			browserName = "NS";
		}

		// and the number
		browserNameLong = browserName + its.major;

	}


// CREATING THE MOUSEOVER IMAGES
// USAGE:	createObject('buttonoff','images/specfeature_celluar_off.gif');
// NOTES:	call it from within the preload function
// WORKS:	ie4+, ns4+, opera5

	function createObject(imgName,imgSrc) {
		if (browserNew && (browserName == "NS")) {
		// a DOM-compatible browser
		// which is probably NS6/mozilla (the other code works better in IE/Opera)
			var tempImg = document.createElement("img");
			tempImg.src = imgSrc;
			tempImg.id = imgName;
			tempImg.style.visibility = 'hidden';
			tempImg.style.position = 'absolute';
			tempImg.style.top = 0;
			document.body.appendChild(tempImg);
		}
		else {
		// a non-DOM-compatible browser
		// and IE/Opera
			eval(imgName+' = new Image()');
			eval(imgName+'.src = "'+imgSrc+'"');
		}
	}


// MOUSEOVER SWITCHING
// USAGE:	<a href="#" onmouseover="changeImage(null,'buttonname','buttonnameon');" onmouseout="changeImage(null,'buttonname','buttonnameoff');">
// NOTES:	if the image is in a DIV, substitute 'null' with the DIV name.
// WORKS:	ie4+, ns4+, opera5

// MOUSEOVER IMAGE SWITCHING
// Works: IE4+, NS4+, Opera
// Notes: NS4 needs the DIV-name in there if image is in a DIV

	function changeImage(layer,imgName,imgObj) {

		if (preloadFlag) {
			if (browserNew) {
				document.getElementById(imgName).src = eval(imgObj+'.src');
			} else {
				if ((!browserNew) && (browserName == "NS") && (layer!=null)) {
					eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
				}
				else {
					document.images[imgName].src = eval(imgObj+'.src');
				}
			}
		}

	}



// REMOVES THE LINK BORDER IN IE5/NS6
// original code by evil@chelu.ro
//
// USAGE:	getLinksToBlur();
// NOTES:	call it from within the preload function
// WORKS:	ie5+, ns6+, opera5+

	function unblur() {
		this.blur();
	}

	function getLinksToBlur() {
		if (!document.getElementById) return
		links = document.getElementsByTagName("a");
		for(i=0; i<links.length; i++) {
			links[i].onfocus = unblur
		}
	}



// POPUP WINDOW (FIXES THE IE4/MAC PROBLEM WHICH MAKES WINDOWS TOO SMALL)
// USAGE:	<a href="#" onclick="spawnWindow('newpage.html','windowname',400,384,'no');">
// NOTES:	substitute 400 with the width, 384 with the height, windowname with the name of the new window, scroll with either 'yes', 'no' or 'auto'
// WORKS:	ie4+, ns4+, opera5

	function spawnWindow(desktopURL,windowName,width,height,scroll) {
 		if (Macintosh) {
 			if (browserNameLong == "IE4") {
				newheight = parseInt(height + 17);
			}
			else if (browserNameLong == "IE4.5") {
				newheight = parseInt(height + 17);
			}
			else {
				newheight = height;
			}
 		}
 		else { newheight = height; }
 		window.open(desktopURL, windowName, "toolbar=no,location=no,status=yes,menubar=no,scrollbars="+scroll+",width="+width+",height="+newheight+",resizable=no" );
	}

	function spawnWindowToo(desktopURL,windowName,width,height) {
 		window.open(desktopURL, windowName, "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width="+width+",height="+height+",resizable=no" );
	}


// HIDE AND SHOW LAYERS (ON THE SAME PAGE)
// USAGE:	show('layername'); hide('layername');
// WORKS:	ie4+, ns4+, opera

	function hide(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","hidden");
		}
		else {
			if (browserName == "NS") { document.layers[id].visibility = "hide"; }
			else { document.all[id].style.visibility = "hidden"; }
		}
	}

	function show(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","visible");
		}
		else {
			if (browserName == "NS") { document.layers[id].visibility = "show"; }
			else { document.all[id].style.visibility = "visible"; }
		}
	}


// DOM / GET PROPERTY
// original code from http://www.alistapart.com/
//
// NOTES:	given an id and a property (as strings), return the given property of that id.
// WORKS:	ie5+, ns6+, opera5+

	function getIdProperty(id,property) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
				if (styleObject[property]) {
					return styleObject[ property ];
				}
			}
		return (styleObject != null) ?
		styleObject[property] :
		null;
	}


// DOM / SET PROPERTY
// original code from http://www.alistapart.com/
//
// NOTES:	given an id and a property (as strings), set the given property of that id to the value provided.
// WORKS:	ie5+, ns6+, opera5+

	function setIdProperty(id,property,value) {

		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			//styleObject = styleObject.style;
			if (value == "false") {
				styleObject.disabled = false;
			} else {
				styleObject.disabled = true;
				}
		}
		//alert(styleObject.disabled);

	}

// RANDOM NUMBER GENERATOR
// USAGE:	var ranNumber = 0+randNum(40);
// NOTES:	call it from within the main html page
// WORKS:	ie4+, ns4+, opera

	function randNum (num) {
		var now = new Date();
		var rand = Math.round(num * Math.cos(now.getTime()));
		if (rand < 0) rand = - rand;
		if (rand == 0) rand++;
		return rand;
	}


// Date Builder
// Usage:	Its pretty much just plug and play.  The code works by itself
// Notes:	None
// Works:	ie4+

							//set todays date
					Now = new Date();
					NowDay = Now.getDate();
					NowMonth = Now.getMonth();
					NowYear = Now.getYear();
					if (NowYear < 2000) NowYear += 1900; //for Netscape

					//function for returning how many days there are in a month including leap years
					function DaysInMonth(WhichMonth, WhichYear)
					{
					  var DaysInMonth = 31;
					  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
					  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
					  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
					  return DaysInMonth;
					}

					//function to change the available days in a months
					function ChangeOptionDays(Which)
					{
					  DaysObject = eval("document.testinit." + Which + "Day");
					  MonthObject = eval("document.testinit." + Which + "Month");
					  YearObject = eval("document.testinit." + Which + "Year");

					  Month = MonthObject[MonthObject.selectedIndex].text;
					  Year = YearObject[YearObject.selectedIndex].text;

					  DaysForThisSelection = DaysInMonth(Month, Year);
					  CurrentDaysInSelection = DaysObject.length;
					  if (CurrentDaysInSelection > DaysForThisSelection)
					  {
					    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
					    {
					      DaysObject.options[DaysObject.options.length - 1] = null
					    }
					  }
					  if (DaysForThisSelection > CurrentDaysInSelection)
					  {
					    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
					    {
					      NewOption = new Option(DaysObject.options.length + 1);
					      DaysObject.add(NewOption);
					    }
					  }
					    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
					}

					//function to set options to today
					function SetToToday(Which)
					{
					  DaysObject = eval("document.testinit." + Which + "Day");
					  MonthObject = eval("document.testinit." + Which + "Month");
					  YearObject = eval("document.testinit." + Which + "Year");

					  YearObject[0].selected = true;
					  MonthObject[NowMonth].selected = true;

					  ChangeOptionDays(Which);

					  DaysObject[NowDay-1].selected = true;
					}

					//function to write option years plus x
					function WriteYearOptions(YearsAhead)
					{
					  line = "";
					  for (i=0; i<YearsAhead; i++)
					  {
					    line += "<OPTION>";
					    line += NowYear + i;
					  }
					  return line;
					}


// FORM VALIDATION
// Usage:	Its pretty much just plug and play.  Whatever field we want to check, we just plug in the work "Required"
//			right before the variable name.
// Notes:	None
// Works:	ie4+

		function checkrequired(which) {
			var pass=true;
			if (document.images) {
			for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
			if (((tempobj.type=="text"||tempobj.type=="textarea")&&
			tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
			tempobj.selectedIndex==0)) {
			pass=false;
			break;
			         }
			      }
			   }
			}
			if (!pass) {
			shortFieldName=tempobj.name.substring(8,30).toUpperCase();
			alert("Please make sure the "+shortFieldName+" field was properly completed.");
			return false;
			}
			else
			return true;
		}



// Form Submitter
// Usage:	This is designed specifically for when we need to submit a form using javascript
// Notes:	None
// Works:	ie4+

		function createQuestion(question_type,question,answer_set,correct_answer,points) {
                                //alert (question_type + " : " + question + " : " + answer_set + " : " + correct_answer + " : " + points);
                                var FormName = document.getElementById ( "test_question" );
				var QuesType = document.getElementById( "question_type" );
                                var Question = document.getElementById( "question" );
                                var AnsSet = document.getElementById( "answer_set" );
                                var CorrAns = document.getElementById( "correct_answer" );
                                var Points = document.getElementById( "points" );
                                //
                                //
				QuesType.value = question_type;
                                Question.value = question;
                                AnsSet.value = answer_set;
                                CorrAns.value = correct_answer;
                                Points.value = points;
                                //
                                //
                                document.all.test_question.submit();
                                }

// Date Selector
// Usage:	This script makes the job of setting a date idiot proof.
// Notes:	None
// Works:	ie4+

							//set todays date
					Now = new Date();
					NowDay = Now.getDate();
					NowMonth = Now.getMonth();
					NowYear = Now.getYear();
					if (NowYear < 2000) NowYear += 1900; //for Netscape

					//function for returning how many days there are in a month including leap years
					function DaysInMonth(WhichMonth, WhichYear)
					{
					  var DaysInMonth = 31;
					  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
					  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
					  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
					  return DaysInMonth;
					}

					//function to change the available days in a months
					function ChangeOptionDays(Which)
					{
					  DaysObject = eval("document.all.date_form." + Which + "Day");
					  MonthObject = eval("document.all.date_form." + Which + "Month");
					  YearObject = eval("document.all.date_form." + Which + "Year");

					  Month = MonthObject[MonthObject.selectedIndex].text;
					  Year = YearObject[YearObject.selectedIndex].text;

					  DaysForThisSelection = DaysInMonth(Month, Year);
					  CurrentDaysInSelection = DaysObject.length;
					  if (CurrentDaysInSelection > DaysForThisSelection)
					  {
					    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
					    {
					      DaysObject.options[DaysObject.options.length - 1] = null
					    }
					  }
					  if (DaysForThisSelection > CurrentDaysInSelection)
					  {
					    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
					    {
					      NewOption = new Option(DaysObject.options.length + 1);
					      DaysObject.add(NewOption);
					    }
					  }
					    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
					}

					//function to set options to today
					function SetToDate(Which,Whatday,Whatmonth,Whatyear)
					{
					  DaysObject = eval("document.date_form." + Which + "Day");
					  MonthObject = eval("document.date_form." + Which + "Month");
					  YearObject = eval("document.date_form." + Which + "Year");

					  YearObject[0].selected = true;
					  MonthObject[Whatmonth-1].selected = true;
					  DaysObject[Whatday-1].selected = true;
					  ChangeOptionDays(Which);
					}

					//function to write option years plus x
					function WriteYearOptions(YearsAhead)
					{
					  line = "";
					  for (i=0; i<YearsAhead; i++)
					  {
					    line += "<OPTION>";
					    line += NowYear + i;
					  }
					  return line;
					}



//	Check all checkboxes

	function checkAll (name, toggle) {
		var checkGroup = document.getElementById(name);
		var checkToggle = document.getElementById(toggle);

		for (var i=0;i<checkGroup.elements.length;i++)
			{
				var e = checkGroup.elements[i];
				if (e.name != toggle) {
					e.checked = checkToggle.checked;
				}
			}
	}

			isNS4 = (document.layers) ? 1 : 0;
			isIE4 = (document.all) ? 1 : 0;
			isW3C = (document.getElementById && !document.all) ? 1 : 0;

			function setStyle(objName, property, val) {

			    if (isIE4) {
			          var layer = document.all[objName];
			        layer.style[property] = val;
			          return;
			    }
			    if (isW3C) {
			          var obj = document.getElementById( objName );
			        if (obj != null) {
			            var s = obj.style;
			            s[ property ] = val;
			               return;
			          }
			           return;
			    }
			    if (isNav4) {
			          document[objName][property] = val;
			          return;
			    }
			}			
			
			function getCalculatedProperty(objName, property) {
			     // thanks to Ian Grant, http://www.faqts.com/knowledge_base/view.phtml/aid/7157

			     if (isW3C) {
			        docObj = document.getElementById(objName);
			          
			        if (property == "visibility") {
			              cssp = docObj.style.visibility;
			               return (cssp == "") ? "inherit" : cssp;
			          }

			          if (property == "clip") {
			              cssp = docObj.style.clip;

			                 if (cssp == "") {
			                    cssStr = "rect(0px "; 
			                    cssStr += getCalculatedProperty(objName, "width") + " ";
			                    cssStr += getCalculatedProperty(objName, "height") + " ";
			                    cssStr += "0px)";
			                    return cssStr;
			              }
			              return cssp;
			          }

			          if (property == "zIndex") {
			              cssp = docObj.style.zIndex;
			              return (cssp == "") ? "inherit" : cssp;
			          }

			          cssp = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);

			          return (cssp == "") ? "unknown" : cssp;
			    }

			    // ***** Netscape Navigator 4+ DOM *****

			    if (isNS4) {
			          docObj = document.layers[objName];

			          if (property == "visibility") {
			              cssp = docObj.visibility;
			              return (cssp == "hide") ? "hidden" : (cssp == "show") ? "visible" : "inherit";
			          }
			          if (property == "clip") {
			                  cssStr = "rect(" + docObj.clip.top + "px ";
			              cssStr += docObj.clip.right + "px ";
			              cssStr += docObj.clip.bottom + "px ";
			              cssStr += docObj.clip.left + "px)";
			              return cssStr;
			          }
			          if ((property == "width") || (property == "height")) {
			                   return eval("docObj.clip." + property) + "px";
			          }
			          if (property == "top") property = "pageY";
			          if (property == "left") property = "pageX";
			          
			          cssp = eval("docObj." + property);
			          if (property != "zIndex") cssp += "px";
			          return cssp;
			    }

			    // ***** Internet Explorer 4+ DOM *****

			    if (isIE4) {
			          if (property == "width") return eval(objName + ".offsetWidth") + "px";
			          if (property == "height") return eval(objName + ".offsetHeight") + "px";
			          if (property == "top") return eval(objName + ".offsetTop") + 'px';
			          if (property == "left") return eval(objName + ".offsetLeft") + 'px';
			          if (property == "clip") {
			                cssp = eval(objName + ".style.clip");
			              if (cssp == "") {
			                    cssStr = "rect(0px ";
			                    cssStr += getCalculatedProperty(objName, "width") + " ";
			                    cssStr += getCalculatedProperty(objName, "height") + " ";
			                    cssStr += "0px)";
			                    return cssStr;
			              }
			              return cssp;
			          }
			          return eval(objName + ".currentStyle." + property);
			    }
			}
			
			function pxval(valAsStr) {
			     if ((i = valAsStr.indexOf("px")) != -1) { 
			          val = parseInt(valAsStr.substring(0,i)); 
			     }
			     else { 
			          val = 0; 
			          alert("problem parsing valAsStr:"+valAsStr);
			     }
			     return val;
			}
			
        	function toggleGradeDetail (testID) {
	        	var toggleTarget = document.getElementById(testID + "_detail");
	        	var toggleIcon = document.getElementById(testID + "_toggle");
	        	//
	        	if (toggleTarget.style.display == "none") {
		        	toggleIcon.src = "images/collapseIcon.gif";
					try {
					  //standards compliant browsers
					  xDisplay(toggleTarget.id,"table");
					} catch(e) {
					  //IE stupidity
					  xDisplay(toggleTarget.id,"block");
					}
	        	}else {
		        	toggleIcon.src = "images/expandIcon.gif";
		        	xDisplay(toggleTarget.id,"none");	
	        	}
        	}			