/******************************************************************************
 * Global functions for Timeshare Luquidation Service.
 * jQuery framework is required.
 * 
 * Author: Neal Krouse, Browning & Browning, Inc (neal@jbrowning.biz)
 *
 * NOTES:
 * 27 Nov 2007
 * Started source code
 *
 ******************************************************************************/

$(document).ready(function(){
	// add external icon only if external URLs are present
	if ( $("#primary a[@href^='http'], #primary a[@href^='https']").length > 0 ) { 
		$("#primary a[@href^='http'], #primary a[@href^='https']")
		.filter(function(index){return $("img", this).length==0;}) // if exclude links around images
		.not("[@href*='www.timeshareliquidationservice.com']") //example of excluding specific urls			
		.wrap("<span class=\"external\"><\/span>");
	};


	// add email icon only if external URLs are present
	if ( $("#primary a[@href^='mailto:']").length > 0 ) { 
		$("#primary a[@href^='mailto:']")
		.wrap("<span class=\"email\"><\/span>");
	};
	
	$(".request #primary form label em").each(function(){
		// add help icon and toggle display of help text
		var $this = $(this);
		var $thistext = $this.text(); 
		var $help = $("<img src='images/help.gif' alt='help' title='More information' /> ");
		$help.toggle(
			function(){ $(this).next("span").show(); },
			function(){ $(this).next("span").hide(); }
		);
		$this.text("").append( $("<span style='display:none;'>"+$thistext+"</span>") ).prepend($help);
	});
	
	// add text explaining what the help icon does
	$(".request #primary p:first").append(" Click the ").append($("<img src='images/help.gif' alt='help' />")).append(" icon for more information." );
	
	// temp. Adds class to inventory pages "SCROLL DOWN..." text
	$(".inventory #primary b:first").addClass("temp");
	
});

