/**
 * 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).siblings('label').text());
		   }
	   );
   },
   
   /*
	* Show / hide text from inputs
	*/
   inputText : function(){
	   $("input, textarea").focus(function(event){
		   if($(this).val() === $(this).siblings('label').text())
			   $(this).val("");
	   }).blur(function(event){
		   if($(this).val() === "")
			   $(this).val($(this).siblings('label').text());
	   });
   },
   
   /*
	* Set target blank on external links
	*/
   externalLinks : function(){
		if (!document.getElementsByTagName) return;  
		var anchors = document.getElementsByTagName('a');  
		for (var i=0; i<anchors.length; i++) {  
			var anchor = anchors[i];  
			if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external')  
				anchor.target = '_blank';  
		}
   }   
}
