$(document).ready(function(){

	$('#cfform').validate();
	$('.cycle').cycle();
	$('.accordion').accordion({ header: '.accordion-header', autoHeight: false });
	$('#gallery_thumbs a').fancybox();
	
	/*$('#gallery-newest-slideshow').cycle({ 
	    pager:  '#gallery-newest-nav' 
	});*/

	$('#search-input').focus(function(){
		if ($(this).val() == 'szukaj' ) { $(this).val(''); }
	});
	$('#search-input').blur(function(){
		if ($(this).val() == '' ) { $(this).val('szukaj'); }
	});
	$('#newsletter-input').focus(function(){
		if ($(this).val() == 'e-mail' ) { $(this).val(''); }
	});
	$('#newsletter-input').blur(function(){
		if ($(this).val() == '' ) { $(this).val('e-mail'); }
	});
	
	$('a[rel="external"]').click(function(){
        window.open(this.href);
        return false;
    });
    
    $('.has-children').click(function(){
    	var childClass = '.branched-link.'+$(this).attr('id');
    	$(childClass).toggle();
    });
    
    $('a').click(function(){
    	var hash = $(this).attr('href').substr(0, 1);
    	if ((hash == '#') && ($(this).attr('href').length() > 1)) {
    		var anchorName = 'a[name="'+$(this).attr('href').substr(1)+'"]';
    		$(window).scrollTo(anchorName, 1000);
    		return false;
    	}
    });
    
    $('.text a, .nav_box a, #made-by a, .content-container a').hover(function(){ $(this).css('color', '#000').stop().animate({ color: '#6e6e6e' }); }, function(){ $(this).stop().animate({color: '#000'}); });
    $('.news-pager-right a, #otherlinks a, .news-pager-left a[class!="pager-active"]').hover(function(){ $(this).css('color', '#6e6e6e').stop().animate({ color: '#000' }); }, function(){ $(this).stop().animate({color: '#6e6e6e'}); });
    
    $('.logoitem a img').css('opacity', 0.5);
    $('.logoitem a').hover(function(){
    	$(this).css('color', '#6e6e6e').stop().animate({ color: '#000' });
   		$('img', this).stop().animate({ opacity: 1 });
   	}, function(){ 
   		$(this).stop().animate({color: '#6e6e6e'});
   		$('img', this).stop().animate({ opacity: 0.5 });
   	});
		
});
