// JavaScript Document
(function() 
{	
	$id = function (el) {
		return document.getElementById(el);	
	}
	$(document).ready(function()
	{
		$('.wish_list_item, .wish_list_item_selected ').click(function(ev) 
		{
			// stop the click action
			ev.preventDefault();
			//var content = this.childNodes[0].innerHTML; // the a node is the first node - if this changes this will have to be updated
			//alert ( this.className );
			var selectIt = true;
			( this.className == 'wish_list_item' ) ? ( selectIt = true ) : ( selectIt = false );
			// wl item is an li so we need the a inside it to get the content
			( selectIt ) ? ( this.className = 'wish_list_item_selected' ) : ( this.className = 'wish_list_item' )
			var content = this.getElementsByTagName('a')[0].innerHTML;
			if ( selectIt ) {
				$id('show_selected_items').className = ''; // get rid of the nodisplay on the <ul>
				var html = '<li>' + content + '</li>';
				$('#show_selected_items').append(html);
				$id('selected_items_input').value += '|' + content;
			} else {
				$('#show_selected_items > li').remove(":contains('" + content + "')");
				$id('selected_items_input').value = $id('selected_items_input').value.replace('|' + content, '');
			} // end if else select it
			
		});
	}); // close dom ready
})();