$(function() {
	function resize() {
		$('#input-search').width( window.innerWidth < 980 ? window.innerWidth - 144 : 275 );
	}

	$(window).resize(resize);
	resize();
});

$(function () {
	if(self != top){
		$(document).ready(function() {

			var body = document.getElementsByTagName("BODY")[0];
			var affiliate = body.className.match(/affiliate_/);

			if (affiliate == null){
				body.className += ' wlecIframe';
			}
		});
	}
})

function updateCountdown() {
	var cartSize = document.getElementById('cartSize');
	var store = document.getElementById('secondsLeft');
	var countdown = document.getElementById('countdown');
	if (cartSize && store && countdown) {
		if (cartSize.value > 0) {
			var endDate = new Date(new Date().getTime() + store.value * 1000);
			var interval = setInterval(function() {
				var secs = Math.floor((endDate - new Date()) / 1000);
				if (secs >= 0) {
						var secsPart = secs % 60;
						var minutes =  ~~(secs / 60);

					if (minutes < 10) {
						minutes = '0' + minutes;
					}

					if (secsPart < 10) {
						secsPart = '0' + secsPart;
					}

					countdown.innerHTML = minutes + ':' + secsPart;
				} else {
					clearInterval(interval);

                    alert(headerTranslations['timeout_info']);
					if( window.location.href.indexOf('cart') >= 0) {
                        window.location = "index.php?view=cart&emptycart=1";
                        window.setTimeout("window.location.reload()", 1000);
                    } else if (window.location.href.indexOf('vouchercodes') >= 0) {
                        window.location = "index.php?view=vouchercodes";
                        window.setTimeout("window.location.reload()", 1000);
                    } else {
                        $('#cart_bar').hide();
					}
					return;
				}
			}, 250);
		}
	}
}

function hideSearchInput() {
	$('.brand, .btn-search').removeClass('hidden-phone hidden-tablet');$('.navbar-form').addClass('visible-desktop');
}
