$(function(){
	
	$('#soliTab > a').click(function(){
		var toLoad = '/fragments/ejw_stocksofinterest/en_CA_quotefile_soliTbl.html';
		$(this).parent().addClass("selected").siblings().removeClass("selected");
		$.ajaxSetup({ cache: false});		
		$('#soliContents > div').load(toLoad, function(){
			$(this).css('height','auto');
			$("table.dataTable tr:nth-child(even)").addClass("greyBack");
			$("a.glossary").click(function(){
				window.open(this.href,'glossary','scrollbars=yes,resizable=yes,width=300,height=400');
				return false;
			});
			$("a.disclaimer").click(function(){
				window.open(this.href,'disclaimer','scrollbars=yes,resizable=yes,width=500,height=250');
				return false;
			});			
		});
		$.ajaxSetup({ cache: true});
		return false;
	});
	$('#activeNYSETab > a').click(function(){
		var toLoad = '/fragments/ejw_stocksofinterest/en_CA_quotefile_tseTbl.html';
		$(this).parent().addClass("selected").siblings().removeClass("selected");
		$.ajaxSetup({ cache: false});
		$('#soliContents > div').load(toLoad, function(){
			$(this).css('height','auto');
			$("table.dataTable tr:nth-child(even)").addClass("greyBack");
			$("a.glossary").click(function(){
				window.open(this.href,'glossary','scrollbars=yes,resizable=yes,width=300,height=400');
				return false;
			});
			$("a.disclaimer").click(function(){
				window.open(this.href,'disclaimer','scrollbars=yes,resizable=yes,width=500,height=250');
				return false;
			});			
		});
		$.ajaxSetup({ cache: true});
		return false;
	});
	$('#indicesTab > a').click(function(){
		var toLoad = '/fragments/ejw_stocksofinterest/en_CA_quotefile_indexesTbl.html';
		$(this).parent().addClass("selected").siblings().removeClass("selected");
		$.ajaxSetup({ cache: false});		
		$('#soliContents > div').load(toLoad, function(){
			$(this).css('height','auto');
			$("table.dataTable tr:nth-child(even)").addClass("greyBack");
			$("a.glossary").click(function(){
				window.open(this.href,'glossary','scrollbars=yes,resizable=yes,width=300,height=400');
				return false;
			});
			$("a.disclaimer").click(function(){
				window.open(this.href,'disclaimer','scrollbars=yes,resizable=yes,width=500,height=250');
				return false;
			});			
		});
		$.ajaxSetup({ cache: true});
		return false;
	});
	$('#watchListTab > a').click(function(){
		var toLoad = '/fragments/ejw_stocksofinterest/en_CA_quotefile_watchListBasicTbl.html';
		$(this).parent().addClass("selected").siblings().removeClass("selected");
		$.ajaxSetup({ cache: false});
		$('#soliContents > div').load(toLoad, function(){
			$(this).css('height','auto');
			$("table.dataTable tr:nth-child(even)").addClass("greyBack");
			$("a.glossary").click(function(){
				window.open(this.href,'glossary','scrollbars=yes,resizable=yes,width=300,height=400');
				return false;
			});
			$("a.disclaimer").click(function(){
				window.open(this.href,'disclaimer','scrollbars=yes,resizable=yes,width=500,height=250');
				return false;
			});			
		});
		$.ajaxSetup({ cache: true});
		return false;
	});

	$('#newsInsightsTab').click( function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		$("#newsInsightsBody").addClass("selected").siblings().removeClass("selected");
	});
	$('#branchEventsTab').click( function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		$("#branchEventsBody").addClass("selected").siblings().removeClass("selected");
		$("ul.eventList li").equalHeights();
	});
	$('#featuredInvestTab').click( function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		$("#featuredInvestBody").addClass("selected").siblings().removeClass("selected");
	});
	$("#newsInsightsTab a,#branchEventsTab a,#featuredInvestTab a").click(function(event) {
		event.preventDefault();
	});
	
	$('#featuredInvestTab > a').each(function(){
		var toLoad = $("#featuredInvestBody > a").attr("href");
		$.ajaxSetup({ cache: false});
		$("#featuredInvestBody").load(toLoad);
		$.ajaxSetup({ cache: true});
	});
	
	if (typeof(myFaPic) !== 'undefined') 
		$('#faPic').attr("src", myFaPic);
});
