var title = null;
var timer = null;
var activeAnchor = null;

function trackPdf(type) {
	switch(type) {
		case 'orderform':
			pageTracker._trackPageview("/pdf/Simplicity_Order_Form.zip");
			break;
		case 'brochure':
			pageTracker._trackPageview("/pdf/Simplicity_Brochure.zip");
			break;
	}
		
}

function removeFNPopup() {
	clearTimeout(timer);
	$("div#fn_popup").fadeOut(100, function() {
		$("div#fn_popup").remove();
		$(activeAnchor).attr("title", title);
		$(activeAnchor).removeClass("fn_anchor-active");
	});		
}

$(document).ready(function(e) {
    $("body").addClass("js");
	
	if($.browser.msie) {
		var version = $.browser.version.slice(0,3);
		switch(version) {
			case '6.0':
				$("body").addClass("ie6");
				break;
			case '7.0':
				$("body").addClass("ie7");
				break;
			case '8.0':
				$("body").addClass("ie8");
				break;	
		}
	}
	
	$("header#masthead nav ul li a").each(function(i) {
		var content = $(this).html();
		$(this).html('<span class="valign">'+content+'</span>');
		$(this).children("span.valign").css({
			'top': ($(this).height()/2) - ($(this).children("span:first-child").height()/2)
		});
	});
	
	
	
	$("a.fn_anchor").mouseover(function() {
		$("a.fn_anchor-active").removeClass("fn_anchor-active");
		clearTimeout(timer);
		$("div#fn_popup").remove();
		var linkTag = $(this).attr("href");
		activeAnchor = $(this);
		title = $(this).attr("title");
		
		$("div#content").after('<div id="fn_popup"><div class="holder"><p class="close"><a href="#">Close</a></p><p>'+ $(linkTag).html() +'</p></div></div>');
		$("div#fn_popup").css({'top':$(this).offset().top + $(this).height() + 2, 'left':$(this).offset().left});
		
		$(this).attr("title", "");
		$(this).addClass("fn_anchor-active");
	}).mouseout(function() {		
		timer = setTimeout("removeFNPopup()", 500);
	}).click(function() {
		return false;
	});
	
	$("div#fn_popup").live("mouseover", function() {
		clearTimeout(timer);
	}).live("mouseout", function() {
		timer = setTimeout("removeFNPopup()", 500);
	});
	
	$("div#fn_popup p.close a").live("click", function() {
		removeFNPopup();
		return false;
	});
});
