// JavaScript Document
$(document).ready(function () {
	//Submenu
	$(".mainmenu").hover(
		function() {
			jQuery(".submenu", this).fadeIn('fast');
		},
		function() {
			jQuery(".submenu", this).fadeOut('fast');
		}
	);
	
	//Home Solutions
	$("#home-logo").hover(
		function() {
			var duration = 300;
			$("#ht1").fadeIn(duration);
			$("#ht2").fadeOut(duration);
			$("#ht3").fadeOut(duration);
			$("#ht4").fadeOut(duration);
		}
	);
	$(".solution-btn").hover(
		function() {
			var me = $(this).attr("id");
			var duration = 300;
			$("#ht1").fadeOut(duration);
			if( me == 'guest-link' ) {
				$("#ht2").fadeIn(duration);
				$("#ht3").fadeOut(duration);
				$("#ht4").fadeOut(duration);
			}
			if( me == 'upcell' ) {
				$("#ht2").fadeOut(duration);
				$("#ht3").fadeIn(duration);
				$("#ht4").fadeOut(duration);
			}
			if( me == 'social-points' ) {
				$("#ht2").fadeOut(duration);
				$("#ht3").fadeOut(duration);
				$("#ht4").fadeIn(duration);
			}
		}
	);
	
	//Content Nav
	$("#content-left .link").click(function(){
		var id = $(this).attr("cont");
		showContent(id);
	});
	
	//FAQ
	$("div.faq > a").click(function(){
		$(this).siblings("div").slideToggle("fast");
	});
});

function initContent(id) {
	$("#content-left a:nth-child("+id+")").addClass("active");
	$("#content-right div:nth-child("+id+")").removeClass("hide");
}

function showContent(id) {
	var cont = $("#content-right");
		cont.slideUp(400, function() {
			$("#content-left > a").each(function(index){
				if( id == index+1 ) {
					$(this).addClass("active");
				} else {
					$(this).removeClass("active");
				}
			});
			$("#content-right > div").each(function(index){
				if( id == index+1 ) {
					$(this).removeClass("hide");
				} else {
					$(this).addClass("hide");
				}
			});
			$(this).slideDown(400);
		});
}

function transitionBanners() {
	setTimeout(function(){
		$(".transition-banner").fadeToggle(400, function(){
			transitionBanners();
		});
	}, 4000);
}
