$(function() {

		var isPage = $('body').attr('id');
		console.log(isPage);
		var windowWidth = $(window).width();

		$(window).resize(function() {
			windowWidth = $( window ).width();
		});

		switch(isPage){
			//o-nas
		    case 'about-us':
			    	$('#about-us .menu .row nav ul li a').click(function(e){
						e.preventDefault();
						$('#about-us .menu .row nav ul li a').removeClass('active');
						$(this).addClass('active');

						var clickedTab = $(this).data();
						$('.our-approach,.experts,.press-room,.career').hide();
						$('.'+clickedTab.tab).show();

						var headerTitle = '';
						var headerSeoTitle = '';
						var headerDesc = '';
						var containers = '#about-us .menu, .our-approach,.experts,.press-room,.career';

						$(containers).removeClass('black');
						switch(clickedTab.tab) {
							case 'our-approach':
								headerTitle = _lang.philosophy;
			    				headerDesc  = _lang.przeczytaj_czym_rozni;

			    				headerSeoTitle = _lang.seo_title_philosophy;
							break;
							case 'experts':
								$(containers).addClass('black');
								headerTitle = _lang.experts;
								headerDesc  = _lang.wysoka_jakosc_produktow;
								headerSeoTitle = _lang.seo_title_experts;
							break;
							case 'press-room':
								headerTitle = _lang.press_room;
								headerDesc  = _lang.w_tej_sekcji_mozesz_pobrac;
								headerSeoTitle = _lang.seo_title_press_room;
							break;
							case 'career':
								headerTitle = _lang.career;
								headerDesc  = _lang.tutaj_znajdziesz_aktualne_ogloszenia;
								headerSeoTitle = _lang.seo_title_career;
							break;
						}

						$('#about-us .menu .row header h2').text(headerTitle);
						$('#about-us .menu .row header p').html(headerDesc);
						document.title = headerSeoTitle;
					});


			    //320:667

			    if(windowWidth >= 320 && windowWidth <= 667){
			    	//filozofia
			    	$(".our-approach .philosophy .col.img").clone().appendTo(".our-approach .philosophy .col.txt h3");
			    	$(".our-approach .philosophy > .col.img").remove();

			    	$(".our-approach .mark-out .col.video").clone().appendTo(".our-approach .mark-out .col.txt h3");
			    	$(".our-approach .mark-out > .col.video .video-responsive").remove();

			    	$(".innovation .col.img").clone().appendTo(".innovation .col.txt h4");
			    	$(".innovation > .col.img").remove();

			    	$(".trust .col.img").clone().appendTo(".trust .col.txt h4");
			    	$(".trust > .col.img").remove();

			    	$(".complex .col.img").clone().appendTo(".complex .col.txt h4");
			    	$(".complex > .col.img").remove();

			    	$(".row.difference .col.video").clone().appendTo(".row.difference .col.txt h3");
			    	$(".row.difference > .col.video").remove();

			    	$(".row.expect .col.img").clone().appendTo(".row.expect .col.txt h3");
			    	$(".row.expect > .col.img").remove();

			    	//career
			    	$(".career .col.video .video-responsive").clone().appendTo(".career .col.txt h3");
			    	$(".career .col.video > .video-responsive").remove();
			    }

			    if(windowWidth >= 768 && windowWidth <= 1024){
			    	$(".our-approach .philosophy .col.txt h3").clone().prependTo(".our-approach article");
			    	$(".our-approach .philosophy .col.txt h3").remove();

			    	$(".our-approach .mark-out .col.video").clone().appendTo(".our-approach .mark-out .col.txt h3");
			    	$(".our-approach .mark-out > .col.video .video-responsive").remove();

			    	$(".row.difference .col.video").clone().appendTo(".row.difference .col.txt h3");
			    	$(".row.difference > .col.video").remove();

			    	$('#about-us .experts .row.expect .col.txt h3').clone().prependTo("#about-us .experts .row.expect");
			    	$('#about-us .experts .row.expect .col.txt h3').remove();

			    	$(".career .col.video .video-responsive").clone().appendTo(".career .col.txt h3");
			    	$(".career .col.video > .video-responsive").remove();
			    }



		    break;
		    case 'salons-offices':
		    	var a=$("form");$(a).validate({errorPlacement:function(a,b){},submitHandler:function(b){var c="./includes/freshdesk/add.php";return $.ajax({type:"POST",url:c,data:a.serialize(),success:function(a){$("form").hide(),$("h6").html("<img src='img/svg/bullet-black.svg'> "+_lang.thankYouMsg+'<span>'+_lang.skontaktujemy_sie_z_toba+'</span>'),$('.row.title').css('margin-bottom',0),$('.row.form').css('background','#fff')}}),!1}})

		    $('a[href*="#"]:not([href="#"])').click(function() {
				    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
				      var target = $(this.hash);
				      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
				      if (target.length) {
				        $('html, body').animate({
				          scrollTop: target.offset().top
				        }, 1000);
				        return false;
				      }
			}});

		    break;
				case 'contact':
				$('.thankYou').hide();
					var a=$("form");$(a).validate({errorPlacement:function(a,b){},submitHandler:function(b){return $.ajax({type:"POST",data:a.serialize(),success:function(a){$("form").hide(),	$('.thankYou').show();}}),!1}})

				$('a[href*="#"]:not([href="#"])').click(function() {
						if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
							var target = $(this.hash);
							target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
							if (target.length) {
								$('html, body').animate({
									scrollTop: target.offset().top
								}, 1000);
								return false;
							}
			}});

				break;
				case 'onlinestore':

				var lColFixed = $('#fxD').offset();
				if(windowWidth > 768){
				$(window).scroll(function(){
//					console.log(lColFixed);
					if($(window).scrollTop() > lColFixed.top){
						console.log($(window).scrollTop());
						$('#fxD').addClass('_sFixed');
						$('.lCol-oShop li').css({'margin-top':'10px'});
					} else {
						$('#fxD').removeClass('_sFixed');
						$('.lCol-oShop li').css({'margin-top':'20px'});
					}
					mH = $('#fxD').outerHeight();
					trD = $('#produkty').outerHeight();
					trP = $('body > header').outerHeight();
					zA = (trD-mH)+trP;
					console.log(zA);
					if($(window).scrollTop() >= zA)
					{
						$('#fxD').addClass('_sFixAbs');
						$('#fxD').css({'top':zA});
					}else{
						$('#fxD').removeClass('_sFixAbs');
						$('#fxD').css({'top':'0'});
						//$('#fxD').css({'position':'inherit','top':'0'});
					}
				});
				}
				$('a[href*="#"]:not([href="#"])').click(function() {
				    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
				      var target = $(this.hash);
				      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
				      if (target.length) {
				        $('html, body').animate({
				          scrollTop: target.offset().top
				        }, 1000);
				        return false;
				      }
			}});
				break;

		}


		if((isPage == 'online-store' || isPage == 'products') && windowWidth >= 768) {

			// Get heighest .description

			var heights = $(".description").map(function ()
				    {
				        return $(this).outerHeight();
				    }).get(),

			maxHeight = Math.max.apply(null, heights);


			// Setr heighest .description to all
			$('.description').hide().fadeIn();
			$('.description').css('height',maxHeight+10);

		}

});
