
var controller = {
	
	init:	function () {
				
				$('#mainMenu li, #leftPane-bottom div').hover(function () {
						$(this).addClass('hover');
					}, function () {
						$(this).removeClass('hover');
					});
					
				$('#btnAllgemeineInformationen').bind('click', function(event) {
						window.location.href = 'index.html';
					});
				$('#btnNeuigkeiten').bind('click', function(event) {
						window.location.href = 'neuigkeiten.html';
					});
				$('#btnLaufstrecke').bind('click', function(event) {
						window.location.href = 'laufstrecke.html';
					});
				$('#btnAnmeldung').bind('click', function(event) {
						window.location.href = 'anmeldung.html';
					});
				$('#btnLaufcup').bind('click', function(event) {
						window.location.href = 'laufcup.html';
					});
					
				$('#btnAusschreibung').bind('click', function(event) {
						window.location.href = 'index.html';
					});
					
					$('#btnHaftungsausschluss').bind('click', function(event) {
						window.location.href = 'haftungsausschluss.html';
					});
					
					$('#btnAnfahrt').bind('click', function(event) {
						window.location.href = 'anfahrt.html';
					});
					
					$('#btnErgebnisliste').bind('click', function(event) {
						window.location.href = 'ergebnisse.html';
					});
					
					$('#btnDownloads').bind('click', function(event) {
						window.location.href = 'downloads.html';
					});
					
					$('#btnBilder').bind('click', function(event) {
						window.location.href = 'bilder.html';
					});
					
					$('#btnUnterstuetzer').bind('click', function(event) {
						window.location.href = 'unterstuetzer.html';
					});
										

			}
		
};

$(document).ready(function() {
	controller.init();
});

var ImageFolder = "img"; //Folder name containing the images
var ImageFileNames = new Array("ad_001.png", "banner_maritim.png", "banner_sparkasse.png", "banner_infuracom.png", "ad_002.png", "ad_003.jpg"); 
var ImageFileNames_Footer = new Array("footer_ads.gif", "footer_ads.gif", "footer_ads.gif", "footer_ads.gif", "footer_ads.gif", "footer_ads.gif");

var ImageURLs = new Array('http://www.lauf-news.de/', 'http://www.maritim.de/de/hotels/deutschland/rhein-main-hotel-darmstadt', 'http://sparkasse-darmstadt.de/', 'http://www.infuracom.net/', 'http://bayram.seat.de/', 'http://www.pfungstaedter.de'); 
var DefaultURL = 'http://www.lauf-news.de'; 
var DisplayInterval = 6; //Number of seconds to wait before the next image is displayed
var TargetFrame = "blank"; //Name of the frame to open the hyperlink into

//Internal variables (do not change these unless you know what you are doing)
var IsValidBrowser = false;
var BannerAdCode = 0;
var BannerAdImages = new Array(NumberOfImages);
var DisplayInterval = DisplayInterval * 1000;
var NumberOfImages = ImageFileNames.length;

//Add a trailing forward slash to the ImageFolder variable if it does not already have one
if (ImageFolder.substr(ImageFolder.length - 1, ImageFolder.length) != "/" && ImageFolder != "") { ImageFolder += "/";
}

if (TargetFrame == '') {
var FramesObject = null;
} else {
var FramesObject = eval('parent.' + TargetFrame);
}

window.onload = InitialiseBannerAdRotator;


//Function runs when this page has been loaded and does the following:
//1. Determine the browser name and version  (since the script will only work on Netscape 3+ and Internet Explorer 4+).
//2. Start the timer object that will periodically change the image displayed by the Banner Ad.
//3. Preload the images used by the Banner Ad rotator script
function InitialiseBannerAdRotator() {

//Determine the browser name and version
//The script will only work on Netscape 3+ and Internet Explorer 4+
var BrowserType = navigator.appName;
var BrowserVersion = parseInt(navigator.appVersion);

if (BrowserType == "Netscape" && (BrowserVersion >= 3)) {
IsValidBrowser = true;
}

if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) {
IsValidBrowser = true;
}

if (IsValidBrowser) {

TimerObject = setTimeout("ChangeImage()", 3000);
BannerAdCode = 0;

for (i = 0; i < NumberOfImages; i++) {
BannerAdImages[i] = new Image();
BannerAdImages[i].src = ' ' + ImageFolder + ImageFileNames[i];

}

}

}

//Function to change the src of the Banner Ad image
function ChangeImage() {

if (IsValidBrowser) {
BannerAdCode = BannerAdCode + 1;

if (BannerAdCode == NumberOfImages) {
BannerAdCode = 0;
}
//window.document.bannerad.src = BannerAdImages[BannerAdCode].src;
if (document.getElementById("rightPane")!=null)
{
opacity("rightPane",0,100,500);
document.getElementById("rightPane").style.backgroundImage = "url(" + ImageFolder + ImageFileNames[BannerAdCode]  +")"; 
document.getElementById("footer").style.backgroundImage = "url(" + ImageFolder + ImageFileNames_Footer[BannerAdCode]  +")"; 
TimerObject = setTimeout("ChangeImage()", DisplayInterval);
}

}
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

//Function to redirect the browser window/frame to a new location,
//depending on which image is currently being displayed by the Banner Ad.
//If Banner Ad is being displayed on an old browser then the DefaultURL is displayed
function ChangePage() {

if (IsValidBrowser) {

if (TargetFrame != '' && (FramesObject)) {
FramesObject.location.href = ImageURLs[BannerAdCode];
} else {
document.location = ImageURLs[BannerAdCode];
}

} else if (!IsValidBrowser) {
document.location = DefaultURL;
}

}



