$(document).ready(function(){
	
	// INLINE FORM LABELS
	$(function(){ $("label").inFieldLabels(); });
		
	// MAIN NAVIGATION	
	$("#Nav a").mouseout(function () {
		$("#Nav").css("background-position","0px 0px");
		$("#NavBgRight").css("background-position","0px 0px");
		$(this).parent().find("span.arrow").animate({
			backgroundPosition:"0px",
			opacity:"0"}, 300);
	});
	$("#Nav a").mouseover(function () {
		$(this).parent().find("span.arrow").animate({
			backgroundPosition:"22px", 
			opacity:"1"}, 200);
	});
	$("#Nav a.about").mouseover(function () {
		$("#Nav").css("background-position","0px -120px");
		$("#NavBgRight").css("background-position","0px -120px");
	});
	$("#Nav a.gcc").mouseover(function () {
		$("#Nav").css("background-position","0px -240px");
		$("#NavBgRight").css("background-position","0px -240px");
	});
	$("#Nav a.contact").mouseover(function () {
		$("#Nav").css("background-position","0px -360px");
		$("#NavBgRight").css("background-position","0px -360px");
	});
	
	// SUPPORT CTA FORM
	$("#SupportCTAForm").ajaxForm({
		success: function(e) {
			$("blockquote").parent().append(e);
			$("blockquote").hide();
			$("#SupportCTAForm").parent().hide();
		}
	});
	
	// CONTACT US FORM
	$("#ContactForm").ajaxForm({
		success: function(e) {
			$("#ContactForm").hide();
			$("#ContactForm").parent().append(e);	
		}
	});
	
	$("#ContactForm .hide").hide().css("visibility","visible");
	
	$("#ContactForm input:radio").click(function(){
		var id = "." + $(this).attr("id");
		$("#ContactForm").find(id).fadeIn("fast");	
	});
	
	// ROTATING BANNER
	$('#BannerSlides').innerfade({
		containerheight: '270px',
		speed: 800,
		timeout: 8000,
		type: 'sequence'
	});
	
	// TABS
	$(".tab-content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab-content:first").show();
	
	function indexSwap() {
		var z = 20;
		$("ul.tabs li").each(function() {
			$(this).css('z-index', z--);
		});
		$(".active").css('z-index', 21);
		return false;
	}
	
	indexSwap();

	$("ul.tabs li").click(function() {
		var top = $('body').scrollTop();
		
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab-content").hide();
		
		indexSwap();

		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		
		$("body").scrollTop(top);
		return false;
	});
	
	// FANCY BOX
	$("a.img-zoom").fancybox({
		'imageScale': true,
		'overlayColor': '#403D39',
		'overlayOpacity': 0.7,
		'overlayShow': true,
		'showCloseButton': true,
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300
	});
});
