/* Shadowbox */
if (typeof(Shadowbox) != 'undefined') {
	Shadowbox.init({
		displayCounter: false,
		displayNav: false,
		onFinish: function() {
			if (typeof(Cufon) != 'undefined') {
				Cufon('#sb-nav-close');
			}
		}
	});
}
/* Related Link Video */
function appreciateVideo() {
	
	if (typeof(Shadowbox) != 'undefined') {
		Shadowbox.open({
			content: URI_SKIN + '/flash/player.swf',
			player: 'swf',
			width: 450,
			height: 300,
			options: {
				flashVars: {
					'link1': URI_SKIN + '/flash/video/home/appreciate.flv',
					'quality': 'high',
					'wmode': 'transparent'
				}
			}
		});
	}
	
	return;
}
/* jQuery DOM-load */
$(function() {
	
	/* Font Replacement */
	if (typeof(Cufon) != 'undefined') {
		Cufon('#primary-navigation a, #utility-navigation a, #buckets a .off, #customer-service-navigation a, #about-navigation a, #shadowbox-container h1, #shadowbox-container.people .name', { hover: true });
	}
	/* Jumper */
	$('#jumper').change(
		function() {
			
			url = $(this).val();
			if ($(this).attr('selected') != 'selected') {
				
				if (typeof(pageTracker) != 'undefined') {
					pageTracker._link(url);
				}
				
				window.location = url;
			}
			
			return false;
		}
	);
	/* About Us */
	$('#about-navigation li a').hover(
		function() {
			
			var parent = $(this).parents('li');
			var half = Math.ceil($('#about-navigation li').length / 2);
			
			if ($(parent).index() >= half) {
				$(parent).toggleClass('right-hover');
			}
			else {
				$(parent).toggleClass('left-hover');
			}
		}
	);
	/* Customer Service - FAQs */
	$('.expanding li > a').click(
		function() {
			
			$('.expanding li.select').removeClass('select');
			$(this).parents('li').addClass('select');
			
			return false;
		}
	);
	/* Buckets */
	$('#buckets li:odd').addClass('even');
	$('#buckets li:even').addClass('odd');
	$('#buckets li a').hover(
		function() {
			$('.on, .off', $(this)).toggle();
		}
	);
	/* About Us - Talk Form */
	$('#about-talk input[name=type]').bind(
		'focus',
		function() {
			
			if ($(this).val() == 2) {
				$('#more-info').slideDown();
			}
			else {
				$('#more-info').slideUp();
			}
		}
	);
	/* Off-site Links */
	$('a[href^=http]:not([href^=http://' + location.host + ']):not([href^=https://' + location.host + ']):not([rel^=shadowbox])').live(
		'click',
		function() {
			
			window.open($(this).attr('href'), $(this).text());
			
			return false;
		}
	);
	/* About Us - Shadowboxes */
	$('#shadowbox-container #navigation li a').click(
		function() {
			if ($(this).parents('li').hasClass('selected')) return false;
			var element = $(this);
			$('#items li.selected').fadeOut(
				125,
				function() {
					$(this).removeClass('selected');
					$($(element).attr('href')).fadeIn(
						125,
						function() {
							$(this).addClass('selected');
						}
					);
				}
			);
			$('#navigation li.selected img').fadeTo(
				250,
				1,
				function() {
					$(this).parents('li').removeClass('selected');
				}
			);
			$('img', this).fadeTo(
				250,
				.2,
				function() {
					$(this).parents('li').addClass('selected');
				}
			);
		}
	);
	
	/* Contact form - request type slider */
	$('#about-talk-form input[name=request-type]').change(function(){
		$('#more-info').slideToggle();
	});
});
