/**
 * 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')
   } 
}

function initialize() {    
	// Set a new map and set the lat and long
	var latlng = new google.maps.LatLng(51.506748, -3.57974);  
	
        // Set map options 
        var myOptions = {      
		zoom: 15,      
		center: latlng,      
		mapTypeId: google.maps.MapTypeId.ROADMAP    
	};    
	
	var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions); 
	
	// Create a new map marker
	var marker = new google.maps.Marker({
		position: latlng,       
		map: map,      
		title: "Gareth L Edwards Ltd, 4-6 Dunraven Place, Bridgend, CF31 1JD"
	});
}

$(function() {	
	if ($('h1.title').text() == "Search Results") {
		getValues();
	}
	
	lh.setInputTexts();
	lh.inputText();
	lh.externalLinks();
	
	$('form.contact').highlight('fieldset');
	
	initialize();
});
