/**
 * @author matt
 */

$(document).ready(function() {
	$.sifrSettings({path:'/fonts/'});
	$("h1, h3").sifr({font:'District Thin'});
	
	$('.hide-image').click(function()
	{
		$('#navigation .banner').each(function(){
			if ($(this).is(':hidden')) {
				$(this).slideDown('slow');
				$('.hide-image').html("hide banner").removeClass("show-image");
				$.get("/ajax.php", { banner: "show" } );
			} else {
				$(this).slideUp('slow');
				$('.hide-image').html('show banner').addClass("show-image");
				$.get("/ajax.php", { banner: "collapsed" } );
			}
		});
		
		return false;
	});
	
	$(".increase-text").click(function() {
		var currentFontSize = $('body').css("font-size");
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum + 2;
		
		if (newFontSize >= 16) 
			newFontSize = 16;
		
		$("body").css("font-size", newFontSize+"px");
		$.get("/ajax.php", { fontSize: newFontSize } );
		
		return false;
	});
	
	$(".decrease-text").click(function() {
		var currentFontSize = $('body').css("font-size");
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum - 2;
		
		if (newFontSize <= 10) 
			newFontSize = 10;
		
		$("body").css("font-size", newFontSize+"px");
		$.get("/ajax.php", { fontSize: newFontSize } );
		
		return false;
	});
	
	$('a[rel=new]').click(function() {
		window.open($(this).attr('href'));
        return false;
	});
});

function checkEmail(eadd){
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(eadd)) 
		return true;
	
	return false;
}