$(document).ready(function(){

	$("div.text_change a.c1").live('click', function(){

		fontSize($(this).attr('rel'), 'plus');
		return false;
	});
	$("div.text_change a.c2").live('click', function(){
		fontSize($(this).attr('rel'), '');
		return false;
	});


	if ($('#prev_photo').length || $('#next_photo').length) {
		$(document).keydown(function(e){
			if (e.keyCode == 37 && $('#prev_photo').length) {
				window.location.href = $('#prev_photo').attr('href');
			} else if (e.keyCode == 39 && $('#next_photo').length) {
				window.location.href = $('#next_photo').attr('href');
			}
		});
	}
});


if (typeof FB != 'undefined' && typeof recommends_config != 'undefined')
{
	FB.init({appId: recommends_config.app_id, status: true, cookie: true, xfbml: true});
	FB.Event.subscribe('edge.create', function(response)
	{
		$.ajax({
			url: recommends_config.url,
			success: function(data)
			{
				if (data == 1)
				{
					var id = '#recommends_' + recommends_config.article_id;

					$('.recommends').html(parseInt($(id).html()) + 1);
					$(id).addClass('visited');
				}
			}
		});
	});
}


function fontSize(target, action) {
	obj = document.getElementById(target);
	current = obj.className;
	size = parseInt(current.charAt(1) + current.charAt(2));

	if (action == 'plus'){
 		size = size + 1;
		if (size > 11) return;
	}
 	else{
  		size = size - 1;
 		if (size <= 0) return;
 	}

  	obj.className = "s" + size;
}
