// JavaScript Document

// education/pricing.shtml -> hide product blurbs after 10 seconds
function pricingHide(){
	$('.pricing-info').slideUp(300);
}

function leavingMTI(){
	window.location = "http://www.fxcurrencytraders.com";
}


// When JQuery is ready
$(function(){
			   
/* ----- Top Navigation ----- */
	$('#topNav li').hover(function(){
		var dmenu = $(this).attr("class");
		$('.dropmenu').fadeOut(50);
		$('#nav-dropdown .' + dmenu).fadeIn(200);
	});
	
	$('.dropmenu').hover(function(){
	
	}, function(){
		$(this).fadeOut(200);
	});
	
	$('body').click(function(){
		$('.dropmenu').fadeOut(50);
	});



/* ----- Home Page ----- */

	// Home Page Modal Box
		// set slide up/down speeds (in milliseconds)
		var speeddown = 100;
		var speedup = 800;
	
		// when a modal nav link is clicked
		$('.home-modal-link').click(function(){
					
			// fade out and remove any showing items (change 'selected' class)
			$('.home-modal-item .home-modal-text').fadeOut(speeddown);
			$('.home-modal-link').removeClass('selected');
			$(this).addClass('selected');
			
			// figure out which stage item to open
			var stageitem = $(this).attr("id");
			// fade in selected stage after adding to page
			$('.home-modal-stage .' + stageitem).fadeIn(speedup);
			$('.home-modal-stage .' + stageitem + ' .home-modal-text').fadeIn(speedup);

		});
		
	// Testimonial switcher
		var numtestimonials = 4;
		var num = Math.floor(Math.random()*numtestimonials);
		$('#pullQuote .name').load("/mti-clients/testimonials.aspx #testimonial" + num + ' .personName');
		$('#pullQuote .quote').load("/mti-clients/testimonials.aspx #testimonial" + num + ' .quote span', function(){
			$('#pullQuote .quote span').prepend("<img src=\"/global-images/left-quote.jpg\" width=\"28\" height=\"23\" />");
			$('#pullQuote .quote span').append('<img src="/global-images/right-quote.jpg" width="28" height="23" />');
		});
	


/* ----- Education Section ----- */
	// syllabus.shtml -> add workbook icon and up arrow images to each lsiting
	$('.schedule h3.learnmore').prepend('<img src="/forex-education/images/pricing-workbook.png" style="margin:0 5px -5px 0;" /> ');
	$('.schedule h3.learnmore').prepend('<a href="#pagetop"><img src="/global-images/uparrowsm.png" style="float:right;" /></a>');
		
	// education/index.shtml -> hide all product info if javascript enabled
	$('.other-ed-info').hide();
	// education/index.shtml -> reveal product info on rollover
	$('.other-ed h3').hover(function(){
		$(this).next('p.other-ed-info').slideDown(500);
	});
	// education/index.shtml -> hide product info on body click
	$('body').click(function(){
		$('p.other-ed-info').slideUp(300);
	});
	
	// education/pricing.shtml -> reveal product blurbs on rollover
	$('.pricing-feature').hover(function(){
		$(this).next('.pricing-info').slideDown(500);
		setTimeout("pricingHide()",10000);
	});
	$('body').click(function(){
		$('.pricing-info').slideUp(300);
	});


/* ----- Charting Section ----- */

	// charting phasebox script
	$('.phasebox').hide();
	$('.ph1').show();

	var outspeed = 0;
	var inspeed = 500;

	$('.tph1').click(function(){
		$('.phasebox').stop().fadeOut(outspeed);
		$('.ph1').fadeIn(inspeed);
		return false;
	});
	$('.tph2').click(function(){
		$('.phasebox').stop().fadeOut(outspeed);
		$('.ph2').fadeIn(inspeed);
		return false;
	});
	$('.tph3').click(function(){
		$('.phasebox').stop().fadeOut(outspeed);
		$('.ph3').fadeIn(inspeed);
		return false;
	});
	$('.tph4').click(function(){
		$('.phasebox').stop().fadeOut(outspeed);
		$('.ph4').fadeIn(inspeed);
		return false;
	});



	// charting/index.shtml -> when tab "learn more" button clicked, load appropriate page content
	$('.lm-fxcharting').click(function(){
		$('.loadmoreinfo').fadeOut(0)
			.load('/forex-charting/forex-charting-systems.aspx #loadtocharting')
			.fadeIn(500);
		window.location = "#loadmoreinfo";
		return false;
	});
	$('.lm-fxindicators').click(function(){
		$('.loadmoreinfo').fadeOut(0)
			.load('/forex-charting/forex-indicators.aspx #loadtocharting')
			.fadeIn(500);
		window.location = "#loadmoreinfo";
		return false;
	});
	$('.lm-fxanalysis').click(function(){
		$('.loadmoreinfo').fadeOut(0)
			.load('/forex-charting/forex-technical-analysis.aspx #loadtocharting')
			.fadeIn(500);
		window.location = "#loadmoreinfo";
		return false;
	});


/* ----- About MTI Section ----- */
	$('.aboutfaq h3.learnmore').prepend('<a href="#pagetop"><img src="/global-images/uparrowsm.png" style="float:right;" /></a>');
	$('.aboutglossary h3.learnmore').prepend('<a href="#pagetop"><img src="/global-images/uparrowsm.png" style="float:right;" /></a>');


/* ----- Analyst Article Section ----- */

	$('.articleListing').hide();
	$('.articleListing:first').show();
	
	$('.analystNewsTabs li a').click(function(){
		var anewstab = $(this).attr("class");
		$('.analystNewsTabs li a').removeClass("selected");
		$(this).addClass("selected");
		$('.articleListing').hide();
		$('div.' + anewstab).show();
		return false
	});

/* ----- Referral Section ----- */
	$('.seeDetails').css("display","block");
	$('.referralDetailsBlurb').hide();
	
	$('.seeDetails').click(function(){
		$('.referralDetailsBlurb').show();
		$(this).hide();
		$('.closeDetails').css("display","block");
		return false;
	});
	$('.closeDetails').click(function(){
		$('.referralDetailsBlurb').hide();
		$(this).hide();
		$('.seeDetails').css("display","block");
		return false;
	});



/* ----- Clients Section ----- */
	// testimonials.shtml -> make person name font: oceania
	$('.clients .personName').addClass('oceania');
	$('.clients .testimonial').before('<div class="hr"><hr /></div>');

}); // Close JQuery