function loadImg(varurl,targetID) {
	var url = varurl;
	var img = new Image();
	$(img).load(function () {
		$(this).css('display', 'none');
		$(this).hide();
		$('#' + targetID).removeClass('loading').html(this);
		$(this).fadeIn();
	}).error(function () {
		//alert("Es ist ein Fehler beim laden aufgetreten");
	}).attr('src', "http://triathlon.commerzbank.de/" + url);
};

function GetRandom( min, max ) {
	if( min > max ){
		eturn( -1 );
	}
	if( min == max ){
		return( min );
	}
	return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

 var headline_count;
 var headline_interval;
 var old_headline = 0;
 var current_headline = 0;
 
function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 

$("div.headline:eq(" + old_headline + ")").animate(
	{top: -99}, 
	1000, 
	"easeout", 
	function(){
		$(this).css('top','210px');
	}
);
	
	
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},{duration: 1000, easing: 'easeout'});
   old_headline = current_headline;
 }




$(document).ready(function(){	
		if(document.getElementById("rspAthl")!=null){
			var athpref = "athlrsp_";
			var anzahl = 8;
			var rand = GetRandom(1,anzahl);
			var newRand = 1;
			loadImg($("#" + athpref + rand).attr("href"),"rspAthl");
			$("a#prevAth").click( function(){ 
					while(rand==newRand) newRand = GetRandom(1,anzahl);
					rand = newRand;
					url = $("#" + athpref + rand).attr("href");
					loadImg(url,"rspAthl"); 
			});
			$("a#nextAth").click( function() { 
					while(rand==newRand) newRand = GetRandom(1,anzahl);
					rand = newRand;
					url = $("#" + athpref + rand).attr("href");
					loadImg(url,"rspAthl");
			});
		}
	
	
	headline_count = $("#scrollup div.headline").size();
   $("#scrollup div.headline:eq("+current_headline+")").css('top','5px');
 
   headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
   $('#scrollup').hover(function() {
     clearInterval(headline_interval);
   }, function() {
     headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
     //headline_rotate();
   });
	
	
	$(window).bind("load", function() {
		$("div#mygalone").slideView({
			easeFunc: "easein",
			easeTime: 400,
			backCon: "#back",
			nextCon: "#next"
		}); 
		
		$("div#persSlide").slideView({
			easeFunc: "easein",
			easeTime: 400,
			displayImages: 1,
			pictHeight: 186,
			pictWidth: 501,
			nextCon: "#nextone",
			backCon: "#backone",
			ContainerClass: ".personenSlide"
		});				
		
	});
	FontJazz.apply("h3", "font"); 
	
});
function getFlashMovie(movieName) {   
	var isIE = navigator.appName.indexOf("Microsoft") != -1;   
	return (isIE) ? window[movieName] : document[movieName];  
} 
function getTimezone( param ){
	var d = new Date();
	var gmtHours = -d.getTimezoneOffset()/60;
	getFlashMovie(param).sendTimezoneToFlash(gmtHours);
}	