$(document).ready(function() {
	$('.sazinaties, .apply').fancybox({
		'type': 'ajax',
		'padding': 0,
		'overlayColor': '#fff',
		'overlayOpacity': 0.5,
		'width': 510,
		'height': 370,
		'autoDimensions': false,
		'titleShow': false
	});
	
	$('.home_menu').hover(function(){
		$('em', this).stop().animate(
			{ opacity: 0.5 }, 100
		).animate(
			{ marginTop: 0, marginBottom: 5 }, { duration: 200, easing: "swing", queue: false }
		);
	}, function(){
		$('em', this).stop().animate(
			{ opacity: 1 }, 100
		).animate(
			{ marginTop: 5, marginBottom: 0 }, { duration: 200, easing: "swing", queue: false }
		);
	});
	

	function mycarousel_initCallback(carousel) {
		var slide_count = $('#carousel li').length;
		var page_count = Math.round(slide_count / 7) + 1;
		
		for(n=1;n<=page_count;n++) {
			if(n===1) {
				css_class = ' class="active"';
			} else {
				css_class = '';
			}
			$('.slider_pages').append('<a href="" rel="'+n+'"'+css_class+'>&nbsp;</a>');
		}

	    jQuery('.slider_pages a').bind('click', function() {
	    	var page_to_scroll = jQuery(this).attr('rel');
	        jQuery('.slider_pages a').removeClass('active');
	        jQuery('.slider_pages a[rel='+page_to_scroll+']').addClass('active');
	        if(page_to_scroll == 1) {
		        carousel.scroll(1);
	        } else {
		        carousel.scroll(page_to_scroll+(page_to_scroll*7));
	        }
	        return false;
	    });
	    
	    $('.jcarousel-prev').click(function(){
	    	if($(this).attr('disabled') != 'true') {
				$e = $('.slider_pages a.active');
				$e.prev().addClass('active');	    		
				$e.removeClass('active');
	    	}
	    });
	    
	    $('.jcarousel-next').click(function(){
	    	if($(this).attr('disabled') != 'true') {
				$e = $('.slider_pages a.active');
				$e.next().addClass('active');	    		
				$e.removeClass('active');
	    	}
	    });
	    
	    
	};

	$('#carousel').jcarousel({
		buttonNextHTML: '<a href="#next">Next</a>',
		buttonPrevHTML: '<a href="#prev">Prev</a>',
		initCallback: mycarousel_initCallback
	});
	
	$('.jcarousel-next-horizontal, .jcarousel-prev-horizontal').click(function(){ return false; });
	
});
