/* 
 * Fleea Script
 * Last Updated: 2011-12-07
 * Author: Lya Santoso - http://www.fleea.nl
 * Email : l.santoso at fleea.nl (remove space, change 'at' to '@')
 * Twitter: @lyasantoso
 */

$(document).ready(function(){

/*
 * GENERAL ANIMATION
 */

// Animate a when it's being hovered, one color each
$("#home #content a, #home .introduction a, #home #banner a").hover(function(){
	$(this).animate({ color: "#ff0000"}, 500);
},function(){
	$(this).animate({ color: "#b55252"}, 200);
});


/*
 * HOMEPAGE SPECIFIC ANIMATION
 */
if($("#home #banner #left")){
	$("#home #banner #left").effect("bounce", { times:2, direction: "left", distance:15 }, 500);
}
if($("#home #banner #right")){
	$("#home #banner #right").effect("bounce", { times:2, direction: "right", distance:15 }, 500);
}

 /* 
  * CONTACT SPECIFIC
  */
contactDetectChange();
$("#contact-purpose").change(function () {
  var str = "";
  str = contactDetectChange();
  $("#contact-form #"+str).effect("highlight", {}, 3000);
})

function contactDetectChange(){
  var str2 = "";
  $("#contact-purpose option:selected").each(function () {
		str2 += $(this).val() + " ";
      });
  $("#contact-form fieldset").hide();
  $("#contact-form #"+str2).show();
  return str2;
}

/*
 * NUDGE SPECIFIC ANIMATION
 */
try{
    var defaultNudgeValue = "your email";
    $('#nudge-email').focus(function(i) {
        var value = $(this).val();
        if(value == defaultNudgeValue){
            $(this).val("");
        }
    });
} catch(e){}

/*
 * PORTFOLIO SPECIFIC ANIMATION
 */
try{
	$('.portfolio-slideshow').each(function(i) {
	    var $container = $(this).cycle({ 
	        fx: 'fade', 
	        speed: 300, 
	        autostop: 1, 
	        autostopCount: 1 
	    }); 
	    $container.siblings('aside').children('.thumbnails').children().each(function(i) {
	        $(this).click(function() { 
                $container.cycle(i, 'fade'); 
                return false; 
	        }); 
	    });
	});
} catch(e){}

/*
 * SERVICE SPECIFIC ANIMATION
 */
try{
	$('.slideshow').cycle({
		fx: 'fade',
                timeout:8000
	});
} catch(e){}

try{
	$('#example-user-experience').cycle({
		fx: 'scrollHorz',
		speed: 'fast', 
		pager: '#nav-user-experience', 
	        autostop: 1, 
	        autostopCount: 1 
	});
} catch(e){}

try{
	$('#example-front-end').cycle({
		fx: 'scrollHorz',
		speed: 'fast', 
		pager: '#nav-front-end', 
	        autostop: 1, 
	        autostopCount: 1 
	});
} catch(e){}

});
