$(document).ready(function(){
//paginacja
   $('.news_paginator').live('click',function(){
	   $('#loaderNewsList').show();
	   loadNewsList($(this).attr('module_id'),$(this).attr('per_page'),$(this).attr('page_id'),$(this).attr('site'));
   });
   
   
   
    $("#slides").slides();
       
       
       $("a.showImage").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
                                'titlePosition'	: 'over'
			});
      
      
      $("a.showVideo").fancybox({
                        'padding'       : 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'width'			: 640,
			'height'		: 385,
			'type'			: 'swf',
			'swf'			: {
			'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});
      
      $("a.iframe").fancybox({
                        'padding'       : 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'width'			: 640,
			'height'		: 385
		});
   
   
   
      $('#add_to_basket').click(function(){
          
          var id_product = $('#id_product').val();
          var price_opcja = $('#price_opcja').val();
          //alert(id_product+'/'+price_opcja);
          document.location.href=$('#base_url').val()+'/dodaj_do_koszyka/'+id_product+'/'+price_opcja+'/';
          
      });
      
      
      
   
      $('.delete_from_basket').click(function(){
          
          var id_tab = $(this).attr('id_del');
          var obj_this = $(this);
          $.get($('#base_url').val()+'/usun_z_koszyka/'+id_tab+'/', function(data) {
          $('li.productno'+id_tab).remove();
          $('span.suma_koszyk').html(data);
        });
          
      });
   
   
      $('#checkout_step_2').click(function(){
          $('#checkout_form_cart').attr('action',$('#checkout_form_cart').attr('action').replace('koszyk','transport'));
          $('#checkout_form_cart').submit();
      });
   
});


//pobranie i wyświetlenie drzewa stron	
function loadNewsList(id,per_page,offset,site){
	$('#loaderNewsList').hide();
	$("#newsList").load($('#base_url').val()+'/news/listnews/id:'+id+'/per_page:'+per_page+'/site:'+site+'/offset:'+offset);
	//alert($('#base_url').val()+'/news/listnews/id:'+id+'/per_page:'+per_page+'/site:'+site+'/offset:'+offset);
}

$('.form_input').live('blur',function(){

        var input_value= $(this).val();
        var input_name= $(this).attr('name');
        var this_input=$(this);

        $.post($('#base_url').val()+'/contacts/validate/', { value: input_value , name:  input_name},
           function(data) {
               if(data!=true){
             
               this_input.parent().parent().addClass('required');
              }else{
               this_input.parent().parent().removeClass('required');
                  }
           });
});  
$('.form_input').live('focus',function(){
        var this_input=$(this);
		this_input.parent().parent().removeClass('required');
});


/*-------------------/CMS---------------*/

$(document).ready(function(){

//start Cufon-a jest w default.ctp, na koncu, ponizej ustawienia:
	Cufon.replace('nav li a, article h1, .news h2');
	Cufon.replace('#quotation', { fontFamily: 'Geogrotesque Light Italic' });
	
	//Hovery menu gornego:
	$('#nav li a').hover(function(){
		$(this).css("backgroundColor","rgba(47,116,138,0.1)");
		$(this).stop().animate({
			backgroundColor: "rgba(47,116,138,1)",
		},1000);
	},function(){
		$(this).stop().animate({
			backgroundColor: "rgba(47,116,138,0)",
		},500);
	});
	
	// //Ruch loga:
	// $('#top a.logo').hover(function(){
	// 	$(this).children().stop().effect('slide',600);
	// },function(){});
	
	
	
	





	
});

