// JavaScript Document

// DYNAMIC RESOLUTION SWITCHER
// Originally from ParticleTree
// Simplified with Prototype by Ian White of Argument from Design 2008
// include prototype.js (>=1.6) before this file

// you need to edit this function as per your situation

function applyDynamicLayout() {
	  var width = document.viewport.getWidth();
	  if (width <= 970 )                 { applyStylesheet("small") }
	  if (width > 970 && width <= 1210)  { applyStylesheet("average") }
	  if (width > 1210 && width <= 1400) { applyStylesheet("wide") }
	  if (width > 1400) 				{ applyStylesheet("xtrawide") }

	  if (width >970) {
			var blokken_links = $$('#leftSidebar .blokgeheel');
			//als er links blokken staan. gooi deze dan naar rechts.
			
			if (blokken_links.length>0) {
				if ($('rightSidebar') && $('smallSide')) {
					$('rightSidebar').innerHTML = $('smallSide').innerHTML;
					$('smallSide').innerHTML = '';
			
					var rightSidebar = $('rightSidebar').innerHTML;
					rightSidebar.evalScripts();
					
				}
			}
		  } else { //andersom. als er rechts blokken staan. doe deze dan links.
			var blokken_rechts = $$('#rightSidebar .blokgeheel');
			if (blokken_rechts.length>0) {
				if ($('smallSide') && $('rightSidebar')) {
					$('smallSide').innerHTML = $('rightSidebar').innerHTML;
					$('rightSidebar').innerHTML = '';
					var smallside = $('smallSide').innerHTML;
					smallside.evalScripts();
				}
			}	  
	  }

}


// you shouldn't need to edit past here
function applyStylesheet(title) {
//	alert('test');
  var i, stylesheet;
  for(i=0; (stylesheet = document.getElementsByTagName("link")[i]); i++) {
    // is it a stylesheet with a title attribute?
    if(stylesheet.getAttribute("rel").indexOf("style") != -1 && stylesheet.getAttribute("title")) {
      stylesheet.disabled = true;
      if (stylesheet.getAttribute("title") == title) {
        stylesheet.disabled = false;

      } 
    }
  }
}

//Run applyDynamicLayout function when window is ready and when it resizes.
Event.observe(document, 'dom:ready', applyDynamicLayout);
Event.observe(window, 'resize', applyDynamicLayout);
//Event.observe(document, 'load', applyDynamicLayout);
window.onload = applyDynamicLayout;

