var bConfirmed = false;
$(function()
{
    $('.date-pick').datePicker();
});

checkLogin = function( nUserId )
{
    var sCookie = document.cookie;
    var aCookie = sCookie.split( ';' );
    for(var i=0;i<aCookie.length;i++) 
    {   
        
        if( aCookie[ i ] == " logintime=time" )  
           var bExists = true;
        else
           var bExists = false; 
           
        if( aCookie[ i ].substr( 0, 5 ) == "admin" )
        {
            var adminCookie = aCookie[ i ].substr( 0, 5 );
        }
    }
    
    if( !bConfirmed && !bExists )
    {
        if( confirm( "You will be logged out within 5 minuten, please click ok to stay logged in." ) )
        {
            bConfirmed = true;
            var oXML = new klib3.xml();
            
            oXML.request( "/rpc.php", "post", true, {command:"increasecookietime",_format:"xml"}, userid=nUserId );
        } 
    }
    
    if( !adminCookie )
    {
        window.location = '/admin/login.php';
    }
}

sfHover = function() 
{
    var sfEls = document.getElementById("menu").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) 
    {
        sfEls[i].onmouseover=function() 
        {
            this.className+=" ie_does_hover";
        }
        sfEls[i].onmouseout=function() 
        {
            this.className=this.className.replace(new RegExp(" ie_does_hover\\b"), "");
        }
    }
}

function startUpload()
{
      document.getElementById('upload_process').style.visibility = 'visible';
      //document.getElementById('f1_upload_form').style.visibility = 'hidden';

      return true;
}

function stopUpload(success){
      var result = '';

      if (success == 1){
         result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
      }
      else {
         result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
      }
      //document.getElementById('upload_process').style.visibility = 'hidden';
      document.getElementById('upload_process').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
      //document.getElementById('f1_upload_form').style.visibility = 'visible';      
      return true;   
}

function showType( sType )
{
    if( sType == "user" )
    {
        document.getElementById( "user" ).style.display = 'block';
        document.getElementById( "group" ).style.display = 'none';
    }
    else if( sType == "group" )
    {
        document.getElementById( "user" ).style.display = 'none';
        document.getElementById( "group" ).style.display = 'block';
    }
    else
    {
        document.getElementById( "user" ).style.display = 'none';
        document.getElementById( "group" ).style.display = 'none';
    }
}

//if (window.attachEvent) 
//    window.attachEvent("onload", sfHover);


