/*	
	Emergento.com
	Stefano Giliberti, kompulsive@gmail.com	
*/

$(document).ready(function(){
	
	/* Featured */
	$("#promo #slides-dock .slide").fadeIn(500);
	$("#promo #slides-dock").cycle({
		fx: 'fade',
		timeout: 5000,
		speed: 1000,
		pause: 1
	});

	/* Content slider */
	$("#content-slider .dock").cycle({
    		speed: 800,
        	next: '#content-slider a.next',
		prev: '#content-slider a.prev',
		nowrap:  1,
		easing: 'easeInOutCirc',
		timeout: 0,
   		fx:      'custom',
    		cssBefore: {
    			top: 900,
        		display: 'block' 
    		}, 
    		animIn: {
        		top: 0  
    		}, 
    		animOut: {
        		opacity: 0
    		},
        	cssAfter: {
        		opacity: 1,
        		top: 900,
        		display: 'block'  
    		},
    		before: update
    	});
    		
	function update(curr,next,opts) {
		var eq = (opts.nextSlide);
		$("ul#anchor li").removeClass("selected");
		$("ul#anchor li:eq("+ eq +")").addClass("selected");
		
		var nextHeight = $(next).height();
		$("#content-slider .dock").animate({
			height: nextHeight
		}, { duration: 300, easing: 'easeInOutSine' })
	}

	$("ul#anchor li a").click(function() {
		$('#content-slider .dock').cycle($("ul#anchor li a").index(this));
	});

	$("#content-slider a.next, #content-slider a.prev").click(function() {
		$(this).fadeOut().fadeIn();
	});
	
	/* Adjustements */
	$("ul#anchor li a").attr("href", "javascript:void(0)");
	$("ul#anchor li").removeClass("selected");
	$("ul#anchor li:eq(0)").addClass("selected");
		
	/* Testimonials */
	$("#social .wrap #testimonials").cycle({
		slideExpr: 'blockquote',
		fx: 'fade',
		speed: 1000,
		timeout: 4000,
		pause: 1
	});
	
	/* Portfolio */
	$(".project .preview").hover(function () {
		$(this).stop().animate({ opacity: 0.5 }, 250)
	},function () {
	 	$(this).animate({ opacity: 1 })
	});
  	
  	/* Lightbox */
  	if ($("a[rel*=facebox]").length > 0) {
  		$("a[rel*=facebox]").facebox({
  			opacity: '0.2'
  		})
  	}
	$("div.menu ul ul").hide();


	$().piroBox({
	      my_speed: 300, //animation speed
	      bg_alpha: 0.5, //background opacity
	      slideShow : 'false', // true == slideshow on, false == slideshow off
	      close_all : '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
	      });



});


