$(document).ready(function(){
	/**
	*	SOCIAL MENU
	*/
	$("#social-menu").fadeTo(0, 0.5).hover(function()
	{
		$(this).stop().fadeTo("fast", 1);
	},
	function()
	{
		$(this).stop().fadeTo("fast", 0.5);
	});
	
	/*
	*	BROCHURE
	*/
	$('.brochure a').click(function(e)
	{
		var url = $(this).attr("href");
		window.open(url);
 
		e.preventDefault();
 
	});
	
	/**
	*	MAIN MENU
	*/
	$("a[href='#']").click(function(e)
	{
		e.preventDefault();
	})
	$("#main-menu > ul > li").hover(function()
	{
		$(this).find("> a").addClass("hover");
		$(this).find('ul:hidden').slideDown("fast");
	},
	function()
	{
		$(this).find("> a").removeClass("hover");
		$(this).find('ul').slideUp("fast");
	});
	/**
	*	SCROLL TO TOP
	*/
	$('#scrollup').click(function()
	{
		$('html, body').animate({scrollTop:0}, 1000, 'easeOutExpo');
    });
	/**
	*	SHOWCASE
	*/
	function beforeChange()
	{
		$('#sc-content a:visible').find(".caption").fadeOut();
	}
	function afterChange()
	{
		$('#sc-content a:visible').find(".caption").hide().fadeIn();
	}
	$('#sc-content').nivoSlider({
        effect: 'slideInLeft', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 5000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        randomStart: false, // Start on a random slide
        beforeChange: beforeChange, // Triggers before a slide transition
        afterChange: afterChange, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
    /**
    *	MODAL PARTNERS SPONSORS
    */
	$(".partner.modal, .sponsor.modal").click(function()
	{
		$.fancybox({
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'autoDimensions': false,
			'width'			: 640,
			'height'		: 360,
			'content'		: $(this).next(".description").html()
		});
	return false;
	});
	
	$(".sponsors-list a, .partners-list a").hover(function()
	{
		$(this).addClass("hovered");
		$(this).parent().find("> a").not(".hovered").stop().fadeTo('fast',0.2);
	},
	function()
	{
		$(this).removeClass("hovered");
		$(this).parent().find("> a").not(".hovered").stop().fadeTo('fast',1);
	});
	
	/**
	*	SPEAKERS LIST HOME
	*/	
	function speakerslist_initCallback(carousel)
	{
		$('#sp-slide-right').bind('click', function()
		{
			carousel.startAuto(0);
			carousel.options.animation = 1000;
			carousel.options.scroll = 2;
			carousel.next();
        	return false;
		});
	
		$('#sp-slide-left').bind('click', function()
		{
			carousel.startAuto(0);
			carousel.options.animation = 1000;
			carousel.options.scroll = 2;
			carousel.prev();
        	return false;
		});
		
		carousel.clip.hover(function()
		{
			carousel.startAuto(0);
		},
		function()
		{
			carousel.startAuto(1);
		});
	};
	function callback(carousel)
	{
		carousel.options.animation = 1000;
		carousel.options.scroll = 1;
		carousel.startAuto(1);
	}
    
	$('#sp-slider').jcarousel({
		auto: 1,
        wrap: 'circular',
        scroll: 1,
        animation: 1000,
        buttonNextHTML: null,
        buttonPrevHTML: null,
        initCallback: speakerslist_initCallback,
		itemLoadCallback: {
			onAfterAnimation: callback
		}
	});
	/**
	*	HOME NEWS
	*/
	$("#news-content").cycle(
	{
		fx: 'scrollUp'
	});
	
	
	/**
	*	MODAL PERSON
	*/
	$(".person.modal:not('.organizer')").click(function()
	{
		$.fancybox({
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'autoDimensions': false,
			'width'			: 640,
			'height'		: 360,
			'content'		: $(this).next(".biography").html()
		});
	return false;
	});
	$(".organizer").click(function(e)
	{
		e.preventDefault();
	});
	
	/**
	*	MODAL YOUTUBE
	*/
	$(".modal-video").click(function()
	{
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'width'			: 640,
			'height'		: 360,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
				'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
	return false;
	});
	
	/**
	*	NEW REGISTER NOW
	*/
	$("#registration_form").validationEngine(
	{
		autoPositionUpdate : true,
		binded : false,
		onValidationComplete: function(form, status)
		{
			if (status == true)
			{
				$.post($('#registration_form').attr('action'), $("#registration_form").serialize(), function(data)
				{
					$('#response').html(data).slideDown('slow');
				});
			}
		} 
	});
});
