// JavaScript Document

$(document).ready( function(){
		

	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                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]];
           }
		} });

		$(window).load(function(){ 
			var cntnt_mHeight = $('#sidebar').height() - 308;
			$('#content').css('min-height',cntnt_mHeight);
		});

		var crrnt_H = $('#wrapper').height()  - ($('#wrap_right').height() + $('#footer').height());
//		console.log($('#wrapper').height())
//		console.log(crrnt_H)
		var last_H = crrnt_H + $('.wp_weather').height() - 40;
//		console.log(last_H)
		$('.wp_weather').height(last_H); 
		// $('#sidebar div:last-child').css('height',finalH)
		
		i = 0;
		
		$("ul#main-menu > li").each( function(){
	            i++;
		 		$(this).addClass('bg_slide_'+i);
				
		});
	
		// $("#header").css({backgroundPosition: "0 0"});
		
		$(".bg_slide_1").mouseover(function(){
			$("#header").stop().animate({backgroundPosition:"(0px 0px)"}, 200);
						 });
	
		$(".bg_slide_2").mouseover(function(){
			$("#header").stop().animate({backgroundPosition:"(-733px 0px)"},200);
						 });
	
		$(".bg_slide_3").mouseover(function(){
			$("#header").stop().animate({backgroundPosition:"(-1465px 0px)"}, 200);
						 });
		
		$(".bg_slide_4").mouseover(function(){
			$("#header").stop().animate({backgroundPosition:"(-2199px 0px)"}, 200);
						 });
				
		$(".bg_slide_5").mouseover(function(){
			$("#header").stop().animate({backgroundPosition:"(-2932px 0px)"}, 200);
						 });

		$('#slide_sidebarform').click(function(){
			$(this).next('.wpcf7').stop().slideToggle();								   
	   	});

		$('#toggle_login').click(function(e){
			e.preventDefault();
			$(this).next('#login').slideToggle(100);								   
	   });
		
		
		// KONTAKTDATEN 
		$('.shop-daten').hide();
		$('a.daten-show').click(function(e){
			e.preventDefault();
			$(this).next('.shop-daten').toggle();			 
		});
});
