// JavaScript Document
//Menu left
$(document).ready(function(){
		
	// first example
	$("#navigation").treeview({
		persist: "location",
		collapsed: true,
		unique: true,
		animated: "slow",
	});
});

//Toggle for Panels section

$(document).ready(function(){	
	$(".toggle_container").hide();
	$("h2.trigger").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});	
	$("h2.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("slow,");
	});
});

$(document).ready(function(){	
	$(".register_container").hide();
	$("h5.reg-trigger").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});	
	$("h5.reg-trigger").click(function(){
		$(this).next(".register_container").slideToggle("slow,");
	});
});

// Right Navigation

ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 300, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='http://www.smartfix.com.au/images/btn/arrow_down.gif' class='statusicon' />", "<img src='http://www.smartfix.com.au/images/btn/arrow_up.gif' class='statusicon' />",], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "slow", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		
	}
})
//Rotating Tabs

$(document).ready(function() {	
	//Get the height of the first item
	$('#mask').css({'height':$('#panel-1').height()});		
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div').width($('#mask').width());	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();		
		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 800);		
		//Discard the link default behavior
		return false;
	});
});