$(document).ready(function(){



    
    setSite();

    //login-field
    var tmr;
    $("#loginfield").hover(
      function () {
        clearTimeout(tmr);
        $("#loginfield").animate(
          {"height": "150px", "width": "140px"},
        "fast" );
      }, 
      function () {
        tmr=setTimeout("$('#loginfield').animate({'height': '20px', 'width': '50px'},'fast');",2000);
      }
    );
    
    $("#logo").attr('title','Startseite');
    $("#logo").click(function() {
      window.location = url_server; 
    });

    $(".seitenzahlen a").mouseup(function() {
        if( $('.nvisi'+(parseInt ($(this).html())-1)).hasClass('nvisi') !== true ) return;
        setVisible($(this).html());
    });
    
    
    
    
    
  $('.layout-login-0').corner();

//    $('#layer2_top_left div div div').corner("round 5px");
 

  timer_keepsession = setInterval(function () {
    $.ajax({
       type: "POST",
       url: url_server+"_lib/php/keepsession/keepsession.php",
       error: function(msg){
       },
       success: function(msg){
       }
     });
  },60000);
  

});//ende doc ready


function returnElmValArray(objectclass){
  elmArray =  new Array();
  elmArray={'ahelp': 'ahelp'};
  $("."+objectclass).each(function(i){
    var sval=$(this).val();
    if ($(this).is('input:checkbox')) $(this).is(':checked') ? sval='1' : sval='0';
    if($(this).is('[type=textarea]')) sval = $(this).val();
    sval = Url.encode(sval);
    if ($(this).attr("name")) elmArray[$(this).attr("name")]=sval;
  });
  return   elmArray ; 
}


var Url = {
 
  // public method for url encoding
  encode : function (string) {
    return escape(this._utf8_encode(string));
  },
 
  // public method for url decoding
  decode : function (string) {
    return this._utf8_decode(unescape(string));
  },
 
  // private method for UTF-8 encoding
  _utf8_encode : function (string) {
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";
 
    for (var n = 0; n < string.length; n++) {
 
      var c = string.charCodeAt(n);
 
      if (c < 128) {
        utftext += String.fromCharCode(c);
      }
      else if((c > 127) && (c < 2048)) {
        utftext += String.fromCharCode((c >> 6) | 192);
        utftext += String.fromCharCode((c & 63) | 128);
      }
      else {
        utftext += String.fromCharCode((c >> 12) | 224);
        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
        utftext += String.fromCharCode((c & 63) | 128);
      }
 
    }
 
    return utftext;
  },
 
  // private method for UTF-8 decoding
  _utf8_decode : function (utftext) {
    var string = "";
    var i = 0;
    var c = c1 = c2 = 0;
 
    while ( i < utftext.length ) {
 
      c = utftext.charCodeAt(i);
 
      if (c < 128) {
        string += String.fromCharCode(c);
        i++;
      }
      else if((c > 191) && (c < 224)) {
        c2 = utftext.charCodeAt(i+1);
        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
        i += 2;
      }
      else {
        c2 = utftext.charCodeAt(i+1);
        c3 = utftext.charCodeAt(i+2);
        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
        i += 3;
      }
 
    }
 
    return string;
  }
 
}


  function gr_set_check2 (name) {
    if (document.getElementsByName("gr_ch"+name)[0].checked==true) document.getElementsByName(name)[0].value="1";
    if (document.getElementsByName("gr_ch"+name)[0].checked==false) document.getElementsByName(name)[0].value="0";
  }

  function setVisible(mval){
      $('.seitenzahlen').css('text-decoration','none');
      $('#seitenzahlen').find('a:eq('+(mval-1)+')').parent().css('text-decoration','underline');
      var mkl=$('.nvisi'+(parseInt (mval)-1));
      $('.tcontent').animate({
        opacity: 0.0
      }, 100, function() {
        $('.tcontent').addClass('nvisi');
        mkl.removeClass('nvisi');
        $('.tcontent').animate({
          opacity: 1
        }, 100, function() {
        });
      });
  }

function setSite(){
    var surl = document.URL;
    var ssearch = surl.search(/#seite_/);
    if (ssearch != -1){
      surl_s1 = surl.split('#');
      surl_s2 = surl_s1[1].split('_');
      setVisible(surl_s2[1]);
    } else {
      setVisible(1);
    } 
}

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}



