// JavaScript Document
$(document).ready(function(){
	// Handle the menu items in the bottom content area.
	$("#emotional-eating").click(function(e) {
		SetArticleContent(e, "/content/fat-loss-articles/overcome-emotional-eating.php", this)
	});
	
    $("#rebel-tricks").click(function(e) {
		SetArticleContent(e, "/content/fat-loss-articles/3-rebel-fat-loss-tricks.php", this);
	});
	
    $("#diets-fail").click(function(e) {
		SetArticleContent(e, "/content/fat-loss-articles/3-reasons-diets-fail-you.php", this);
	});
	
    $("#weight-loss-tricks").click(function(e) {
		SetArticleContent(e, "/content/fat-loss-articles/4-weight-loss-tricks.php", this);
	});
	
    $("#burn-fat").click(function(e) {
		SetArticleContent(e, "/content/fat-loss-articles/5-things-to-burn-fat.php", this);
	});
	//$("#rebel-tricks").click();	
});

function SetArticleContent(e, url, menuItem)
{
	e.preventDefault();
	
	$.ajax({ url: url, 
	   	context: document.body, 
	   	dataType: "html",
	   	processData: false,
	   	success: function(data){
		  	$("#article-content").html(data);
	   	},
	   	error:function(xhr,err,e){ 
	   		alert( "Error: " + err ); 
		}
	})
	
	currentTab = menuItem.id;
		
	var oldCurrent = $("#article-items").children(".article-item-selected");
	
	oldCurrent.removeClass('article-item-selected');
	
	//$(menuItem).removeClass('video-tab');
	$(menuItem).parent().addClass('article-item-selected');
	
	$('html, body').animate({
		scrollTop: $("#article-content").offset().top
	}, 500);
	
	var videoDiv = $("#video-menu");
	if (window.PausePlayer) {
		PausePlayer();
	}
}
