// JavaScript Document

$(function() {
	

// Subpage tabs code
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
// nth child table fix
	$("table tr:nth-child(even)").addClass("stripe");


// equal columns

// sidebar simple toggler
	$('#accordion div').hide();
	$('#accordion .switch a').click(function(){
		$('#accordion div').slideUp();
		$(this).parent().next().slideDown();
		return false;
	});
	
// Superfish navigation 

// to test that the external file is being accessed

// GOOGLE ANALYTICS
	

// MARKETSITE SLIDES

	
// TABS AREA

// PARTNERS SLIDES
	$('#partnersSlides').slides({
		preload: true,
		preloadImage: 'img/slideshow/loading.gif',
		play: 5000,
		pause: 3000,
		hoverPause: true,
		effect: 'fade'
	});

// Rotation SLIDES
	$('#rotationSlides').slides({
		preload: true,
		preloadImage: 'img/slideshow/loading.gif',
		play: 5000,
		pause: 3000,
		hoverPause: true,
		effect: 'scrollLeft'
	});


// MAIN ROTATION


// DIV BOX



// IMPORT XML
// Financial
	$.get('ajax-content/merc_fin.xml', function(finTable){
		var container = document.getElementById("table_fin");
		$(finTable).find('cd').each(function(){
			var $cd = $(this);
			var theTitle = $cd.find('name').text();
			var theUnit = $cd.find('unit').text();
			var thePrice = $cd.find('price').text();

			var html = '<tr><td>' + theTitle + '</td>';
			html += '<td>' + theUnit + '</td>';
			html += '<td class="change">' + thePrice + '</td></tr>';
			
			$("#table_fin").append($(html));
			//alert(title);
		});
	});
	
// Environmental
	$.get('ajax-content/merc_enviro.xml', function(enviroTable){
		var container = document.getElementById("table_enviro");
		$(enviroTable).find('cd').each(function(){
			var $cd = $(this);
			var theTitle = $cd.find('name').text();
			var theUnit = $cd.find('unit').text();
			var thePrice = $cd.find('price').text();

			var html = '<tr><td>' + theTitle + '</td>';
			html += '<td>' + theUnit + '</td>';
			html += '<td class="change">' + thePrice + '</td></tr>';
			
			$("#table_enviro").append($(html));
			//alert(title);
		});
	});
	
// Environmental
	$.get('ajax-content/merc_energy.xml', function(energyTable){
		var container = document.getElementById("table_energy");
		$(energyTable).find('cd').each(function(){
			var $cd = $(this);
			var theTitle = $cd.find('name').text();
			var theUnit = $cd.find('unit').text();
			var thePrice = $cd.find('price').text();

			var html = '<tr><td>' + theTitle + '</td>';
			html += '<td>' + theUnit + '</td>';
			html += '<td class="change">' + thePrice + '</td></tr>';
			
			$("#table_energy").append($(html));
			//alert(title);
		});
	});

});


