var timeBlockPage;
var timeWhiteLogo;
var objLogoOffset = "";

jQuery.fn.height_opera95_fixed = function() {
    if ( this[0] == window && jQuery.browser.opera && jQuery.browser.version >= 9.50) {
        return window.innerHeight;
    }
    else {
        return $(this[0]).height();
    }
};

jQuery.blockPage = function() {
  if($.browser.msie) {
    $("input").hide();
    $("select").hide();
  }
  
  iDocumentWidth = $(document).width();
  iDocumentHeight = $(document).height();
  if ($.browser.opera) {
    
    iHeight = $(window).height_opera95_fixed();
    
    if(iHeight>iDocumentHeight) {
        iDocumentHeight=iHeight;
    }
    
    if ($('#hide').length>0) {
        if ($('#hide').css("display")=="none") {
            $('#hide').css("display","block");
            $('#hide').css("width",iDocumentWidth);
            $('#hide').css("height",iDocumentHeight);
            $('#hide').fadeIn("slow");
        }
        
        if ($('#hide').css("width")!=iDocumentWidth||$('#ukryj').css("height")!=iDocumentHeight) {
            $('#hide').css("width",iDocumentWidth);
            $('#hide').css("height",iDocumentHeight);
        }
    }
    else {
        $("body").append("<div id=\"hide\" style=\"position:absolute;left:0px;top:0px;background-color:black;width:"+iDocumentWidth+"px;height:"+iDocumentHeight+"px;\"></div>");
        $('#hide').css("opacity",0.5);
    }
  }
  else {
    if ($('#hide').length>0) {
      if ($('#hide').css("display")=="none") {
        $('#hide').css("display","block");
        $('#hide').css("width",iDocumentWidth);
        $('#hide').css("height",iDocumentHeight);
        $('#hide').fadeIn("slow");
      }

      if ($('#hide').css("width")!=iDocumentWidth||$('#ukryj').css("height")!=iDocumentHeight) {
        $('#hide').css("width",iDocumentWidth);
        $('#hide').css("height",iDocumentHeight);
      }
    }
    else {
        $("body").append("<div id=\"hide\" style=\"display:none;position:absolute;left:0px;top:0px;background-color:black;width:"+iDocumentWidth+"px;height:"+iDocumentHeight+"px;\"></div>");
        $('#hide').css("opacity",0.5);
        $('#hide').fadeIn("slow");
    }
  }
  $.showWhiteLogo();
  timeBlockPage = setTimeout("$.blockPage();",5000);
}

jQuery.blockPageDarker = function() {
  if($.browser.msie) {
    $("input").hide();
    $("select").hide();
  }
  
  iDocumentWidth = $(document).width();
  iDocumentHeight = $(document).height();
  if ($.browser.opera) {
    
    iHeight = $(window).height_opera95_fixed();
    
    if(iHeight>iDocumentHeight) {
        iDocumentHeight=iHeight;
    }
    
    if ($('#hide').length>0) {
        if ($('#hide').css("display")=="none") {
            $('#hide').css("display","block");
            $('#hide').css("width",iDocumentWidth);
            $('#hide').css("height",iDocumentHeight);
            $('#hide').fadeIn("slow");
        }
        else if ($('#hide').css("width")!=iDocumentWidth||$('#ukryj').css("height")!=iDocumentHeight) {
            $('#hide').css("width",iDocumentWidth);
            $('#hide').css("height",iDocumentHeight);
        }
    }
    else {
        $("body").append("<div id=\"hide\" style=\"position:absolute;left:0px;top:0px;background-color:black;width:"+iDocumentWidth+"px;height:"+iDocumentHeight+"px;\"></div>");
        $('#hide').css("opacity",0.8);
    }
  }
  else {
    if ($('#hide').length>0) {
      if ($('#hide').css("display")=="none") {
        $('#hide').css("display","block");
        $('#hide').css("width",iDocumentWidth);
        $('#hide').css("height",iDocumentHeight);
        $('#hide').fadeIn("slow");
      }

      if ($('#hide').css("width")!=iDocumentWidth||$('#ukryj').css("height")!=iDocumentHeight) {
        $('#hide').css("width",iDocumentWidth);
        $('#hide').css("height",iDocumentHeight);
      }
    }
    else {
        $("body").append("<div id=\"hide\" style=\"display:none;position:absolute;left:0px;top:0px;background-color:black;width:"+iDocumentWidth+"px;height:"+iDocumentHeight+"px;\"></div>");
        $('#hide').css("opacity",0.8);
        $('#hide').fadeIn("slow");
    }
  }
  $.showWhiteLogo();
  timeBlockPage = setTimeout("$.blockPageDarker();",5000);
}

jQuery.unblockPage = function() {
    $.hideWhiteLogo();
    if ($.browser.opera) {
        $('#hide').css('display',"none");
        clearTimeout(timeBlockPage);
    }
    else {
        $('#hide').fadeOut();
        $('#hide').css('display',"none");
        clearTimeout(timeBlockPage);
    }
    
    if($.browser.msie) {
      $("input").show();
      $("select").show();
    }
}

jQuery.showWhiteLogo = function() {
  if(objLogoOffset=="") {
    objLogoOffset = $("#logo").offset();
  }

  $("#logo").hide();
  if ($.browser.opera) {
    $("#hide").html("<img id=\"whitelogo\" src=\""+strBaseHref+"public/images/swistekb.gif\" style=\"position:absolute;top:"+objLogoOffset.top+"px;left:"+objLogoOffset.left+"px;\" />");
  }
  else {
    $("#hide").html("<img id=\"whitelogo\" src=\""+strBaseHref+"public/images/swistekb.gif\" style=\"position:absolute;top:"+objLogoOffset.top+"px;left:"+objLogoOffset.left+"px;\" />");
  }
}

jQuery.hideWhiteLogo = function() {
    $("#logo").show();
    $("#logo").attr("src",strBaseHref+"public/images/swistek.gif");
    $("#logo").css("z-index","");
}
