function openCustomWindow(url, width, height) { popupWin = window.open(url,'new_page','width=' + width + ',height=' + height) } function openWindow(url) { popupWin = window.open(url,'new_page','scrollbars=1,width=350,height=450') } function highlightAndCopy(theField) { theField.focus(); theField.select(); if (document.all){ therange = theField.createTextRange(); therange.execCommand('Copy'); window.status = 'Contents highlighted and copied to clipboard!'; setTimeout('window.status=""', 2400); } } function InsertAtCursor(elementField,ins) { var el = document.getElementById(elementField); if (el.setSelectionRange){ el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length); } else if (document.selection && document.selection.createRange) { el.focus(); var range = document.selection.createRange(); range.text = ins + range.text; } } function PrintPage() { window.print(); } function MoveSelections(sourceSelectName, destSelectName, action) { //Set up the variables for these select boxes. var sourceSelect = document.getElementsByName(sourceSelectName)[0]; var destSelect = document.getElementsByName(destSelectName)[0]; //Go through the list of options in the left select for (i=sourceSelect.options.length - 1; i>=0; i--) { if (sourceSelect.options[i].selected == true) { sourceValue=sourceSelect.options[i].value; sourceText=sourceSelect.options[i].text; if (sourceValue.length > 0) { //Get the current value of the 'ChangesMade' variable. var ChangesMade = document.getElementsByName('ChangesMade')[0].value; //Now update the 'ChangesMade' variable with this new action. document.getElementsByName('ChangesMade')[0].value = ChangesMade + action + ' ' + sourceValue + ', '; //Add the new row to the destination select and remove it from the old one. var newRow = new Option(sourceText,sourceValue); destSelect.options[destSelect.length]=newRow; sourceSelect.options[i]=null; } } } } function RandNum(loNum, hiNum) {return Math.floor((Math.random() * (hiNum - loNum)) + loNum);} function setDiv(responseText, divID) {document.getElementById(divID).innerHTML = responseText;} function setDivRoster(responseText, divID) { document.getElementById(divID).innerHTML = responseText; var alertText = document.getElementById('RosterAlert').innerHTML; if (alertText.length > 2) alert(alertText); } function swapDisplay(divID1, divID2) { var div1 = document.getElementById(divID1); var div2 = document.getElementById(divID2); if (div1.style.display == "none") { div1.style.display = ""; div2.style.display = "none"; } else { div1.style.display = "none"; div2.style.display = ""; } } function GoConfirm(confirmMessage, url) {if (confirm(confirmMessage)) window.location.href = url;} function tierMenu(objMenu,objImage) { var myElement = document.getElementById(objMenu,objImage); if ((myElement.className.length > 0)&&(myElement.className.indexOf("infolderclosed") >= 0)) { if (myElement.className == "infolderclosed") { myElement.className = "infolderopen"; if (arguments.length > 1) objImage.src = "/images/treeminus.gif"; } else { myElement.className = "infolderclosed"; if (arguments.length > 1) objImage.src = "/images/treeplus.gif"; } } else if (myElement.style.display == "none") { myElement.style.display = ""; if (arguments.length > 1) objImage.src = "/images/treeminus.gif"; } else { myElement.style.display = "none"; if (arguments.length > 1) objImage.src = "/images/treeplus.gif"; } } function tierMenuPlus(objMenu,objImage) { var myElement = document.getElementById(objMenu,objImage); if ((myElement.className.length > 0)&&(myElement.className.indexOf("infolderclosed") >= 0)) { if (myElement.className == "infolderclosed") { myElement.className = "infolderopen"; if (arguments.length > 1) objImage.src = "/images/treeminuss.gif"; } else { myElement.className = "infolderclosed"; if (arguments.length > 1) objImage.src = "/images/treepluss.gif"; } } else if (myElement.style.display == "none") { myElement.style.display = ""; if (arguments.length > 1) objImage.src = "/images/treeminuss.gif"; } else { myElement.style.display = "none"; if (arguments.length > 1) objImage.src = "/images/treepluss.gif"; } } function DeleteFunction(forwardLocation,objName,objGroup,isRecoverable) { var msg = "Are you sure you want to remove " + objName + " from " + objGroup + "?"; if (isRecoverable == false) msg = msg + "\n\nThis information cannot be recovered once removed."; if (confirm(msg)) window.location = forwardLocation; } function ConfirmLogout(forwardLocation) { var msg = "Are you sure you want to log out?"; if (confirm(msg)) window.location = forwardLocation; } function SetField(FormName, FieldName, FieldValue) { FieldValue = FieldValue.replace('\'', '\\\''); eval("document.forms." + FormName + "." + FieldName + ".value = '" + FieldValue + "';"); } //This is for the dropdown dates and times used with commonfunctions.asp function SetNextDropDown(FormName, OldFieldName, NewFieldName) { eval("document.forms." + FormName + "." + NewFieldName + ".selectedIndex = document.forms." + FormName + "." + OldFieldName + ".selectedIndex"); } //This is for the file upload script on files.asp function DoUpload() { theFeats = "height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no"; theUniqueID = (new Date()).getTime() % 1000000000; window.open("/progressbar.asp?ID=" + theUniqueID, theUniqueID, theFeats); document.forms.FileForm.action = "files.asp?Action=WriteFile&ID=" + theUniqueID; document.forms.FileForm.submit(); } //This is for the file upload script on /class/classfiles.asp function DoUploadClass(ClassID) { theFeats = "height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no"; theUniqueID = (new Date()).getTime() % 1000000000; window.open("/progressbar.asp?ID=" + theUniqueID, theUniqueID, theFeats); document.forms.FileForm.action = "classfiles.asp?Action=WriteFile&ClassID=" + ClassID + "&ID=" + theUniqueID; document.forms.FileForm.submit(); } function DoUploadGeneric(SubmitAction) { theFeats = "height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no"; theUniqueID = (new Date()).getTime() % 1000000000; window.open("/progressbar.asp?ID=" + theUniqueID, theUniqueID, theFeats); document.forms.FileForm.action = SubmitAction + "&ID=" + theUniqueID; document.forms.FileForm.submit(); } function capsDetect( e ) { //Code found at: http://www.howtocreate.co.uk/jslibs/otherdemo.html#cld //if the browser did not pass event information to the handler, //check in window.event if( !e ) { e = window.event; } if( !e ) { return; } //what (case sensitive in good browsers) key was pressed //this uses all three techniques for checking, just in case var theKey = 0; if( e.which ) { theKey = e.which; } //Netscape 4+, etc. else if( e.keyCode ) { theKey = e.keyCode; } //Internet Explorer, etc. else if( e.charCode ) { theKey = e.charCode } //Gecko - probably not needed //was the shift key was pressed var theShift = false; if( e.shiftKey ) { theShift = e.shiftKey; } //Internet Explorer, etc. else if( e.modifiers ) { //Netscape 4 //check the third bit of the modifiers value (says if SHIFT is pressed) if( e.modifiers & 4 ) { //bitwise AND theShift = true; } } //if upper case, check if shift is not pressed if( theKey > 64 && theKey < 91 && !theShift ) { handleCapsOn(); } //if lower case, check if shift is pressed else if( theKey > 96 && theKey < 123 && theShift ) { handleCapsOn(); } //caps lock isn't on at this point else { handleCapsOff(); } } var clockID = 0; var tDate; function UpdateClock() { if(clockID) { clearTimeout(clockID); clockID = 0; } var myElement = document.getElementById("Clock"); //var tDate = new Date(); //document.theClock.theTime.value = "" // + tDate.getHours() + ":" // + tDate.getMinutes() + ":" // + tDate.getSeconds(); var Hours = tDate.getHours(); var Minutes = tDate.getMinutes(); var Seconds = tDate.getSeconds(); var timeValue = "" + ((Hours >12) ? Hours - 12 : Hours) timeValue += ((Minutes < 10) ? ":0" : ":") + Minutes timeValue += ((Seconds < 10) ? ":0" : ":") + Seconds timeValue += (Hours >= 12) ? " PM" : " AM" myElement.innerHTML = timeValue; tDate.setSeconds(tDate.getSeconds() + 1); clockID = setTimeout("UpdateClock()", 1000); } function StartClock(StartTime) { tDate = new Date(StartTime); tDate.setSeconds(tDate.getSeconds() + 1); clockID = setTimeout("UpdateClock()", 500); } function KillClock() { if(clockID) { clearTimeout(clockID); clockID = 0; } } function insertAtCursor(myField, myValue) { //Code found at: http://www.alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/ //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } function startCountdown(myTextID, myTimeMinutes, myTimeSeconds, my10PercentMinute, my10PercentSecond) { //Time Mathematics if (myTimeSeconds == 0) { myTimeMinutes -= 1; myTimeSeconds = 59; } else myTimeSeconds -= 1; //Display any related alerts if ((myTimeMinutes == 5)&&(myTimeSeconds == 0)) { var myAlertElement = document.getElementById("alertcontent"); myAlertElement.innerHTML = "You have 5 minutes remaining. Please check your work. This test will auto-submit itself when your time is up." initbox(); } if ((myTimeMinutes == 2)&&(myTimeSeconds == 0)) { var myAlertElement = document.getElementById("alertcontent"); myAlertElement.innerHTML = "You have 2 minutes remaining. Please check your work. This test will auto-submit itself when your time is up." initbox(); } if ((myTimeMinutes == 1)&&(myTimeSeconds == 0)) { var myAlertElement = document.getElementById("alertcontent"); myAlertElement.innerHTML = "You have 1 minute remaining. This is your final warning. This test will auto-submit itself when your time is up." initbox(); } if (((myTimeMinutes == 0)&&(myTimeSeconds == 0))||(myTimeMinutes < 0)) { document.TestForm.submit(); } //Update the clock var myElement = document.getElementById(myTextID); if (myTimeSeconds < 10) myElement.innerHTML = myTimeMinutes + ":0" + myTimeSeconds + " minutes"; else myElement.innerHTML = myTimeMinutes + ":" + myTimeSeconds + " minutes"; //Determine the new background color if (((myTimeMinutes == my10PercentMinute)&&(myTimeSeconds <= my10PercentSecond))||(myTimeMinutes < my10PercentMinute)) { if (myTimeSeconds % 2 == 1) myElement.bgColor = "#cc3333"; else myElement.bgColor = "#ffffff"; } setTimeout("startCountdown('" + myTextID + "', " + myTimeMinutes + ", " + myTimeSeconds + ", " + my10PercentMinute + ", " + my10PercentSecond + ")", 1000); } function URLEncode(plainVal) { // The Javascript escape and unescape functions do not correspond // with what browsers actually do... var SAFECHARS = "0123456789" + // Numeric "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()"; // RFC2396 Mark characters var HEX = "0123456789ABCDEF"; var plaintext = plainVal; var encoded = ""; for (var i = 0; i < plaintext.length; i++ ) { var ch = plaintext.charAt(i); if (ch == " ") { encoded += "+"; // x-www-urlencoded, rather than %20 } else if (SAFECHARS.indexOf(ch) != -1) { encoded += ch; } else { var charCode = ch.charCodeAt(0); if (charCode > 255) { alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" + "(URL encoding only supports 8-bit characters.)\n" + "A space (+) will be substituted." ); encoded += "+"; } else { encoded += "%"; encoded += HEX.charAt((charCode >> 4) & 0xF); encoded += HEX.charAt(charCode & 0xF); } } } // for return encoded; } /* Note by Bill: I don't know what these do or how they work, but they seem to fix a Netscape problem. Fine by me! */ // Netscape fix resize bug Ns4 function WM_netscapeCssFix() { if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) { document.location = document.location; } } 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; } } WM_netscapeCssFixCheckIn(); // catch all errors... //function stopError() {return true;} //window.onerror=stopError;