

<!--
/**
 * jQuery equalHeights plugin
 * @name jquery.equalHeights.js
 * @version 1.0
 * @author bartekg - www.k2.pl
 * @date October 1, 2010
 * @category jQuery plugin
 */
(function(jQuery) {
 jQuery.fn.equalHeights = function(options) {
  // zmienne globalne
  var h = [];
  var maxH = 0;
  // ustawienia domyslne
  var defaults = {
   items: 'auto'
  };
  var o = jQuery.extend({}, defaults, options);
  // funkcja glowna
  var init = function(_this){
   var item = jQuery(_this).children();
   jQuery(item).each(function(i){
    h[i] = $(this).outerHeight();
   });
      if(o.items === 'auto'){
    var elemsW = 0;
    var k = 0;
    jQuery(item).each(function(i){
     if(elemsW < $(item).parent().width()){
      elemsW += $(item).outerWidth() + parseInt($(item).css('margin-left'), 10) + parseInt($(item).css('margin-right'), 10);
      k++;
     } else{
      return false;
     }
    });
    var itemsInRow = k;
   } else{
    var itemsInRow = o.items;
   }
   var j = 0;
   jQuery(item).each(function(i){
    eval('maxH = Math.max('+h.slice(j*itemsInRow,j*itemsInRow + itemsInRow).join()+')');
    jQuery(this).height(maxH - parseInt($(this).css('padding-top'), 10) - parseInt($(this).css('padding-bottom'), 10));
    if((i+1)%itemsInRow === 0) { j++; }
   });
   return true;
  };
  return this.each(function(){
   init(this);
   if( o.callback !== undefined && typeof o.callback === 'function' ) { o.callback(); }
  });
 };
  /**
 * jQuery checkall plugin
 * @name jquery.checkall.js
 * @version 1.0
 * @author pawelw - www.k2.pl
 * @category jQuery plugin
 */
 jQuery.fn.checkall = function(options) {
  var events = function(elem) {
   var $elem = jQuery(elem);
   $elem.click(function() {
    if ($elem.is(':checked')) {
     jQuery('.checkall').attr('checked','checked');
     jQuery('.check_left input[type=checkbox]').attr('checked','checked');
     jQuery('.check_left input[type=checkbox]').parent().parent().parent().addClass('active');
    } else {
     jQuery('.checkall').removeAttr('checked');
     jQuery('.check_left input[type=checkbox]').removeAttr('checked');
     jQuery('.check_left input[type=checkbox]').parent().parent().parent().removeClass('active');
    }
   });
  };
  return this.each(function() {events(this);});
 };

jQuery.fn.cssCheckbox1 = function () {
 jQuery("#askForm dl.cb :checkbox + dt", this)
  .each( function(){
   if ( jQuery(this).prev().is(":checked") ) {
    jQuery(this).addClass("checked").prevAll(":checkbox").val("on");
   } else {
    jQuery(this).addClass("unchecked").prevAll(":checkbox").val("off");
   }
  })
  /*.click( function() {
   //jQuery(this).toggleClass("checked").prev().checked = !jQuery(this).prev()[0].checked;
   //jQuery(this).toggleClass("unchecked").prev().checked = jQuery(this).prev()[0].checked;
   if( jQuery(this).hasClass('checked') ){
  jQuery(this).removeClass('checked').addClass('unchecked');
  jQuery(this).prev().removeAttr('checked');
   }else if( jQuery(this).hasClass('unchecked') ){
  jQuery(this).removeClass('unchecked').addClass('checked');
  jQuery(this).prev().attr('checked', 'true');
 }
   (jQuery(this).hasClass("checked"))
   ?  jQuery(this).prevAll(":checkbox").val("on")
   :  jQuery(this).prevAll(":checkbox").val("off");*/
    /* if( !jQuery.browser.msie ){
   jQuery(this).toggleClass("checked").prev().checked = !jQuery(this).prev()[0].checked;
   jQuery(this).toggleClass("unchecked").prev().checked = jQuery(this).prev()[0].checked;
  }else{
    if( jQuery(this).hasClass('checked') ){
   jQuery(this).removeClass('checked').addClass('unchecked');
   jQuery(this).prev().removeAttr('checked');
    }else if( jQuery(this).hasClass('unchecked') ){
   jQuery(this).removeClass('unchecked').addClass('checked');
   jQuery(this).prev().attr('checked', 'true');
    }
    if( !jQuery(this).parent().parent('div.checkbox').length ){
     (jQuery(this).hasClass("checked"))
     ?  jQuery(this).prevAll(":checkbox").val("on")
     :  jQuery(this).prevAll(":checkbox").val("off");
    }
   }
  })*/
   .toggle(
  function(){
   jQuery(this).addClass('checked').removeClass('unchecked');
   if( !jQuery(this).parent().parent('div.checkbox').length ) {
    jQuery(this).siblings('input').val('on');
    jQuery(this).siblings('input').attr('checked','checked');
   }
  },
  function(){
    jQuery(this).addClass('unchecked').removeClass('checked');
   if( !jQuery(this).parent().parent('div.checkbox').length ) {
    jQuery(this).siblings('input').val('off');
    jQuery(this).siblings('input').removeAttr('checked');
   }
  })
  .prev().css({
 position: "absolute",
 display: "none"
 });
};
jQuery.fn.cssCheckbox = function () {
 jQuery("#fserwis p.cb :checkbox + label", this)
  .each( function(){
  if( !jQuery(this).parent().parent('div.checkbox').length ){
  if ( jQuery(this).prev().is(":checked") ) {
   jQuery(this).addClass("checked").prevAll(":checkbox").val("on");
  } else {
   jQuery(this).addClass("unchecked").prevAll(":checkbox").val("off");
  }
   }else{
  if ( jQuery(this).prev().is(":checked") ) {
   jQuery(this).addClass("checked");
  } else {
   jQuery(this).addClass("unchecked");
  }
   }
  })
  //.click( function() {
   /*if( !jQuery.browser.msie ){
     jQuery(this).toggleClass("checked").prev().checked = !jQuery(this).prev().attr('checked');
     jQuery(this).toggleClass("unchecked").prev().checked = jQuery(this).prev().attr('checked');
   }else{*/
  /* if( jQuery(this).hasClass('checked') ){
      jQuery(this).removeClass('checked').addClass('unchecked');
      //jQuery(this).prevAll(":checkbox").removeAttr('checked');
      jQuery('#' + jQuery(this).attr('for') ).removeAttr('checked');
    if( !jQuery(this).parent().parent('div.checkbox').length ){
      jQuery(this).prevAll(":checkbox").val("off");
    }
   }else if( jQuery(this).hasClass('unchecked') ){
      jQuery(this).removeClass('unchecked').addClass('checked');
      //jQuery(this).prevAll(":checkbox").attr('checked', 'true');
      jQuery('#' + jQuery(this).attr('for') ).attr('checked', 'true');
    if( !jQuery(this).parent().parent('div.checkbox').length ){
      jQuery(this).prevAll(":checkbox").val("on");
    }
   }*/
    //}
  /* 02.04.2010 lukaszro */
  /*if( jQuery(this).parent().parent('div.checkbox').length ){
   jQuery(this).toggleClass('checked').toggleClass('unchecked').toggle(function(){ $(this).prev().attr('checked','true'); }, function(){ $(this).prev().removeAttr('checked'); } );
  }else{*/
 .toggle(
  function(){
   jQuery(this).addClass('checked').removeClass('unchecked');
   jQuery(this).siblings('input').attr('checked','checked');
   if( !jQuery(this).parent().parent('div.checkbox').length ) { jQuery(this).siblings('input').val('on'); }
  },
  function(){
   jQuery(this).addClass('unchecked').removeClass('checked');
   jQuery(this).siblings('input').removeAttr('checked');
   if( !jQuery(this).parent().parent('div.checkbox').length ) { jQuery(this).siblings('input').val('off'); }
  })
  //} //else end
  /* --- */
  //}) //end click
  .prev().css({
 position: "absolute",
 display: "none"
 });
};
// IE6 image flicker fix
try {
 document.execCommand("BackgroundImageCache", false, true);
} catch(err) {
}
}(jQuery));
// init on DOM ready
$(document).ready(function(){
function zeroDate(date) {
    return (date < 9) ? "0" + (date + 1) : (date + 1);
  }
if ($("#askForm").length > 0) {
  if ($.fn.cssCheckbox1) { $().cssCheckbox1(); }
  }
if ($("#fserwis").length > 0) {
  if ($.fn.cssCheckbox) { $().cssCheckbox(); }
  $('textarea#txt_usterki').keyup(function(){
   var max = 1000;
   if($(this).val().length > max){
    $(this).val($(this).val().substr(0, max));
   }
  });
  var d = new Date();
  $("#txt_date").val(zeroDate(d.getDate() - 1) + "." + zeroDate(d.getMonth()) + "." + d.getFullYear());
  var azs = [];
  $("#fserwis select[name=s_wojewodztwo]").change(function(){
    if ($(this).children(":selected").val() === "0") {
   $("#fserwis select[name=s_miejscowosc]").html("").selectbox();
   $("#fserwis select[name=s_punkt]").html("").selectbox();
   return false;
    }
  $.ajax({
   url: "/azsCities/" + $(this).children(":selected").val(),
   dataType: "json",
   type: "POST",
   success:  function(json){
    $("#fserwis select[name=s_miejscowosc]").html("");
    $("#fserwis select[name=s_miejscowosc]").prepend('<option value="0"> - vyberte - </option>');
    var i = 0;
    jQuery.each(json, function(id, val) {
     $("#fserwis select[name=s_miejscowosc]").append('<option value="' + id + '">' + id + '</option>');
     var j = 0;
     azs[i] = [];
     jQuery.each(val, function(id2, val2) {
      azs[i][j] = [id2, val2];
      j++;
     });
     i++;
    });
    $("#fserwis select[name=s_miejscowosc]").selectbox();
    $("#fserwis select[name=s_punkt]").html("");
    $("#fserwis select[name=s_punkt]").prepend('<option value="0"> - vyberte - </option>');
        $("#fserwis select[name=s_punkt]").selectbox();
        $("#fserwis select[name=s_miejscowosc]").change(function(){
        //$("#sel_miejscowosc_container li").click(function(){
//         var index = $("#sel_miejscowosc_container li").index(this)-1;
         var index = $("#fserwis select[name=s_miejscowosc] option").index($(this).find(":selected"))-1;
       $("#fserwis select[name=s_punkt]").html("");
       $("#fserwis select[name=s_punkt]").prepend('<option value="0"> - vyberte - </option>');
     if (index === -1) {
      $("#fserwis select[name=s_punkt]").selectbox();
      return false;
     }
     for (var j=0; j<azs[index].length; j++) {
      $("#fserwis select[name=s_punkt]").append("<option value='"+azs[index][j][0]+"'>"+azs[index][j][1].join("; ")+"</option>");
     }
     $("#fserwis select[name=s_punkt]").selectbox();
          $("#fserwis select[name=s_punkt]").change(function(){
          //$("#sel_punkt_container li").click(function(){
      var v = $("#fserwis select[name=s_punkt] :selected").html();
      $("#sel_punkt_input").val(v);
     });
          $("#fserwis select[name=s_punkt] option:first").attr("selected", "selected");
          //$("#sel_punkt_container li:eq(0)").click();
    });
   },
      error:  function(){
        alert("Przepraszamy, wystąpił problem w połączeniu z serwerem.");
      }
  });
    return false;
  });
/*
  var buildSelect = setInterval(function(){
    if ($("#sel_wojewodztwo_container li").length > 0) {
      $("#sel_wojewodztwo_container li:eq(0)").click();
      clearInterval(buildSelect);
      return false;
    }
  }, 300);
*/
  // zmodyfikowane: 2010.03.22 przez Lukasz Ro.
 $(".f1526").ajaxForm({
  beforeSubmit: function(){
   $("#fserwis #azs_submit").append("<span style=>Prosím čekejte...</span>");
  },
  dataType: 'json',
  success:  function(json, statusText){
 // alert( statusText )
 // SUCCESS
 if( json.result === 'error_validation' ){
    // ERROR
  var errorMsg = 'Wprowadź poprawne dane:\n';
  $.each(json.value, function(k,v){
   errorMsg += '- ' + v + '\n';
  });
  $("#fserwis #azs_submit span").remove();
  alert( errorMsg );
  //alert("Przepraszamy, wystąpił problem w połączeniu z serwerem.");
 }else{
  $("#fserwis #azs_submit span").remove();
  $("#fserwis span.azsError").remove();
  $("#fserwis .azsError").removeClass("azsError");
  if (json.result === "error_validation") {
   jQuery.each(json.value, function(id, val) {
    $("#fserwis input[name=" + id + "]").addClass("azsError")
     .after('<span class="azsError">' + val + '</span>');
    $("#fserwis textarea[name=" + id + "]").addClass("azsError")
     .after('<span class="azsError">' + val + '</span>');
    $("#fserwis select[name=" + id + "]").after('<span class="azsError">' + val + '</span>')
     .prevAll("input").addClass("azsError");
   });
  } else {
   $("#fserwis").fadeOut(function(){
    $(this).replaceWith(json.result);
   });
  }
 }
  },
  error: function(){
 $("#fserwis #azs_submit span").remove();
    alert("Przepraszamy, wystąpił problem w połączeniu z serwerem.");
  },
  iframe: true
 });
  $(".f1526").submit(function(){
 //$(this).ajaxSubmit();
    return false;
  });
  /* form 1204 */
    $(".f1204").submit(function(){
    var d = "";
    $("#fserwis fieldset").each(function(){
      $(this).find("select").each(function(){
      d = d + $(this).attr("name") + "=" + $(this).children(":selected").val() + "&";
      });
      $(this).find("input:not(.sbBlueInput)[type!=submit], textarea").each(function(){
      d = d + $(this).attr("name") + "=" + $(this).val() + "&";
      });
    });
    d = d.slice(0, d.length - 1);
    var options = {
      dataType: "json",
      data:   d,
      beforeSend: function(){
        $("#fserwis #azs_submit").append("<span>Prosím čekejte...</span>");
      },
      success: function(json){
        $("#fserwis #azs_submit span").remove();
        $("#fserwis span.azsError").remove();
        $("#fserwis .azsError").removeClass("azsError");
        if (json.result === "error_validation") {
          jQuery.each(json.value, function(id, val) {
            $("#fserwis input[name=" + id + "]").addClass("azsError")
            .after('<span class="azsError">' + val + '</span>');
            $("#fserwis textarea[name=" + id + "]").addClass("azsError")
            .after('<span class="azsError">' + val + '</span>');
            $("#fserwis select[name=" + id + "]").after('<span class="azsError">' + val + '</span>')
            .prevAll("input").addClass("azsError");
          });
        } else {
          $("#fserwis").fadeOut(function(){
            $(this).replaceWith(json.result);
          });
        }
      }/*,
      error:  function(){
        $("#fserwis #azs_submit span").remove();
        alert("Przepraszamy, wystąpił problem w połączeniu z serwerem.");
      }  */
    };
    $(this).ajaxSubmit(options);
    return false;
  });
  /* /form 1204 */
}
 $("#head h1 a").hover(function(){
  $(this).toggleClass("hover");
 }, function(){
  $(this).toggleClass("hover");
 });
 /*
 $("#content ul.productList li").hover(function(){
  $(this).addClass("hover");
 }, function(){
  $(this).removeClass("hover");
 });*/
 var menuToggler = new KOLO.ChangingText($("#menuFold"));
 if($("#menuFold").length){
  var mainMenu = new KOLO.Menu($("div.tabs ul,ul.level2", "#mainNavigation"), $("#menuFold"), function(){
   this.toggler.parent().toggleClass("fold");
   menuToggler.toggle();
  }, KOLO.config.menu.cookieName);
 }
 var arrangementMenu = new KOLO.ArrangementThumbnailsMenu({
   menuHolder: 'body.aranz #thumbs',
   buttonPrev: 'body.aranz #thumbs .prev',
   buttonNext: 'body.aranz #thumbs .next',
   thumbnailsCollectionHolder: 'body.aranz #thumbs .cont',
   thumbnailWidth: 75,
   thumbnailsMax: KOLO.config.arrangements.thumbnailsMax
 });
 $("#content form.filter select").change(function() {
  $("form.filter").submit();
 });
 /*
  * KOD INICJUJďż˝CY OBSďż˝UGďż˝ SCHOWKA DZIAďż˝AJďż˝CY W POďż˝ďż˝CZENIU Z BACK-ENDEM
 */
 KOLO.ClipBoard.init($("#head a.clipboard"),null,/%/g,$("#form_clipboard div.sum dl"));
 KOLO.ClipBoard.getState('/schowek/stan');
 $("#content a.addToClipboard").each(function() {
  new KOLO.ClipBoard.handler($(this),"click");
 });
 $("#content p.doSchowka a").each(function () {
  new KOLO.ClipBoard.handler($(this),"mousedown");
  $(this).mouseup(function () {
   $(this).parent().html($(this).attr('rel'));
  });
 });
 $("#content form.filter option").click(function() {
  $("form.filter").submit();
 });
 $('form.filter.series').submit(function() {
  location.href = $(this).attr('action') + $("select#id").val();
  return false;
 });
 $("#form_clipboard ul.productList li").each(function(){
  new KOLO.ClipBoard.item(this, $("a.changeValue",this),$("dfn.price",this),$(".count",this),$("input[type=checkbox]",this));
 });
 KOLO.ClipBoard.itemsCollection.ini({
  buttons: {
   compareSelected: $('.functions a.thickbox'),
   selectAll: $('.functions a.check_all'),
   unselectAll: $('.functions a.uncheck_all')
  },
  maxComparisionItems: KOLO.config.products.compareMax,
  comparisionTarget: $('#compare')
 });
 $('select#year').change(function() {
  if ($(this).val() !== 0 && $(this).val() < 2008) {
   $('#month').val(0).attr('disabled', 'disabled');
  } else {
   $('#month').removeAttr('disabled');
  }
  KOLO.Select.refresh($('#month'));
 });
  $("#content .oneColumn ul.boxes li:nth-child(4n+4)").css("margin-right", "0");
//});
// init on window ready (when css is loaded & applied)
//$(window).load(function () {
 // font replacement
 //$("#content").find("h2, .subHeadings h3, h3 a, .productLeft h3, h4").customFont();
 // $("#mainNavigation .level1 li").each(function() {   $(this).width($(this).width() * 1.1);   $(this).css("padding-top","15px");  });
 //$("#mainNavigation .level1 li a.customFont").css("font-size","14px");
 //$("#mainNavigation li a.customFont").customFont();
//zmniejszLi();
 /* New window */
 $("a[rel=external]").click( function() {
          window.open($(this).attr('href'),"","");
          return false;
      });
/* /new window */
/* Active menu */
var active = document.getElementById('activMenu');
if (active) {
    var activeMenu = active.innerHTML;
    var rightMenu = $(".menu li a");
    var j=0;
    activeMenu = activeMenu.replace(/^\s+|\s+$/g, '');
for(var i=0; i<rightMenu.length; i++)
{
    if(activeMenu === rightMenu[i].innerHTML)
    {
        j=i;
    }
}
    $(".menu li").eq(j).addClass("active");
}
/* /Active menu */
$("ul.level1 li.active").next().find('a').css('background','none');
//});
function openWin(theURL) {
 //alert('openWin.theURL:'+theURL);
 window.open(theURL);
 }
function zmniejszLi(){
$('.level1 li').each(function(){
$(this).width($(this).width()-8);
});
}
//$(document).ready(function(){
 var phrase = $('.search input[name=phrase]');
 var searchVal = 'Hledat';
 if (phrase.val() === '') { phrase.val(searchVal); }
 phrase.click(function() {
  if (phrase.val() === searchVal) { $(this).val(''); }
 });
 phrase.blur(function() {
  if (phrase.val() === '') { phrase.val(searchVal); }
 });
    $('form#askForm').submit(function(){
     $(this).ajaxSubmit({
                url:  $(this).attr("action"),
                dataType: "json",
                type:     "POST",
                success:  function(json){
                  if (json.result === "error_validation") {
                   $('#askForm dl.ctrl span.azsError').remove();
                      $('#askForm dl.ctrl #askCancel').before('<span class="azsError"></span>');
                      var locHtml = [];
                      $.each(json.value,function(key,value) {
                       locHtml.push('<span>'+value+'</span>');
                      });
                      $('#askForm dl.ctrl span.azsError').append(locHtml.join(''));
                  } else {
                      window.location="/gdzie_kupic/zapytaj_eksperta.html";
                  }
                },
                error:  function(){
                  $("#fserwis #azs_submit span").remove();
                  alert("Przepraszamy, wystąpił problem w połączeniu z serwerem.");
                }
              });
            return false;
    });
    $("#cb_34").attr("checked","checked");
    $("#cb_34").click(function(){
        $(this).attr("value","1");
        $("#cb_34_2").attr("value","");
    });
    $("#cb_34_2").click(function(){
        $(this).attr("value", "2");
        $("#cb_34").attr("value","");
    });
    $('.aranz #content .twoColumns div img').each(function(){
if ($(this).attr('src') ==='http://partner.sanitec.artcom24.com/storage/images/aranzacje/ceramika_kolo/aranzacyjne/Ego_plus_5_460x345.jpg') { $(this).parent().remove(); } });
    $('.aranz #content .twoColumns div img').each(function(){
if ($(this).attr('src') ==='http://partner.sanitec.artcom24.com/storage/images/aranzacje/aranzacje_2008/ego_plus/Ego_plus_11_460x345.jpg') { $(this).parent().css('margin-bottom','50px'); } });
});
$(window).load(function(){
 //jQuery('div.twoColumns, div.oneColumn ul.boxes, .where #content .pos .items li').equalHeights();
 $('div.oneColumn ul.boxes, .where #content .pos .items li').equalHeights();
 $('input.checkall').checkall();
  Cufon.replace('.customFont');
 Cufon.replace('#content ul.boxes li strong');
 Cufon.replace('#content div.headings h2');
 Cufon.replace('#content .color');
 Cufon.replace('#content div.article .mapInfoText');
 Cufon.replace('#content div.sectionBoxes li span.header');
 Cufon.replace('.teaser ul li strong');
 Cufon.replace('#content .mainBoxes li span.header');
 Cufon.replace('#content h3');
 Cufon.replace('#content h4');
 Cufon.replace('#content form.miniSearch h5');
 Cufon.replace('#content ul.smallBoxes li h5');
 Cufon.replace('#content p.topBtn a');
 Cufon.replace('.infoText');
 $('#content ul.boxes li:nth-child(3n)').css({'margin-right' : '0'});
 $('#content .oneColumn ul.boxes li:nth-child(3n)').css({'margin-right' : '12px'});
 $('#content .oneColumn ul.boxes li:nth-child(4n+4)').css({'margin-right' : '0'});
 $('.aranz #content .twoColumns div:nth-child(2n+2) ').css({'margin-right' : '0'});
 $("#head #mainNavigation ul.level2 > li:nth-child(2n)").css({'background-color' : '#D2D7DD'});
 $(".products #content .productCat ul.enlarger li:nth-child(2n)").css({'margin-right' : '0'});
 $("#content .productCat:nth-child(2n)").css({'margin-right' : '0'});
 $("#content ul.arrangelist li:nth-child(4n)").css({'margin-right' : '0'});
 $("#content ul.smallBoxes li:nth-child(5n)").css({'margin-right' : '0'});
 $("#content div.img_results ul.smallTiles li:nth-child(6n)").css({'margin-right' : '0'});
 $('#content ul.enlarger li a.enlarge em, #content .productList li div').hover(function() {
 $(this).css({bottom:'5px',right:'5px'});
 }, function() {
 $(this).css({bottom:'0',right:'0'});
 });
  $('#content ul.enlarger li a.enlarge em span.header').css({
    padding: $(this).height() > 16 ? '3px 5px 3px 15px' : ''
  });
 /*
 var elem = $('.navigation.main.level1 li');
 for(var i=0; i<elem.length; i++){
  z = $(elem).eq(i).children('a').children('img').attr('src').replace('/ffffff/','/transparent/');
  $(elem).eq(i).children('a').children('img').attr('src', z);
 }
 var elem = $('.headings h2 img');
 for(var i=0; i<elem.length; i++){
  z = $(elem).eq(i).attr('src').replace('/ffffff/','/transparent/');
  $(elem).eq(i).attr('src', z);
 }
 */
});
//-->


