/*
	***Talent Drzwi***
	version: 2010	
	author: Gosia Kmieć
	Copyright Enzo Sp. z o.o., http://enzo.pl

*/

/*------------slider na str. glownej--------------------*/

MainSlider = function() {
  $('#main-slider').cycle({
        fx:     'none',
        timeout: 0,
        pager:  '#nav',
        pagerAnchorBuilder: function(idx, slide) {  
          return '#nav li:eq(' + idx + ') a'; 
       } 
  });  
  
  $('.slide').click(function() {
    var link = $(this).find('h2 a').attr('href');
    window.location.href = link;  
  });

}

FotoSlider = function() {
  $('#main-foto').cycle({
      fx:     'none',
      timeout: 0,
      pager:  '#thumbs',
      pagerAnchorBuilder: function(idx, slide) {
          // return selector string for existing anchor
          return '#thumbs li:eq(' + idx + ') a';
      }
  });
  
  $("a[rel=gallery]").fancybox({
  		'transitionIn'		: 'none',
  		'transitionOut'		: 'none',
  		'titlePosition' 	: 'over',
  		'autoScale'			:	false,
  		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
  		    return '<span id="fancybox-title-over">Zdjęcie ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
  		}
  });
    
}

Colors = function() {
   if($('.box-right').length > 0){var c =$('.box-right').offset().left;}
  
  $('#colors dt a').each(function(index) {
    var a=$(this).attr('href');
    $(this).parent().next('dd').load(a + ' #content', function() {
         $(this).prepend('<span class="close" title="zamknij">zamknij</span>');
         $('.close').click(function() {$('#colors dd').hide();$('#colors dt a').removeClass('selected');});
    }); 
  });
  
  
   $('#colors dt a').click(function() {
     if($(this).hasClass('selected')){
       $(this).parent().next('dd').hide();
       $(this).removeClass('selected');
     }else{
       $('#colors dd').hide();
       $('#colors dt a').removeClass('selected');
       $(this).parent().next('dd').fadeIn();    
       $(this).addClass('selected'); 
       var b=$(this).offset().left-c+30;
       $("#colors dd").css({'background-position': b + 'px 0'});
     }
     return false;
   });
  
   
}

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

$(document).ready(function() {

  $('body').addClass('js');
  Cufon.replace('#top-menu li, h2', {textShadow: '1px 1px 1px #fff'});
  Cufon.replace('#footer #info');
  Cufon('#footer #info a', {hover:{hover: 'true'}});
  Cufon.replace('h3', {textShadow: '1px 1px 1px #fff'});
  MainSlider();
  FotoSlider();
  Colors();
});

