function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

$(document).ready(function(){
   $(".bg_round").corner("4px");
   $(".bg_round2").corner("4px");
   $(".bg_round2 h3").corner("top 4px");
   $("#search_box input[name=szukaj_w]").change(function(){
         var value = $(this).attr("value");
         var action = '';
         if(value == 1) { action = './index.php?page=search'; }
         else { action = 'http://www.katalogautomatyki.pl/katalog_glowny.html?stronaKatalog=1'; }
         $("#search_box form:first").attr('action', action);
   });
   var pages = window.location.href.slice(window.location.href.indexOf('.pl') + 4).split('/')
   var get_page = pages[0];
   if (typeof get_page == 'undefined' || get_page == '') get_page = 'glowna';
   $("#menu_"+get_page).addClass("active");
   $(".baners").children("div").children("a:first").children('img:first').css({ 'opacity' : 0 });
   $(".baners").children("div:first").next().children("a:first").children('img:first').css({ 'opacity' : 0 });
   $(".baners").children("div:first").next().next().children("a:first").children('img:first').css({ 'opacity' : 0 });
   $(".baner").mouseover(function(){
      $(this).children("a:first").children('img:first').animate({'opacity' : 1}, 300);
   });
   $(".baner").mouseout(function(){
      $(this).children("a:first").children('img:first').animate({'opacity' : 0}, 300);
   });
   $("#wizerunek .img").cycle('fade');
   $("#logotypy").cycle('fade');


   // kropka w Partnerzy
      $("#menu_left .poziom2a").each(function(index){
            if( $(this).hasClass('active') ) {
               $(this).css({ 'backgroundPosition' : '-243px 8px' , 'fontWeight' : 'bold' });
               menu_offset = $("#menu_left").offset();
               offset = $(this).offset();
               $("#menu_left").scrollTop( offset.top - menu_offset.top );
            }
      });
      $("#menu_left .poziom3").each(function(index){
            if( $(this).hasClass('active') ) {
               $(this).css({ 'backgroundPosition' : '-195px 8px' , 'fontWeight' : 'bold' });
            }
      });

/*
   function pozycjonuj(img) {
      var hmax = 72;
      var h = img.height;
      var w = img.width;
      if (w > 120) w = 120;
      var pos_top = Math.round((hmax-h)/2);
      img.parentNode.style.top = pos_top+"px";
   }
   var logotypy = document.getElementById("logotypy");
   var elementy = document.querySelectorAll("#logotypy img");
   for(var i in elementy) {
      var img = document.createElement("img");
      img.src = elementy[i].src;
      img.onload = pozycjonuj(img);
      if (img.complete == true) pozycjonuj(img);
   }
*/
/*
      $("#logotypy img").each(function(){
         var hmax = 72;
         var h = $(this).height();
         var pos_top = Math.round((hmax-h)/2);
         alert("(" + hmax + " - " + h + " ) / 2 = " + pos_top);
         $(this).css("top",pos_top+"px");
      });
*/
});
