<!--
dojo.registerModulePath("boonekamp", "/js");
dojo.require("boonekamp.widget.FullscreenBackground");

dojo.require("dojo.fx.easing");
dojo.require("dojox.fx.scroll");
dojo.require("dijit.Dialog");


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();
	}
}

function leeftijdCheck() {
	dojo.xhrGet({
		url: '/ajax/leeftijd.asp?leeftijd=ok',
		load: function(response, ioArgs){
			//nothing
			diag.hide();
		}, error: function(response, ioArgs){} 
	})
}

/** 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);
}
// -->


