function input_value(el){
    var old_value= $(el).val();
    $(el).focus(function(){
        if($(this).val() == old_value){
        	$(this).attr("value","");
		}
    }).blur(function(){
        if($(this).val() == "" || $(this).val() == " "){
            $(this).attr("value", old_value);
        } 
    });
}

function setValidator (form){
	if(form.length!=0){
		form.validate({					
			errorPlacement: function(error, element) {					
								element.parent().prepend(error);
							}
		})
			
	}
}

jQuery(document).ready(function($) {	
	input_value("#search-input");	
		
	setValidator($("#contactForm"));
	setValidator($("#digestForm"));
		
	if($('#thank-you-block').length){	
		if(location.hash && location.hash == '#thank-you'){			
			if($('.form-box').length){$('.form-box').hide();}
			$('#thank-you-block').show();
		}
	}
	
	if($("#home-about-message").length){
		var $expandBut 	  =	$("#home-about-message .button-expand");
		var $collapseBut  = $("#home-about-message .button-collapse")
		var $messExpanded = $("#home-about-message .message-expanded");		
		
		$expandBut.on('click',function(){			
			$messExpanded.slideDown(300,"easeInOutCubic");		
			$(this).fadeOut(100);	
			$collapseBut.fadeIn(100);
			return false;
		});
		$collapseBut.on('click',function(){			
			$messExpanded.slideUp(300,"easeInOutCubic");		
			$(this).fadeOut(100);	
			$expandBut.fadeIn(100);
			return false;
		});
		
		
	}
});  

