<!--
//dojo.registerModulePath("boonekamp", "/js");
//dojo.require("boonekamp.widget.FullscreenBackground");

//dojo.require("dojo.fx.easing");
//dojo.require("dojox.fx.scroll");
dojo.require("dijit.Dialog");
dojo.require("dijit.TitlePane");
dojo.require("dijit.layout.ContentPane");

function clearField(field) {
  // Check if field contains the default value
  if (field.value == field.defaultValue) {
    // It does, so clear the field
    field.value = "";
  }
}

function toggleDiv(divje) {
	var speed = 1000;
	var spacer = 250;
	var node = dojo.byId(divje);
	
	if (node._anim) {
		node._anim.stop();
	}
	
	if (dojo.style(node,"display") == "none") {
		node._anim = dojo.fx.wipeIn({
			node: node,
			duration: speed,
			easing: dojo.getObject("dojo.fx.easing.expoOut")
		})
		node._anim.play();
	}
	else {
		node._anim = dojo.fx.wipeOut({
			node: node,
			duration: speed,
			easing: dojo.getObject("dojo.fx.easing.expoOut")
		});
		node._anim.play();
	}
}


/** Call a Dialog with URL	*/
function popPage (titel,url, idname, onLoadHandler) {
	diag = new dijit.Dialog({href: url, title: titel, id: idname, autofocus: false});
	//pas de positie aan.
	diag._endDrag = function(e){
	if(e && e.node && e.node === this.domNode){
	   var p = e._leftTop || dojo.coords(e.node,true);
	   this._relativePosition = { //we don't want our dialog to scroll.
	    t: p.t,
	    l: p.l
	   }   
	   this._firstRun = false;  
	  }
	 }
	  
	 diag._position = function(){
	  if(!dojo.hasClass(dojo.body(),"dojoMove")){
	    
	   var node = this.domNode;
	   if (!this._relativePosition || this._firstRun  ) { 
	    this._firstRun = this._firstRun ? false: true;
	    var viewport = dijit.getViewport();
	    var mb = dojo.marginBox(node);
		//console.log("vp.w="+viewport.w+" mb.w="+mb.w);
	    this._relativePosition = {
	      l: Math.floor(viewport.l + ((((viewport.w - mb.w) / 2) < 0) ? 10 : ((viewport.w - mb.w) / 2))),
	      t: Math.floor(viewport.t + ((((viewport.h - mb.h) / 2) < 0) ? 10 : ((viewport.h - mb.h) / 2)))
	    }  
	   }
	   
	   var p = this._relativePosition;
	   dojo.style(node,{
	    left: p.l + "px",
	    top: p.t + "px"
	   });
	  }
	 }
	 	 
	diag.connect(diag, "hide", dojo.hitch(diag, function() {
 		this.connect(this._fadeOut, "onEnd", dojo.hitch(this, function() {
 			this.destroyRecursive();
 		}));
	}));
	//diag.connect(diag, "_onBlur", "hide");
	
	if (onLoadHandler) {
		  diag.connect(diag, "onLoad", onLoadHandler); 
	};	
	
	diag.show();
	//console.dir(diag);
}


/* STYLESHEET FONT RESIZE TOOL */

function setActiveStyleSheet(title) {
 /* if (getActiveStyleSheet() == 'klein' && title == 'groot') {
  	title = 'normaal';
  }
  if (getActiveStyleSheet() == 'groot' && title == 'klein') {
  	title = 'normaal';
  }*/
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function setPrintableStyleSheet(title) {
  var i, a, main;
  var activeCSS = getPreferredStyleSheet();
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      	if(a.getAttribute("title") == title) {
	  		a.disabled = false;
			window.print();
		    setActiveStyleSheet(''+activeCSS+'');
			return false;
		}
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


// -->


