function redirect(url,absolute)
{
window.location=(absolute ? '':baseUrl)+url;
}


(function($){
    
    $(function(){
        $('.box-switchable .box-switchable-page-container').each(function(){
            nav = $j(this).find('.box-switchableControlNav');
            nav.css('top', $j(this).height() / 2 - nav.height() / 2);
        });
		
        $("#product-gallery").imageScroller({
            next: "btn1",
            prev: "btn2",
            frame: "viewFrame",
            width: 1,
            child: "a",
            auto: false
        });
    	
    	
	    $('.cart-delete-button').click(function(){
	    	  (function (row){
	    	  $.post('koszyk,usun,format,json',{id:row.attr('name').replace('usun_','')},function(data){
	    		
	    		  if (data.deleted) row.parents('.cart-row').remove();
	    		  $('.cart-totalPrice').text(data.totalPrice);
	    	  },'json');
	    	  })($(this));
	      });  
	   
	    $('.cart-change-select').change(function(){
	    	  (function (row){
	    	  $.post('koszyk,zmien,format,json',{id:row.attr('name').replace('ilosc_',''), quantity:row.val()},function(data){
	    		  if (data.quantity==0) row.parents('.cart-row').remove();
	    		  else {
	    			  row.val(data.quantity);
	    			  row.parents('.cart-row').find('.priceCell').text(data.valuePrice);
	    		  	}
	    		  if (data.message) $('.cart-message').text(data.message);
	    		  $('.cart-totalPrice').text(data.totalPrice);
	    	  },'json');
	    	  })($(this));
	      });  	 
	      
	    });
})(jQuery);