    var lastColorUsed;
    var blocked;
    var isIE;
    var isNN;
    var isN4;

    blocked = false;

    //when checking if the browser is IE be sure to exclude the Mac IE browser
    //because it doesnt have the same support as the PC side
    isIE = ((document.all) && (navigator.platform == 'Win32'));

    function highlight(row, enable) {
	    //enable is true when the mouse goes over a row, and false when it leaves the row
	    if (enable) {
		    lastColorUsed = row.style.backgroundColor;
		    row.style.backgroundColor = '#FFFFCC';
	    }
	    else { row.style.backgroundColor = lastColorUsed; }
    }

    function popUpBlocked(winReference) {
	    //only used in this include
	    var isNull, isUndefined;
    	
	    isUndefined = ( typeof(winReference) == "undefined" );
	    isNull = ( winReference == null );
    	
	    if ( !isUndefined && !isNull ) {
		    if ( !winReference.closed ) { return false; }
		    else { return false; }
	    }else if ( isUndefined ) { return true; }
	    else if ( isNull ) { return true; }	
    }

    function post(cid,messageid,level,action) {
	    //used only in coursepage.aspx, functions_coursepage.aspx, classes_chatuser.aspx, and the other bb pages
	    window.open('messages.aspx?cid=' + cid + '&messageid=' + messageid + '&level=' + level + '&action=' + action,'messages','menubar=no,scrollbars=yes,resizable=yes,status=no,height=600,width=800');
    }


    function closeFocusRefresh() {
	    //used in the footer, messages.aspx and login
	    window.close();
	    window.opener.focus();
	    window.opener.location = removePound(window.opener.location);
    }

    function reloadParent() {
	    if (reloadParent.arguments.length == 0) { window.opener.location = removePound(window.opener.location); }
	    else { window.opener.location = reloadParent.arguments[0]; }
    }

    function email(queryString) {
	    //used in a bunch of places
	    pop('email.aspx?' + queryString,'','','','email');
    }

    function quickHelp(event,key) {
	    var xVal;
	    var yVal;
	    var helpWin; 
    	
	    if (!document.layers) {
		    xVal = event.screenX;
		    yVal = event.screenY;
	    }
	    else {
		    xVal = event.pageX;
		    yVal = event.pageY;
	    }
	    xVal = (xVal - 200);
	    yVal = (yVal - 75);
	    helpWin = window.open('help_content.aspx?key=' + key, 'quickHelp', 'menubar=no,scrollbars=yes,resizable=yes,status=no,height=150,width=400,top=' + yVal + ',screenY='+ yVal + ',left=' + xVal + ',screenX=' + xVal);
	    helpWin.moveTo(xVal,yVal);
	    helpWin.focus();
    	
	    return true;
    }

    function checkAll() {
	    var myString;
	    for (i=0; i < document.form1.length; i++) {
		    if (document.form1[i].type == 'checkbox') {
			    //make sure to only check those boxes that have a name of "*checkbox_moddel*"
			    myString = document.form1[i].name;
			    if (document.form1[i].name.indexOf('checkbox_moddel') != -1) {
				    document.form1[i].checked = document.form1.checkAllBox.checked;
			    }
		    }
	    }
    }

    function clickFooterLink() {
	    //this is used in header.ascx to tie the header close link to the footer close link, that way they have the same functionality
	    //it only works in IE for now, so we just use the normal close link for FireFox/Netscape/Mac.  make sure to verify that the DIV
	    //is an object before trying to refernece it or you will get an error on pages like print_content.aspx that dont contain the DIV at the bottom
	    if ((isIE) && (document.getElementById('closeDiv'))) {
		    document.getElementById('closeDiv').click();
	    }
	    else {
		    closeAndFocus();
	    }
    }

    function closeOnLogout() {
	    //this is used to close the window on logout; only used in login.aspx
	    if (navigator.appName == 'Microsoft Internet Explorer') { top.window.close(); }
    }

    function popExport(filename) {
	    //this is used by a lot of scripts to open the export window
	    if (!filename) { filename = ''; }
	    pop('export.aspx?file=' + filename,'yes','500','700','export');
    }

    function selectRow(clientID) {
	    //only call the toggle if they have clicked on a TD tag, not a checkbox
	    //FireFox seem to handle the window.event, so we need to make sure its an object
	    //http://www.webswapp.com/codesamples/viewsource.aspx?file=~/codesamples/aspnet20/gridview_multiplerows_selection/vb.aspx
	    if(window.event) {
		    if (window.event.srcElement.tagName=="TD") {
    		    var row = window.event.srcElement.parentNode;
    		    var chk = row.cells[0].firstChild.firstChild;
			    chk.checked = !chk.checked;
		    }
	    }
    }

    function findY(objName) {
	    //function to locate an object by name, and return its Y (vertical) location on the page
	    //function will return zero if the element is not found
	    var curtop = 0;
	    var obj = document.getElementById(objName);
    	
	    if (obj.offsetParent) {
		    while (obj.offsetParent) {
			    curtop += obj.offsetTop
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.y) { curtop += obj.y; }
	    return curtop;
    }

    function getWinHeight() {
	    //function to return the height of the current window; returns zero if the
	    //appVersion cannot be determined as Netscape or Microsoft correctly
	    var winH = 0;
	    if (parseInt(navigator.appVersion)>3) {
		    if (navigator.appName=="Netscape") { winH = window.innerHeight; }
		    if (navigator.appName.indexOf("Microsoft")!=-1) { winH = document.body.offsetHeight; }
	    }
	    return winH;
    }

    function setListingHeight() {
	    //function to set the size of the DIV that contains the datagrid; the function will not execute
	    //if the DIV cannot be found.  note, the  "60" listed below will just give us a little buffer so that the window
	    //scrollbars do not activate even when the DIV scrollbars are turned on
	    if ((isIE) && (document.getElementById('listDiv'))) {
		    var currDivHeight = (findY('footerStart') - findY('listDiv'));
		    var newDivHeight = (getWinHeight() - findY('listDiv') - (findY('footerStop') - findY('footerStart')) - 60);

		    if ((currDivHeight > newDivHeight) && (newDivHeight > 0)) {
			    if (newDivHeight < 200) { document.getElementById('listDiv').style.height = '200px'; }
			    else { document.getElementById('listDiv').style.height = newDivHeight + 'px';	}
		    }
	    }
    }

    function goToCoursepage(cid) {
	    //used on courseindex.aspx
	    window.location = 'coursepass.aspx?cid=' + cid;
    }

    function handleEnterOnIndex(myfield,e,elementID) {
	    //used on courseindex.aspx, rename.aspx and resourceindex.aspx
	    var keycode;
	    if (window.event) { keycode = window.event.keyCode; }
	    else { if (e) { keycode = e.which; } }
	    if (keycode == 13) { document.getElementById(elementID).click(); return false; }
	    else { return true; }
    }

    function setColor(myCell,hexCell,color) {
	    //used on colors.aspx
	    myCell.style.backgroundColor = color;
	    document.getElementById('hex').innerHTML = color;
    }
    	
    function returnColor(myBox,myColor) {
	    //used on colors.aspx
	    window.opener.document.getElementById(myBox).value = myColor;
	    window.close();
	    window.opener.focus();
    }

    function reload() {
	    //used in chat_history.aspx; normally wont be called
	    document.location.href = document.location.href;
    }

    function popLogout(cid) {
	    //used in chat_frame.aspx
	   // pop('chat_logout.aspx?cid=' + cid,'yes','','','logout');
	   pop('print_frame.aspx?page=chat_logout.aspx','yes','','','logout');
    }

    function setDocumentView() {
	    //used in documentview.aspx
	    isIE=document.all;
	    isNN=!document.all && document.getElementById;
	    isN4=document.layers;
	    if (isIE||isNN) { document.oncontextmenu=checkV; }
	    else { document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP); document.onmousedown=checkV; }
    }

    function checkV(e) {
	    //used in documentview.aspx
	    if (isN4) { if (e.which==2||e.which==3) { blockClick(); return false; } }
	    else { blockClick(); return false; }
    }

    function left(str, n){
	    if (n <= 0)
	        return "";
	    else if (n > String(str).length)
	        return str;
	    else
	        return String(str).substring(0,n);
    }

    function right(str, n){
        if (n <= 0)
           return "";
        else if (n > String(str).length)
           return str;
        else {
           var iLen = String(str).length;
           return String(str).substring(iLen, iLen - n);
        }
    }

    function removePound(myURL) {
	    if (right(myURL,1) != "#") { return myURL; }
	    else { return left(myURL,String(myURL).length-1); }
    }

    function getRandomPass() {
	    var chars = "0123456789abcdefghiklmnopqrstuvwxyz";
	    var randomstring = '';
	    for (var i=0; i<8; i++) {
		    var rnum = Math.floor(Math.random() * chars.length);
		    randomstring += chars.substring(rnum,rnum+1);
	    }
	    return randomstring;
    }
    
    function jstest() {
        alert("Javascript is working");
    }