<!-- Hide from older browsers 

 
var myTimer = null;
var endTime = 0;
var endSaveTime = 0;
var warning5 = 0;
var warning1 = 0;
var doingSaveTimer = false;
var doingTestTimer = false;

function stopTimer()
{
    clearTimeout(myTimer);
    endTime = 0;
}

function startTimer(saveTimer, theDelta)
{
    var time = new Date();
    warning5 = 0;
    warning1 = 0;
    if (saveTimer > 0) doingSaveTimer = true;
    if (theDelta > 0) doingTestTimer = true;
    if (theDelta < 300000) // less than 5 minutes
    {
        warning5 = 1;
        if (theDelta < 60000)// less than 1 minute
            warning1 = 1;
    }
    endTime = 1*time.getTime() + 1*theDelta;
    endSaveTime = 1*time.getTime() + 1*saveTimer;
    continueTimer();
}

function continueTimer()
{
    var time = new Date();
    doc = parent.frames[0].document;
    var myDispTarget=doc.getElementById("msg_to_display");
    var testMsg ="";
    var saveMsg ="";
    var nextTestTimeout=10000000;
    var nextSaveTimeout=10000000;
    
    if (doingSaveTimer)
    {
        delta = endSaveTime - time.getTime();
        if (delta > 0)
        {
            minutes = Math.floor(delta/60000);
            fraction = Math.round(59*(delta/60000 - minutes)) ;
            saveMsg = "save in: <b>" + 
                minutes + ":" + ((fraction <= 9)?"0"+fraction:""+fraction)+"</b>"; 
            // Wait another minute
            nextSaveTimeout = Math.min(10000,(delta+1000));
        }
        else if (delta > -100000)
        {
            update_form_action('big_form', 'Save');
        }

    }
    if (doingTestTimer)
    {
        delta = endTime - time.getTime();
        if (delta > 0)
        {
            minutes = Math.floor(delta/60000);
            fraction = Math.round(59*(delta/60000 - minutes)) ;
            testMsg = "time left: <b>" + 
                minutes + ":" + ((fraction <= 9)?"0"+fraction:""+fraction)+"</b>"; 
            // Wait another minute
            nextTestTimeout = Math.min(10000,(delta+1000));
            if (delta < 300000 && warning5==0)// 5 minutes
            {
                warning5 =1;
                testMsg = "<b>Less than 5 minutes left</b>";
            }
            if (delta < 60000 && warning1 == 0) // 1 minute
            {
                warning1 = 1;
                testMsg = "<b>Less than 1 minute left</b>";
            }        
        }
        else if (delta > -100000)
        {
            update_form_action('big_form', 'Submit_Terminate');
            testMsg = "Time Left: None";
        }
    }//end of if(doingTestTimer)
    
    
    myDispTarget.innerHTML = saveMsg + "<br>" + testMsg; 
    myTimer = setTimeout("continueTimer()",Math.min(nextTestTimeout, nextSaveTimeout)  );

   
}

function set_msg_to_display_invisible(saveTimeout, timeout) 
{
    doc = parent.frames[0].document;  
    myDispTarget=doc.getElementById("msg_to_display");
    if (myDispTarget != null)myDispTarget.innerHTML=" "; 
    if (timeout > 0 || saveTimeout > 0)
           startTimer(saveTimeout, timeout);       
}
        
   //     stdBrowser = (document.getElementById) ? true : false
        function popUpExtra()
        {
           var extraWindow = window.open("empty.html", "aardvarkExtra",
             "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500,left=400,top=0");
            if (extraWindow != null)
            {
                   try
                   {
                        extraWindow.focus();
                   }catch (e){}
            }
        }
        
       
   
        
        function popUpWeb()    
        {
            var webWindow = window.open("empty.html", "Aardvark_Web",
             "toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=780,height=420,left=20,top=20");
            if (webWindow != null)
            {
                   try
                   {
                        webWindow.focus();
                   }catch (e){}
            }
        }


        
        function popUpHelp()    
        {
            var webWindow = window.open("empty.html", "Aardvark_Help",
             "toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=780,height=420,left=20,top=20");
            if (webWindow != null)
            {
                   try
                   {
                        webWindow.focus();
                   }catch (e){}
            }
        }
         
        function gotoPopUpHelp(page)    
        {
            var webWindow = window.open(page, "Aardvark_Help",
             "toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=780,height=420,left=20,top=20");
            if (webWindow != null)
            {
                   try
                   {
                        webWindow.focus();
                   }catch (e){}
            }
            self.close();
        }
        

        


        
        function popUpChat(teacherFlag)
        {
            var actualScreen = "chat/S_chat.jsp";
            if (teacherFlag == 1) actualScreen = "chat/T_chat.jsp"
            var webWindow = window.open(actualScreen, "Aardvark_Chat",
             "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=500,left=100,top=100");
            if (webWindow != null)
            {
                   try
                   {
                        webWindow.focus();
                   }catch (e){}
            }
        }


        function closeMe()
        {
            var mywind = window.open("#aardvarkTop","_self");
            mywind.close();
         }      
        function init_menus()
        {
            navigateContents('navigateMenu', -1);
        }
        function init_teacher_menus()
        {
            navigateContents('navigateMenu', -1);
        }

        
        function isDumb()
        {
              if( document.layers ) return true; // Netscape 4
              return false;
        }
                
        function resetScroll(contentsdoc)
        {
           // scrollTo(0,0);
            var url_scroll_top = contentsdoc.location.href;
            
            // Strip off any previous local anchor references
            var index = url_scroll_top.indexOf("#", 0);
            if (index >=0) url_scroll_top = url_scroll_top.substring(0,index); 
            
            url_scroll_top += "#aardvarkTop";
            //alert("location.href="+url_scroll_top);                
            contentsdoc.location.href = url_scroll_top;                   
        }
        
        function setCmdDropdown(enable)
        {
       
        }
        
        function navigateContents(currElem,nextPos) {
           contentsdoc = parent.frames[1].document;
        
           if (nextPos == 0)
           {
                resetScroll(contentsdoc);
            }
     

         //  menuObj = (stdBrowser) ? contentsdoc.getElementById(currElem).style : eval("contentsdoc." + currElem);
           menuObj = contentsdoc.getElementById(currElem).style ;
         //  menuObj = contentsdoc.getElementById(currElem);

           if (menuObj != null)
               menuObj.visibility = (nextPos==-1) ? "hidden" : "visible";


            // **** Interesting options
            // if (navigateContents.arguments.length == 1) {
            //    nextPos = (parseInt(menuObj.top) == -5) ? -90 : -5
            // }
            // window.event.cancelBubble=true;
            // return true;
        }


        function update_form(big_form)
        {
            big_form.submit();
        }
        
        function update_form_action(big_form, actionValue)
        {
            contentsdoc = parent.frames[1].document;
            if (contentsdoc == null)
            {
                alert("update_form_action, contentsdoc=null");
                return;
            }            
            contentsdoc.big_form.action.value=actionValue;
            contentsdoc.big_form.submit();
        }
         
        function update_form_action1(actionValue)
        {
            document.big_form.action.value=actionValue;
            document.big_form.submit();
        }
        
        function update_form_action2( actionValue)
        {
            contentsdoc = parent.frames[1].document;
            if (contentsdoc == null)
            {
                alert("update_form_action, contentsdoc=null");
                return;
            }     
            if (actionValue == "Goto")
            {
                var value_to_store = prompt("Enter \"Goto\" question number.   If you have skipped questions, you can also start with # followed by number as seen by student.","");
                contentsdoc.big_form.gotoIndex.value = value_to_store;
            }       
            contentsdoc.big_form.action.value=actionValue;
            contentsdoc.big_form.submit();
        }
        function update_form_action3( actionValue)
        {
            contentsdoc = parent.frames[1].document;
            if (contentsdoc == null)
            {
                alert("update_form_action, contentsdoc=null");
                return;
            }     
           
           var name = confirm('This action will End your test!!!!!!!      Click on "OK" if you have finished the test and want to Submit it.');
           if (name != true)
            return;

           
            contentsdoc.big_form.action.value=actionValue;
            contentsdoc.big_form.submit();
        }

        function update_form_blur(myobj )
        {
            contentsdoc = parent.frames[1].document;
            if (contentsdoc == null)
            {
                alert("update_form_blur, contentsdoc=null");
                return;
            }     
            
            contentsdoc.big_form.copyTo.value=myobj.value;
        }


        function update_msg_to_display(value)
        {
            doc = parent.frames[0].document;
            if (doc != null)  myDispTarget=doc.getElementById("msg_to_display");
            
            if (myDispTarget!=null) myDispTarget.innerHTML =unescape(value);
        }



        function areYouSure(msg)
        {
            var name = confirm(msg);
            if (name == true)
                return true;
            else
                return false;
        }
        
function set_button(object, value) {
    var actual_name = object.src;
    var len= actual_name.length;
    
    index = actual_name.lastIndexOf("_");
   
    if (index > 0)
        actual_name= actual_name.substring(0, index);
        
    if (value == 3)
        actual_name +="_down" + ".gif"; 
    else if (value == 2)
        actual_name +="_select" + ".gif";
    else 
        actual_name +="_up" + ".gif";
   
    object.src=actual_name;
}


function properName(myObj, fieldName)
        {
            var txt="";
            if (myObj != null) txt= myObj.value;
            var newTxt="";
            var good=true;
            var cbad;
            
            for( i=0; i < txt.length; i++)
            {
                c=txt.charAt(i);
                if ( (c >= 'a' && c <='z') || (c >= 'A' && c <= 'Z') ||
                    (c >= '0' && c <= '9') || c == '_' )
                {
                    newTxt += c;
                    continue;
                }
                good = false; 
                cbad = c;                  
            }
            if (!good)
            {
                alert(fieldName +" contains the character: " + cbad + "\r\nProper Names should only contain: a-z, A-Z, 0-9 or '_' ");
                if (myObj != null) myObj.value = newTxt;
                return false;
            }
            if (newTxt.length > 0) return true;
            else 
            {
                alert(fieldName +" needs at least one character (a-z, A-Z, 0-9, or '_')");
                return false;
            }
        }


function properName2(value, fieldName)
        {
            var txt=value;
            var newTxt="";
            var good=true;
            var cbad;
            
            for( i=0; i < txt.length; i++)
            {
                c=txt.charAt(i);
                if ( (c >= 'a' && c <='z') || (c >= 'A' && c <= 'Z') ||
                    (c >= '0' && c <= '9') || c == '_'  )
                {
                    newTxt += c;
                    continue;
                }
                good = false; 
                cbad = c;                  
            }
            if (!good)
            {
                alert(fieldName +" contains the character: " + cbad + "\r\nProper Names should only contain: a-z, A-Z, 0-9 or '_' ");
                return false;
            }
            if (newTxt.length > 0) return true;
            else 
            {
                alert(fieldName +" needs at least one character (a-z, A-Z, 0-9, or '_')");
                return false;
            }
        }


function noCommas(myObj, fieldName, nonEmpty)
        {
            var txt="";
            if (myObj != null) txt= myObj.value;
            var newTxt="";
            var good=true;
            var cbad;
            
            for( i=0; i < txt.length; i++)
            {
                c=txt.charAt(i);
                if (c != ',' )
                {
                    newTxt += c;
                    continue;
                }
                good = false; 
            }
            if (!good)
            {
                alert(fieldName +" contains a Comma. \r\nProper values should not contain a comma. ");
                if (myObj != null) myObj.value = newTxt;
                return false;
            }
            if (nonEmpty==1 && newTxt.length == 0)
            {
                alert(fieldName +" needs at least one character ");
                return false;
            }
            return true;
        }




function launch(url)
{
    //  window.open("http://clem.downstairs:8080/hmk/Links.html","AaClassRoom",
    //      "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no");
       
    //    window.open("http://clem.downstairs:8080/hmk/login_stu.jsp","AaClassRoom",
    //      "status=yes,menubar=yes,resizable=yes,scrollbars=yes,copyhistory=no");

         window.open(url,"AaClassRoom",
            "status=yes,menubar=yes,resizable=yes,scrollbars=yes,copyhistory=no");

}

// End hiding -->


