/* Global variables */
var border_radius;
var scroll_position;
var header_top;
var header_left;
var header_height;
	
function setUpCollapsibleTableRows(){
//Collapsible Table Sections pre-hide
//	$j("#email-specs").hide();
//	$j("#addon-specs").hide();
//	$j("#languages-specs").hide();
//	$j("#servertech-specs").hide();
	$j("#misc-specs").hide();
	$j("#webapp-specs").hide();

	$j("#email-title").click( function(){
		$j("#email-specs").toggle();
	});
	$j("#addon-title").click( function(){
		$j("#addon-specs").toggle();
	});
	$j("#languages-title").click( function(){
		$j("#languages-specs").toggle();
	});
	$j("#servertech-title").click( function(){
		$j("#servertech-specs").toggle();
	});
	$j("#misc-title").click( function(){
		$j("#misc-specs").toggle();
	});
	$j("#webapp-title").click( function(){
		$j("#webapp-specs").toggle();
	});
	return true;
}

function enableExpandCollapseAllButton(){
	/* Expand All Button */
	$j("#expand-all").click( function(){
		$j("#email-specs").show();
		$j("#addon-specs").show();
		$j("#languages-specs").show();
		$j("#servertech-specs").show();
		$j("#misc-specs").show();
		$j("#webapp-specs").show();
	});
		/* Collapse All Button */
	$j("#collapse-all").click( function(){
		$j("#email-specs").hide();
		$j("#addon-specs").hide();
		$j("#languages-specs").hide();
		$j("#servertech-specs").hide();
		$j("#misc-specs").hide();
		$j("#webapp-specs").hide();
	});
	return true;
}

/* Sticky Header 
function attach_header(){
	//Get current position of scrollbar
	if (window.innerHeight) //Firefox Support
		scroll_position = window.pageYOffset;
	else
		scroll_position = document.body.scrollTop;
	
	var oldTopMargin = "0px";
	var newTopMargin = "115px";
	if (scroll_position > header_top){
		$j("#plan-chart thead").addClass("header-fixed"); //fixed class
		$j("#plan-chart").css("margin-top", newTopMargin); //prevents jumping and stuttering of rest of page
		//Fix borders and background colours
		$j("#plan-chart thead").css("border-bottom", "4px solid white");
		$j("td.specs-column").css({"background":"#3c3c3c", "border-bottom":"1px solid black"});
		//remove rounded corners
		$j("thead td.plan-title.ultimate, thead td.plan-title.reseller").css({
			"-webkit-border-radius": "0px",
			"-moz-border-radius": "0px",
			"border-radius": "0px"
		});
	}
	else{
		//remove fixed header class
		$j("#plan-chart thead").removeClass("header-fixed");
		$j("#plan-chart").css("margin-top", oldTopMargin);
		//remove border & background
		$j("td.specs-column").css({"background":"none", "border-bottom":"none"});
		//re-add rounded corners
		$j("thead td.plan-title.ultimate").css({
			"-webkit-border-top-left-radius": border_radius,
			"-moz-border-radius-topleft": border_radius
		});
		$j("thead td.plan-title.reseller").css({
			"-webkit-border-top-right-radius": border_radius,
			"-moz-border-radius-topright": border_radius
		});
	}		
	return true;
}
*/

/* Events */
$j('document').ready( function(){
	setUpCollapsibleTableRows();
	enableExpandCollapseAllButton();
	/*Get and set variables for the sticky header */
	header_top = $j("#plan-chart").offset().top;
	header_height = $j("#plan-chart thead").height();
	border_radius = $j("thead td.plan-title.ultimate").css("-webkit-border-top-left-radius");
});
//$j(window).scroll( attach_header );
//$j(window).resize(function(){
	//Get updated left position on window resize and set change it on the fly
//	header_left = $j("#plan-chart").offset().left;
//	$j("#plan-chart thead").css("left", header_left);
//});