
// COMMON: Load page in a new window; use class="new_window" on <a> tags
$(document).ready(function(){
	$("a.new_window").click(function(){
		w = window.open(this.href, 'new_window');
		return false;
	});
});

// COMMON: Awards box in column 1 is clickable
$(document).ready(function(){
	$("div.awards").css('cursor', 'pointer');
	$("div.awards").click(function(){
		location.href = http_base + '/historique/';
	});
});

// MANCHETTES: Rotate news items with images
var count = 0;
var index = 0;
var key = 0;

$(document).ready(function(){
	if (page == 'manchettes')
	{
		/* Set timer to rotate news stories */
		$.timer(6000, function(timer){
			if (count < 5){
				rotateStories();
				count++;
			}
		});
	}
});

function rotateStories()
{
	$.getJSON(http_base + '/ajax/manchettes/',
		{type: 1, index: index},
		function(json){
			index = json.index;
			key = json.key;
			
			$("#emplacement1 .wrap").fadeOut("slow", function(){
				$("#emplacement1 .wrap").html(json.content).fadeIn("slow");
			});

			$.get(http_base + '/ajax/manchettes/',
				{type: 2, key: key},
				function(html){
					$("#emplacement2").html(html);
				}
			);

		}
	);
}
