
$(function(){

// Page Transition IN

$('#pageCover').animate({opacity: '0'}, 1000, function(){
	$(this).css({visibility: 'hidden'});
});


// Top Logo

$('#topLogo').click(
function(){
	window.location = ('http://culturepilot.com/');
});

$('.accel').css({top: '-50px'});
$('.design').css({top: '-50px'});
$('.marketing').css({top: '-50px'});
$('.culture').css({top: '-50px'});

$('#topLogo').hover(
	function(){
		$('#topLogo h1').stop().animate({top: '50px'}, 100);
		$('.accel').stop().animate({top: '50px'}, 100, function(){
		$('.accel').css({top: '-10px'});
		$('.accel').animate({top: '10px'}, 200);
		});
		$('.design').stop().animate({top: '50px'}, 200, function(){
		$('.design').css({top: '-10px'});
		$('.design').animate({top: '10px'}, 200);
		});
		$('.marketing').stop().animate({top: '50px'}, 300, function(){
		$('.marketing').css({top: '-10px'});
		$('.marketing').animate({top: '10px'}, 200);
		});
		$('.culture').stop().animate({top: '50px'}, 400, function(){
		$('.culture').css({top: '-10px'});
		$('.culture').animate({top: '10px'}, 200);
		});
		},
	function(){
		$('.culture').stop().animate({top: '-20px'}, 200);
		$('.marketing').stop().delay(20).animate({top: '-20px'}, 200);
		$('.design').stop().delay(40).animate({top: '-20px'}, 200);
		$('.accel').stop().delay(60).animate({top: '-20px'}, 200);
		$('#topLogo h1').stop().delay(80).animate({top: '7px'}, 100, 'easeOut');
	}	
);


// Recent Rolls

$("#homepage ul.recent li").hover(
 function()
 {
  $(this).children('a').children('.plus').css({visibility: 'visible'});
  $(this).children('a').css({fontSize: "14px"});
  $(this).css({marginBottom: '-1px'});
  $(this).children('a').stop().animate({marginLeft: '15px'}, 100);
 },
 function()
 {
 if( $(this).attr("class") !="marked"){
 $(this).children('a').children('.plus').css({visibility: 'hidden'});
 $(this).children('a').css({fontSize: "10px"});
 $(this).css({marginBottom: '0px'});
 $(this).children('a').stop().animate({marginLeft: '0px'}, 800);
 }
 }
);


$("#portfoliopage ul.recent li").hover(
 function()
 {
  $(this).children('a').children('.plus').css({visibility: 'visible'});
  $(this).children('a').css({fontSize: "14px"});
  $(this).css({marginBottom: '-1px'});
  $(this).children('a').stop().animate({marginLeft: '15px'}, 100);
  $(this).animate({backgroundPosition: '0px 4px'}, 100);
 },
 function()
 {
 $(this).children('a').children('.plus').css({visibility: 'hidden'});
 $(this).children('a').css({fontSize: "10px"});
 $(this).css({marginBottom: '0px'});
 $(this).children('a').stop().animate({marginLeft: '0px'}, 800);
 $(this).css({backgroundPosition: '0px -10px'});
 }
);
	


$('h2.recentworks').click(
	function(){
		window.location = ('http://culturepilot.com/loves');
	});

//Contact

$('#contactIcon').delay(800).animate({left: '265px', top: '24px'}, 800, 'easeOut');	


messages = ["Hey! Whats your name? (your full name that is)", "And an email or phone number to reply to?", "What can we help you with? (be specific now)", "Wait! Would you like to receive future CP news?" ];
counter = 0;
answers = new Array();
 
$("#name").attr("value", messages[counter]);
 
$("#name").focus(function(){
	$(this).attr("value", "");
	$(this).val("");
})
$("#name").blur(function(){
	if($(this).attr("value") == ""){
		$("#name").attr("value", messages[counter]);
	}
	if($(this).val()==""){
$("#name").val(messages[counter]);
}
})

$(".next").click(function(event){
	
	$("#contactpage #name").css("margin", "0 0 0 7px");
	$(".section #name").css("margin", "0");
	
	event.preventDefault();

	if(messages[counter] != $("#name").val()){
 
		if(counter <3){
			answers.push($("#name").val());
			counter++;
			
            $(".indexer").html("( "+(counter+1)+" of 4 )");
			$("#name").val('');
			$("#name").fadeOut("fast", function(){
			
			//console.log(messages[counter]);

				$("#name").attr('value',messages[counter]);
				$("#name").val(messages[counter]);
				$("#name").css("border", "none");
				$("#contactpage #name").css("margin", "0 0 0 7px");
				$(".section #name").css("margin", "0");
				$(this).fadeIn("fast", function(){ });
			})
			
		}else if(counter == 3){
			answers.push($("#name").val());
			answers.push(String(window.location.href));
			event.preventDefault();
			$("form").animate({opacity: '0'}, 200);
			$("#process").slideUp()
			$("#thanks").slideDown()
			$("#contactpage #thanks").animate({marginTop: '-70px'}, 200);
			$(".section #thanks").animate({marginTop: '-40px'}, 200);
			sendMail(answers);
		}
	}else{
		$("#contactpage #name").css("border", "solid red 2px");
		$("#contactpage #name").css("margin", "-2px 0 0 5px");
		$(".section #name").css("border", "solid red 2px");
		$(".section #name").css("margin", "-2px 0 0 -2px");	
	}
});
 	
});



function sendMail(a){
var arr = a;
$.post("http://culturepilot.com/php/post.php", { name: arr [0],email: arr [1],project:arr [2],desc:arr [3],theurl:arr [4]});
 
}




	
