
$(document).ready(function() {
	//i_utils.js
	CheckIframe();
	mapBaseActions();
	
	//i_menu.js
	//menuHorizontalPadding("menu_top"); //wysrodkowanie menu horyzontalnego (lewo - prawo) na cala szerokosc kontenera
    
    // Wlaczenie fade'ow dla elementow gaszonych ;-)
    $(".fadeable").hover(function(){
            $(this).fadeTo("fast", 0.50);
    },function(){
            $(this).fadeTo("fast",1.00);
    });
    
    // Klikanie w opcje rozwija!
    $(".optionable").click(function(){
        $("#options").hide();
        $(".option_"+$(this).attr('id')).fadeIn("fast");
        return false;
    });
    // Klikanie w fotke prez. prostej powraca do opcji!
    $(".returnable").click(function(){
        $(this).parent().hide();
        $("#options").fadeIn("fast");
        return false;
    });
    
    // Przygotowanie menu
    if (!document.getElementById("menu")) return false;
    var menu = document.getElementById("menu");

    // Usun puste elementy UL
    $("ul:empty").remove();
    
    // for each of the li on the root level check if the element has any children
    // if so append a function that makes the element appear when hovered over

    var root_li = menu.getElementsByTagName("li");
    for (var i = 0; i < root_li.length; i++) {
          var li = root_li[i];
          // search for children
          var child_ul = li.getElementsByTagName("ul");
          if (child_ul.length >= 1) {
              // we have children - append hover function to the parent
              li.onmouseover = function () {
                  if (!this.getElementsByTagName("ul")) return false;
                  var ul = this.getElementsByTagName("ul");
                  ul[0].style.display = "block";
                  return true;
              }
              li.onmouseout = function () {
                  if (!this.getElementsByTagName("ul")) return false;
                  var ul = this.getElementsByTagName("ul");
                  ul[0].style.display = "none";
                  return true;
              }
          }
    }
    
    $("ul.nested li").parent().parent().find("a:first").addClass('expandable');
    
    if($.browser.version <= 6.0 && $.browser.msie == true && ! /ie6_teaser_off/.test(document.cookie))
    {
        $("#teaser").slideDown("slow");
        $("#teaser a.remove").click(function(){
            $(this).parent().parent().slideUp("slow");
            document.cookie = "ie6_teaser_off = 1";
        });
    }
	
});

