$(document).ready( function(){

	// enable the contact email
	$('a').click( function(){
		//document.location.href = 'mai' + 'lto' + ':' + 'licensing' + '@' + 'barfbrand' + '.' + 'com';
		if( $(this).text().toLowerCase() == 'email' ){
			// tell analytics someone clicked
			pageTracker._trackPageview( '/Contact/' + window.location.hostname );
		}else{
			pageTracker._link(this.href);
		}
	});

	// if we have a picturebox element
	if( $('#picturebox img')[0] ){
		// load the slide images after the document is already displayed so page displays faster
		$(window).load( function(){
			$('#picturebox img').each( function(){
				// load if we don't already have a src
				var src = $(this).attr('src');
				var ext = src.substring(src.lastIndexOf('.'),src.length);
				if( ext != '.jpg' ){
					$(this).attr('src', 'assets/' + $(this).attr('class') );
				}
			});
			// load the cycle plugin
			$('#picturebox span').cycle('fade');
		});
	}

	// if we have li elements, animate them to fade in
	if( $('#picturebox li')[0] ){
		$('#picturebox li').hide();
		var next = function(){
			var vis = $('#picturebox li:not(:visible):eq(0)');
			if( !vis[0] ){
				clearTimeout(t);
				return false;
			}
			vis.fadeIn( 'slow', function(){ t = setTimeout(next,100); } );
		}
		next();
	}

});
