

<!--
/*Object.prototype.toBoolean = function(){
 if(this.constructor === String) {
  if(this == "true") {
   return true
  } else if(this == "false") {
   return false
  }
 } else if(this.constructor === Boolean) {
  if(this == true) {
   return true
  } else {
   return false
  };
 } else {
  return null;
 }
};*/
Function.prototype.inheritsFrom = function( parentClassOrObject ){
 if ( parentClassOrObject.constructor == Function )
 {
  //Normal Inheritance
  this.prototype = new parentClassOrObject;
  this.prototype.constructor = this;
  this.prototype.parent = parentClassOrObject.prototype;
 }
 else
 {
  //Pure Virtual Inheritance
  this.prototype = parentClassOrObject;
  this.prototype.constructor = this;
  this.prototype.parent = parentClassOrObject;
 }
 return this;
}
//(function(){
 var KOLO = window.KOLO = new Object();
 KOLO.config = {
  menu: {
   cookieName:"KOLOMENU"
  },
  arrangements: {
   thumbnailsMax: 6
  },
  products: {
   compareMax: 2
  }
 };
 /*
  * ChangingText objects can toggle their DOM text nodes between 2 states
  * The constructor method gets the alternative text from the jQuery el
  * object's rel attribute
  * @param jQuery el element whose text will be changing
  * @param str alt the alternative text
  */
 KOLO.ChangingText = function(el,alt){
  this.el = el;
  this.text = {
   original: this.el.text(),
   alt: alt || this.el.attr("rel") || ""
  };
  this.state = "original";
 };
 KOLO.ChangingText.prototype = {
 /*
  * toggles the given ChangingText instance between the alt
  * and original state
  */
  toggle: function(){
   if(this.state == "original") {
    this.el.text(this.text.alt);
    this.state = "alt";
   } else {
    this.el.text(this.text.original);
    this.state = "original";
   };
  },
 /*
  * changes the stored alt text and switches to it
  */
  change: function(newVal,replacedVal) {
   if(!replacedVal)
    this.text.alt = newVal
   else
    this.text.alt = this.text.alt.replace(replacedVal, newVal)
   this.alt();
  },
 /*
  * switches to original text
  */
  original: function(){
   this.el.text(this.text.original);
  },
 /*
  * switches to alt text
  */
  alt: function(){
   this.el.text(this.text.alt);
  }
 };
 /*
  * Constructs an object with toggling elements and the "toggler" element
  * @param jQuery   togglingEls elements in menu to be toggled
  * @param  jQuery  toggler  element toggling the object
  * @param  str   eventType event on which the toggling occurs,
  *      "click" when none is specified
  * @param function callback callback function fired after each toggle
  * @param str   cookieName cookie name for meun state saving
  */
 KOLO.Menu = function(togglingEls, toggler, eventType, callback, cookieName) {
  this.togglingEls = togglingEls;
  this.toggler = toggler;
  if($.isFunction(eventType)) {
   cookieName = callback;
   callback = eventType;
   eventType = null;
  };
  if(!$.isFunction(callback)) {
   callback = function(){};
  };
  this.eventType = eventType || "click";
  this.callback = callback;
  this.cookieName = cookieName;
  this.toggler.bind(this.eventType, {rel:this}, function(e){
   e.data.rel.toggle();
   return false;
  });
  this.visible = $.cookie(this.cookieName) || 1;
  this.setState = function(state){
   this.visible = state;
   $.cookie(this.cookieName, state);
  };
  this.getState = function(){
   return this.visible;
  };
  this.init();
 };
 KOLO.Menu.prototype = {
 /*
  * shows/hides relevant menu elements, fires callback
  */
  init:function(){
   if(this.visible == 1) {
    this.show()
    this.callback()
   } else {
    this.hide()
   }
  },
  hide:function(){
   this.togglingEls.hide();
   this.setState(0);
   this.callback();
  },
  show:function(){
   this.togglingEls.show();
   this.setState(1);
   this.callback();
  },
  toggle:function(){
   this.togglingEls.toggle();
   this.setState((this.getState()) ? 0 : 1);
   this.callback();
  }
 };
 KOLO.Select = new Object();
 KOLO.Select.refresh = function(elem) {
 if($.browser.opera || $.browser.safari) return;
  setTimeout(function() {
   var dl = $(elem).parents('dl').eq(0);
   var dd = $(elem).parents('dd').eq(0);
   var w = parseInt(dl.width());
   dl.css('width', w + 'px');
   dd.hide();
   $(elem).selectbox();
   dd.show();
   dl.css('width', 'auto');
  }, 500);
 };
 KOLO.Select.rebuild = function(elem, options) {
  if($.browser.opera || $.browser.safari) return;
  var dom = elem.get(0);
  var oldLabel = dom.options[dom.selectedIndex].text;
  // wyczyszczenie listy
  elem.get(0).length = 1;
  jQuery.each(options, function(val, label) {
   if (typeof(label) == 'string') {
//    elem.append(new Option(label, val));
    elem.append("<option value='"+val+"'>"+label+"</option>");
    if (label == oldLabel) {
     elem.val(val);
    }
   }
  });
 };
 KOLO.ArrangementThumbnailsMenu = function (options) {
  if (arguments.length>0) {
   if ($(options.menuHolder).length > 0)
   {
    this.init(options)
   }
  }
 }
 KOLO.ArrangementThumbnailsMenu.prototype = {
  menuHolder: null,
  buttonPrev: null,
  buttonNext: null,
  thumbnailsCollection: null,
  init: function (options) {
   this.menuHolder = $(options.menuHolder);
   this.buttonPrev = $(options.buttonPrev);
   this.buttonNext = $(options.buttonNext);
   this.buttonPrev.get(0)._parentObject = this;
   this.buttonNext.get(0)._parentObject = this;
   this.buttonPrev.click(this.prev);
   this.buttonNext.click(this.next);
   this.thumbnailsCollection = new KOLO.ArrangementThumbnailsCollection({
    holder:options.thumbnailsCollectionHolder,
    thumbnailsMax:options.thumbnailsMax,
    thumbnailWidth:options.thumbnailWidth,
    _parentObject:this
   });
   this.updateButtonVisibility();
  },
  prev: function () {
   this._parentObject.thumbnailsCollection.slideTo(-1);
   return false;
  },
  next: function () {
   this._parentObject.thumbnailsCollection.slideTo(1);
   return false;
  },
  updateButtonVisibility: function () {
   if (this.thumbnailsCollection.isMoreItemsToRight()) {
    this.buttonNext.show();
   } else {
    this.buttonNext.hide();
   }
   if (this.thumbnailsCollection.isMoreItemsToLeft()) {
    this.buttonPrev.show();
   } else {
    this.buttonPrev.hide();
   }
  }
 }
 KOLO.ArrangementThumbnailsCollection = function (options) {
  if (arguments.length>0) this.init(options)
 }
 KOLO.ArrangementThumbnailsCollection.prototype = {
  _parentObject: null,
  holder: null,
  thumbnails: null,
  thumbnailsMax: null,
  thumbnailsFirstShownIndex: null,
  thumbnailWidth: null,
  thumbnailBasicCSSClass: '',
  thumbnailActiveCSSClass: 'active',
  thumbnailLastCSSClass: 'last',
  thumbnailLastActiveCSSClass: 'last lastactive',
  init: function (options) {
   this.holder = $(options.holder);
   this.thumbnailsMax = options.thumbnailsMax;
   this._parentObject = options._parentObject;
   this.thumbnailWidth = options.thumbnailWidth;
   this.thumbnailsFirstShownIndex = 0;
   this.setupThumbnails();
   this.setupHolder();
  },
  slideTo: function (i) {
   if ((i == -1 && this.isMoreItemsToLeft()) || (i == 1 && this.isMoreItemsToRight())) {
    this.thumbnailsFirstShownIndex = this.thumbnailsFirstShownIndex + i;
    this._parentObject.updateButtonVisibility();
    this.applyThumbnailClasses();
    var offset = parseInt(this.thumbnailWidth) * parseInt(this.thumbnailsFirstShownIndex);
     offset = '-' + offset + 'px';
    $(this.holder).animate({left:offset});
   }
  },
  setupHolder: function() {
   var wrapperOffset = parseInt(this.holder.parent().width());
   var offset = parseInt(this.thumbnails.length) * parseInt(this.thumbnailWidth);
   if (wrapperOffset <= offset) this.holder.get(0).style.width = offset + 'px';
  },
  setupThumbnails: function () {
   var items = this.holder.find("a img");
   var thumbnails = new Array();
   for (var i = 0;items.length>i ;i++ )
   {
    thumbnails[i] = this.applyBehaviour(items[i])
   }
   this.thumbnails = thumbnails;
   this.applyThumbnailClasses();
  },
  applyBehaviour: function (item) {
   item.basicCSSClass = this.thumbnailBasicCSSClass;
   item.activeCSSClass = this.thumbnailActiveCSSClass;
   item.onmouseover = function () {
    if (this.parentNode.parentNode.className.length > 0) {
     this.basicCSSClass = this.parentNode.parentNode.className;
    }
    this.parentNode.parentNode.className = this.activeCSSClass;
   }
   item.onmouseout = function () {
    this.parentNode.parentNode.className = this.basicCSSClass;
   }
   return item;
  },
  applyThumbnailClasses: function() {
   for (var i = 0;this.thumbnails.length > i ;i++ )
   {
    if (i == (this.thumbnailsFirstShownIndex+this.thumbnailsMax-1))
    {
     this.thumbnails[i].basicCSSClass = this.thumbnailLastCSSClass;
     this.thumbnails[i].activeCSSClass = this.thumbnailLastActiveCSSClass;
    } else {
     this.thumbnails[i].basicCSSClass = this.thumbnailBasicCSSClass;
     this.thumbnails[i].activeCSSClass = this.thumbnailActiveCSSClass;
    }
   }
  },
  isMoreItemsToLeft: function() {
   return (this.thumbnailsFirstShownIndex > 0) ? true : false;
  },
  isMoreItemsToRight: function() {
   return (this.thumbnailsFirstShownIndex+this.thumbnailsMax-1 < this.thumbnails.length-1) ? true : false;
  }
 }
 /*
  * KOD OBSĹ�UGI SCHOWKA DZIAĹ�AJÄ�CY W POĹ�Ä�CZENIU Z BACK-ENDEM
 */
 KOLO.ClipBoard = new Object();
 KOLO.ClipBoard.totalPrice = new Object();
 KOLO.ClipBoard.init = function(indicatorEl,alt,pattern,totalPriceEl) {
  this.pattern = pattern;
  this.indicator = new KOLO.ChangingText(indicatorEl,alt,pattern);
  this.totalPrice.el = totalPriceEl;
  try {
   this.totalPrice.price = parseInt(this.totalPrice.el.html().match(/(\d)+/g));
  } catch(e) {
   this.totalPrice.price = 0;
  }
 }
 KOLO.ClipBoard.totalPrice.change = function(val){
  this.price = parseInt(val);
  try {
   this.el.html(this.el.html().replace(/(\d)+/g,this.price));
  } catch(e) {}
 }
 KOLO.ClipBoard.totalPrice.increaseBy = function(val){
  sum = this.price + parseInt(val);
  KOLO.ClipBoard.totalPrice.change(sum);
 }
 KOLO.ClipBoard.totalPrice.decreaseBy = function(val){
  sum = this.price - parseInt(val);
  KOLO.ClipBoard.totalPrice.change(sum);
 }
 KOLO.ClipBoard.updateIndicator = function(newVal){
  newVal > 0 ? this.indicator.change(this.indicator.el.attr('rel').replace(this.pattern,newVal)) : this.indicator.original();
 }
 KOLO.ClipBoard.getState = function(url){
  $.get(url,function(data){
   KOLO.ClipBoard.updateIndicator(data);
  });
 }
 KOLO.ClipBoard.handler = function(handler,eventType) {
  this.handler = new KOLO.ChangingText(handler);
  this.handler.el.data("rel",this).bind(eventType + ".CB",function() {
   $(this).data("rel").change($(this).attr("href"));
   if (eventType == "click") return false;
  });
 }
 KOLO.ClipBoard.handler.prototype = {
  change: function(url) {
   var handler = this.handler;
   $.get(url,function(data) {
    KOLO.ClipBoard.updateIndicator(data);
    handler.toggle();
   });
  }
 }
 KOLO.ClipBoard.item = function(el,quantityModifiers,priceEl,quantityEl,comparisionChooserEl){
  this.el = el;
  this.itemId = el.id.substr(1);
  this.quantityEl = quantityEl;
  this.priceEl = priceEl;
  this.comparisionChooserEl = comparisionChooserEl;
  this.isBeingProcessed = false;
  var private = {
   price: parseInt(priceEl.text()),
   quantity: parseInt(quantityEl.text()),
   selected: (comparisionChooserEl.get(0).checked || comparisionChooserEl.get(1).checked)
  }
  this.get = function(key){
   return private[key]
  };
  this.setQuantity = function(val) {
   private.quantity = parseInt(val);
   this.quantityEl.text(parseInt(val));
  }
  this.adder = quantityModifiers.slice(0,1).bind("click",{rel:this},function(e){
   e.data.rel.increase($(this)); 
   return false
  });
  this.remover = quantityModifiers.slice(1,2).bind("click",{rel:this},function(e){
   e.data.rel.decrease($(this)); 
   return false
  });
  this.selector = comparisionChooserEl.bind("click",{rel:this},function(e){
   e.data.rel.setSelected($(this),this.checked);
   return true;
  });
  this.isSelected = function () {
   return private.selected;
  }
  this.setSelected = function (el,checked) {
   if (private.selected == checked) return
   private.selected = checked;
   if (checked)
   {
    $(this.el).addClass("active");
    KOLO.ClipBoard.itemsCollection.addItemToCompare(this);
   } else {
    $(this.el).removeClass("active");
    KOLO.ClipBoard.itemsCollection.removeItemToCompare(this);
   }
   this.comparisionChooserEl.each(function () {
    this.checked = checked;
   })
  }
  this.setSelected(this,private.selected);
  KOLO.ClipBoard.itemsCollection.addItem(this);
 }
 KOLO.ClipBoard.item.prototype = {
  increase: function(el){
   var $this = this;
   if ($this.isBeingProcessed == true) return
   $this.isBeingProcessed = true;
   this.updateClipBoardState(el, function(){
    KOLO.ClipBoard.totalPrice.increaseBy($this.get("price"));
    $this.setQuantity(parseInt($this.get("quantity")) + 1);
    $this.isBeingProcessed = false;
   })
  },
  decrease: function(el){
   var $this = this; 
   if ($this.isBeingProcessed == true) return
 //  if(this.get("price") <= KOLO.ClipBoard.totalPrice.price && this.get("quantity") > 0) {
    if(this.get("quantity") > 1) {
    $this.isBeingProcessed = true;
    this.updateClipBoardState(el, function(){
     KOLO.ClipBoard.totalPrice.decreaseBy($this.get("price"));
     $this.setQuantity(parseInt($this.get("quantity")) - 1);
     $this.isBeingProcessed = false;
    });
   };
  },
  updateClipBoardState: function(el,fun){
   var handler = el;
   var fun = fun;
   $.get(handler.attr("href"),function(data) {
    KOLO.ClipBoard.updateIndicator(data);
    fun();
   });
  }
 }
 KOLO.ClipBoard.itemsCollection = {
  buttons: {
   compareSelected:null,
   selectAll: null,
   unselectAll: null
  },
  items: [],
  comparisionItems: [],
  maxComparisionItems: null,
  comparisionTarget: null,
  ini: function (options) {
   this.buttons.compareSelected = options.buttons.compareSelected;
   this.buttons.selectAll = options.buttons.selectAll;
   this.buttons.unselectAll = options.buttons.unselectAll;
   this.maxComparisionItems = options.maxComparisionItems;
   this.comparisionTarget = options.comparisionTarget;
   this.buttons.selectAll.bind("click",{rel:this},function(e){
    e.data.rel.selectAll();
    return false
   });
   this.buttons.unselectAll.bind("click",{rel:this},function(e){
    e.data.rel.unselectAll();
    return false
   });
   this.buttons.compareSelected.bind("mouseenter",{rel:this},function(e){
    if (e.data.rel.comparisionItems.length >= e.data.rel.maxComparisionItems)
    {
     $(this).css({cursor:'pointer'});
     tb_init(this)
    } else {
     $(this).css({cursor:'default'});
     $(this).unbind("click")
    }
   });
   this.buttons.compareSelected.bind("mousedown",{rel:this},function(e){
    return e.data.rel.compareSelected();
   });
  },
  addItem: function (item) {
   this.items.push(item);
  },
  addItemToCompare: function (item) {
   this.comparisionItems.push(item);
  },
  removeItemToCompare: function (item) {
   for (var i = 0;this.comparisionItems.length > i ;i++ )
   {
    if (this.comparisionItems[i].itemId == item.itemId) this.comparisionItems.splice(i,1)
   }
  },
  selectAll: function () {
   for (var i = 0;this.items.length > i; i++)
   {
    if (!this.items[i].isSelected()) this.items[i].setSelected(this.items[i],true)
   }
  },
  unselectAll: function () {
   for (var i = 0;this.items.length > i; i++)
   {
    if (this.items[i].isSelected()) this.items[i].setSelected(this.items[i],false)
   }
  },
  compareSelected: function () {
   if (this.comparisionItems.length >= this.maxComparisionItems) {
    for (var i = 1;this.maxComparisionItems >= i ;i++ )
    {
     this.buildUpComparementHTML(i,this.comparisionItems[this.comparisionItems.length-i].el);
    }
    return true;
   } else {
    return false;
   }
  },
  buildUpComparementHTML: function (i,item) {
   var src = $(item);
   var li = $(this.comparisionTarget).find('ul li:eq('+(i-1)+')');
   // copy photo
   li.find('em.cont').html(src.find('a.img img').clone())
   // copy name
   li.find('span.name').html(src.find('p span a').html())
   // copy code
   var code = new String(src.find('p em').html());
   code = code.substr(code.lastIndexOf('kod'));
   li.find('span.code').html(code);
   // copy description
   li.find('em.descr dfn').html(src.find('p dfn').html())
   // copy price
   li.find('em.price strong').html(src.find('dfn.price').html())
  }
 }
//})();
$(document).ready(function() { $("ul.faq li").each(function() {
 var p = $(this).children("p").eq(0);
 $(this).children("p").not(p).hide();
 $(p).children("a").click(function() {
  if($(p).nextAll("p.active").length > 0) return false;
  $("ul.faq p.active").slideUp("300",function() { $(this).removeClass("active"); });
  $(p).nextAll("p").addClass("active").slideDown("300");
  return false;
 });
}); });
//-->


