$(document).ready(function() {

	// Fade in h1 on home page
/*
	if ($("body").attr("class") == "home") {
		$("body.home h1 span").hide().EffectChain({effect: "fadeIn"});
	}
*/

	// Ad graphic
	$("#home-ad img").hide();
	$("#home-ad img.text").css("margin-left", "180px");
	$("#home-ad img.text").animate({ marginLeft: 0, opacity: 'show'}, 1000, function() { $("#home-ad img.logo").fadeIn(2000); });

	// System Features
	$("#features ul").tabs();
	$("#features ul li a").click(
		function() {
			var position = $(this).position();
			var title = $(this).attr("href");
			var box_height = $(title).height() + 42;
			if (position.top > 19 ) {
				position.top = position.top - 17;
			}
			if ( (position.top + box_height) > $("#features").height() ) {
				position.top = $("#features").height() - box_height;
			}
			$("#features div.details").css("margin-top", position.top + "px");
		}
	);

	// Simparel Clients
	$("div.client-list ul.nav").tabs();
	$("div.client-list ul.nav li a").click(
		function() {
			var position = $(this).position();
			var title = $(this).attr("href");
			var box_height = $(title).height() + 42;
			if (position.top > 19 ) {
				position.top = position.top - 17;
			}
			if ( (position.top + box_height) > $("div.client-list").height() ) {
				position.top = $("div.client-list").height() - box_height - 4;
			}
			$("div.client-list div.client").css("margin-top", position.top + "px");
		}
	);

	// Toggle FAQ answers
	$('dl.faq dd').hide();
	$('dl.faq dt').addClass('inactive');
	$('p.faq-controls').show();
	$('dl.faq dt').hover(
		function() { $(this).addClass('hover');	},
		function() { $(this).removeClass('hover'); }
	);
	$('dl.faq dt').toggle(
		function() { $(this).removeClass('inactive'); },
		function() { $(this).addClass('inactive'); }
	);
	$('dl.faq dt').click(
		function() { $(this).next('dd').slideToggle('fast'); }
	);

	// Display submit message for ROI form
	$('div.submit-message').parent('#roi-form').width(500);
	$('div.submit-message').parent('#roi-form').parent('#roi-form-wrapper').show();
	$('div.submit-message').parent('#msbreakfast-form').width(500);
	$('div.submit-message').parent('#msbreakfast-form').parent('#msbreakfast-form-wrapper').show();

});

// Expand or close all FAQ answers at once
function faq_expand() {
	$('dl.faq dt').removeClass('inactive');
	$('dl.faq dd').show();
}
function faq_close() {
	$('dl.faq dt').addClass('inactive');
	$('dl.faq dd').hide();
}
