// Font replacement
if (typeof(Cufon) != 'undefined') {

	Cufon('.gotham-bold', { fontFamily: 'Gotham Bold', hover: true });
	Cufon('.gotham-medium', { fontFamily: 'Gotham Medium', hover: true });
	Cufon('.gotham-book', { fontFamily: 'Gotham Book', hover: true });
}
// Shadowbox setup
if (typeof(Shadowbox) != 'undefined') {

	Shadowbox.init({
		displayCounter: false,
		displayNav: false,
		onFinish: function() {
			if (typeof(Cufon) != 'undefined') {
				Cufon('#sb-nav-close', { fontFamily: 'Gotham Bold', hover: true });
			}
		}
	});
}
// Enclosure
;(function($) {

	// Variables
	var URL = window.location;
	
	// Homepage Canvases
	$('.home #canvas').slideShow();

	// Input defaults
	$('.swap-default').each(function() {
		if ($(this).val() != '') {
			$(this).data('default-value', $.trim($(this).val()));
		}
		$(this).bind(
			'focusin focusout',
			function() {
				var currentValue = $.trim($(this).val()).toUpperCase();
				if (currentValue == $(this).data('default-value').toUpperCase()) {
					$(this).addClass('focus').val('');
				}
				else if (currentValue == '' || currentValue == $(this).data('default-value').toUpperCase()) {
					$(this).removeClass('focus').val($(this).data('default-value'));
				}
			}
		);
	});
	
	// Off-site links
	$('a[href^="http"]:not([href^="' + URL.protocol + '//' + URL.host + '"]):not([href^="' + URL.protocol + '//octanner.com"]):not([href^="' + URL.protocol + '//www.octanner.com"]):not([rel*="shadowbox"])').live(
		'click',
		function() {
			
			window.open($(this).attr('href'), $(this).text());
			return false;
		}
	);
	
	// Video Shadowbox
	$('.youtube-sb').click(
		function() {

			if (typeof(Shadowbox) != 'undefined') {

				Shadowbox.open({
					content: $(this).attr('href'),
					player: 'iframe',
					width: 640,
					height: 360
				});

				return false;
			}
		}
	);
	
	$('.video-sb').click(
		function() {

			if (typeof(Shadowbox) != 'undefined') {

				Shadowbox.open({
					content: URI_SKIN+'/flash/player.swf',
					player: 'swf',
					width: 640,
					height: 360,
					options: {
						flashVars: {
							'v': $(this).attr('href'),
							'quality': 'high',
							'wmode': 'transparent'
						}
					}
				});

				return false;
			}
		}
	);

	// 
	$('#subscribe').submit(function() {
		var form = this;
		$('.error', form).hide();
		$.ajax($(this).attr('action'), {
			data: $(this).serializeArray(),
			success: function(data) {
				if (data == 'false') {
					$('.error', form).show();
				}
				else {
					$('#email-signup').load(URI_SITE + '/subscribe?thanks=true', function() {
						if (typeof(Cufon) != 'undefined') {
							Cufon('#email-signup h3', { fontFamily: 'Gotham Bold', hover: true });
						}
					});
				}
			}
		});
		
		return false;
	});

})(window.jQuery);
