$(document).ready(function(){
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		// Fixes no :first-child support in IE6 for footer
		$('#footer li:first-child').addClass('first');
	};
	
	//FAQ accordion
	var fa = ""; // Active FAQ Item
	$("#faq_list").load("inserts/questions.html", function() {
		$("#faq_list").accordion({autoHeight: false});
		$("#faq_list h3 a:first").css({'background-image' : 'url("img/buttons/minus.png")'});
		$("#faq_list h3 a:first").toggleClass("faq_active");
		fa = "#faq_list h3 a:first";
		$("#faq_list h3 a").click(function() {
			$(this).css({'background-image' : 'url("img/buttons/minus.png")'});
			$(fa).css({'background-image' : 'url("img/buttons/plus.png")'});
			$(fa).toggleClass("faq_active");
			fa = this;
			$(this).toggleClass("faq_active");
		});
	});
		
	// Sub_nav button click event handlers
	var accordionActive = "#accordion h3 a:first";
	var subNavActive = "#overview";
	$("#overview a").click(function() {
		$("#service_text").animate({opacity:0}, 200, function() {
			$("#service_text").load("inserts/service_overview.html", function() {
				$("#col_wide h5").text(">> services overview");
				$(subNavActive).toggleClass("active");
				subNavActive = ("#overview");
				$("#overview").toggleClass("active");
				$("#service_text").animate({opacity:1}, 200)
			});
		});
		return false;
	});
	
	$("#concept a").click(function() {
		$("#service_text").animate({opacity:0}, 200, function() {
			$("#service_text").load("inserts/design_concept.html", function() {
				$("#col_wide h5").text(">> design concept");
				$("#accordion").accordion({ autoHeight: false });
				$("#service_text").animate({opacity:1}, 200);
				$(subNavActive).toggleClass("active");
				subNavActive = "#concept";
				accordionActive = "#accordion h3 a:first";
				$(subNavActive).toggleClass("active");
				$(accordionActive).css({'background-image' : 'url("img/buttons/minus.png")'});
				$(accordionActive).toggleClass("current");
				$("#accordion h3 a").click(function() {
					prep(this, accordionActive);
				});
			});
		});
		return false;
	});
	
	$("#development a").click(function() {
		$("#service_text").animate({opacity:0}, 200, function() {
			$("#service_text").load("inserts/design_development.html", function() {
				$("#col_wide h5").text(">> design development");
				$("#accordion").accordion({ autoHeight: false });
				$("#service_text").animate({opacity:1}, 200);
				$(subNavActive).toggleClass("active");
				subNavActive = "#development";
				accordionActive = "#accordion h3 a:first";
				$(subNavActive).toggleClass("active");
				$(accordionActive).css({'background-image' : 'url("img/buttons/minus.png")'});
				$(accordionActive).toggleClass("current");
				$("#accordion h3 a").click(function() {
					prep(this, accordionActive);
				});
			});
		});
		return false;
	});
	
	$("#administration a").click(function() {
		$("#service_text").animate({opacity:0}, 200, function() {
			$("#service_text").load("inserts/design_administration.html", function() {
				$("#col_wide h5").text(">> design administration");
				$("#service_text").animate({opacity:1}, 200);
				$(subNavActive).toggleClass("active");
				subNavActive = "#administration";
				$(subNavActive).toggleClass("active");
				
			});
		});
		return false;
	});
	
// Creates navagation for service content accordion
	function prep(clicked, active) {
		//var item = active;
		$(clicked).css({'background-image' : 'url("img/buttons/minus.png")'});
		$(active).css({'background-image' : 'url("img/buttons/plus.png")'});
		$(active).toggleClass("current");
		$(clicked).toggleClass("current");
		accordionActive = clicked;
	};
// No spam
	$("a.email").nospam({replaceText:true});	
});

// Calls from SWF to JS, Changes breadcrumb nav on subnav click
function sendToJavaScript_kit() {
		$("#col_single h5").text(">> kitchen");
};
function sendToJavaScript_bath() {
		$("#col_single h5").text(">> bathroom");
};
function sendToJavaScript_liv() {
		$("#col_single h5").text(">> living room");
};
function sendToJavaScript_bed() {
		$("#col_single h5").text(">> bedroom");
};
function sendToJavaScript_out() {
		$("#col_single h5").text(">> outdoor");
};