function rotate(x, data){
	//reset everything
	//alert(x);//$("ul.clusters li a#epli"+x).text()!=$("ul.clusters li").eq(0).text());
	
	
	$("ul.clusters li a").animate({'color':'#999'},250);
	if ($("ul.clusters li a#epli"+x).text()==$("ul.clusters li").eq($("ul.clusters li").length-1).text()){
		$("ul.clusters li").eq($("ul.clusters li").length-1).hide(500,function(){
			$(this).prependTo($("ul.clusters")).show(250);
			$("ul.clusters li a#epli"+x).animate({'color':'#444'},500);
			});
	} else if ($("ul.clusters li a#epli"+x).text()!=$("ul.clusters li").eq(0).text()){
		$("ul.clusters li").eq(0).hide(500,function(){
			$(this).appendTo($("ul.clusters")).show(250);
			$("ul.clusters li a#epli"+x).animate({'color':'#444'},500);
			});
	} else {
			$("ul.clusters li a#epli"+x).animate({'color':'#444'},500);
	}
	var startHeight=$(".homepage").height();
	var xmldata=data;
	$(".reverse h5").removeClass("active");
	$("#next, #prev").remove();
	if(x==$("item", xmldata).length-1){nextx=0;} else {nextx=x+1;}//set the index for the next image
	if(x==0){prevx=$("item", xmldata).length-1;} else {prevx=x-1;}//set the index for the previous image
	$(".homepage").css({background:'url('+$("item:eq("+x+")", xmldata).find("image").text()+') no-repeat center   #eee'});
	$(".reverse").hide();
	$(".reverse").html("<h5><a id='itemtitle'>"+$("item:eq("+x+")", xmldata).find("subtitle").text()+"</a></h5>");
	if ($("item:eq("+x+")", xmldata).find("title").text() > ""){
		$(".reverse").prepend('<h3>'+$("item:eq("+x+")", xmldata).find("title").text()+'</h3>');
	}
	$(".reverse").append("<div id='itemwrapper'><div id='itemmedia'></div><div id='iteminfo'></div></div>");
	$("#itemwrapper").hide();
	$(".reverse").slideDown(400, function(){$("#gctwf").animate({bottom: $(".reverse").height()+10+"px"},300).css({zIndex:1000});});
	if($("item:eq("+x+")", xmldata).find("ajaxsrc").text().length==0 && $("item:eq("+x+")", xmldata).find("href").text().length>0){ $("#itemtitle").attr("href",$("item:eq("+x+")", xmldata).find("href").text()).append("&nbsp;<img src='/cgi-bin/images/reverse_nav_hide.gif' />");
	$("#play_link").attr("href",$("item:eq("+x+")", xmldata).find("href").text())	
	}
																				  
	if ($("item", xmldata).length>1){
		$(".homepage").append('<div id="next"><div id="next_img" style="background:url('+$("item:eq("+nextx+")", xmldata).find("image").text()+') no-repeat center  #eee; height:350px" ><img src="/cgi-bin/images/next_white.png"/></div></div>');
		$(".homepage").append('<div id="prev"><div id="prev_img" style="background:url('+$("item:eq("+prevx+")", xmldata).find("image").text()+') no-repeat center  #eee; height:350px" ><img src="/cgi-bin/images/prev_white.png"/></div></div>');
		$("#next").click(function(){
			$(".reverse").slideUp(600);
			$(".homepage").animate({height:startHeight}, 600);
			$("#next_img").html('<img src="/cgi-bin/images/prev_white.png"/>').animate({'width':$(".homepage").width()},600, function(){rotate(nextx, xmldata);});
		}); 
		$("#next").hover(function(){
				$("#next_img").animate({'width':100},300);
			},function(){
				$("#next_img").animate({'width':0},200);
			});
		$("#prev").click(function(){
			$(".reverse").slideUp(600);
			$(".homepage").animate({height:startHeight}, 600);
			$("#prev_img").html('<img src="/cgi-bin/images/next_white.png"/>').animate({'width':$(".homepage").width()},600, function(){rotate(prevx, xmldata);});
		}); 
		$("#prev").hover(function(){
				$("#prev_img").animate({'width':100},300);
			},function(){
				$("#prev_img").animate({'width':0},200);
			});
	}

}


