$(document).ready(function() {

    if(window.location.hash.length > 0)
	{
		var cechaName = '';
		if(window.location.hash == '#cecha_ibuprom')
		{
		  $('.cecha_2.tresc').toggleClass('tresc-open');
          $('.cecha_2').children('div.tekst').toggleClass('tekst-none');	
		}
		
		if(window.location.hash == '#cecha_ibuprom_max')
		{
		  $('.cecha_3.tresc').toggleClass('tresc-open');
          $('.cecha_3').children('div.tekst').toggleClass('tekst-none');	
		}
		
		if(window.location.hash == '#cecha_ibuprom_sprint_caps')
		{
		  $('.cecha_5.tresc').toggleClass('tresc-open');
          $('.cecha_5').children('div.tekst').toggleClass('tekst-none');	
		}
		
		if(window.location.hash == '#cecha_ibuprom_duo')
		{
		  $('.cecha_6.tresc').toggleClass('tresc-open');
          $('.cecha_6').children('div.tekst').toggleClass('tekst-none');	
		}

	}


    $('.more').click(function(){
      $(this).parents('div.tresc').toggleClass('tresc-open');
      $(this).parents('div').children('div.tekst').toggleClass('tekst-none');
	  
	  if($(this).parent().parent().prev('.top-tresc').children('a').attr('id').length)
      {
	    window.location='#'+$(this).parent().parent().prev('.top-tresc').children('a').attr('id');
	  }
    });
  
    $('.poradnik_podroznika a.pobierz_poradnik').click(function(){
      $('#poradnik').fadeIn('slow');
      return false;
    });
  
    $('a[rel*=external]').click( function() {
        window.open(this.href);
        return false;
    });

    $('#image_button').click(function(){
      $('#popup').fadeIn('slow');
      return false;
    });
    $('.popup_close').click(function(){
      $('#popup').fadeOut('slow');
      return false;
    });
     /* animacja dla video */
    if($('.jCarouselLite > ul > li').length > 1)
    {
      $(".jCarouselLite").jCarouselLite({
          btnNext: ".video_thumb_next_btn, .next",
          btnPrev: ".video_thumb_prev_btn, .prev",
          circular: true,
          visible: 2
      });
    }  

    /* open video after thumb clik */
     if($('#video_thumbs').length > 0 && $('#popup_content').length > 0)
    {
    $('#video_thumbs').each(function(){
      $(this).children('div').children('ul').children('li').children('a').click(function(event){
        event.preventDefault();

        var imgSrc = $(this).attr('href');
        if(imgSrc.indexOf('.flv') > 0 || imgSrc.indexOf('.f4v') > 0)
        {
          var flashvars = {  };
          var params = {
            bgcolor: "#FFFFFF",
            allowScriptAccess: "always",
            menu: "false",
            wmode: "transparent",
            flashVars: "movie=../"+imgSrc+"&autostart=false&startThumb=/images/player/startThumb.png&endThumb=/images/player/endThumb.png&iconColor=0xFF0000&progressBarColor=0xff0000&mainColor=0xffffff&bufferBarColor=0x989898&unbufferedBarColor=0xeeeeee"
          };
          swfobject.embedSWF("/player.swf", "popup_content", "600", "350", "6.0.65.0", "/swf/expressInstall.swf",  flashvars, params );
        }
        return false;
      });
    });
    $($('#video_thumbs').children('a')[0]).trigger('click');    
  }    
	
	$('.logo-anchor').click(function(){
	
      //$('.cecha_1.tresc').toggleClass('tresc-open');
      //$('.cecha_1').children('div.tekst').toggleClass('tekst-none');
      
	  
      //$('.cecha_1').children('div.tekst').toggleClass('tekst-none');
	  if($(this).hasClass('footer_logo1'))
	  {
	    if(!$('.cecha_2.tresc').hasClass('tresc-open'))
		{
	      $('.cecha_2.tresc').toggleClass('tresc-open');
          $('.cecha_2').children('div.tekst').toggleClass('tekst-none');	
		}
	  }

	  if($(this).hasClass('footer_logo2'))
	  {
	    if(!$('.cecha_3.tresc').hasClass('tresc-open'))
		{
	      $('.cecha_3.tresc').toggleClass('tresc-open');
          $('.cecha_3').children('div.tekst').toggleClass('tekst-none');	
		}
	  }
	  
 	  
	  if($(this).hasClass('footer_logo4'))
	  {
	    if(!$('.cecha_5.tresc').hasClass('tresc-open'))
		{
	      $('.cecha_5.tresc').toggleClass('tresc-open');
          $('.cecha_5').children('div.tekst').toggleClass('tekst-none');	
		}
	  }

	  if($(this).hasClass('footer_logo5'))
	  {
	    if(!$('.cecha_6.tresc').hasClass('tresc-open'))
		{
	      $('.cecha_6.tresc').toggleClass('tresc-open');
          $('.cecha_6').children('div.tekst').toggleClass('tekst-none');	
		}
	  }
	  
	  
	  
	});
	
});

