function LL_rollOver(img_name, img_src)
{
	document[img_name].src = img_src;
}
    
function LL_setDivHeight(iframe){
	
	var frame = document.getElementById(iframe);
	frame.height = window.document.documentElement.clientHeight;
	frame.style.height = window.document.documentElement.clientHeight - 98 + "px";
}

function LL_setDivHeightFrame(iframe){
	
	var frame = document.getElementById(iframe);
	frame.height = window.document.documentElement.clientHeight;
	frame.style.height = window.document.documentElement.clientHeight - 48 + "px";
}


function backOver(){
	var block = document.getElementById("backblock");
	var link = document.getElementById("backlink");
	block.style.backgroundColor="#333333";
	link.style.color="#FFFFFF";
}

function backOut(){
	var block = document.getElementById("backblock");
	var link = document.getElementById("backlink");
	block.style.backgroundColor="#FFFFFF";
	link.style.color="#333333";
}

function getElementsByClass( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
}



function openPortfolio(id,num,num2,type){
		
		if(typeof type != "undefined"){
			setCategory(type);
		}
		
		serialImages = document.getElementById("serialImages_"+id).value;
		
		aImagesToPreload = serialImages.split(",");
		
			saveSrc = document.getElementById("thumb_"+id).src;
			document.getElementById("thumb_"+id).src = "/assets/img/loading.gif";
		 
		  // set image url
		  	image_url = aImagesToPreload;
			imagesloaded = Array();
			var browser=navigator.appName;
		
		
	   if(aImagesToPreload.length == 1 && aImagesToPreload[0] == ""){
					openPortfolio2(id,num,num2,type);
		   }
		
		   var i = 0;
		   var counter = 0;
		   for(i=0; i<aImagesToPreload.length; i++){
		   		preload_image_object = new Image();
				
		   		preload_image_object.onload = function(){
					counter++;
					imagesloaded[i] = "1";
					//loopDelay(100);
					if(counter == aImagesToPreload.length){
						if(browser=="Microsoft Internet Explorer"){
							loopDelay(200);
							//alert("test");
						}
						openPortfolio2(id,num,num2,type);
						document.getElementById("thumb_"+id).src = saveSrc;
					}	
				};
				if(image_url[i].indexOf("youtube") == -1 && image_url[i].indexOf("vimeo") == -1){
					preload_image_object.src = image_url[i].split("//").join("/");
				}else{
					counter++;
				}
		   }
}

function loopDelay(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
} 

function initGallery(id){
	serialImages = document.getElementById("serialImages_"+id).value;
	aImagesToPreload = serialImages.split(",");
	gallery = document.getElementById("gallery_"+id);
	width = (170)/ aImagesToPreload.length;
	originalImage = aImagesToPreload[0].split("_mod.").join("_thumb.");
	for(img=0;img<aImagesToPreload.length;img++){
		thumbImage = aImagesToPreload[img].split("_mod.").join("_thumb.");
		
		if(aImagesToPreload[img].indexOf("youtube") == -1 && aImagesToPreload[img].indexOf("vimeo") == -1){
		
		if(img % 2 == 0){
		gallery.innerHTML += "<span style='height:170px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}else{
		gallery.innerHTML += "<span style='height:170px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}
		
		}
	}
}

function initGallery2(id){
	serialImages = document.getElementById("serialImages_"+id).value;
	aImagesToPreload = serialImages.split(",");
	gallery = document.getElementById("gallery_"+id);
	width = (170)/ aImagesToPreload.length;
	originalImage = "../cropimages.php?image="+aImagesToPreload[0].toString().substring(1)+"&width=170";// aImagesToPreload[0];//.split("_mod_news.").join("_thumb.");

	for(img=0;img<aImagesToPreload.length;img++){
		thumbImage = "/cropimages.php?image="+aImagesToPreload[img].toString().substring(1)+"&width=170";//aImagesToPreload[img].split("_mod_news.").join("_thumb.");
		if(img % 2 == 0){
		gallery.innerHTML += "<span style='height:170px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}else{
		gallery.innerHTML += "<span style='height:170px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}
	}
}

function initGalleryNews(id){
	serialImages = document.getElementById("serialImages_"+id).value;
	aImagesToPreload = serialImages.split(",");
	gallery = document.getElementById("gallery_"+id);
	width = (170)/ aImagesToPreload.length;
	if(aImagesToPreload[0].indexOf("_mod_news") > -1){
		originalImage = aImagesToPreload[0].split("_mod_news").join("_thumb");
	}else{
		originalImage = aImagesToPreload[0].split("_mod").join("_thumb");
	}
	for(img=0;img<aImagesToPreload.length;img++){
		if(aImagesToPreload[img].indexOf("_mod_news") > -1){
			thumbImage = aImagesToPreload[img].split("_mod_news").join("_thumb");
		}else{
			thumbImage = aImagesToPreload[img].split("_mod").join("_thumb");
		}
		//thumbImage = aImagesToPreload[img].split("_mod_news").join("_thumb");
		if(img % 2 == 0){
		gallery.innerHTML += "<span style='height:75px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}else{
		gallery.innerHTML += "<span style='height:75px;overflow:hidden;padding:0px;margin:0px;background-image:url(/assets/img/trans.gif);display:inline-block;width:"+width+"px;' onMouseOver='gallerySwitch(\""+id+"\",\""+thumbImage+"\")' id='"+thumbImage+"'><img src='"+thumbImage+"' style='visibility:hidden;' /></span>";
		}
	}
}

function gallerySwitch(id,url){
	oldImage = document.getElementById("thumb_"+id);
	//oldImage.src ="cropimages.php?image="+ url;
	oldImage.src = url;
}

function galleryReset(id,url){
	oldImage = document.getElementById("thumb_"+id);
	//oldImage.src = "cropimages.php?image="+ url;
	oldImage.src = url;
}
				
function openPortfolio2(id,num,num2,type){
	document.title = "O.K. PARKING / Interactief & Grafisch Ontwerpers / "+document.getElementById('maintitle' + id).innerHTML;
	//alert("NUM:"+num);
	idnum = id.substring(4);
	var winlok = window.location.toString();
	/*if(winlok.indexOf("?id") == -1){
		window.location.hash = "id="+idnum + "&type=portfolio";
	}*/
	
	if(winlok.indexOf("#") > -1 || (winlok.indexOf("/news/") == -1 && winlok.indexOf("/item/") == -1 && winlok.indexOf("/portfolio/") == -1 && winlok.indexOf("/over/") == -1 && winlok.indexOf("/eigen/") == -1 && winlok.indexOf("?id") == -1)){
		//window.location.hash = "id="+idnum + "&type=news";
		var str = document.getElementById('urlstr'+idnum).value;		
		if(type.toLowerCase() == "initiatief"){
			type = "eigen";
		}
		window.location.hash = "/"+type.toLowerCase()+"/"+str+"/";
	}
	var divElement = document.getElementById(id);
	
	
	var images = document.getElementById("loadImages_"+id).value;
	
	document.getElementById('imageArea_'+id).innerHTML = images;
	
	var p = underscore.position(divElement);
	if(p.x > window.innerWidth-450){
	
	}
	
	
	
	elem = document.getElementById(id);
	if(elem.offsetWidth == '180'){
		elem.style.width='588px';
		elem.style.height='auto';
		elem.style.zIndex='200';
		elem.className = elem.className + " threecols";
		if(p.x > window.innerWidth-450){
			
		}
		document.getElementById(id+'_intro').style.display = 'none';
		document.getElementById(id+'_content').style.display = 'block';
	}
	
	
	
	for(var i=1;i<num+1;i++){
		elem = document.getElementById("item"+i);
		if(elem != null){
			
			if(elem.offsetWidth != '180' && id != "item"+i){
				elem.className = "portfolio_item eachpost";
				elem.style.width='180px';
				elem.style.height='210px';
				elem.style.zIndex='2';
				document.getElementById("item"+i+'_intro').style.display = 'block';
				document.getElementById("item"+i+'_content').style.display = 'none';
				
			}
		}else{
			
			if(elem == null){
				//alert(i+" was empty!"+elem);
				//break;	
			}
		}
	}
	
	/*for(var j=1;j<num2+1;j++){
		elem2 = document.getElementById("news"+j);
		if(elem2 != null){
			elem2.className = "nieuws_item eachpost";
			if(elem2.offsetWidth != '180'){
				elem2.style.width='180px';
				elem2.style.height='210px';
				elem2.style.zIndex='2';
				document.getElementById("news"+j+'_intro').style.display = 'block';
				document.getElementById("news"+j+'_content').style.display = 'none';
				
			}
		}
		
	}*/
	
	arrangeFunc(id);
	
	

	

}



function closePortfolio(id){
	document.title = "O.K. Parking - Interactief & Grafisch Ontwerp Arnhem - website, tijdschrift, boeken, catalogus, infographics, huisstijlen, logo, jaarverslag, grafisch design bureau, design bureau, ontwerpbureau, ontwerp, vormgeving, grafische, vormgever, vormgevers, webdesign, website, grafisch ontwerpbureau arnhem, grafische vormgevers, grafische vormgever arnhem, radactioneel ontwerp, redactioneel, visitekaartje, huisstijl, ontwerpers, design, magazine, ok, collections, glitch, logo, jaarverslag, CMS, interactief, tentoonstelling, tentoonstellingen, nijmegen, utrecht, arnhem, amsterdam, den haag, rotterdam, velp, ede, wageningen, apeldoorn, eindhoven, den bosch, ipad ontwikkelaar, iphone ontwikkelaar, iphone app, ipad app";
	elem = document.getElementById(id);
	if(elem.offsetWidth != '180'){
		elem.style.width='180px';
		elem.style.height='210px';
		elem.style.zIndex='2';
		elem.className = "portfolio_item eachpost";
		document.getElementById(id+'_intro').style.display = 'block';
		document.getElementById(id+'_content').style.display = 'none';
	}
	arrange();
	
}

function openNews(id,num,num2){
serialImages = document.getElementById("serialImages_"+id).value;
		
	aImagesToPreload = serialImages.split(",");
	
	var browser=navigator.appName;
		saveSrc = document.getElementById("thumb_"+id).src;
		document.getElementById("thumb_"+id).src = "/assets/img/loading_blue.gif";
	 
	  // set image url
	  image_url = aImagesToPreload;
	
	   var i = 0;
	   var counter = 0;
	   
	   if(aImagesToPreload.length == 1 && aImagesToPreload[0] == ""){
					openNews2(id,num,num2);
	   }
	   
	   for(i=0; i<aImagesToPreload.length; i++){
	   		preload_image_object = new Image();
			preload_image_object.src = image_url[i];
	   		preload_image_object.onload = function(){
				counter++;
				if(counter == aImagesToPreload.length){
					if(browser=="Microsoft Internet Explorer"){
						loopDelay(200);
						//alert("test");
					}
					openNews2(id,num,num2);
					document.getElementById("thumb_"+id).src = saveSrc;
				}
				
			};	
			
	   }
}

function openNews2(id,num,num2){
	document.title = "O.K. PARKING / Interactief & Grafisch Ontwerpers / "+document.getElementById('maintitle' + id).innerHTML;
	idnum = id.substring(4);
	var winlok = window.location.toString();
	if(winlok.indexOf("#") > -1 || (winlok.indexOf("/news/") == -1 && winlok.indexOf("/item/") == -1 && winlok.indexOf("/portfolio/") == -1 && winlok.indexOf("/over/") == -1 && winlok.indexOf("/eigen/") == -1 && winlok.indexOf("?id") == -1)){	//window.location.hash = "id="+idnum + "&type=news";
		var str = document.getElementById('urlstr'+idnum).value;		
		
		window.location.hash = "/news/"+str+"/";
	}
	//alert("NUM:"+num);
	var divElement = document.getElementById(id);
	
		var images = document.getElementById("loadImages_"+id).value;
	
	document.getElementById('imageArea_'+id).innerHTML = images;
	
    var p = underscore.position(divElement);
	if(p.x > window.innerWidth-450){
	
	}
    
	elem = document.getElementById(id);
	if(elem.offsetWidth == '180'){
		elem.style.width='383px';
		elem.style.height='auto';
		elem.style.zIndex='200';
		elem.className = elem.className + " twocols";
        if(p.x > window.innerWidth-450){
			
		}
		document.getElementById(id+'_intro').style.display = 'none';
		document.getElementById(id+'_content').style.display = 'block';
	}
	
	for(var i=1;i<num2+1;i++){
		elem = document.getElementById("news"+i);
		if(elem != null){
			
			if(elem.offsetWidth != '180' && id != "news"+i){
				elem.className = "nieuws_item eachnews";
				elem.style.width='180px';
				elem.style.height='210px';
				elem.style.zIndex='2';
				document.getElementById("news"+i+'_intro').style.display = 'block';
				document.getElementById("news"+i+'_content').style.display = 'none';
                
			}
		}else{
			
            if(elem == null){
				//alert(i+" was empty!"+elem);
				//break;	
			}	
		}
	}
	
	/*for(var j=1;j<num+1;j++){
		elem2 = document.getElementById("item"+j);
		if(elem2 != null){
			elem2.className = "portfolio_item eachpost";
			if(elem2.offsetWidth != '180'){
				elem2.style.width='180px';
				elem2.style.height='210px';
				elem2.style.zIndex='2';
				document.getElementById("item"+j+'_intro').style.display = 'block';
				document.getElementById("item"+j+'_content').style.display = 'none';
				
			}
		}
		
	}*/
	
	arrangeFunc(id);
	arrangeNews();
}


function closeNews(id){
	document.title = "O.K. Parking - Interactief & Grafisch Ontwerp Arnhem - Nieuws / Contact - ontwerpbureau, concept, experiment, redactioneel, ontwerp, vormgeving, webdesign, website, boeken, catalogus, infographics, huisstijlen, idee, grafisch ontwerpbureau arnhem, grafische vormgevers, visitekaartje, internetpagina, internet, ontwerpers, design, informatie, visie, magazine, ok, collections, glitch";
	elem = document.getElementById(id);
	if(elem.offsetWidth != '180'){
		elem.style.width='180px';
		elem.style.height='210px';
		elem.style.zIndex='2';
		elem.className = "nieuws_item eachnews";
		document.getElementById(id+'_intro').style.display = 'block';
		document.getElementById(id+'_content').style.display = 'none';
	}
	arrangeNews();
}


underscore = {
    position: function (element) {
        var p = {x: element.offsetLeft || 0, y:element.offsetTop || 0};
        while (element = element.offsetParent) {
            p.x += element.offsetLeft;
            p.y += element.offsetTop;
        }
        return p;
    }
}

	var MIN_COLS_NEWS = 1;
	var MIN_COLS = 3;
	var COL_WIDTH = 180;
	var GAP = 24; 
	
	var offx, offy, topY = 12;
	maxy = new Array();
	
	// on site load (DOM READY)
	$(function() { 
		offy = $('#blockfield').offset().top - 70;
		offx = $('#blockfield').offset().left;
		
		
		arrange(); 
		$.localScroll();

	});
	var count = 0;
	// on window resize, call again
	window.onresize = function(){
			
			//count++;
			//document.title = count;
			$("#blockfield").width($("body").innerWidth() - ($("#blockfield-news").innerWidth()+GAP));
			if($(".top_nav").width() < 809){
				$(".top_nav").width(809);
			}
			//document.title = $("#blockfield").width();
			
			//$("#over-ons").width($("#blockfield").width());
			
			arrange();
		
 	};

	function arrange(test) {
		
		//parseInt($('body').innerWidth() replacen met de width van het blok waar ze in moeten komen!
		//Daarna aparte functies maken voor zowel de Nieuws als de Portfolio items.
		
		
		//$('#iframe').css('height',$(window).height - 98);
		$('#blockfield').each(function(i) {
			offy = $('#blockfield').offset().top - 70;
			offx = $('#blockfield').offset().left;
		});
		if(typeof test != "undefined"){
			offx = 221;
		}
		//if($('#blockfield').innerWidth() == 0){
			var diff = $("body").innerWidth() - ($("#blockfield-news").innerWidth()+GAP);
			$("#blockfield").width(diff);
			
			//$("#over-ons").width((diff));
		//}
		// how many columns fits here?
		var diff = (($('#blockfield').innerWidth()+GAP) / (COL_WIDTH+GAP));
		var columns = Math.max(MIN_COLS, parseInt(diff));
		
		//alert("X "+offx+" Y "+offy+" T "+test);
		$('.eachpost').css('width',COL_WIDTH  + 'px');
		$('.twocols').css('width', COL_WIDTH*2 + GAP  );
		$('.threecols').css('width', COL_WIDTH*3 + GAP*2);
		for (x=0; x < columns; x++) {
			maxy[x] = 0;
		}
		var maxHeight = 0;
		// lets iterate over all posts
		$('.eachpost').each(function(i) {
			if($(this).css('display') != "none"){
			var pos, cursor, w , altura= 0;
			
			
			if($(this).hasClass("twocols")){
				
				GAPBOT = GAP - 75;				
			}else if($(this).hasClass("threecols")){
				GAPBOT = GAP - 75;
				
			}else{
				GAPBOT = GAP;	
			}
			
			w = (Math.floor($(this).outerWidth() / COL_WIDTH));
			
			cursor = 0;

			if (w>1) {
				for (x=0; x < columns-(w-1); x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}
				pos = cursor;
				
				for (var x=0; x<w; x++) {
					altura = Math.max(altura, maxy[pos+x]);
				}
				for (var x=0; x<w; x++) 
					maxy[pos+x] = parseInt($(this).outerHeight()) + GAPBOT + altura;
					
				$(this).css('left', pos*(COL_WIDTH+GAP) + offx).css('top',altura + offy);
				
				if (altura+topY > maxHeight) {
				  maxHeight=maxy[pos+w-1];
				}

			}
			else {
			
				for (x=0; x < columns; x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}

				$(this).css('left', cursor*(COL_WIDTH+GAP) + offx).css('top',maxy[cursor] + offy);
				
				maxy[cursor] += 220 + GAPBOT;
				if (maxy[cursor] > maxHeight) {maxHeight=maxy[cursor];}
				
			}
			}
		});
		
		
		
	}
	
	function arrangeNews(test) {
		//alert("GO");
		//parseInt($('body').innerWidth() replacen met de width van het blok waar ze in moeten komen!
		//Daarna aparte functies maken voor zowel de Nieuws als de Portfolio items.
		
		
		if($('.twocols').length > 0){
			$("#blockfield-news").width(221+180+GAP);
			var diff = $("body").innerWidth() - ($("#blockfield-news").innerWidth()+GAP);
			$("#blockfield").width(diff);
			//$("#over-ons").width((diff));
			$(".menu-title").css("margin-left",221+180+GAP+2);
			arrange();
		}else{
			$("#blockfield-news").width(221);
			var diff = $("body").innerWidth() - ($("#blockfield-news").innerWidth()+GAP);
			$("#blockfield").width(diff);
			//$("#over-ons").width((diff));
			$(".menu-title").css("margin-left",223);
			arrange();
		};
		//alert($('#blockfield-news').innerWidth()+" - "+$('#blockfield').innerWidth()+" - "+$('#over-ons').innerWidth()+" - "+$("body").innerWidth()+" - "+diff);
		
		//$('#iframe').css('height',$(window).height - 98);
		$('#blockfield-news').each(function(i) {
			offy = $('#blockfield-news').offset().top - 70;
			offx = $('#blockfield-news').offset().left;
		});
		if(typeof test != "undefined"){
			//alert("GO");
		}
		
		if(offx < 17){
			offx = 17;
		}
		if($('#blockfield-news').innerWidth() == 0){
			$('#blockfield-news').width($("body").innerWidth() - 247);
		}
		// how many columns fits here?
		var columns = Math.max(MIN_COLS_NEWS, parseInt($('#blockfield-news').innerWidth() / (COL_WIDTH+GAP)));
		
		//alert("X "+offx+" Y "+offy+" T "+test);
		$('.eachnews').css('width',COL_WIDTH  + 'px');
		$('.twocols').css('width', COL_WIDTH*2 + GAP  );
		$('.threecols').css('width', COL_WIDTH*3 + GAP*2);
		for (x=0; x < columns; x++) {
			maxy[x] = 0;
		}
		var maxHeight = 0;
		// lets iterate over all posts
		$('.eachnews').each(function(i) {
			if($(this).css('display') != "none"){
			var pos, cursor, w , altura= 0;
			
			
			if($(this).hasClass("twocols")){
				
				GAPBOT = GAP - 75;				
			}else if($(this).hasClass("threecols")){
				GAPBOT = GAP - 75;
				
			}else{
				GAPBOT = GAP;	
			}
			
			w = (Math.floor($(this).outerWidth() / COL_WIDTH));
			
			cursor = 0;

			if (w>1) {
				for (x=0; x < columns-(w-1); x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}
				pos = cursor;
				
				for (var x=0; x<w; x++) {
					altura = Math.max(altura, maxy[pos+x]);
				}
				for (var x=0; x<w; x++) 
					maxy[pos+x] = parseInt($(this).outerHeight()) + GAPBOT + altura;
					
				$(this).css('left', pos*(COL_WIDTH+GAP) + offx).css('top',altura + offy);
				
				if (altura+topY > maxHeight) {
				  maxHeight=maxy[pos+w-1];
				}

			}
			else {
			
				for (x=0; x < columns; x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}
				$(this).css('left', cursor*(COL_WIDTH+GAP) + offx).css('top',maxy[cursor] + offy);
				
				maxy[cursor] += 220 + GAPBOT;
				if (maxy[cursor] > maxHeight) {maxHeight=maxy[cursor];}
				
			}
			}
		});
		
		
		
	}
	
	function arrangeFunc(id) {
		
		//$('#iframe').css('height',$(window).height - 98);
		$('#blockfield').each(function(i) {
			offy = $('#blockfield').offset().top - 70;
			offx = $('#blockfield').offset().left;
		});
		// how many columns fits here?
		var diff = (($('#blockfield').innerWidth()+GAP) / (COL_WIDTH+GAP));
		var columns = Math.max(MIN_COLS, parseInt(diff));
		
		
		$('.eachpost').css('width',COL_WIDTH  + 'px');
		$('.twocols').css('width', COL_WIDTH*2 + GAP  );
		$('.threecols').css('width', COL_WIDTH*3 + GAP*2);
		for (x=0; x < columns; x++) {
			maxy[x] = 0;
		}
		var maxHeight = 0;
		// lets iterate over all posts
		$('.eachpost').each(function(i) {
			if($(this).css('display') != "none"){
			var pos, cursor, w , altura= 0;
			
			if($(this).hasClass("twocols")){
				GAPBOT = GAP;				
			}else if($(this).hasClass("threecols")){
				GAPBOT = GAP - 75;
				
			}else{
				GAPBOT = GAP;	
			}
			
			w = (Math.floor($(this).outerWidth() / COL_WIDTH));
			cursor = 0;
			
			if (w>1) {
				for (x=0; x < columns-(w-1); x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}
				pos = cursor;
				
				for (var x=0; x<w; x++) {
					altura = Math.max(altura, maxy[pos+x]);
				}
				for (var x=0; x<w; x++) 
					maxy[pos+x] = parseInt($(this).outerHeight()) + GAPBOT + altura;
					
				$(this).css('left', pos*(COL_WIDTH+GAP) + offx).css('top',altura + offy);
				
				if (altura+topY > maxHeight) {
				  maxHeight=maxy[pos+w-1];
				}

			}
			else {
			
				for (x=0; x < columns; x++) {
					cursor = maxy[x] < maxy[cursor] ? x : cursor;
				}
				
				$(this).css('left', cursor*(COL_WIDTH+GAP) + offx).css('top',maxy[cursor] + offy);
				
				maxy[cursor] += 220 + GAPBOT;
				
				if (maxy[cursor] > maxHeight) {maxHeight=maxy[cursor];}
				
			}
			}
		});
	
		

		
		$.scrollTo(document.getElementById(id).offsetTop, 600);
		
		
	}

function setCategory(cat,nav){
	if(nav){
	
	var winlok = window.location.toString();
		if(winlok.indexOf("#") > -1 || (winlok.indexOf("/news/") == -1 && winlok.indexOf("/item/") == -1 && winlok.indexOf("/portfolio/") == -1 && winlok.indexOf("/over/") == -1 && winlok.indexOf("/eigen/") == -1 && winlok.indexOf("?id") == -1)){	//window.location.hash = "id="+idnum + "&type=news";	
		
		if(cat == "Initiatief"){
			window.location.hash = "/eigen/";
		}else if(cat == "Over"){
			window.location.hash = "/over/";
			
		}else if(cat == "Portfolio"){
			window.location.hash = "/portfolio/";
		
		}
	}
	
	}

//document.title = "cat: "+cat;

	$(".eachpost").each(function(){
		if($("#typer",this).val() != cat && $("#typer2",this).val() != cat && $("#typer3",this).val() != cat && $("#typer4",this).val() != cat){
			$(this).hide();
		} 
		if($("#typer",this).val() == cat || $("#typer2",this).val() == cat || $("#typer3",this).val() == cat || $("#typer4",this).val() == cat){
			$(this).show();
		} 
	});
	$(".menu-title a").removeClass("active");
	$(".menu-title a."+cat.toLowerCase()).addClass("active");
	if(cat == "Over"){
		
		//$("#over-ons").width($("#blockfield").width());
		$("#blockfield").css("margin-top",$("#over-ons").height()+24);
		$("#over-ons").show();
	}else{
		$("#blockfield").css("margin-top",0);
		$("#over-ons").hide();
	}
	arrange();
}


function testResize(){
	$("#blockfield-news").width(221+180+GAP);
	$("#blockfield").width($("body").innerWidth() - ($("#blockfield-news").innerWidth()+GAP));
	arrange();
}

function testResizeBack(){
	$("#blockfield-news").width(221);
	$("#blockfield").width($("body").innerWidth() - ($("#blockfield-news").innerWidth()));
	arrange();
}
	
function testResizeOver(){
	//$("#over-ons").width($("#blockfield").width());
	$("#blockfield").css("margin-top",$("#over-ons").height()+24);
	$("#over-ons").show();
	arrange();
}

function blurAnchors(){
	if(document.getElementsByTagName) {
		var a = document.getElementsByTagName("a");
		//collect all anchors A
		for(var i = 0; i < a.length; i++){
			// mouse onfocus, blur anchors
			a[i].onfocus = function(){this.blur();};
		}
		var a = document.getElementsByTagName("input");
		//collect all anchors A
		for(var i = 0; i < a.length; i++){
			// mouse onfocus, blur anchors
			if(a[i].type == 'submit')
			a[i].onfocus = function(){this.blur();};
		}
	}
}

$(document).ready(function() { 
    
	blurAnchors();

});
