$(document).ready(function() 
{
$('#MTincludeSS').css("background-color",'');
$('#MTincludeRA').css("background-color",'');
ShowSlideShow();
ShowRelatedArticle();

	if($.cookie('rating_cookie_' + $('#entry_id').text()))
	{
		var message = '<img src="/images/icon-thumbs-up-grey.jpg" align="absmiddle" />  Thank you.';
		
		$('#recommend_wrapper').html(message);
		$('#recommend_wrapper_bottom').html(message);
	}	
	
	$('#recommend_link').click(function() 		 {UpdateEntryRecommedationCount();});
	$('#recommend_link_bottom').click(function() {UpdateEntryRecommedationCount();});	
	
	UpdateEntryViews();	
	

	
});


function ShowSlideShow()
{


	$.ajax({
		type: 'GET',
		async: false,
		url: '/ajax/slideshow.php',
		data: 'entry_id=' + $('#entry_id').text(),
		success: function(data) {
		if(data==0)
		{
		$('#MTincludeSS').hide();
		}else
		{
		
		
		
		$('#MTincludeSS').html(data);
		}
		}
	});		
}


function ShowRelatedArticle()
{
	$.ajax({
		type: 'GET',
		async: false,
		url: '/ajax/relatedarticle.php',
		data: 'entry_id=' + $('#entry_id').text(),
		success: function(data) {
		if(data==0)
		{
		$('#MTincludeRA').hide();
		}else
		{
		
		
		
		$('#MTincludeRA').html(data);
		}
		}
	});	
}


function UpdateEntryViews()
{
	// Update entry views
	$.ajax({
		type: 'GET',
		cache:false,
		url: '/ajax/update_entry_views.php',
		data: 'entry_id=' + $('#entry_id').text(),
		success: function(data) {}
	});		
}

function UpdateEntryRecommedationCount()
{
	// Set a cookie for the current entry
	$.cookie('rating_cookie_' + $('#entry_id').text(), 'rating_value_' + $('#entry_id').text(), { expires: 7 });
	
	// Update entry recommendation count
	$.ajax({
		type: 'GET',
		cache:false,
		url: '/ajax/update_recommendation_count.php',
		data: 'entry_id=' + $('#entry_id').text(),
		success: function(data)
		{
			var message = '<img src="/images/icon-thumbs-up.jpg" align="absmiddle" /> Thank you.';
		
			$('#recommend_wrapper').html(message);
			$('#recommend_wrapper_bottom').html(message);
		}
	});		
}
