$(document).ready(function(){

	/*
	 *	Add Event Tracking to Google Analytics for files and outbound links
	 */
    var filetypes = /\.(jpg|png|zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
	$('a').each(function(){
	    var href = $(this).attr('href');
		if ( href ){
	
		    if ((href.match(/^https?\:/i)) && (!href.match(document.domain))){
		        $(this).click(function() {
		            var extLink = href.replace(/^https?\:\/\//i, '');
		            var domain = extLink.substring(0,extLink.indexOf('/'));
		            pageTracker._trackEvent('Outbound Links', domain, extLink);
		        });
		    }
		    else if (href.match(/^mailto\:/i)){
		        $(this).click(function() {
		            var mailLink = href.replace(/^mailto\:/i, '');
		            var domain = mailLink.substring(0,mailLink.indexOf('/'));
		            pageTracker._trackEvent('Email', domain, mailLink );
		        });
		    }
		    else if (href.match(filetypes)){
		        $(this).click(function() {
		            var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
		            var filePath = href.replace(/^https?\:\/\/(www.)acupcakebar\.com\//i, '');
		            pageTracker._trackEvent('Download', extension+"'s", filePath);
		        });
		    }
		}
	});
	$('#MailingListJoinForm .submit input').click(function(){
		pageTracker._trackEvent('Mailing List Signup','Submit' );
	});
	/* END Google Analytics Event Tracking */
	
	
	// Add FancyBox to Press Links
	$('.Press ul li a').click(function(){
		//console.log( $(this).attr('href') );
		$.fancybox({
			'width': '100%',
			'height': '100%',
			'href': $(this).attr('href'),
			'type': 'iframe',
			'hideOnContentClick':false,
			'transitionIn': 'elastic'
		});
		return false;
	});
});
