/*
	***Salon-Opon***
	author: Gosia Kmieć, Tomek Frelik
	Copyright Enzo Sp. z o.o., http://enzo.pl
*/
/*--------------Font-----------------*/
GetCufon = function() {    
  Cufon.replace('#info, #uwo, #banner-box h2, h3.t-dane, #menu li a, #page #platnosc h3, #page h2, #product-containers h4, #opinie h4,.cufon, #page .ui-tabs-nav a, #montaz-info, .lokalizacje label', { fontFamily: 'Sansation-Regular' });
  Cufon.replace('.links h3', { fontFamily: 'Sansation-Light' });
}
/*--------------Wyszukiwarka - zakladki-----------------*/
GetSearchTabs = function() {
            jQuery('#tab1 a').bind('click',function(){
              jQuery('#search_tire_form_all').show();
              jQuery('#search_wheels_form_all').hide();
              jQuery(this).addClass('selected');
              jQuery('#tab2 a').removeClass('selected');
              jQuery("#rec1").show();
          		jQuery("#rec2").hide();
          		jQuery("#search-form-box").removeClass('v2'); 
          		jQuery('#form-stalowe').hide();
          		return false;
            });
            jQuery('#tab2 a').bind('click',function(){
              jQuery('#search_wheels_form_all').show();
              jQuery('#search_tire_form_all').hide();
              jQuery(this).addClass('selected');
              jQuery('#tab1 a').removeClass('selected');
              jQuery("#rec2").show();
          		jQuery("#rec1").hide();
          		jQuery("#search-form-box").addClass('v2');
          		jQuery("#sizes-box").hide();
          		return false;
            });
            if (jQuery('body').hasClass('body-samochody')){
              jQuery('#search_tire_form').hide();
              jQuery('#typ_samochodu').addClass('selected');
            }
            else{
              jQuery('#boxTireForm').hide();
              jQuery('#typ_opony').addClass('selected');
            }
            jQuery('#typ_opony').bind('click',function(){
              jQuery('#search_tire_form').show();
              jQuery('#boxTireForm').hide();
              jQuery(this).addClass('selected');
              jQuery('#typ_samochodu').removeClass('selected');
          		return false;
            });
            jQuery('#typ_samochodu').bind('click',function(){
              jQuery('#search_tire_form').hide();
              jQuery('#boxTireForm').show();
              jQuery(this).addClass('selected');
              jQuery('#typ_opony').removeClass('selected');
          		return false;
            });
            if (!jQuery('body').hasClass('body-felgi-stalowe')){
              jQuery('#form-stalowe').hide();
              jQuery('#f-aluminiowe').addClass('selected');
            }
            jQuery('#f-stalowe').bind('click',function(){
              jQuery('#carForm').hide();
              jQuery('#form-stalowe').show();
              jQuery(this).addClass('selected');
              jQuery('#f-aluminiowe').removeClass('selected');
          		return false;
            });
            jQuery('#f-aluminiowe').bind('click',function(){
              jQuery('#carForm').show();
              jQuery('#form-stalowe').hide();
              jQuery(this).addClass('selected');
              jQuery('#f-stalowe').removeClass('selected');
          		return false;
            });
            if (jQuery('body').hasClass('body-felgi')){
            		jQuery('#tab2 a').click();
            }else{
            if (jQuery('body').hasClass('body-felgi-stalowe')){
            		jQuery('#tab2 a').click();  
                jQuery('#f-stalowe').click();       			
            }
            else{
            		jQuery('#tab1 a').click();
            }}
            var url_felgi = document.location.toString().split("#");
            if(url_felgi[1]=='felgi') jQuery('#tab2 a').click();
}
/*--------------koszty wysylki-----------------*/
GetPrice = function() {
	jQuery('#koszty_link').click(function() {
	  var link = jQuery(this).attr('href');
    window.open(link,'koszty','scrollbars=no, status=no, toolbar=no, location=no, directories=no, width=700, height=700, left=100, top=100');
    return false;
  });
}	
/*--------------oceny opon-----------------*/
GetRating = function() {
      jQuery('input.star').rating(); 
      jQuery(".overall-rating em span").each(function(i) {
          var o=jQuery(this).text();
          var w=15;
          var w2=o*w + 'px';
          jQuery(this).css({'width':w2});
      }); 
       jQuery(".rating em span").each(function(i) {
          var o=jQuery(this).text();
          var w=11;
          var w2=o*w + 'px';
          jQuery(this).css({'width':w2});
      }); 
}
GetRatingForm = function() {  
   jQuery("#ocena-form").hide();
   jQuery("#ocena-form.show").show();
   jQuery('#dodaj-opine-bt.hide').hide();
   jQuery('#dodaj-opine-bt').click(function() {				
  			jQuery("#ocena-form").show();	
        jQuery(this).hide();     
  		return false;
  	});
}
/*--------zakładki do platnosci----------*/
GetPriceTabs = function() {
    jQuery('.platnosc-tab').hide();
    jQuery('.platnosc-item input').bind('click', function() {
  	    if(!jQuery(this).parent().hasClass('selected')){  
          jQuery('.platnosc-tab').hide();
          jQuery('.platnosc-item input').parent().removeClass('selected');
          var input_id = jQuery(this).attr('id');
          if(input_id == 'p1' || input_id == 'p2' || input_id == 'p3'){
            jQuery('#tab-p1').show();
            jQuery(this).parent().addClass('selected');
          }else{
            jQuery('#tab-' + input_id).show();
            jQuery(this).parent().addClass('selected');
          }
          if(jQuery(this).parent().hasClass('montaz')){
            jQuery('div.montaz-hide').hide();
            jQuery('#zamowienie #t-dane').html('Dane odbiorcy');
            Cufon.replace('#zamowienie #t-dane', { fontFamily: 'Sansation-Regular' });
          }else{
            jQuery('div.montaz-hide').show();
            jQuery('#zamowienie #t-dane').html('Adres dostawy');
            Cufon.replace('#zamowienie #t-dane', { fontFamily: 'Sansation-Regular' });
          }
          if(jQuery(this).parent().hasClass('mokotow')){
            jQuery('#nr-rejestr').html('Numer rejestracyjny');
             jQuery('#zgoda_mokotow').show();
          }else{ 
            jQuery('#nr-rejestr').html('Marka i model pojazdu');
            jQuery('#zgoda_mokotow').hide();
          }
        }
  	}); 
}	
/*----------pomoc-----------------*/
GetAccordion = function() {
	var url1 = document.location.toString().split("#");
	var dt = '.dt';
	var dd = '.dd';
	var delta = 0;
	jQuery(".dd").hide();
	jQuery(".dt").bind('click', function() {
		if (jQuery(this).hasClass('selected')) {
			jQuery(this).removeClass('selected').next('.dd').hide('fast');
		} else {
		  var h = jQuery(dt + '.selected').next('.dd').height() + jQuery(dt + '.selected').height() + 20;
		   var index_1 = jQuery(dt + '.selected').index();
       var index_2 = jQuery(this).index();
       delta = index_1 - index_2;       
      jQuery(dt + '.selected').removeClass('selected').next('.dd').hide('fast');		
      jQuery(this).next('.dd').show('fast');
      jQuery(this).addClass('selected');	
			var url = document.location.toString().split("#");
      var hash = jQuery(this).attr('id');
      if (delta < 0) {
        var ofs = jQuery(this).offset().top - h ;
      }else{
        var ofs = jQuery(this).offset().top;
      }
      jQuery('html,body').animate({scrollTop: ofs}, 800);
      setTimeout(function(){
        window.location.hash=hash;
      },800);
		}
		return false;
	});
	jQuery('.dt#'+url1[1]).click();
}
/*----------wizualizacje felg-----------*/
GetCar = function() {
   jQuery("a.zoom1").each(function(){         
          jQuery(this).fancybox({
        		'transitionIn'	: 'elastic',
        		'transitionOut'	: 'elastic',
        		'autoScale'     	: false,
        		'titleShow'     : true,
        		'type'				: 'iframe',
        		'width'				: 620,
        		'height'			: 300,
        		'scrolling'   		: 'no'
          });
		});
}
/*--------koszyk---------*/

SumaAjax = function(object) { 
   var radio = jQuery("input[type='radio']:checked").attr('id');
   if(radio == 'tab-przesylka-radio'){var container = 'tab-przesylka'}else{var container = 'tab-montaz'}  
   var val1 =  jQuery("#"+container+" select").find("option:selected").val();
   var form = object.parents('form');  
   var w = object.attr('name');
   jQuery.ajax({
			type : "POST",
			cache : true,
			url : form.attr('action'),
			data : form.serializeArray(),
			success : function(data) {	
        var suma = jQuery(data).find('#ajax_suma span').text();	
        var wartosc = jQuery(data).find('input[name="'+w+'"]').parent().next().find('strong').text();
        var cmilow = jQuery(data).find('input[name="'+w+'"]').parent().prev().find('.montaz_cmilow_ajax').text();	
        var cmilow2 = jQuery(data).find('input[name="'+w+'"]').parent().prev().find('.montaz_cmilow_ajax2').text();	
        var select = jQuery(data).find('#form_platnosc').html();
        jQuery('#ajax_suma span').text(suma); 
        jQuery('#form_platnosc').html(select);
        object.parent().next().find('strong').text(wartosc); 
        object.parent().prev().find('.montaz_cmilow_ajax').text(cmilow);
        object.parent().prev().find('.montaz_cmilow_ajax2').text(cmilow2);
        
        var alucena = 0;
        jQuery('.montaz_osobowe_male_alu').each(function() {
          alucena=alucena+ parseFloat(jQuery(this).text());
        });
        jQuery("#f-alu-cena").text(alucena+' zł');
        
        var stalcena = 0;
        jQuery('.montaz_osobowe_male_stal').each(function() {
          stalcena=stalcena+ parseFloat(jQuery(this).text());
        });
        jQuery("#f-stal-cena").text(stalcena+' zł');
  
        if(radio)
          jQuery("#"+radio).click();
        else
          jQuery("#tab-przesylka, #tab-montaz").hide();
        jQuery("#"+container+" select").val(val1);
        jQuery("#"+container+" select").change();
			}
		});   
}

DostawaAjax = function(item) {
          var montaz_cmilow_suma = 0;
          jQuery('.montaz_cmilow_suma').each(function() {
            montaz_cmilow_suma=montaz_cmilow_suma+ parseFloat(jQuery(this).text());
          });

          var kw_przelew = jQuery('#kw_przelew').text();
          
          jQuery(item).live('change', function() {
            var str = jQuery(this).find("option:selected").text();
            
            if(jQuery(this).find("option:selected").val() == 0){
              jQuery('#tab-montaz-koszt, #tab-montaz-dostawa').hide();
            }else{
              jQuery('#tab-montaz-koszt, #tab-montaz-dostawa').show();
            }

            var raty = str.match('Raty');
            if(raty)
              jQuery('#koszyk-suma .zagiel-rata').show();
            else
              jQuery('#koszyk-suma .zagiel-rata').hide();

              str = str.match(/,\s\d+/ig);
              if(str==null){
                str=0;
                //jQuery(this).parents('.platnosci-zakladki').find(".dostawa_suma").html('<a class="cennik" target="_blank" href="http://www.salon-opon.com/serwis-motoryzacyjny_s689.html">według cennika</a>');
                var felga = jQuery('input:radio[name=montaz_felgi]:checked').attr('id');
                var felga_cena = parseFloat(jQuery('#'+felga+'-cena').text());
                if(felga == null)
                jQuery(this).parents('.platnosci-zakladki').find(".dostawa_suma").html('<span style="font-size:13px;">wybierz felgę</span>');
                else
                jQuery(this).parents('.platnosci-zakladki').find(".dostawa_suma").text(felga_cena+montaz_cmilow_suma+' zł');
                
                jQuery('input:radio[name=montaz_felgi]').live('change', function() {
                  felga = jQuery('input:radio[name=montaz_felgi]:checked').attr('id');
                  felga_cena = parseFloat(jQuery('#'+felga+'-cena').text());
                  jQuery(this).parents('.platnosci-zakladki').find(".dostawa_suma").text(felga_cena+montaz_cmilow_suma+' zł');
                });
              }else{
                if(item == '#tab-montaz select')
                  str = str[0].replace(/\D/, '')-parseFloat(kw_przelew);
                else
                  str = str[0].replace(/\D/, '');
                jQuery(this).parents('.platnosci-zakladki').find(".dostawa_suma").text(str+' zł');
             }
              var a = parseFloat(jQuery('#ajax_suma span').text());

              if(item == '#tab-montaz select'){
                if(jQuery(this).val() > 2){
                  var koszt = kw_przelew;
                  jQuery("#alu_stal").hide();
                }else{  
                  var koszt = '0 zł';
                  jQuery("#alu_stal").show();
                }
                
                if(jQuery(this).val() == 0){jQuery("#alu_stal").hide();}
                if(!jQuery('.montaz_osobowe_male_alu').length){
                  jQuery("#f-alu").attr("checked", "checked");
                  jQuery("#alu_stal").hide();
                }
                
                jQuery('#kw_przelew').text(koszt);
                var suma = parseFloat(str) + a + parseFloat(koszt);
              }else{
                var suma = parseFloat(str) + a;
              }
              
              jQuery('#suma_all').text(suma+' zł');
              
              if(jQuery('#kitset_tak').is(':checked')) {
                if(jQuery('#kitset_cena').length){
                   var kit = jQuery('#kitset_cena').text();
                   jQuery('#zestaw_mont').text(kit+' zł');
                   var aa = parseFloat(jQuery('#suma_all').text())+parseFloat(kit);   
                   jQuery('#suma_all').text(aa+' zł');
                }
              }
              
              var s1 = parseFloat(jQuery('#suma_all').text());
              jQuery('input:radio[name=montaz_felgi]').live('change', function() {
                   var felga = jQuery('input:radio[name=montaz_felgi]:checked').attr('id');
                   var felga_cena = parseFloat(jQuery('#'+felga+'-cena').text());
                   var aa = s1 + felga_cena + montaz_cmilow_suma;
                   jQuery('#suma_all').text(aa+' zł');
                   
              });
              
              if(item == '#tab-montaz select'){
                if(jQuery(this).val() == 1 || jQuery(this).val() == 2){
                  if(!jQuery('.montaz_osobowe_male_alu').length){
                    var aa = s1 + montaz_cmilow_suma;
                    jQuery('#suma_all').text(aa+' zł');
                  } 
                }
              } 

          }).change();
}
  
/*--------topplayer z serwisami---------*/
TopPlayer = function() { 
	jQuery("a.topplayer").live('click', function() {
		var zz = jQuery(this).attr('href');
		jQuery.ajax({
			type : "POST",
			cache : false,
			url : zz,
			data : jQuery(this).serializeArray(),
			success: function(data) {
				jQuery.fancybox(jQuery(data).find('#content'));
        jQuery("#fancybox-wrap").width(650);
				jQuery("#fancybox-inner").width(630);
				jQuery("#fancybox-wrap").height(420);
				jQuery("#fancybox-inner").height(400);
				jQuery.fancybox.center();
				Cufon.replace('.lokalizacje h2, .lokalizacje label', { fontFamily: 'Sansation-Regular' });
				jQuery('.serwis-dane, .col370 div').hide();
				jQuery("#serwismap").show();
        MapaAll();
			}
		});
		return false;
	});
}
/*--------koszyk formy platnosci ---------*/
Payment = function() { 
	jQuery("#tab-przesylka, #tab-montaz").hide();
	jQuery("#tab-przesylka-radio").live('click', function() {
	   jQuery("#tab-przesylka").show();
	  jQuery("#tab-montaz").hide();   
     jQuery(this).attr("checked", "checked");
     jQuery("#tab-montaz-radio").removeAttr("checked");
     DostawaAjax("#tab-przesylka select");
     jQuery("#punkt_montazu").val(0);
	}); 
	jQuery("#tab-montaz-radio").live('click', function() {
	   jQuery("#tab-przesylka").hide();
	   jQuery("#tab-montaz").show();  
     jQuery(this).attr("checked", "checked");
     jQuery("#tab-przesylka-radio").removeAttr("checked");  
     DostawaAjax("#tab-montaz select");    
	}); 
	if(!jQuery("#tab-montaz-radio").length) jQuery("#tab-przesylka-radio").click();
  
	jQuery("#kitset_tak").live('click', function() {
      if(jQuery('#kitset_cena').length){
         jQuery(this).attr("checked", "checked");
         jQuery("#kitset_nie").removeAttr("checked"); 
         var kit = jQuery('#kitset_cena').text();
         jQuery('#zestaw_mont').text(kit+' zł');
         var s = parseFloat(jQuery('#suma_all').text());
         var aa = parseFloat(s)+parseFloat(kit);   
         jQuery('#suma_all').text(aa+' zł');
      }
	}); 
	jQuery("#kitset_nie").live('click', function() {
      if(jQuery('#kitset_cena').length){
         jQuery(this).attr("checked", "checked");
         jQuery("#kitset_tak").removeAttr("checked");
         var kit = jQuery('#kitset_cena').text(); 
         jQuery('#zestaw_mont').text('0 zł');
         var s = parseFloat(jQuery('#suma_all').text());
         var aa = parseFloat(s)-parseFloat(kit);   
         jQuery('#suma_all').text(aa+' zł');
      }
	}); 
  	

}
/*--------koszyk ilosci ---------*/
Ilosc = function() { 
  jQuery('.detail .action input.text, .tabela-opon .input-ilosc').after('<span class="plus">+</span><span class="minus">-</span>');
  var i = 0;
  jQuery('.detail .action .plus, .tabela-opon .plus').live('click', function() {
    i++;
    var a = jQuery(this).prev().val();
    a++;    
    jQuery(this).prev().val(a);
    if(jQuery(this).parents('#tabela-opon-koszyk').length) SumaAjax(jQuery(this).prev());  
  });
  jQuery('.detail .action .minus, .tabela-opon .minus').live('click', function() {
    var a = jQuery(this).prev().prev().val();
    a--;
    if(a<1){jQuery(this).prev().prev().val('1');}
    else{jQuery(this).prev().prev().val(a);}
    if(jQuery(this).parents('#tabela-opon-koszyk').length) SumaAjax(jQuery(this).prev().prev());
  });
}  
/*--------info o montazu ---------*/
MontazInfo = function() { 
  jQuery('#montaz-info p').append('<span class="info-close">zamknij</span>');
  jQuery('.info-close').live('click', function() {
    jQuery('#montaz-info').remove();
    // zamknięcie informacji o montażu
    jQuery.cookie('montaz_info_close', true, { expires: 30 });
  });
}
/*--------galeria opony ---------*/
OponaFancy = function() { 
  var tab = Array();
  var fancyidx = 0;
  jQuery("ul.thumb li a").each(function(i){
        tab[i] = 'http://salon-opon.com'+jQuery(this).find('img').attr('alt');
  });
    jQuery("#main_view a").bind('click', function() {
        var title = jQuery(this).attr('title');
      if(!tab[0]){     
          jQuery("#main_view a").fancybox({
        		'titleShow'     : true,
        		'transitionIn'	: 'elastic',
        		'transitionOut'	: 'elastic'
        	});
    	}else{
            if(!tab[2]){
              jQuery.fancybox([
            			{
            				'href'	: tab[0],
            				'title'	: title,
            				'index' : 1
            			},
            			{
            				'href'	: tab[1],
            				'title'	: title,
            				'index' : 2
            			}
          		], {
            		'titleShow'     : true,
            		'transitionIn'	: 'elastic',
            		'transitionOut'	: 'elastic',
            		'type'          : 'image'
          		}); 
            }else{
              jQuery.fancybox([
            			{
            				'href'	: tab[0]
            			},
            			{
            				'href'	: tab[1]
            			},
            			{
            				'href'	: tab[2]
            			}
          		], {
                		'titleShow'     : true,
                		'transitionIn'	: 'elastic',
                		'transitionOut'	: 'elastic',
                		'type'          : 'image',
                		'title'         : title,
                		'index'         : fancyidx
              		}); 
                }
       }      
    		return false;
    });
    jQuery("ul.thumb li").hover(function() {
    	jQuery(this).css({'z-index' : '10'});
    	jQuery(this).find('img').addClass("hover").stop()
    		.animate({
    			marginTop: '-5px', 
    			marginLeft: '-5px', 
    			width: '85px' 
    		}, 200);
    	} , function() {
    	jQuery(this).css({'z-index' : '0'});
    	jQuery(this).find('img').removeClass("hover").stop()
    		.animate({
    			marginTop: '0', 
    			marginLeft: '0', 
    			width: '75px'
    		}, 400);
    });
  	jQuery("ul.thumb li a").click(function() {
  		fancyidx=jQuery(this).find('span').text()-1;
  		var mainImage = jQuery(this).attr("href"); //Find Image Name
  		var fullImage = jQuery(this).find('img').attr("alt"); //Find Image Name
  		jQuery("#main_view img").attr({ src: mainImage });
  		jQuery("#main_view a").attr({ href: fullImage });
  		return false;		
  	});
}
/*--------slidery polecanych na glownej ---------*/
TopSlider = function() { 
  jQuery('#slider') 
  .before('<div class="pager" id="nav">') 
  .after('<div class="pager" id="nav2">') 
  .cycle({ 
      fx:     'scrollHorz', 
      speed:  'slow', 
      timeout: 0, 
      pager:  '.pager',
      pagerAnchorBuilder: function(idx, slide) {
			  return '<a id="n'+idx+'" href="#">'+idx+'</a>';
		}
  });
  jQuery('#slider2') 
  .before('<div class="pager2" id="nav">') 
  .after('<div class="pager2" id="nav2">') 
  .cycle({ 
      fx:     'scrollHorz', 
      speed:  'slow', 
      timeout: 0, 
      pager:  '.pager2',
      pagerAnchorBuilder: function(idx, slide) {
			  return '<a id="n'+idx+'" href="#">'+idx+'</a>';
		}
  });
}
/*--------pozostale funkcje do zamowienia/opony---------*/
Inne = function() { 

  if(!jQuery("#faktura").hasClass('checked')){
    jQuery("#form_faktura").hide();
  }
  
  jQuery("#faktura").bind('click', function() {
	    if(jQuery(this).hasClass('checked')){
        jQuery("#form_faktura").hide();
        jQuery(this).removeClass('checked');
      }
      else{
        jQuery("#form_faktura").show();
        jQuery(this).addClass('checked');
      }
	}); 
  jQuery("#komentarz_form textarea").hide();
  jQuery("#komentarz_form .tip").hide();
  jQuery("#komentarz_form label").bind('click', function() {
	    if(jQuery(this).hasClass('checked')){
        jQuery("#komentarz_form textarea").hide();
        jQuery("#komentarz_form .tip").hide();
        jQuery(this).removeClass('checked');
      }
      else{
        jQuery("#komentarz_form textarea").show();
        jQuery("#komentarz_form .tip").show();
        jQuery(this).addClass('checked');
      }
	}); 
	jQuery("#dzialalnosc").bind('click', function() {
	    if(jQuery(this).hasClass('checked')){
        jQuery(this).removeClass('checked');
      }
      else{
        jQuery(this).addClass('checked');
      }
	}); 

  if(document.getElementById('faktura[nip]') != null && document.getElementById('faktura[nip]').value != ''){
    jQuery("#dzialalnosc").attr("checked", "checked");
    jQuery("#dzialalnosc").addClass('checked');
  }
  jQuery("#nip input").focus(function() {
	  if(!jQuery("#dzialalnosc").hasClass('checked')){
	    alert('Potwierdź prowadzenie działalności gospodarczej!');
    }
  });
  var link = jQuery('#basket-box a').attr('href');
  jQuery('#basket-box').bind('click', function() {
  	  window.location.href = link;  
  }); 
	jQuery(function() {
		jQuery('#container-1 > ul').tabs();
	});
}

/*--------ograniczenie ilosci znakow w textarea---------*/

Textarea = function() { 
     jQuery("#komentarz_form textarea").keyup(function(){
          var maximum = 255; 
          var box=jQuery(this).val();
          if(box.length > maximum){
          alert('Dopuszczalna ilość znaków to '+maximum);
               jQuery(this).val(jQuery(this).val().substring(0,maximum));
          }
     });
}

/*--------ubezpieczenia---------*/

Ubezpieczenia = function() { 

  jQuery('.link_ub').bind('click',function(){
        var a = jQuery('#u_tab').offset();
        jQuery('#u_tab').click();
        jQuery('html,body').animate({scrollTop: a.top}, 1000);
        return false;
  });
  
  var ubezpiecz = document.location.toString().split("#");
  if(ubezpiecz[1]=='warunki_ubezpieczenia'){
        var a = jQuery('#u_tab').offset();
        jQuery('#u_tab').click();
        jQuery('html,body').animate({scrollTop: a.top}, 1000);
  }
  
  jQuery('.warunki').click(function() {
	  var link = jQuery(this).attr('href');
    window.open(link,'warunki','scrollbars=yes, status=no, toolbar=no, location=no, directories=no, width=700, height=700, left=100, top=100');
    return false;
  });
}

/*--------------*/

CarouselMax = function() { 
  jQuery('.jcarousel-skin-tango').each(function() {
  	var max = null;
  	jQuery(this).find('.carousel_name').each(function() {
  		if (!max || max.height() < jQuery(this).height())
  			max = jQuery(this);
  	});
  	if (max) {
  		max = max.height();
  		jQuery(this).find('.carousel_name').css("min-height", max + "px");
  	}
	});
	
	
	  var max1 = null;
  	jQuery('.jcarousel-container-horizontal').each(function() {
  		if (!max1 || max1.height() < jQuery(this).height())
  			max1 = jQuery(this);
  	});
  	if (max1) {
  		max1 = max1.height();
  		jQuery('.jcarousel-container-horizontal').css("min-height", max1 + "px");
  	}
	
}    
/*----------document ready------------------*/            
jQuery(document).ready(function() {
  GetCufon();

	jQuery('.fbook_button').toggle(function(){
      jQuery('#panel_fbook').animate({right: '0px'}, 500 );
      jQuery(this).addClass('selected');
      return false;
   },
   function(){   
      jQuery('#panel_fbook').animate({right: '-196px'}, 500 );
      jQuery(this).removeClass('selected');
      return false;
   });
     
  var alucena = 0;
  jQuery('.montaz_osobowe_male_alu').each(function() {
    alucena=alucena+ parseFloat(jQuery(this).text());
  });
  jQuery("#f-alu-cena").text(alucena+' zł');
  
  var stalcena = 0;
  jQuery('.montaz_osobowe_male_stal').each(function() {
    stalcena=stalcena+ parseFloat(jQuery(this).text());
  });
  jQuery("#f-stal-cena").text(stalcena+' zł');

 /*------------*/
  
  jQuery("#alu_stal").hide();
  Textarea();
  jQuery('.lista-art .hide, #koszyk-suma .zagiel-rata').hide();
  jQuery('.jcarousel-skin-tango').jcarousel();
  CarouselMax();
  TopPlayer();	
  Payment();
  Ubezpieczenia();
  jQuery('.art-more').bind('click',function(){
        jQuery(this).next('.hide').show();
        jQuery(this).hide();
        return false;
  });
  //DostawaAjax();
  MontazInfo();
  if(jQuery('#nr_rej').hasClass('nr_wymagany')){
     jQuery('#zamowienie').liveValidation({
          validIco:    'images/new/jquery.liveValidation-valid.png', 
          invalidIco:  'images/new/jquery.liveValidation-invalid.png', 
          required:    ['zamow[imie_nazwisko]', 'zamow[adres1]', 'zamow[adres2]', 'zamow[kod]', 'zamow[miasto]', 'zamow[telefon]', 'zamow[email]','zamow[nr_rejestracyjny]',
          'faktura[imie_nazwisko]','faktura[nip]','faktura[adres1]','faktura[adres2]','faktura[kod]','faktura[miasto]']
      });  
  }else{
      jQuery('#zamowienie').liveValidation({
          validIco:    'images/new/jquery.liveValidation-valid.png', 
          invalidIco:  'images/new/jquery.liveValidation-invalid.png', 
          required:    ['zamow[imie_nazwisko]', 'zamow[adres1]', 'zamow[adres2]', 'zamow[kod]', 'zamow[miasto]', 'zamow[telefon]', 'zamow[email]',
          'faktura[imie_nazwisko]','faktura[nip]','faktura[adres1]','faktura[adres2]','faktura[kod]','faktura[miasto]']
      });
  }
  Ilosc();
  jQuery('.submit-ilosc').change(function() {SumaAjax(jQuery(this));});    
  OponaFancy();  
  jQuery('.help').tooltip({showURL: false});
  jQuery('#welcome-link').bind('click', function() {
  	   jQuery('#welcome').slideUp();
  	   return false;
  }); 
  TopSlider();  
  GetSearchTabs();       
  GetPrice();	
  GetRating();
  GetRatingForm();
  GetPriceTabs();
  GetAccordion();
//galeria
  Inne();
	GetCar();
  jQuery("a#zoom2, a.lightbox").fancybox({
		'titleShow'     : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});

  // to chyba nie działa ale na wszelki wypadek zostawie
  jQuery('#lc_invite_layer').live('click', function() {
        _gaq.push(['_setCustomVar',1,'Kontakt','Chat toplayer',2],['_trackPageview','/chat_toplayer' + location.pathname],['_trackEvent', 'Kontkat', 'Chat toplayer', location.pathname]);
  });
});
/*----------conversion---------*/
function Conversion() {
      if (document.getElementById('p1').checked == false && 
      document.getElementById('p2').checked == false && 
      document.getElementById('p3').checked == false && 
      document.getElementById('p3').checked == false && 
      document.getElementById('p3').checked == false) {
        _gaq.push(['_trackEvent', 'Formularze', 'Rejestracja','zamow[platnosc] - pusty']);
      }
      if (document.getElementById('p1').checked == true || document.getElementById('p2').checked == true || document.getElementById('p3').checked == true) {
    			if (document.getElementById('zamow[imie_nazwisko]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Imię i nazwisko - pusty']);
    			}
    			if (document.getElementById('zamow[miasto]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Miejscowoć - pusty']);
    			}
          if (document.getElementById('zamow[kod]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Kod pocztowy - pusty']);
    			}
          if (document.getElementById('zamow[adres1]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Ulica - pusty']);
    			}
          if (document.getElementById('zamow[adres2]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Numer lokalu - pusty']);
    			}
          if (document.getElementById('zamow[telefon]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Telefon - pusty']);
    			}
          if (document.getElementById('zamow[email]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','E-mail - pusty']);
    			}
          if (document.getElementById('zamow[marka]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Marka i model pojazdu - pusty']);
    			}
          if (document.getElementById('faktura').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Dane do faktury - pusty']);
    			}
          if (document.getElementById('zamow[regulamin]').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Akceptuję regulamin - pusty']);
    			}
          if (document.getElementById('zamow[zgoda_freshmail]').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: przelew, pobranie, raty','Wyrażam zgodę - pusty']);
    			}		
			}
			if (document.getElementById('p4') != null && document.getElementById('p4').checked == true) {
    			if (document.getElementById('zamow[imie_nazwisko]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Imię i nazwisko - pusty']);
    			}
          if (document.getElementById('zamow[telefon]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Telefon - pusty']);
    			}
          if (document.getElementById('zamow[email]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','E-mail - pusty']);
    			}
          if (document.getElementById('zamow[marka]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Marka i model pojazdu - pusty']);
    			}
          if (document.getElementById('faktura').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Dane do faktury - pusty']);
    			}
          if (document.getElementById('zamow[regulamin]').checked == false) {
    		  	_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Akceptuję regulamin - pusty']);
    			}
          if (document.getElementById('zamow[zgoda_freshmail]').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Lublin','Wyrażam zgodę - pusty']);
    			}	      
      }
			if (document.getElementById('p5') != null && document.getElementById('p5').checked == true) {
    			if (document.getElementById('zamow[imie_nazwisko]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Imię i nazwisko - pusty']);
    			}
    			if (document.getElementById('zamow[miasto]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Miejscowoć - pusty']);
    			}
          if (document.getElementById('zamow[kod]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Kod pocztowy - pusty']);
    			}
          if (document.getElementById('zamow[adres1]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Ulica - pusty']);
    			}
          if (document.getElementById('zamow[adres2]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Numer lokalu - pusty']);
    			}
          if (document.getElementById('zamow[telefon]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Telefon - pusty']);
    			}
          if (document.getElementById('zamow[email]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','E-mail - pusty']);
    			}
          if (document.getElementById('zamow[marka]').value=='') {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Marka i model pojazdu - pusty']);
    			}
          if (document.getElementById('faktura').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Dane do faktury - pusty']);
    			}
          if (document.getElementById('zamow[regulamin]').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Akceptuję regulamin - pusty']);
    			}
          if (document.getElementById('zamow[zgoda_freshmail]').checked == false) {
    				_gaq.push(['_trackEvent', 'Formularze', 'Rejestracja: montaż Warszawa','Wyrażam zgodę - pusty']);
    			}		
      }
}
function SprawdzFormularz() {	
    var a = '';
    if (document.getElementById('zamow[imie_nazwisko]').value=='') {
				a = 'Imię i nazwisko';
		}
		if (document.getElementById('zamow[adres1]') != null && document.getElementById('zamow[adres1]').value=='') {
				a = a + '\nUlica';
		}
		if (document.getElementById('zamow[adres1]') != null && document.getElementById('zamow[adres2]').value=='') {
				a = a + '\nNumer lokalu';
		}		
		if (document.getElementById('zamow[adres1]') != null && (document.getElementById('zamow[kod]').value=='' || !(/^[0-9]{2}-?[0-9]{3}$/.test(document.getElementById('zamow[kod]').value)))) {
				a = a + '\nKod pocztowy';
		}	
		if (document.getElementById('zamow[adres1]') != null && document.getElementById('zamow[miasto]').value=='') {
				a = a + '\nMiejscowość';
		}	
		if (document.getElementById('zamow[telefon]')=='' || !(/^\d+$/.test(document.getElementById('zamow[telefon]').value))){
				a = a + '\nTelefon';
		}	
    if ( ((document.getElementById("zamow[email]").value.indexOf('@',1))==-1)||(document.getElementById("zamow[email]").value.indexOf('.',1))==-1 ) {
      a = a + '\nE-mail';
    }
    if(jQuery('#nr_rej').hasClass('nr_wymagany')){
  		if (document.getElementById('zamow[nr_rejestracyjny]') != null && document.getElementById('zamow[nr_rejestracyjny]').value=='') {
  				a = a + '\nNumer rejestracyjny';
  		}
    }
    if (document.getElementById('faktura').checked && document.getElementById('faktura[imie_nazwisko]').value=='') {
			a = a + '\nfaktura: Imię i nazwisko / Nazwa firmy';
		}
    if (document.getElementById('faktura').checked && !document.getElementById('dzialalnosc').checked) {
			a = a + '\nfaktura: Prowadzenie działalności gospodarczej';
		}    		
    if (document.getElementById('faktura').checked && (document.getElementById('faktura[nip]').value=='')) {
			a = a + '\nfaktura: Numer NIP';
		}
    if (document.getElementById('faktura').checked && document.getElementById('faktura[adres1]').value=='') {
			a = a + '\nfaktura: Ulica';
		}
    if (document.getElementById('faktura').checked && document.getElementById('faktura[adres2]').value=='') {
			a = a + '\nfaktura: Numer lokalu';
		}		
    if (document.getElementById('faktura').checked && (document.getElementById('faktura[kod]').value=='' || !(/^[0-9]{2}-?[0-9]{3}$/.test(document.getElementById('faktura[kod]').value)))) {
			a = a + '\nfaktura: Kod pocztowy';
		}				
    if (document.getElementById('faktura').checked && document.getElementById('faktura[miasto]').value=='') {
			a = a + '\nfaktura: Miejscowość';
		}			
    if (document.getElementById("zamow[regulamin]").checked == false ) {
      a = a + '\nRegulamin sklepu';
    }	
    if(a!=''){		
      alert('Niektóre pola wymagane nie zostały wypełnione lub zawierają błędy:\n\n'+a);
      $('t-dane').scrollTo();
      return false;
    }else {
     return true;
    }
}
