$(document).ready(function(){
	if($('#tourviewer').length > 0) { makeCycle("#tourviewer a"); }
	if($('#rotater').length > 0) {
		$('#rotater #images').cycle({ 
  	  fx:    'fade', 
  	  pause:  1 
		});
	}
	
	$(".featurelist>li:odd").addClass("odd");
	
	$(".quickfacts").css("display", "none");
	$("#facts_toggle").toggle(function(){
		$(".quickfacts").slideDown("slow");
		$(this).css("background-image", "url(./_media/interface/facts_arrowdown.gif)");
	}, function(){
		$(".quickfacts").slideUp("slow");
		$(this).css("background-image", "url(./_media/interface/facts_arrowup.gif)");
	});
});

function makeCycle($targets){

	$($targets).each(function(){
		$imageurl = $(this).attr("href");
		$imagecaption = $(this).text();
		
		$(this).empty().append('<img alt="'+$imagecaption+'" height="400px" src="'+$imageurl+'" />');
	});
	
	$("#tourviewer").cycle({ 
    fx:     'fade', 
    speed:  'slow', 
    timeout: 0,
    next: '#tournext',
    prev: '#tourprev',
    slideExpr: 'img',
    before: function(){ 
    	$("#tourcaption").empty().append($(this).attr("alt"));
    },
    delay: 5000
	});
}