var bg0 = 'images/intro/bg_intro.jpg';
var bg1 = 'images/start/bg_start.jpg';
var bg2 = 'images/munich/bg_munich.jpg';
var bg3 = 'images/berlin/bg_berlin.jpg';
var bg4 = 'images/dortmund/bg_dortmund.jpg';
var bg5 = 'images/hamburg/bg_hamburg.jpg';
var bg6 = 'images/frankfurt/bg_frankfurt.jpg';
var bg7 = 'images/impressum/bg_impressum.jpg';


var lastKey = 0;

jQuery(document).ready(function($) {

/*	
	jQuery('#contentListXXX').jcarousel({
		vertical: true,
		scroll: 1,
        visible: 1,
        animation: 'slow',
        initCallback: mycarousel_initCallback,
        itemFirstInCallback: {
  			//onAfterAnimation: callback_setScreenTitle
		},
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
*/  
    
   
    
    var actObj = '';
    jQuery('#menu a.menuLink, #impressum').bind('click', function() {
    	
    	//alert(jQuery(this + " IMG"))
    	
		var thisImg = jQuery(this).html();
		thisImg = thisImg.replace(/_lo/g,"_hi");
		jQuery(this).html(thisImg);

		if(actObj) {
			var actImg = jQuery(actObj).html();
			actImg = actImg.replace(/_hi/g,"_lo");
			jQuery(actObj).html(actImg);
		}
		actObj = jQuery(this);
	


		var key = jQuery(this).attr("accesskey");
    	
    	
    	// Hintergrund austauschen
    	jQuery("#allBackground").animate({ 
				opacity: 'hide'
		}, 500, function() {
    		$("#allBackground").css("background-image","url(" + eval('bg' + key )+ ")");
    		
    		jQuery("#allBackground").animate({ 
				opacity: 'show'
		}, 500);
		
  		});
				
		
		window.setTimeout("reloadContent(" + key + ")", 100);
		//alert(actObj)
		initRollover(key);
		
		return false;
		
    });
    
    
    initRollover();
	
	
	introTimer = window.setTimeout("intro()", 5000);
    
     

});


function initRollover(key){

	//alert(jQuery(actObj).html());

	 // Rollover für Menu
    $("#menu a.menuLink IMG").hover(function(){
    	//alert(this.src);
    	
    	//alert(jQuery(this).parent().attr("accesskey"));
    	
    	
    	thisKey = jQuery(this).parent().attr("accesskey");

    	//alert(key + ' -- ' + thisKey);
    	
    	if(key != thisKey){
			this.src = this.src.replace("_lo","_hi");
		}
	}, function() {
	
		thisKey = jQuery(this).parent().attr("accesskey");
		
		if(key != thisKey){
			this.src = this.src.replace("_hi","_lo");
		}
	});
	
}


function intro() {

	window.clearTimeout(introTimer);


	reloadContent(1);
	
	jQuery("#menu").animate({ 
		opacity: 'show'
	}, 500);
	$("#allBackground").css("background-image","url(" + eval("bg1")+ ")");
	lastKey = 1;
	
}


function reloadContent(key){

		// Contentelemente für Home aus- oder einblenden		
    	if(key >= 2){
		
			jQuery("#contentHome").animate({ 
				opacity: 'hide'
			}, 500);
		
			jQuery("#homeLinkFB").animate({ 
				opacity: 'hide'
			}, 100);
			
			jQuery("#homeLink").animate({ 
				opacity: 'show'
			}, 300);
		
		} else {
	
			jQuery("#homeLink").animate({ 
				opacity: 'hide'
			}, 100);
			
			
			jQuery("#contentHome").animate({ 
				opacity: 'show'
			}, 300);
		
			jQuery("#homeLinkFB").animate({ 
				opacity: 'show'
			}, 500);
			
			
		}


		
    	// Content/alt ausblenden
		jQuery("#contentItem" + lastKey).animate({ 
				opacity: 'hide'
		}, 500);
		
		// Content/neu einblenden
		jQuery("#contentItem" + key).animate({ 
				opacity: 'show'
		}, 300);
		
		
		lastKey = key;



}


/*
function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("accesskey")));
        
        
       
		
		
		jQuery("#allBackground").animate({ 
				opacity: 'hide'
		}, 500);
		
		$("#allBackground").css("background-image","url(" + eval('bg' + jQuery(this).attr("accesskey") )+ ")");
		
		
		jQuery("#allBackground").animate({ 
				opacity: 'show'
		}, 500);
		
		if(jQuery(this).attr("accesskey") >= 2){
		
			 jQuery("#contentHome").animate({ 
				opacity: 'hide'
			}, 500);
		
			jQuery("#home").animate({ 
				opacity: 'show'
			}, 500);
		
		} else {
		
		
			jQuery("#contentHome").animate({ 
				opacity: 'show'
			}, 500);
		
			jQuery("#home").animate({ 
				opacity: 'hide'
			}, 500);
		}
		
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });

};
*/