$(document).ready(function(){
	// font size
	fontResizer('12px','14px','16px');

	// external Links
	$("a[rel='external']").live("click", function(){
		window.open($(this).attr("href"));
		return false;
	})

	// news ticker
	if(typeof $().newsTicker == "function" && $("ul#ticker")) {
		var options = {
			newsList: "ul#ticker",
			tickerRate: 40,
			startDelay: 10,
			loopDelay: 4000,
			placeHolder1: " -",
			placeHolder2: ""
		}
		$().newsTicker(options);
	}

	// show hide
	var navItems = $(".box"); 
	$("div.sl-content",navItems).hide();
	$(navItems).hover( 
	function(){ $(this).children("div.sl-content").fadeIn("slow"); },
	function(){ $(this).children("div.sl-content").fadeOut("fast"); } );

	// social bookmarks share button
	$("#share").click(function(){
		$("#share-detail").toggleClass("sd");
	})
	// print page
	$("#print").click(function(){
		window.print();return false;
	})

	// accordion
	$('.accordion .accontent').hide();
	$('.accordion:first .accontent').show();
	$('.accordion:first').addClass('active');
	$('.accordion h2').click(function(){
		// active toggle
		if ($(this).parent().hasClass('active')) {
			$(this).parent().removeClass('active');
		} else {
			// check others for active and close
			$('.accordion.active .accontent').slideUp('slow');
			$('.accordion.active').removeClass('active');
			$(this).parent().addClass('active');
		}

		$(this).parent().find('.accontent').slideToggle('slow');
	})

	// stretchy content
	$("#content div.ex-block h2.ex-heading").click(function(){
		$(this).closest('div.ex-block').toggleClass('ex-active');
	})
	//ie sub nav
	$('#subnav li li:last-child').css('border-bottom','none');

	// email this page
	$("#email a").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 425

	});

	// email this page submit
	$("#email_this_page #submit").live("click",function(){

		$.post("/forms/emailPage/", $("#email_this_page").serialize(), function(data){

			if(data == "success") {
				alert("your message has been sent");
				$.fn.fancybox.close();
			} else {
				alert("your message could not be sent");
			}
		});

	})

	// useful links
	$("#selectbox").change(function(){
		window.open($("#selectbox").val(), "_self");
	});
	
});