jQuery(document).ready(function() {
	
	var x = 0;
	for( x==0; x <= rotation_items.length - 1 ; x++)
	{	
		var o = rotation_items[x];
		jQuery("#cimg"+x).html(o.thumb);
		jQuery("#rotation_main_image-"+x).html(rotation_items[x].thumb2);
		jQuery("#cimg"+x).css({"cursor":"pointer"});
		
	}
	jQuery("#thumb_container ul li").click( function() {
		clearInterval(timer);
		current_item=jQuery(this).attr("idx")-1;
		rotate(99);
		jQuery("#thumb_container ul li img").removeClass("cm_WhiteborderON");
		jQuery(this).find("img").addClass("cm_WhiteborderON");
		timer = setInterval("rotate(99)", 11000);
	});
	rotate(99);
	timer = setInterval("rotate(99)", 11000);
	jQuery("#rotator_container").css({"visibility":"visible"});
});
var timer;
var current_item = -1;
function rotate(intItem) {
	if (intItem != 99) current_item = intItem;
	jQuery("#cimg"+current_item+" img").removeClass("cm_WhiteborderON");
	jQuery("#rotation_main_image-0").hide();
	jQuery("#rotation_main_image-1").hide();
	jQuery("#rotation_main_image-2").hide();
	jQuery("#rotation_main_image-3").hide();
	current_item +=1;
	if (current_item > rotation_items.length - 1) current_item=0;
	jQuery("#cimg"+current_item+" img").addClass("cm_WhiteborderON");
	jQuery("#rotation_main_image-"+current_item).fadeIn("fast");
	jQuery("#plat-overlay p").html(rotation_items[current_item].title);
	jQuery("#rotTitle").html(rotation_items[current_item].title);
	jQuery("#rotDate").html(rotation_items[current_item].date);
	jQuery("#rotExcerpt").html(rotation_items[current_item].excerpt);
	jQuery("#rotReadmore1").attr("href",rotation_items[current_item].permalink);
	jQuery("#rotReadmore2").attr("href",rotation_items[current_item].permalink);
	
	
}
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}
