$homeslideshow = {
    context: false,
    tabs: false,
    timeout: 10000,      // time before next slide appears (in ms)
    slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 300,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'scrollLeft',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#homeslider');
        
        // set tabs to current hard coded navigation items
        this.tabs = $('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.slides > ul', $homeslideshow.context).cycle({
            fx: $homeslideshow.fx,
            timeout: $homeslideshow.timeout,
            speed: $homeslideshow.slideSpeed,
            fastOnEvent: $homeslideshow.tabSpeed,
            pager: $('ul.slides-nav', $homeslideshow.context),
            pagerAnchorBuilder: $homeslideshow.prepareTabs,
            before: $homeslideshow.activateTab,
            pauseOnPagerHover: true,
			next:   '#nextHome', 
			prev:   '#previousHome',
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $homeslideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('a[href="#' + nextSlide.id + '"]', $homeslideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $homeslideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};

function IE7Alert() {
	var is_ie7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
	
	if(is_ie7 == true) {
		alert('Diese Funktion ist aufgrund Kompatiblit\u00e4tsproblemen f\u00fcr den Internet Explorer 7 deaktiviert.');
	}
}

$(function() {
    // add a 'js' class to the body
    $('body').addClass('js');
	//setInterval("alert('" + window.location + "');", 5000);
    setInterval("$('" + window.location.hash + "').addClass('active');", 1000);
    // initialise the slideshow when the DOM is ready
    $homeslideshow.init();
    Shadowbox.init();

	// Internet Explorer Fix
	$("#design #designtable td.navigation ul li ul.submenu li:last-child").css("background-position", "0 100%");
	$("#design #designtable td.navigation ul li ul.submenu li:last-child").css("height", "40px");
	$("#design #designtable td.navigation ul li ul.submenu li:last-child").css("border", "none");
	$("#design #designtable td.navigation ul li ul.submenu li:last-child span").css("border","none");

});
