/* Author: 
Feast 2011
*/
$(document).ready(function() {

	/* Check alert state in cookie
	/* ------------------------------------------------------------------*/	
	var as = readCookie('alert_state');		
	//console.log(as);	
	
	if(as == null){
		createCookie('alert_state', 'up', 365);
		$('a#alert_toggle').html("Show alert");
	};
	
	if(as == "down"){
		$('#alert').slideDown(500,function(){
			swapAlertText("Hide alert");
		});	
	};
	
	var as = readCookie('alert_state');		
	//console.log(as);		
	
	/* Alert togggle
	/* ------------------------------------------------------------------*/
	$('#alert_toggle').click(function(e){
		
		e.preventDefault();
		var as = readCookie('alert_state');				
		console.log(as);	
		
		if(as == null || as == 'down' ){
			
			$('#alert').slideUp( 400, function() {
				createCookie('alert_state', 'up', 365);
				swapAlertText("Show alert");
			});				
		
		} else {
		
			$('#alert').slideDown( 400, function() {
				createCookie('alert_state', 'down', 365);
				swapAlertText("Hide alert");		
			});							
		};
	});
	
	function swapAlertText(text){
		$('a#alert_toggle').fadeOut(200,function(){
			$(this).html(text).fadeIn(300)	
		});
	}
	
	/* Project Hover
	/* ------------------------------------------------------------------*/	
	$(".project-item").hover(
	  function () {
			$('.info', this).stop().animate({bottom:0, opacity: 0.8}, 250);
	  }, 
	  function () {
			$('.info', this).stop().animate({bottom:-40, opacity: 0.6}, 250);
	  }
	);	
	
	// inputs
	// ------------------------------------------------------------------------------------------------			
	$('input[type=text]').focus(function(){
		if($(this).val() == $(this).data('val')){
			$(this).val("");
		};
	}).blur(function(){
		if(!$(this).val()){
			$(this).val($(this).data('val'));
		};			
	});
		

});

