$(function () {
	var intPaus;
	var total = $("div#etalage").children().length;
	var totalLi = total;
	var intNext = 1;
	var nameEtaBtn = 1;
	var play = true;

	$("div#etalage").append('<ul></ul>');
	$("div#etalage div h1 a").each(function (i){
		$(this).parent().parent().parent().find('ul')
		.append('<li id="et_'+(totalLi - i)+'"></li>');
	});
	totalLi = total;
	$("div#etalage ul").children().each(function (i){
		$(this).text((totalLi) - i);
		$(this).click(function (i){
			var idData = $(this).attr('id').replace('et_', '');
			n = idData -1;
			play = false;
			clearInterval(nInt);
			goN ();
		});
	});
	
	var n = 0;
	var nInt;
	var st = 4000;
	function goN () {
		st = 3000;
		n++;
		clearInterval(nInt);
		
		$("div#etalage div").each(function (){
				$(this).stop();
				$(this).hide();
				$("#eta_"+(n - 1)).show();
		});
		if (play) {
			$("#eta_"+(n - 1)).fadeOut('slow');
			$("#eta_"+n).fadeIn('slow', reGen);
		}else{
			$("#eta_"+(n - 1)).fadeOut('slow');
			$("#eta_"+n).fadeIn('slow');
		}
		

		$("div#etalage ul li").removeClass("curSlide");
		$("#et_"+n).addClass("curSlide");
		if (n == 1) {
				$("#eta_"+total).fadeOut('slow');
		}
		if (n > (total -1)) {
				n = 0;
		}
		
		
	}
	function reGen () {
		nInt = setInterval(goN, st);
	}
	goN ();
	
	/*Img cutting on stickers*/
	
	$("ul#stickers img, .productShop img, .leftProds img").each(function(){
		var thisElem = $(this);
		$(this).load(function () { 
			if ($(thisElem).attr('id') != "big") {
			/*var grote = 120;
			var heightPerc = grote / $(this).height();
			$(this).height(grote);
			$(this).width($(this).width() * heightPerc);*/
			var perc = 40;
			var wiImg = Math.round(($(this).width() * perc) / 100);
			var hiImg = Math.round(($(this).height() * perc) / 100);
			$(thisElem).width(wiImg);
			$(thisElem).height(hiImg);
			
			$(thisElem).parent().wrap('<div></div>').parent()
			.css({"position":"relative", "overflow":"hidden"})
			.find('img').css({"position":"absolute", "left":"50%", "top":"50%", "marginTop": -($(this).height() / 2)+"px","marginLeft": -($(this).width() / 2)+"px"});
			}
		
		});
	});
	
	/*Sending a qoute*/
	$('#btnQoute').sendQuote({
				input:{name: 'name', phone:'phone'},
				email: {email: 'email'},
				textarea:{comment: 'comment'},
				setBtnId:'qBtn',
				load: '/incl/mail.php',
				btnName : 'Send'
	});
	
	$("#langVoorw").click(function (){
		
		var lang = $(this).attr('href').split('-');
		window.open('/voorwaarden.php?lang='+lang[1],'voorwaarden', 'width=750,height=500,scrollbars=yes,toolbar=no,location=no'); return false
	
	})
	
	
});
