$(document).ready(function(){
	
	//Setup
	var openDD = false;
	$(".toggle").next("p").hide();
	$(".toggle ").next("div").hide();
	
	
	$('h2.toggle').each(function(){
		$(this).click(function(){
			if($(this).hasClass("arrow_off")){
				$(this).next("p").slideUp('fast');
				$(this).next("div").slideUp('fast');
				$(this).addClass("arrow_on");
				$(this).removeClass("arrow_off");	
			}else{
			hideAllNestedDD();
			hideAllDD();
			if(openDD == false){
				$(this).next("p").css('margin-left','10px').slideDown('fast');
				$(this).next("div").css('margin-left','10px').slideDown('fast');
				$(this).addClass("arrow_off");
				$(this).removeClass("arrow_on");
				openDD = true;
			}
			}
		});
		
	});
	
	function hideAllDD(){
		openDD=false;
		$('h2.toggle').next("p").slideUp('fast');
		$('h2.toggle').next("div").slideUp('fast');
		$('h2.toggle').addClass("arrow_on");
		$('h2.toggle').removeClass("arrow_off");	
	}
	
	
	
	
	
	//Nested toggle
	var openNestedDD = false;
	$(".doubleToggle").next("p").hide();
	
	$('h2.doubleToggle').each(function(){
		$(this).click(function(){
			if($(this).hasClass("arrow_off")){
				$(this).next("p").slideUp('fast');
				$(this).next("div").slideUp('fast');
				$(this).addClass("arrow_on");
				$(this).removeClass("arrow_off");	
			}else{
			hideAllNestedDD();
			if(openNestedDD == false){
				$(this).next("p").css('margin-left','10px').slideDown('fast');
				$(this).next("div").css('margin-left','10px').slideDown('fast');
				$(this).addClass("arrow_off");
				$(this).removeClass("arrow_on");
				openNestedDD = true;
			}
			}
		});
		
	});
	
	function hideAllNestedDD(){
		openNestedDD=false;
		$('h2.doubleToggle').next("p").slideUp('fast');
		$('h2.doubleToggle').next("div").slideUp('fast');
		$('h2.doubleToggle').addClass("arrow_on");
		$('h2.doubleToggle').removeClass("arrow_off");	
	}
	
});//end of dom ready
