/******* homepage hero space *******/
var banner_loop = false;
var banner_delay = 10000;
var banner_next = 0;

var banner_controls_html = "";
$("#rotating_hero_frames div").each(function(index) {
	banner_controls_html += '<a href="javascript:swapHerospace('+index+');"><img src="/images/home_hero/home_hero_dot_on.png" width="11" height="11" id="rotating_hero_controls_'+index+'" alt="" /></a>';
});
$("#rotating_hero").prepend('<div id="rotating_hero_controls">'+banner_controls_html+'</div>');

var reload_swf_html = $("#rotating_hero_frames .first").html();

swapHerospace(0,1);

function swapHerospace(override_banner_next, speed){
	clearInterval(banner_loop);
	if(typeof(override_banner_next) != 'undefined'){
		banner_next = override_banner_next
	}
	if(typeof(speed) == 'undefined'){
		speed = 500
	}
	
	$("#rotating_hero_frames div").stop();
	$("#rotating_hero_controls img").stop();
	$("#rotating_hero_frames div").each(function(index) {
		if(index==banner_next){
			$(this).css('display','block');
			$(this).animate({opacity:1}, speed*2);
			$("#rotating_hero_controls_"+index).animate({opacity:1}, 500);
		}else{
			$(this).animate({opacity:0}, speed,
				function(){$(this).css('display','none');});
			$("#rotating_hero_controls_"+index).animate({opacity:0}, 500);
		}
	});
	banner_next = (banner_next+1)%($("#rotating_hero_frames div").length);
	banner_loop = setInterval("swapHerospace()", banner_delay);
}



/******* scrolling client logos *******/
var client_logos_elem = "#scroll_client_logos";
var client_logos_speed = 35000;
// scroll height + the window height to get set back to start, before adding duplicates
var client_logos_height = $(client_logos_elem)[0].scrollHeight;
//repeat logos so for smooth transition to top, bottom show until it matches top
$(client_logos_elem).html($(client_logos_elem).html()+$(client_logos_elem).html());
scrollupclientlogos();
function scrollupclientlogos(){
	$(client_logos_elem)[0].scrollTop = 0;
	$(client_logos_elem).animate(
		{scrollTop: '+='+client_logos_height}, 
		client_logos_speed, 'linear', 
		function(){scrollupclientlogos();/*memory hog?*/}
		);
}
$("#scroll_client_logos img").hover(
	function(){
		var t = $(this).attr("src");
		if(t.indexOf("-ro.png")<0){
			t = t.replace(".png","-ro.png");
		}
		$(this).attr("src", t);
	},
	function(){
		var t = $(this).attr("src");
		t = t.replace("-ro.png",".png");
		$(this).attr("src", t);
	}
);


/******* learn more button roll overs *******/
$("#homepage_hero_sub a img").hover(
	function(){
		var t = $(this).attr("src");
		if(t.indexOf("-ro.png")<0){
			t = t.replace(".png","-ro.png");
		}
		$(this).attr("src", t);
	},
	function(){
		var t = $(this).attr("src");
		t = t.replace("-ro.png",".png");
		$(this).attr("src", t);
	}
);
