(function($) {

	$.fn.extend({
							
		// log function
		log: function (msg) {
      console.log("%s: %o", msg, this);
      return this;
  	},
		
		tabbedFaqList: function() {
			
			// implicit iteration for maintaining good ref to THIS
			return this.each(function(){	
				var prefix = "js-";
				
				// add tabs
				$(".page_navigation", this).tabs({selectedClass:'current'});
				
				// create faq per fragment
				$('div.fragment', this).each(function(index) {
				
					var $items = $('ul.faq-list li.faq-item', this);
					// insert anchors
					$('.question', $items).each(function(index) {
						var faqItemId = this.parentNode.id;
						var anchorTag = "<a href='#" + prefix + faqItemId + "'></a>";
						$(this.childNodes).wrap(anchorTag);
					}).find("a").click(function(event) {
						var objLi = this.parentNode.parentNode;
						$items.not(objLi).removeClass("open");
						$(objLi).toggleClass("open");
						event.preventDefault();
					});
					
				});
			});
			
		},
		// end faqList 
		
		appliancePicker: function() {
			// implicit iteration for maintaining good ref to THIS
			return this.each(function(){	
				// init stuff
				$(".top-image", this).hide();
				$(".top-image:eq(0)", this).show();
				$("ol li:eq(0)", this).addClass("current");
				
				$("ol li a", this).click(function(event) {
					// set color
					$(this).parents(".appliance-colors").find("li").removeClass("current");
					$(this).parent().addClass("current");
					// set appliance
					var applianceId = $(this).attr("href");
					$(this).parents("#appliance-picker").find(".top-image").hide();
					$(applianceId).show();
					event.preventDefault();
				});
			});
		}
		// end appliancePicker
		
	});

})(jQuery);
