jQuery(function($) {
	$(document).ready(function() {
		
		$(".row:nth-child(even)").addClass("row-color")

		
		$('.main-nav ul > li').hover(
			function(){
				$(this).find('a').eq(0).addClass('active');
				$(this).find('.dd').show();
			}, 
			function(){
				$(this).find('a').eq(0).removeClass('active');
				$(this).find('.dd').hide();
			}
		);
		
		$('.row .img').hover(
			function(){
				$(this).find('p').stop(true ,true).fadeIn();
			}, 
			function(){
				$(this).find('p').fadeOut();
			}
		);
		
		$(window).load(function () { 
			$('.slider .text .title').addClass('title-active');
			$('.slider .text .container').slideDown('slow',function () { 
				var text_position = $('.slider .text').position();
				$('.slider .nav').animate({
					top: text_position.top
				}, 300, function() {
				});
			 });
		 });
		
		if ($('.slider').length) {
			var text_position = $('.slider .text').position();
			$('.slider .nav').css( 'top' , text_position.top)
		};
		$('.slider .text .title').click(function () {  
			if ($(this).hasClass('title-active')) {}else{
				$('.slider .text .title').addClass('title-active');
				$('.slider .text .container').slideDown('slow',function () { 
					var text_position = $('.slider .text').position();
					$('.slider .nav').animate({
						top: text_position.top
					}, 300, function() {
					});
				 });
			};


			return false;
		});

		$('.slider .text .close').click(function () {  
			$('.slider .text .title').removeClass('title-active');
			$('.slider .text .container').slideUp('slow',function () { 
				var text_position = $('.slider .text').position();
				$('.slider .nav').animate({
					top: text_position.top
				}, 300, function() {
				});
			 });

			return false;
		});
		
		$('.slider .carousel ul').jcarousel({
			'scroll' : 1,
			'auto': 8,
			'buttonNextHTML': '',
			'buttonPrevHTML': '',
			'initCallback':  init_carousel,
			'wrap': 'both'
		});
		
		$('#main-nav ul li ul').wrap('<div class="dd">');

		$("a#fancy").fancybox({
			'overlayShow'	: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});

		
	});

});	
function init_carousel(carousel) {
	$('.slider .nav a.prev').click(function(){
		carousel.prev();
		return false;
	});
	
	$('.slider .nav a.next').click(function(){
		carousel.next();
		return false;
	});
};

