onresize = function(){
	box = document.getElementById('layer');
	setwidthandheight(box);
}

$(document).ready(function(){
	if( $("#pagina").height() < $(window).height() ){
		$("#pagina").height($(window).height());
	}
});

/* Lightbox */
function Lightbox(content, widthtable, marginleft, marginheight){	
	document.getElementById('layertable').style.display='block';
	
	if( marginleft === undefined){
		if(widthtable != undefined){
			marginleft = Math.round($(window).width()/2 - widthtable/2);
		}
		else{
			marginleft = Math.round($(window).width()/4);
		}		
	}
	
	if( marginleft < 21){
		marginleft = 20;
	}
	
	if( marginheight === undefined){
		if (window.pageYOffset) {
			marginheight = Math.round(window.pageYOffset + 20);
		} else {
			marginheight = Math.round(document.documentElement.scrollTop + 20);
		}		
	}

	table = document.getElementById('layertable');
	table.width	= '';
	if(widthtable != undefined){table.width	= widthtable +'px';}	
	table.style.left	= marginleft +'px';
	table.style.top		= marginheight +'px';
	document.getElementById('lightcontent').innerHTML = '<br>' + content;
	
	box = document.getElementById('layer');
	setwidthandheight(box);
	box.style.display	='block';
}

function setwidthandheight(box){
	var height;
	height = $(document).height();
	
	var width;
	width = $(document).width();
	
	if( ($("#layertable").height() + 20) > height ){
		height = $("#layertable").height() + 20;
	}	
	box.style.height	= height+'px';	
	box.style.width		= width+'px';	
}

function getPageSizeWithScroll(){     
	if (window.innerHeight && window.scrollMaxY) {// Firefox        
		yWithScroll = window.innerHeight + window.scrollMaxY;         
		xWithScroll = window.innerWidth + window.scrollMaxX - 20;  

	} 
	else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac 
				yWithScroll = document.body.scrollHeight;   
				xWithScroll = document.body.scrollWidth;  
            }
    else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
			yWithScroll = document.body.offsetHeight;         
			xWithScroll = document.body.offsetWidth;       
    }    
		arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);     
        //alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );     
        return arrayPageSizeWithScroll; 
}

function zoekoptie(menu){
	
	if (getCookie(menu) == "dicht"){
		
		document.getElementById('kop-' + menu).style.backgroundImage = 'url(/images/blauw-verloop-h4-open.png)';
		$('#tekst-' + menu).slideDown('slow');
		
		try{
			document.getElementById('meer-' + menu).style.display = 'none';
		}catch(e){}
		document.cookie = menu + "=" + "open" + ";expires=" + verloopt.toUTCString(); 
				
	}else{
		
		document.getElementById('kop-' + menu).style.backgroundImage = 'url(/images/blauw-verloop-h4-dicht.png)';
		$('#tekst-' + menu).slideUp('slow');
		
		try{
			document.getElementById('meer-' + menu).style.display = 'inline';
		} catch(e){}
		document.cookie = menu + "=" + "dicht" + ";expires=" + verloopt.toUTCString(); 
	}
}

function getCookie(zoekoptie){
	if(document.cookie.length > 0){
	
		c_start = document.cookie.indexOf(zoekoptie + "=");
		if(c_start != -1){
			c_start	= c_start + zoekoptie.length +1;
			c_end		= document.cookie.indexOf(";", c_start);
			if(c_end == -1){
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		}	
	}
	return "";
}

function ShowLijst(lijst){
		
	if (document.getElementById(lijst).style.display == "none"){
		document.getElementById(lijst).style.display = "block";
	}else{
		document.getElementById(lijst).style.display = "none";
	}	
}

function Showaflever(type){	
	
	switch(type){
		
		case "0":
			document.getElementById("afleverinputs").style.display = "none";
			document.getElementById("afleverlabels").style.display = "none";
			break;
			
		case "1":
			document.getElementById("afleverinputs").style.display = "block";
			document.getElementById("afleverlabels").style.display = "block";
			break;	
	}
}

function VerwijderZoekCriteria(id){
	
	if(id == "minimumprijs" || id == "maximumprijs" || id == "minimumbreedte" || id == "maximumbreedte" || id == "minimumhoogte" || id == "maximumhoogte" || id == "kunstenaar" ){
		document.getElementById(id).value = 0;	
	}else if( id == "zoekeengiclee"){
		document.getElementById(id).value = "";
	}else{
		document.getElementById(id).checked = false;
	}	
	document.forms["zoekfilterform"].submit();
}

/*TICKERTAPE HOME PAGINE VOOR DE GICLEE'S*/
var doorgaan;
var marginleft;
doorgaan = false;

function tickertape(kant, actie){
		
	if(actie == "stop"){
		doorgaan = false;
	}else if(actie == "start"){		
		doorgaan = true;
		tickerinactie(kant);
	}
}

function initialeer(){
	try{
		marginleft = $('#tickercontent span:first-child').width();
		$('#tickercontent').margin({left: -marginleft});		
		for(i=1; i< Math.ceil( $('#tickertape').width() / marginleft ) +2 ; i++){			
			$('#tickercontent').append($('#tickercontent span:first-child').clone(true));
		}
	}catch(e){}	
}

function tickerinactie(kant){

	if(doorgaan){
		
		huidigemargin = parseInt($('#tickercontent').css("marginLeft").replace('px', ""));
		switch(kant){
		
			case "links":				
				if( huidigemargin < -(2*marginleft) ){
					$('#tickercontent').margin({left: huidigemargin + marginleft}); 
				}
				
				$('#tickercontent').animate({"margin-left": "-="+ 10 +"px"}, 75, "linear", function(){tickerinactie(kant)});
				break;
				
			case "rechts":
				if( huidigemargin >= 0){
					$('#tickercontent').margin({left: huidigemargin - marginleft}); 
				}
				$('#tickercontent').animate({"margin-left": "+="+ 10 +"px"}, 75, "linear", function(){tickerinactie(kant)});
				break;		
		}		
	}
}
