var qltmr = null;
var qlovr = false;
$(function(){
	// external links
	$("a[rel='external']").click(function(){
		window.open($(this).attr("href"));
		return false;
	})

	// swap out top banner
	$('#banner').html('').flash({
		swf: '/assets/uploads/flash/banner_txt.swf',
		width:535,
		height:105
	});

	// search form
	$("#searchbox").focus(function(){
		if($(this).val() == "Search site") {
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == "") {
			$(this).val("Search site");
		}
	})

	// signup form
	$("#signup_email").focus(function(){
		if($(this).val() == "Your email address") {
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val() == "") {
			$(this).val("Your email address");
		}
	})

	// quick links handlers
	$("#quicklinks p").mouseover(function(){
		clearTimeout(qltmr);
		qlovr = true;
		$("#quicklinks ul").slideDown();
	})

	$("#quicklinks ul").mouseover(function(){
		qlovr = true;
		clearTimeout(qltmr);
	}).mouseout(function(){
		qlovr = false;
		qltmr = setTimeout("hideQl()",200);
	})

	// sifr
	$("#content h2:not(.nosifr)").each(function(){
		$(this).addClass("sifrplease");
	})

	if(typeof sIFR == "function"){

		sIFR.replaceElement(named({
			sSelector:"#content h1, #content h2.sifrplease",
			sWmode: "transparent",
			sFlashSrc:"/assets/flash/avantgarde.swf",
			sColor:"#330066"
		}));

		$("h2.panelhead").each(function(){
			$(this).html('<span>'+$(this).text()+'</span>');
		})
		sIFR.replaceElement(named({
			sSelector:"h2.panelhead span",
			sWmode: "transparent",
			sFlashSrc:"/assets/flash/avantgarde.swf",
			sColor:"#FFFFFF"
		}));
	}
})

function hideQl() {
	if(!qlovr) {
		$("#quicklinks ul").slideUp();
	}
}