$(document).ready(function() {
	$('input.opening-hours').each(function() {
		if ($(this).val() == '') {
			$(this).addClass('example');
			$(this).val('11:15 - 23:45');
		}
	});
	
	$('input.opening-hours').focus(function() {
		if ($(this).val() == '11:15 - 23:45') {
			$(this).removeClass('example');
			$(this).val('');
		}
	});
	
	$('input.opening-hours').blur(function() {
		if ($(this).val() == '') {
			$(this).addClass('example');
			$(this).val('11:15 - 23:45');
		}
	});
	
	$('#visual-big-text').supersleight();
	$('#sfeer-right').supersleight();
	//$('#agecheck-content').supersleight();
	
	$('#shoppingcart-table tr:last td').css({'border-bottom':'none'});
	
	$('#image-popup-close').click(function() {
		$('#image-popup').fadeOut('fast');
		return false;
	});
	
	$('.pakket-preview').click(function() {
		var rel           = $(this).attr('rel');
		var pos           = $(this).position();
		var a_height      = $(this).height();
		var div_content   = $('.pakket-preview-contents[rel=' + rel + ']');
		
		$('#image-popup').fadeOut('fast', function() {
			$('#image-popup-contents').html(div_content.html());
			$('#image-popup').css({
				left  : pos.left,
				top   : pos.top + a_height + 5,
				width : div_content.outerWidth() + 30
			}).fadeIn('fast');
		});
		
		return false;
	});
	
	$('input[name=afleveradres]').change(function() {
		if ($(this).is(':checked')) {
			$('input[name=address2]').val($('input[name=address1]').val()).blur();
			$('input[name=zip2]').val($('input[name=zip]').val()).blur();
			$('input[name=city2]').val($('input[name=city]').val()).blur();
		}
	});
	
	$('.download-image').click(function() {
		var div_content = $('#download-image-contents');
		var href        = $(this).attr('href');
		var title       = $(this).attr('title');
		var pos         = $('#content-right').position();
		var a_height    = $(this).height();
		var href_parts  = href.split('/');
		var filename    = href_parts[href_parts.length - 1];
		
		$('#image-popup').fadeOut('fast', function() {
			$('#download-image-contents img').attr('src', '/admin_assets/downloads/thumbs/' + filename);
			$('#download-image-contents .image-title').html(title);
			$('#download-image-contents .download-file').attr('href', href);
			
			$('#image-popup-contents').html(div_content.html());
			$('#image-popup').css({
				left  : pos.left - 10,
				top   : pos.top + 10,
				width : div_content.outerWidth() + 30
			}).fadeIn('fast');
		});
		
		return false;
	});
});


setInterval(function() {
	$.get('/lib/keepalive.php');
}, 60000);


