$(document).ready(function() { 
	$('.stnd').blur(function() {
		if($(this).val()==''){
			$(this).val($(this).attr('alt'));
		}
	});
	$('.stnd').focus(function() {
		if($(this).val()==$(this).attr('alt')){
			$(this).val('');
		}
	});
	$('.stnd').each(function(){
		if($(this).val()==''){
			$(this).val($(this).attr('alt'));
		}
	});

	$(".popupImg").fancybox({
		'overlayShow':	true,
		'speedIn':	300, 
		'speedOut':	0,
		'type':'image'
	});
	$(".popup").fancybox({
		'overlayShow':	true,
		'speedIn':	300, 
		'speedOut':	0
	});

	initZoombox();

});

function initZoombox(){
	$('.zoomBox').each(function(){
		var s = $(this).find('input.thumb').val();
		var o = $(this).find('input.zoom').val();
		$(this).empty().imageZoom({
			small: s,
			original: o,
			viewpoint: {
				width: 200,
				height: 175
			}
		});
	});	
}

function reloadZoombox(thumb, zoom){
	$('.zoomBox').append('<input class="zoom" type="hidden" />');
	$('.zoomBox .zoom').val(zoom);
	$('.zoomBox').append('<input class="thumb" type="hidden" />');
    $('.zoomBox .thumb').val(thumb);
    $('#afblarge').attr('src', thumb);
    $('#afbpopup').attr('href', zoom);
    initZoombox();
}
function logout(){
	$.post('../controller/logout.php', function(){
		window.location='checkout';
	});
}

function show_bankkeuze(val){
	if(val=='iDeal' || val==1){
		$('#ideal').show();
	} else {
		$('#ideal').hide();
	}
}

function doSearch(){
	if($('#searchBox').hasClass('active')){
		$('#searchForm').submit();
	} else {
		$('#searchBox').addClass('active');
		$('#searchBox input').select();
	}
}

function friendly_url_encode(tekst){
	tekst = tekst.toLowerCase();
	tekst = tekst.replace(/%/g, '');
	tekst = tekst.replace(/ &amp; /g, '-en-');
	tekst = tekst.replace(/&amp;/g, '-en-');
	tekst = tekst.replace(/ & /g, '-en-');
	tekst = tekst.replace(/&/g, '-en-');
	tekst = tekst.replace(/ \/ /g, '\\');
	tekst = tekst.replace(/\//g, '\\');
	tekst = tekst.replace(/ /g, '-');
	return(tekst);
}

function submitZoek(f)
{
	f.action = f.action + friendly_url_encode($('#keyword').val());
}
function selecttype(type) {
	$('#canvasli').removeClass("active");
	$('#posterli').removeClass("active");
	$('#forexli').removeClass("active");
	$('#aluminiumli').removeClass("active");	
	
	$('#canvasdiv').hide();	
	$('#posterdiv').hide();
	$('#forexdiv').hide();
	$('#aluminiumdiv').hide();
	
	$('#'+type+'div').show();
	$('#'+type+'li').addClass("active");
}

function setLoginMethod(){
	if($('.loginMethod').is(':checked')){
		$('.loginMethodText1').hide();
		$('.loginMethodText2').show();
	} else {
		$('.loginMethodText1').show();
		$('.loginMethodText2').hide();
	}

}

function toggleBedrijfsvelden(){
	if($('#bedrijfsnaam').val()){
		$('.bedrijfsVelden').show();
	} else {
		$('.bedrijfsVelden').hide();
	}
}
