// JavaScript Document

/*

tablet.js

author: Jamie Boyd
date: March 2008

**This script requires jquery.js**

*/

$(function(){
	// Hide panel heading
	$(".tablet .section h2 ").each(function(){
		$(this).hide();
	});
	
	// Give first tab "selected" class
	var tabSelect = false;
	$(".tablet .controls li").each(function(){
		if (tabSelect == false){
			$(this).addClass("selected");
			tabSelect = true;
		}
		else {  }
	});
	
	// Make first panel visible and hides others //
	var visible = false;
	$(".tablet  .section ").each(function(){
		if (visible == false){
			visible = true;
		}
		else { $(this).hide(); }
	});
	
	// On tab click, show corresponding panel and hide others
	$(".tablet .controls a").click(function(){
		var secLink = $(this).attr("href");
		secLink = secLink.replace(/#/, "");		
		$(".tablet .sections .section").each(function(){
			if($(this).attr("id").match(secLink)) {
				$(this).show();
			}
			else { $(this).hide(); }
		});
		
		// Set "selected" class on parent LI 
		$(".tablet .controls a").each(function () {
			$(this).parent().removeClass("selected");
		});
		$(this).parent().toggleClass("selected");

		// Disable link
		return false;
	});
});


