/*
 * Scripts for Louise Naunton Morgan's website
 * © Joe Davis 2010
 *
 */
var test;
$(document).ready(function(){
	
	$("#menu li").hide();
	$("#menu li.section-title").show();
	
	$(".active").parent().children().show();
	
	if ($(".active").parent().children("li.section-title").text() != "#"){
		$(".active").parent().children("li.section-title").attr("content_open","true").wrapInner("<u></u>").append("<span class='drop-down'> v</span>").addClass("active-section-title");
	}
	
	$("li.section-title").each(function(){
		if ($(this).text() == "#"){
			$(this).parent().children().css("margin-bottom","12px").show();
			$(this).hide();
		}
	});
	
	$("#menu li a").each(function(){
		if ($(this).attr("href") == "http://www.louisenauntonmorgan.com/index.php?/root/shop/"){
			/*$(this).parent().css({
				"margin-top":"18px",
				"margin-bottom":"18px"
				});*/
			$(this).parent().before("<br />").after("<br />");
		} 
	});
	
	if ( $(".active").html() != null){
		test = $(".active").position().top;
		$("#content .container").css("padding-top",test+"px");
	}
	
	$("#menu li.section-title").click(function(){
		if ($(this).attr("content_open") == "true"){
			//$(this).hide();
			$(this).parent().children().hide();
			$(this).parent().children("li.section-title").show();
			$(this).parent().children("li.section-title").children(".drop-down").remove();//removeClass("open-section-title");
			//$("#menu li").hide();
			//$("#menu li.section-title").show();
			//$(this).parent().children("li.section-title").show();
			$(this).attr("content_open","false");
		} else {
			//$("#menu li").hide();
			//$("#menu li.section-title").show();
			$(this).parent().children().show();
			$(this).parent().children("li.section-title").append("<span class='drop-down'> v</span>");//addClass("open-section-title");
			$(this).attr("content_open","true");
		}
		if ( $(".active").html() != null){
			test = $(".active").position().top;
			if (test == 0){
				test = $(".active").parent().children("li.section-title").position().top;
			}
			$("#content .container").css("padding-top",test+"px");
		}
	});
});