﻿jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
}; 

function changeSite(){
    var site = $("#dropdown_menu select option:selected").val();
    
    if(site == 'CFC Düsseldorf'){
        window.location = 'http://www.w-only.de/cityfitclub/';
    }else if(site == 'Woman Only'){
        window.location = 'http://www.w-only.de/';
    }else{
        
    }
}

$(document).ready(function() {
    
    notFirst = 0;

	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});

    $('#slider').after('<div id="nav" class="nav">').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 7000,
        pager: '#nav',
        before: onBefore
    });

    $("#dropdown_menu select").sb(); 
});           

function onBefore() {
    var this_title = $(this).find('a').attr('title');
    var this_p = $(this).find('img').attr("alt");
    var this_href = $(this).find('a').attr("href");  
    
    
    var this_p_head_split = this_p.split(' -- ');
    var this_p_head = "<strong>"+ this_p_head_split[0] +"</strong>";
    
    if(this_p_head_split[1] != undefined){
        var this_p_body = "<br /><br />" + this_p_head_split[1];
        var this_p = this_p_head + this_p_body;
    }else{
        var this_p = this_p_head;
    }
    
    
    if(notFirst == 1){
        $("#overlay span.link_slider a").attr("href", this_href);
        
        $("#overlay").find('h1').fadeOut(500, function(){
           $(this).html(this_title).fadeIn(500); 
        });
        
        $("#overlay").find('p').fadeOut(500, function(){
            $(this).html(this_p).fadeIn(500); 
        });
    }else{
        $("#overlay span.link_slider a").attr("href", this_href);
        $("#overlay").find('h1').html(this_title);
        $("#overlay").find('p').html(this_p);
        
        notFirst = 1;
    }
}

function top(){
    jQuery('html, body').animate({scrollTop:0}, 'slow');
}

