/*	
	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
	      });

    $("#cloudy").css("left", $("#cloudy").position().left).circulate({
            sizeAdjustment: 150,
            speed: 2000,
            width: 700,
            height: 100,
            loop: true,
            zIndexValues: [1000, 1000, 1000, 1000]
    });


	setTimeout("animation()",300);



});

	(function(){
		var corecss = document.createElement('link');
		var themecss = document.createElement('link');
		var corecssurl = "http://www.emergento.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/styles/shCore.css?ver=2.1.364b";
		if ( corecss.setAttribute ) {
				corecss.setAttribute( "rel", "stylesheet" );
				corecss.setAttribute( "type", "text/css" );
				corecss.setAttribute( "href", corecssurl );
		} else {
				corecss.rel = "stylesheet";
				corecss.href = corecssurl;
		}
		document.getElementsByTagName("head")[0].appendChild(corecss);
		var themecssurl = "http://www.emergento.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/styles/shThemeDefault.css?ver=2.1.364b";
		if ( themecss.setAttribute ) {
				themecss.setAttribute( "rel", "stylesheet" );
				themecss.setAttribute( "type", "text/css" );
				themecss.setAttribute( "href", themecssurl );
		} else {
				themecss.rel = "stylesheet";
				themecss.href = themecssurl;
		}
		document.getElementsByTagName("head")[0].appendChild(themecss);
	})();
	SyntaxHighlighter.config.clipboardSwf = 'http://www.emergento.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/clipboard.swf';
	SyntaxHighlighter.config.strings.expandSource = 'mostra sorgente';
	SyntaxHighlighter.config.strings.viewSource = 'vedi sorgente';
	SyntaxHighlighter.config.strings.copyToClipboard = 'copia negli appunti';
	SyntaxHighlighter.config.strings.copyToClipboardConfirmation = 'Il codice é da ora nei tuoi appunti';
	SyntaxHighlighter.config.strings.print = 'stampa';
	SyntaxHighlighter.config.strings.help = 'info';
	SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n';
	SyntaxHighlighter.config.strings.noBrush = 'Non é stato possibile trovare il file di sintassi per: ';
	SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Il file di sintassi non é stato configurato per l\'opzione html-script';
	SyntaxHighlighter.all();



