/**
 * lh.js
 * @author Lewis Howles
 *
 * Default Niceties.
 */

var lh = {
	
	/*
	 * Set default text for inputs (title attribute)
	 */
	setInputTexts : function(){
	   $("input[type=text], textarea").each(
		   function(){
			   $(this).val($(this).attr('title'));
		   }
	   );
	},
	
	/*
	* Show / hide text from inputs
	*/
	inputText : function(){
	   $("input, textarea").focus(function(event){
		   if($(this).val() === $(this).attr('title'))
			   $(this).val("");
	   }).blur(function(event){
		   if($(this).val() === "")
			   $(this).val($(this).attr('title'));
	   });
	},
	
	/*
	* Set target blank on external links
	*/
	externalLinks : function(){
		$('a[rel="popup"]')
			.attr('target', '_blank')
	},
	
	greeting : function(){
		var now = new Date();
		var $greeting = $('#greeting');
		
		if (now.getHours() >= 12) {
		    $greeting.text('Good Afternoon');
		}
		else if (now.getHours() >= 17) {
			$greeting.text('Good Evening');
		}
		else {
			$greeting.text('Good Morning');
		}
	}
}

$(function() {  	
	lh.greeting();
	
	$('#images').innerfade({
		speed: 1000,
		timeout: 6000,
		containerheight: '204px'
	});
	
	$('#greeting-background, #search-background').css({'opacity' : '0.6'});
	
	$('#menu li:first-child a').css({'padding' : '7px 32px'});
	
	$('#footer-menu li:first-child').css({'border' : 'none'});
	
	lh.setInputTexts();
	lh.inputText();
	lh.externalLinks();
	
	if ($('h1').text() == "Search Results") {
		getValues();
	}
	
	$('form.contact').highlight('fieldset');
});