var navbg = new Image();
var navbgend = new Image();
navbg.src = '/i/nav-link-bg.gif';
navbgend.src = '/i/nav-link-bg-end.gif';

var xml;
var item;
var item_count;
var item_interval;
var current_item = 0;
var old_item = 0;
var top;

$('document').ready(function() {
	
	$('body#home > #header > #intro').css('cursor','pointer');
	$('body#home > #header > #intro').attr('title','Read more about Chandos House');
	$('body#home > #header > #intro').click(function(){ window.location = '/about/'; });

	if($('body#home').length==1) {
		$.ajax({
			type: "GET",
			url: "/rss/?section=testimonials&category=on-rotation",
			success: function(data) {
				$("#testimonials").click(function(){window.location = '/testimonials/'; });
				$("#testimonials").css('cursor','pointer');
				$("#testimonials").attr('title','Read more about what the residents of Chandos say');
				xml = data;
				item_count = $("item",xml).length;
				rotate_item();
				item_interval = setInterval(rotate_item, 10000);
			}
		});
	}
});

function rotate_item() {
	$("#testimonials").children().remove();
	item = $("item > description",xml).eq(current_item).text();
	$(item).appendTo("#testimonials").fadeIn('slow');
	top = 45 - ($("#testimonials > blockquote").height()/2) + 'px';
	$("#testimonials > blockquote").css('top', top);
	current_item = (old_item + 1) % item_count;
	old_item = current_item;
}

window.onunload = function(){ clearInterval(item_interval); }