$(document).ready(function() {	
	//Sign In Button
	var signInVisible = false;
	var signUpVisible = false;
	//Sign In Menu
	$('a#sign-in-btn').click(function(){
		if(!$('a#sign-in-options').is(':visible')){
			//if ($('a#sign-up-options').is(':visible')) {
			if (signUpVisible == true) {
				$('#sign-up-options').fadeOut(0);
				signUpVisible = false;
			}
			$(this).addClass('selected');
			$('#sign-in-options').fadeIn();
			window.setTimeout(function() { $('#sign-in-options').fadeOut(2000);}, 5000);
			signInVisible = true;
		}else{
			$(this).removeClass('selected');
			$('#sign-in-options').fadeOut();
			signInVisible = false;
		}
		return false;
	});
	
	$('#sign-in-options a').click(function(){
		$('a#sign-in-btn').removeClass('selected');
		$('#sign-in-options').fadeOut();
		signInVisible = false;
	});
	//Sign Up Menu
	$('a#sign-up-btn').click(function(){
		if(!$('a#sign-up-options').is(':visible')){
			//if($('a#sign-in-options').is(':visible')){
			if (signInVisible == true) {
				$('#sign-in-options').fadeOut();
				signInVisible = false;
			}
			$(this).addClass('selected');
			$('#sign-up-options').fadeIn();
			window.setTimeout(function() { $('#sign-up-options').fadeOut(2000);}, 5000);
			signUpVisible = true;
		}else{
			$(this).removeClass('selected');
			$('#sign-up-options').fadeOut();
			signUpVisible = false;
		}
		return false;
	});
	
	$('#sign-up-options a').click(function(){
		$('a#sign-up-btn').removeClass('selected');
		$('#sign-up-options').fadeOut();
		signUpVisible = false;
	});
	
	//Business Sign In Dialog Box
	$('.launchBus-btn').fancybox({
		'showCloseButton': false,
		'business': true
	});
	$('#modal-closeB').click(function(){
		$.fancybox.close();
		return false;
	})
	
	//Advisor Sign In Dialog Box
	$('.launchAdv-btn').fancybox({
		'showCloseButton': false,
		'advisor': true
	});
	$('#modal-closeA').click(function(){
		$.fancybox.close();
		return false;
	})
	
	//Bus Trial Dialog Box
	$('.trial-btnB').fancybox({
		'showCloseButton': false,
		'soonb': true
	});

	$('#modal-closeTB').click(function(){
		$.fancybox.close();
		return false;
	})
	//Adv Trial Dialog Box
	$('.trial-btnA').fancybox({
		'showCloseButton': false,
		'soona': true
	});

	$('#modal-closeTA').click(function(){
		$.fancybox.close();
		return false;
	})
	//Close for Bus sign up dialog box
	$('#modal-closeSB').click(function(){
		$.fancybox.close();
		return false;
	})
	//Close for Bus sign up dialog box
	$('#modal-closeSA').click(function(){
		$.fancybox.close();
		return false;
	})
	
	// Business Pricing
//	$('a#business-pricing-btn').click(function(){
//		$(this).addClass('selected');
//		$('a#advisor-pricing-btn').removeClass('selected');
//		document.getElementById('content').style.visibility = 'visible';
//		document.getElementById('content').style.display = 'inline';
//		document.getElementById('advisorPricingContent').style.visibility = 'hidden';
//		document.getElementById('advisorPricingContent').style.display = 'none';
//		return false;
//	});
//	
//	//Advisor Pricing
//	$('a#advisor-pricing-btn').click(function(){
//		$(this).addClass('selected');
//		$('a#business-pricing-btn').removeClass('selected');
//		document.getElementById('content').style.visibility = 'hidden';
//		document.getElementById('content').style.display = 'none';
//		document.getElementById('advisorPricingContent').style.visibility = 'visible';
//		document.getElementById('advisorPricingContent').style.display = 'inline';
//		return false;
//	});

	// Business Pricing
	$('a#business-pricing-btn').click(function() {
	    $(this).addClass('selected');
	    $('a#advisor-pricing-btn').removeClass('selected');
	    document.getElementById('businessContent').style.visibility = 'visible';
	    document.getElementById('businessContent').style.display = 'inline';
	    document.getElementById('advisorContent').style.visibility = 'hidden';
	    document.getElementById('advisorContent').style.display = 'none';
	    return false;
	});

	//Advisor Pricing
	$('a#advisor-pricing-btn').click(function() {
	    $(this).addClass('selected');
	    $('a#business-pricing-btn').removeClass('selected');
	    document.getElementById('businessContent').style.visibility = 'hidden';
	    document.getElementById('businessContent').style.display = 'none';
	    document.getElementById('advisorContent').style.visibility = 'visible';
	    document.getElementById('advisorContent').style.display = 'inline';
	    return false;
	});
		
	//Business & Advisor Features: Vertical Tabs
	$('.screenshot-feature img:not(:nth-child(1))').hide();
	$('.captions-wrapper .caption:not(:nth-child(1))').hide();
	$('.vertical-tabs a:nth-child(1)').addClass('selected');
	$('.vertical-tabs a').click(function(){
		$('.screenshot-feature img').hide();
		$('.captions-wrapper .caption').hide();
		$('.vertical-tabs a').removeClass('selected');
		var clickedIndex = $(this).index() + 1;
		$(this).addClass('selected');
		$('.screenshot-feature img:nth-child('+ clickedIndex + ')').show();
		$('.captions-wrapper .caption:nth-child('+ clickedIndex + ')').show();
		return false;
	});
	
});
