(function($) 
{   
    $.extend($.fx.step,
    {       
        backgroundPosition: function(fx) 
        {            
            if (fx.state === 0 && typeof fx.end == 'string') 
            {
                if(navigator.appName == 'Microsoft Internet Explorer')
                {
                    var start = $.curCSS(fx.elem,'backgroundPositionX');
                    start +=  ' ';
                    start += $.curCSS(fx.elem,'backgroundPositionY');
                }
                else
                {
                    var start = $.curCSS(fx.elem,'backgroundPosition');
                }
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
            }

            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

            function toArray(strg)
            {               
                strg = strg.replace(/left|top/g,'0px');
                strg = strg.replace(/right|bottom/g,'100%');
                strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
                var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
                return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
            }        
        }   
    });
})(jQuery);


// Suchtext ersetzen
jQuery(document).ready(function(){
    $("#search").focus(function() {
        $(this).attr("value","");
    });
});


// SPOT
$('a#video_save').hover(function() {
    $('#video-overlay').stop().animate({
        width: '20px'
    }, 300);
	$('#video-play').fadeIn(300);

},function() {
    $('#video-overlay').stop().animate({
        width: '149px'
    }, 300);
    $('#video-play').fadeOut(300);
	
});


$("#video_save").colorbox({iframe:true, innerWidth:640, innerHeight:360});

//Franchise Anzeige
$(".spalte-overlay-save-franchise").colorbox({rel:"anzeige", current:"{current} von {total}"});

//Franchise Flyer
$(".spalte.franchise a").colorbox({rel:"flyer", current:"{current} von {total}"});

$(".spalte.franchise .einverstaendnis1").colorbox({rel:"a5"});

$(".spalte.franchise .ueberweisung1").colorbox({rel:"ueber"});

$(".spalte.franchise .express1").colorbox({rel:"express"});
$(".spalte.franchise .rauchfrei1").colorbox({rel:"rauchfrei"});
$(".spalte.franchise .studio1").colorbox({rel:"studio"});
$(".spalte.franchise .coupon1").colorbox({rel:"coupon"});
$(".spalte.franchise .logo1").colorbox({rel:"logo"});
$(".spalte.franchise .ablauf1").colorbox({rel:"ablauf"});



$('#bestellen-franchise').hide();
$('.buttonfr').click(function () {
    
    var produktnr = $(this).prev().prev().children().next().text();
    
    $('input.produktnummer').attr('value', produktnr);
    
    $('#bestellen-franchise').fadeIn();
    
    
    });
    
$('#closed').click(function () {
    
    $('#bestellen-franchise').fadeOut();
    
    
    });





//Berlin Mahlsdorf
$(".spalte-overlay-save.berlin-mahlsdorf").colorbox({iframe:true, innerWidth:640, innerHeight:360});

$(".spalte-overlay-save.map-berlin-mahlsdorf").colorbox({inline:true, width:"640", height:"360"});

//Berlin Steglitz
$(".spalte-overlay-save.berlin_steglitz").colorbox({rel:'berlin-steglitz'});

$(".spalte-overlay-save.map_berlin_steglitz").colorbox({inline:true, width:"640", height:"360"});

//Cottbus
$(".spalte-overlay-save.cottbus").colorbox({rel:'cottbus'});

$(".spalte-overlay-save.map-cottbus").colorbox({inline:true, width:"640", height:"360"});

//Schwerin
$(".spalte-overlay-save.schwerin").colorbox({rel:'schwerin'});

$(".spalte-overlay-save.map-schwerin").colorbox({inline:true, width:"640", height:"360"});
//Hamburg
$(".spalte-overlay-save.hamburg").colorbox({rel:'hamburg'});

$(".spalte-overlay-save.map-hamburg").colorbox({inline:true, width:"640", height:"360"});
//Rostock
$(".spalte-overlay-save.rostock").colorbox({rel:'rostock'});

$(".spalte-overlay-save.map-rostock").colorbox({inline:true, width:"640", height:"360"});

//Feldberg
$(".spalte-overlay-save.feldberg").colorbox({rel:'feldberg'});

$(".spalte-overlay-save.map-feldberg").colorbox({inline:true, width:"640", height:"360"});

//Leipzig
$(".spalte-overlay-save.leipzig").colorbox({iframe:true, innerWidth:640, innerHeight:360});

$(".spalte-overlay-save.map-leipzig").colorbox({inline:true, width:"640", height:"360"});


//Dresden
$(".spalte-overlay-save.dresden").colorbox({iframe:true, innerWidth:640, innerHeight:360});

$(".spalte-overlay-save.map-dresden").colorbox({inline:true, width:"640", height:"360"});

// Hot Link

$('a.hot-link-overlay-save').hover(function() {
    
    var bewegung = false;
    $(this).next().animate({
        height: '3px',
        paddingTop: '0px',
        paddingBottom: '0px',
        opacity: '0'
    }, 100, function() {
       
       $(this).animate({
        height: '12px',
        paddingTop: '6px',
        paddingBottom: '6px',
        opacity: '1'
    }, 100);
  }).delay(100).queue(function(more) {
    if(bewegung == true) return false;
        
        $(this).html("Mehr <strong>Erfahren</strong>");
        more();
  });  
},function() {    
    $(this).next().stop().animate({
        height: '3px',
        paddingTop: '0px',
        paddingBottom: '0px',
        opacity: '0'
    }, 100, function() {
       $(this).animate({
        height: '12px',
        paddingTop: '6px',
        paddingBottom: '6px',
        opacity: '1'
    }, 100);
  }).delay(100).queue(function(less) {
        
            
        var title = $(this).attr("title");
        $(this).html(title);

        less();
  });
});






    

    
    



$('input.feld33').click(function() {
 
    var vornachname = $('.besteller').children().attr('value');  
    $('.vornachname').html(vornachname);
    
    var strasse = $('.strnr').children().attr('value'); 
    var nr = $('.strnr').children().next().attr('value'); 
    $('.strasse-nummer').html(strasse + ' ' + nr);
    
    var plz = $('.plzort').children().attr('value');  
    var ort = $('.plzort').children().next().attr('value');  
    $('.plz-ort').html(plz + ' ' + ort);

    var email = $('.maille').children().attr('value');  
    $('.email').html(email);

    var telefonnummer = $('.nummero').children().attr('value');  
    $('.telefonnummer').html(telefonnummer);

    var anmerkungen = $('.texte').children().attr('value');  
    $('.anmerkungen').html(anmerkungen);

    var wunschstandort = $('.wuensche option:selected').text();    
    $('.wunschstandort').html(wunschstandort);

    var entwoehnung = $('.rauchen1 option:selected').text(); 
    $('.entwoehnung').html(entwoehnung);

    var balance = $('.rauchen2 option:selected').text(); 
    $('.balance').html(balance);




 
  $('#bestaetigung').fadeIn();  
    
});

$('#bestaetigung #closed').click(function () {
    
    $('#bestaetigung').fadeOut();
    
    
    });

$('.aendern').click(function () {
    
    $('#bestaetigung').fadeOut();
    
    
    });    
    

// SPALTE 


$('a.spalte-overlay-save').hover(function() {
    

    $(this).stop().next().children().animate({
        backgroundPosition:"(210px 0px)",
        paddingLeft: '0px',
        paddingRight: '25px'
        
    }, 200);
		

},function() {
    $(this).stop().next().children().animate({
        backgroundPosition:"(0px 0px)",
        paddingLeft: '15px',
        paddingRight: '0px'
    }, 200);
	

});


// STANDORTE 


$('a.spalte-overlay-save-standort').hover(function() {
    

    $(this).stop().next().children().animate({
        backgroundPosition:"(210px 0px)",
        paddingLeft: '0px',
        paddingRight: '25px'
        
    }, 200);
		

},function() {
    $(this).stop().next().children().animate({
        backgroundPosition:"(0px 0px)",
        paddingLeft: '15px',
        paddingRight: '0px'
    }, 200);
	

});



// HYPERLINK 
$('a.more').hover(function() {
    $(this).stop().animate({
        backgroundPosition:"(130px 0px)",
        paddingLeft: '0px'
    }, 200);
		

},function() {
    $(this).stop().animate({
        backgroundPosition:"(0 0px)",
        paddingLeft: '40px'
    }, 200);
	
});

$('.seite-left> a.more2').hover(function() {
    $(this).stop().animate({
        backgroundPosition:"(100px 0px)",
        paddingLeft: '0px'
    }, 200);
		

},function() {
    $(this).stop().animate({
        backgroundPosition:"(0 0px)",
        paddingLeft: '40px'
    }, 200);
	
});

$('.seite-left> a.more3').hover(function() {
    $(this).stop().animate({
        backgroundPosition:"(175px 0px)",
        paddingLeft: '0px'
    }, 200);
		

},function() {
    $(this).stop().animate({
        backgroundPosition:"(0 0px)",
        paddingLeft: '40px'
    }, 200);
	
});


function MainMenu() {
	this.navLi = $("#navigation> ul> li").children('ul').hide().end();
	
	this.navLi.hover(function() {
		// Mouse over
		$(this).find('> ul').stop(true, true).fadeIn(200);
	}, function() {
		// Mouse out
		$(this).find('> ul').stop(true, true).fadeOut(200);
	});
}

$(document).ready(function() {
	// Activate the menu
	MainMenu();
	
	
});



// Content SLIDEDOWN 	
	

	$(document).ready(function(){        
        
        var sliderHeightRight = 360;
        $('.slidedown').each(function () {
					var currentRight = $(this);
					currentRight.attr("box_h", currentRight.height());
				}
		 );	
		
        $(".slidedown").css("height", sliderHeightRight);		
		
        $(".seite-komplettt.slidedown> .slider").html('<a class="mehr">Mehr</a>');
		
        $(".seite-komplettt.slidedown> .slider a").click(function() { openSliderRight() });
	});

    
    function openSliderRight()
	{
		var open_height = $(".slidedown").attr("box_h") + "px";
		$(".slidedown").animate({"height": open_height}, {duration: "slow" });	

        $('p.hinweis-laser').fadeIn();
		$(".seite-komplettt.slidedown> .slider").html('<a class="weniger">Weniger</a>');	
        $(".slidedown> .slider a").click(function() { closeSliderRight() });
	}
	
	function closeSliderRight()
	{
        var sliderHeightRight = 360;
		$(".slidedown").animate({"height": sliderHeightRight}, {duration: "slow" });	
        $('p.hinweis-laser').fadeOut();
		$(".seite-komplettt.slidedown> .slider").html('<a class="mehr">Mehr</a>');		
        $(".slidedown> .slider a").click(function() { openSliderRight() });
	}
    

