$(document).ready(function(){

	showYearCC();
	$(".element .body").hide();
	$("#contact-form").hide();
	$("#contact-form").css({bottom:"10px", right:"10px"});
 	showFirst();
	
	$(".element .title").click(function(){
	
		var visible = $(this).next().css('display');

		
		$(".element .body").slideUp('fast');
		$(".element .title" + ".active").removeClass('active');
		
		if (visible.indexOf('none')==0){
			$(this).next().slideDown('normal');
			$(this).addClass('active');
		}



	});
	

	$("#ajax-contact-form").submit(function(){

		var str = $(this).serialize();

		$.ajax({
			type: "POST",
			url: "lib/contact-form/contact.php",
			data: str,
			success: function(msg){
		    
				$("#note").ajaxComplete(function(event, request, settings){
					if(msg == 'OK') { // Message Sent? Show the 'Thank You' message and hide the form
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						$("#fields").hide();
					}
					else
						result = msg;

					$(this).html(result);
			});

		   }

		});
		return false;
	});
	
	$(".contact").click(function(){
		$("#contact-form").toggle('slow');
	});
	
	$("#contact-form #close").click(function(){
		$("#contact-form").hide('slow');
	});
	
	$("#contact-form #up").click(function(){
		$("#contact-form").animate({ 
			top: "10px"
		      }, 500 );
		$("#contact-form").css({bottom:""});
      	});

	$("#contact-form #down").click(function(){
		$("#contact-form").animate({ 
			bottom: "10px"
		      }, 500 );
		$("#contact-form").css({top:""});		      
	});
	
	$("#contact-form #left").click(function(){
		$("#contact-form").animate({ 
			left: "10px"
		      }, 500 );
		$("#contact-form").css({right:""});
	});
	
	$("#contact-form #right").click(function(){
		$("#contact-form").animate({ 
			right: "10px"
		      }, 500 );
		$("#contact-form").css({left:""});
	});
	
	
});

function showFirst() {
	$("#first").next().slideDown('normal');
	$("#first").addClass('active');
};


function showYearCC() {
  $("#cc-year").html( (new Date()).getFullYear() )
}
