/*
*   JavaScript HelperScript: myNewHelper.js
*   
*   Developer: Holger Maerz
*   Copyright: OnNet Europe. All rights reserved
*   Date: Jan 2012 
*
*/

//binds function after loading website
window.onload = ZeitAnzeigen;

/************************************************************************
 SERVERTIME in top menue
 dev:  Holger Maerz 
 date: 27.Jan.2012
 desc: shows the actual time of the server
 long: customers live in different time zones. 
       local server time is initially written to the HTML element.
       this time is used to set up the date object of the client.
       this method is called every second to recalculate the actual time.
 dependencies: window.onload= ZeitAnzeigen;     
 more: uses jQuery          
 ************************************************************************/
function ZeitAnzeigen() {

    try {

       
             //actual Servertime
            var strActualDateTime = $("li#Time").find("span").text();
            
            //native javascript
            //var strActualDateTime = document.getElementById("Servertime").firstChild.nodeValue;
            
            //date info is not important.. just the time
            var datum = new Date('1/1/2000 '+ strActualDateTime);
            datum.setTime(datum.getTime() + 1000);
                            
            var Stunden = datum.getHours();
            var Minuten = datum.getMinutes();
            var Sekunden = datum.getSeconds();
            var Vorstd = (Stunden < 10) ? "0" : "";
            var Vormin = (Minuten < 10) ? ":0" : ":";
            var Vorsek = (Sekunden < 10) ? ":0" : ":";
            var Uhrzeit = Vorstd + Stunden + Vormin + Minuten + Vorsek + Sekunden;

            //write the servertime
            $("li#Time").find("span").text(Uhrzeit);
            //native code
            //document.getElementById("Servertime").firstChild.nodeValue = Uhrzeit;

            
        //calls function every second
        window.setTimeout("ZeitAnzeigen()", 1000);
    }
    catch (e) {

        alert("Exception: unexpected error");
    }

}

/************************************************************************
TOGGLE Display of MyCampus UI menue 
dev:  Holger Maerz 
date: 27.Jan.2012
desc: toggles the display of the submenue MyCampus
long: while the hover effect just shows the submenue, a click 
      on the top menue point toogles the display. Therfore, the formular
      is enabled for convenient user input until the user submit an input 
      or toggles the display by another click. The method itself also 
      sets a class in the parent element fpr highlighting the top menue element.
      method is bound after DOM loaded. 
dependencies: CSS class myCampus (not essential)     
more: uses jQuery   

replaced 15.02.       
************************************************************************/
$(document).ready(function () {
    $("#myCampus a:first").mouseover(
        function () {
            $(this).parent("li").addClass("myCampus").find("ul").css("display", "block");
        }
    );


    $("li#close").click(
              function () {
                  $(this).parent("ul").parent("li").removeClass("myCampus").find("ul").css("display", "none");
              }
            );

    /**** select std text value if focussing ****/
    $("input[name$='uid']").focus(
              function () {
                  this.select();
              }
           );

    $("input[name$='pwd']").focus(
              function () {
                  this.select();
              }
           );
});


$(document).ready(function () {
          
 });
