

//tab effects

var TabbedContent = {
	init: function() {
		
		
		$('.tab_item').hover(
		function(){
		    
			$(".moving_bg").fadeTo(500,1);
			$(".slide_content").fadeTo(500,1);

				var background = $(this).parent().find(".moving_bg");

				$(background).stop().animate({ left: $(this).position()['left'], opacity:1}, { duration: 300 });

				TabbedContent.slideContent($(this));

		},
		function(){});
		
		
		$('.tabbed_content').hover(
		function(){},
		function(){
		    $(".moving_bg").fadeTo(500,0);
				$(".slide_content").fadeTo(500,0);
		});
		
		
	},
	
	slideContent: function(obj) {
		
		var margin = $(obj).parent().parent().find(".slide_content").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
		
		$(obj).parent().parent().find(".tabslider").stop().animate({
			marginLeft: margin + "px"
		}, {
			duration: 300
		});
	}
}

$(document).ready(function() {
	
	TabbedContent.init();
	
	$("#sales_support")
	.mouseover(function(){$(this).addClass('sales_support_hover');})
	.mouseout(function(){$(this).removeClass("sales_support_hover");});
	
	$("#technical_support")
	.mouseover(function(){$(this).addClass('technical_support_hover');})
	.mouseout(function(){$(this).removeClass("technical_support_hover");});
	
	$("#submit_question_button a[rel]").overlay({
		mask: {
			color: '#000',
			loadSpeed: 200,
			opacity: 0.7
		}
	});
	
	
	
	// select #flowplanes and make it scrollable. use circular and navigator plugins
	$("#seriespanes").scrollable({ circular: true, mousewheel: true }).navigator({
    
		// select #flowtabs to be used as navigator
		navi: "#seriestabs",
    
		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',
    
		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current',
    
		// make browser's back button work
		history: true
    
	});
	
	$("#t1").bind("click", function() { $("#seriespanes").animate({ height: "550px" }); });
	$("#t2").bind("click", function() { $("#seriespanes").animate({ height: "1680px" }); });
	$("#t3").bind("click", function() { $("#seriespanes").animate({ height: "550px" }); });
	
	$('#seriespanes .item:nth-child(5n)').css('margin-right',0);
	

	
	$("#territories").change(function(){
		$('.rep').fadeOut();
		var selected_id = $("#territories option:selected").val();
		$(selected_id).parent().fadeIn();  
	});
	
	
	
});
