$(document).ready(function() {
	// Nav Menu
	$(".NavTrigger").hover(function() {
        var trigger = $(this);
        var img = trigger.find("img");
        img.animate({opacity:'show'}, 'fast');
    }, function() {
        var trigger = $(this);
        var img = trigger.find("img");
        img.animate({opacity:'hide'}, 'slow');
    });
    
    // Carousel
    $('#Barousel').barousel({
        navType: 1
    });
    
    // DevNotes tipTip Trigger
    $(function(){
        $(".DevNotesTip").tipTip({
            delay:150,
            edgeOffset:8,
            content:"<b>DevNotes</b><br/><br/>\n\
            Sezione tecnica contenente:<br/>\n\
            <ul><li>Plugin jQuery</li><li>Classi PHP</li><li>Appunti vari</li></ul>"
        });
    });
    
    // DevNotes image replace
    $("#DevNotes").hover(function() {
        $(this).attr("src", "res/img/DevNotesOn.gif");
    }, function() {
        $(this).attr("src", "res/img/DevNotesOff.gif");
    });
    
    // Twitter float lateral
	$("#TwitterFloatTrigger, #TwitterFloat").hover(function () {
		$('#TwitterFloat').css('display','block');
		$('#TwitterFloatTrigger').css('left','250px');
	}, function() {
		$('#TwitterFloat').css('display','none');
		$('#TwitterFloatTrigger').css('left','0px');
	});
    
    // CV button tipTip Trigger
    $(function(){
        $(".ButtonCvTip").tipTip({
        	activation: "click",
        	defaultPosition: "top",
            delay:150,
            edgeOffset: 30,
            keepAlive: true,
            content:"<div id='CvTipBox'>CURRICULUM VITAE<br/><br/>\n\
            <a href='res/utils/util_cv_download.php?lang=IT' target='_blank'>Italiano</a> - <a href='res/utils/util_cv_download.php?lang=EN' target='_blank'>English</a></div>"
        });
    });
    
    // Extra Icons social
    $("#IcoLinkedIn").hover(function() {
    	$(this).attr('src', 'res/img/IcoLinkedIn_on.jpg');
    }, function() {
    	$(this).attr('src', 'res/img/IcoLinkedIn_off.jpg');
    });
    $("#IcoStumble").hover(function() {
    	$(this).attr('src', 'res/img/IcoStumble_on.jpg');
    }, function() {
    	$(this).attr('src', 'res/img/IcoStumble_off.jpg');
    });
        
    // Skills Language switch Trigger
    $(".SkillsLangTrigger").click(function() {
    	var it = $("#ProfiloSkillsIT");
    	var en = $("#ProfiloSkillsEN");
    	var img = $("#SkillsTranslate");
    	if (it.is(':visible')) {
        	it.fadeOut("slow");
        	en.fadeIn("slow");
        	img.attr("src", "res/img/TranslateIT.jpg");
        }
        else {
        	en.fadeOut("slow");
        	it.fadeIn("slow");
        	img.attr("src", "res/img/TranslateEN.jpg");
        }
    });
    
    // Testimonials Trigger
    var timer = setInterval(swapTestimonial, 11000);
    var testimonial_count = $("div.TestimonialText").size();
    var testimonial_old = 0;
    var testimonial_current = 0;
    function swapTestimonial() {
    	testimonial_current = (testimonial_old + 1) % testimonial_count;
    	$("div.TestimonialText:eq(" + testimonial_old + ")").fadeOut("slow");
    	$("div.TestimonialText:eq(" + testimonial_current + ")").delay(900).fadeIn("slow");
    	testimonial_old = testimonial_current;
    };
    
    // Featured Projects Trigger
    $(".PrjFeaturedImage").hover(function() {
        var trigger = $(this);
        var div = trigger.find(".PrjFeaturedSlider");
        div.slideDown("slow");
    }, function() {
        var trigger = $(this);
        var div = trigger.find(".PrjFeaturedSlider");
        div.slideUp("fast");
    });
    
    // Mail form Qaptcha
    $('#QapTcha').QapTcha();
});
