/* load */
function init()
{
	opmaak();
}

/* resize */
if(document.addEventListener)
{
	window.addEventListener('resize', opmaak, false);	//W3C: Firefox, Opera, Safari
}
else if(document.attachEvent)
{
	window.attachEvent('onresize', opmaak); //W3C: IE
};

/* opmaak aanpassen */
function opmaak()
{
	var content = document.getElementById("content");
	var background = document.getElementById("content_back");
	var navigatie = document.getElementById("navigatie");
	var dragable = document.getElementById("dragable");
	var copyright = document.getElementById("copyright");
	
	var background_height = content.offsetHeight;
	background.style.height = background_height + "px";

	var navigatie_height = content.offsetHeight + 30;
	navigatie.style.height = navigatie_height + "px";
	
	var background_width = document.body.offsetWidth - 310;
	background.style.width = background_width + "px";
	content.style.width = background_width + "px";
	
	var dragable_width = document.body.offsetWidth - 360;
	dragable.style.width = dragable_width + "px";
	
	copyright.style.top = background_height - 20 + "px";
}

/* drag and drop */
var dragobject={
	z: 0, 
	x: 0, 
	y: 0, 
	offsetx : null,
	offsety : null,
	targetobj : null,
	dragapproved : 0,
	
	initialize:function(){
		document.onmousedown=this.drag
		document.onmouseup=function(){this.dragapproved=0}
	},
	
	drag:function(e){
		var evtobj=window.event? window.event : e
		this.targetobj=window.event? event.srcElement : e.target
		if (this.targetobj.className=="drag"){
			this.dragapproved=1
			if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
			if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
			this.offsetx=parseInt(this.targetobj.style.left)
			this.offsety=parseInt(this.targetobj.style.top)
			this.x=evtobj.clientX
			this.y=evtobj.clientY
			if (evtobj.preventDefault)
			evtobj.preventDefault()
			document.onmousemove=dragobject.moveit
		}
	},
	
	moveit:function(e){
		var evtobj=window.event? window.event : e
		if (this.dragapproved==1){
			this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
			this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
			return false
		}
	}
}

dragobject.initialize()