$(document).ready(function() {
	
	$('a').click(function(e){
		e.preventDefault();
		var elink = $(this).attr('href');
		if(elink.substring(0, 7) != 'http://' && elink.substring(0, 7) != 'mailto:'){
			setTimeout('document.location = "' + elink + '"', 100);
		} else if(elink.substring(0, 7) != 'mailto:') {
			
			if(elink.substring(0, 22) == 'http://www.thebarracks'){
				pageTracker._trackEvent('Subdomain Change', 'Blog to Site');
				setTimeout('document.location = "' + elink + '"', 100);
			} else {
				if(elink.substring(0, 22) == 'http://www.thebarracks' || elink.substring(0, 19) == 'http://202.74.66.38' || elink.substring(0, 23) == 'http://blog.thebarracks'){
					setTimeout('document.location = "' + elink + '"', 100);
				} else {
					pageTracker._trackEvent('Outbound Links', elink);
					setTimeout('window.open("' + elink + '")', 100);
				}
			}
			
		} else if(elink.substring(0, 7) == 'mailto:') {
			if(elink.substring(0, 21) == 'mailto:?subject=Check'){
				pageTracker._trackEvent('Email Link', 'Tell a Friend');
			}
			setTimeout('document.location = "' + elink + '"', 100);
		}
	});
	
 	nd.rollover.init();
 	$('#footer #copyright p').css('opacity', '.5');
 	Cufon.replace('h1', { fontFamily: 'AvantGarde Book' });
 	Cufon.replace('h2.book', { fontFamily: 'AvantGarde Book' });
 	Cufon.replace('h3', { fontFamily: 'AvantGarde Bold' });
 	
 	function signupSuccess() {
		$('#newsletter').hide();
		$('p.signup').hide();
		$('#signup').text('Thanks for signing up!');
		$('#thanks-for-signing-up').show();
	}

	$('#submitbtn').click(function() { 
		$('#newsletter').submit();
	});
 	
 	//Signup
	$("#newsletter").validationEngine({
		success :  function() { signupSuccess() 
		$("#text_response").html('Thank you for signing up to the newsletter');
	},
		ajaxSubmit : false,
		failure : function() {
		$("#text_response").html('Failure');
		
	}
	});
	
	

 	
});
