/* 
Function placeDezeDiv() repositions the 'Deze pagina' div,
depending on resolution.
*/

function placeDezeDiv() {
	var contentHeight = parseInt(document.getElementById('content').offsetHeight);	
	var rNavHeight = parseInt(document.getElementById('rNav').offsetHeight);		
	var browserWidth = getBrowserWidth();
	var dezeDiv = document.getElementById('rNav_dezepagina');
	
	if((contentHeight>rNavHeight) && (browserWidth >= 950)){		
		var dezeDivHeight = parseInt(dezeDiv.offsetHeight);
		var footerPos = parseInt(document.getElementById('footer').offsetTop);		
		dezeDiv.style.position = "absolute";
		var posCorrection = -8;
		if(IE || Safari){
			posCorrection = 6;
		}
		dezeDiv.style.top = ((footerPos-dezeDivHeight)+ posCorrection)+"px";
	} 
	if(browserWidth < 950){
		dezeDiv.style.position = "relative";
		dezeDiv.style.top = "0px";
	}
	if(IE7){
		if(!(dezeDiv.intSet)){
			dezeDiv.checkForIE7 = setInterval('checkrNavPos()',50);
			dezeDiv.intSet = true;
		}
	}
}
// Function specific for IE7's buggy behavior:
function checkrNavPos(){
	var dezeDiv = document.getElementById('rNav_dezepagina');
	
	var dezeDivTop = parseInt(dezeDiv.offsetTop);	
	var rNavtop = parseInt(document.getElementById('rNav').offsetTop);		
	var rNavHeight = parseInt(document.getElementById('rNav').offsetHeight);	
	
	if(dezeDivTop<(rNavtop+rNavHeight)){	
		clearInterval(dezeDiv.checkForIE7);
		if(dezeDiv.style.position == "absolute"){
			dezeDiv.style.position = "relative";
			dezeDiv.style.top = "0px";
		}			
		dezeDiv.intSet = false;
	}
	
}
//Adding events....
// Call for this function is placed in 'switchStyles.js' 
//because it has to take place after stylesheet has been switched

//addEvent(window,'load',placeDezeDiv);
//addEvent(window,'resize',placeDezeDiv);