/**
 * 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')
	},
	
	hideMap : function(map){
		$('#'+map).css({'display' : 'none'});
	}
}

$(function() {	
	lh.setInputTexts();
	lh.inputText();
	lh.externalLinks();
	
	$("a#flash-toggle").fancybox({
		'titleShow'			:	false,
		'centerOnScroll'	:	true,
		'overlayOpacity'	:	0.5,
		'enableEscapeButton': 	true
	});
	
	$("a#rawtenstall-map, a#haslingden-map").fancybox({
		'titleShow'			:	false,
		'centerOnScroll'	:	true,
		'overlayOpacity'	:	0.5,
		'width'				:	'600px',
		'height'			:	'200px',
		'enableEscapeButton':	true
	});
	
	$('form.contact').highlight('fieldset');
});
