$(document).ready(function() {
	var tabContainers = $('div.tab-container > div');
	tabContainers.hide().filter(':first').show();

	$('div.tab-container ul.tab-nav a').click(function() {
		tabContainers.hide();
		tabContainers.filter(this.hash).fadeIn();
		$('div.tab-container ul.tab-nav a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();
});

$(document).ready(function() {
	$("span.popup-holder").mouseover(function() {
		$(this).find("span.popup").show();
	});

	$(this).mouseout(function() {
		$("span.popup").hide();
	});
});
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
Cufon.replace('.table-container th');
Cufon.replace('.vh1');
Cufon.replace('.vh2');

$(function() {
	$('input[title]').blur(function() {
		if ($(this).val() == '') {
			$(this).addClass('hinting').val($(this).attr('title'));
			$(this).one('focus',
			function() {
				$(this).removeClass('hinting').val('');
			});
		}
	}).trigger('blur');
});
$(document).ready(function() {
	$('.slideshow').cycle({
		fx: 'fade',
		speed: 600,
		timeout: 9000,
		next: '.label-image',
		cleartypeNoBg: 'false'
	});
});

$(document).ready(function() {
	$('div.drop-down').click(function() {
		if ($(this).is(".search-on")) return;
		$(this).find("ul").stop(true).show().animate({
			height: 130,
			opacity: 1
		},100);
		$(this).addClass("search-on");
	});
	$('div.drop-down').mouseleave(function() {
		var me = $(this);
		if (me.is(":not(.search-on)")) return;
		me.find("ul").stop(true).show().animate({
			height: 0,
			opacity: 1
		},100,function() {
			me.removeClass("search-on");
		});
	});
	var flashFile = '/flash/Home/slideshow.swf';
		var flashvars = {};
		var params = {};
		params.wmode = "opaque";
		var attributes = {};
		swfobject.embedSWF(flashFile, "flash-container", "1152", "549", "9.0.0", false, flashvars, params, attributes);
	var mailingList = '';
	$('#general').click(function() {
		mailingList = 'MailingList';
		$('.optionSelect').html('Any news');
	});
	
	$('#sub').click(function() {
	      var name = $('#full_name').val();
	      var email = $('#email').val();
		  if (email == 'Enter a valid email address' || name == '' || name == 'Enter Your Name' || email == ''){
			$('#hidError').html("You must select input both name and email address to proceed");
		  } else {
			with (email) {
			  	  apos=email.indexOf("@");
				  dotpos=email.lastIndexOf(".");
				  if (apos<1||dotpos-apos<2) {
					$('#hidError').html("You have not entered a valid email address");
					return false;
				  } else {
					$.ajax({
				          url: "/subscribe_newsletter.php",
				          type: "POST",
				          data: {"name":name, "email": email, "newsletter_name":'MailingList'},
				          success: function() {
				            $('#subscribe').hide();
							$('#hidError').html("");
							$('#hidUpdateSuccess').html("You have successfully been added to the mailing list. Check your email for news updates from WWHQ.");
							return true;
				          }
				        });
				  }
			  }
		   }
	      return false;
	    });
  
  // Setup lightboxes
  if(!($.browser.msie && $.browser.version < 7)) {
    $('ul.news-images').each(function() { $(this).find('a').lightbox(); });
  }
	
});










