function focusText(oTextfield, sDefaultValue) {
	if(oTextfield.value == "") oTextfield.value = sDefaultValue;
	if(oTextfield.value != sDefaultValue) oTextfield.style.color = '#003366';
		else oTextfield.style.color = '#999999';
}
function cleanText(oTextfield, sDefaultValue) {
	if(oTextfield.value == sDefaultValue) {
		oTextfield.value = '';
		oTextfield.style.color = '#003366';
	}
}

function muisover(divblock){
	divblock.style.backgroundColor = '#E8E8E8';
}
function muisaf(divblock){
	divblock.style.backgroundColor='#d4d4ff';
}
function muisover1(divblock){
	divblock.style.backgroundColor = '#d4d4ff'; divblock.style.color = '#0064B0';
}
function muisaf1(divblock){
	divblock.style.backgroundColor='#749DDA'; divblock.style.color = 'FFFFFF';
} 

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip
var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).


var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(datum, titel, thetext, thecolor, thewidth, classy){
	var tipobj= document.getElementById("dhtmltooltip");
	var pointerobj= document.getElementById("dhtmlpointer");
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML='<div class="cel3 ho20 wit pat2 agblauw">' + datum + '</div><div class="cel3 ' + classy + '">' + titel + '</div><div class="cel3">' + thetext + '</div>';
enabletip=true
return false
}
}

function positiontip(e){
	var tipobj= document.getElementById("dhtmltooltip");
	var pointerobj= document.getElementById("dhtmlpointer");
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
	var tipobj= document.getElementById("dhtmltooltip");
	var pointerobj= document.getElementById("dhtmlpointer");
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


//ajax systeem
function createRequestObject() {
	var req;
	try{ req = new XMLHttpRequest(); } 
	catch (e){
		try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch (e) {
			try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } 
			catch (e){ 
				alert("Uw browser ondersteunt geen Asynchronous JavaScript and XML (AJAX)!");
			}
		}
	}
   return req;
}

var http = createRequestObject();

function sendRequest(page,qstr,divid,sluit) {
	if(qstr){ http.open('get', page + qstr, true); }
	else{ http.open('get', page, true); }
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){	   
		  if(http.responseText) {
			document.getElementById(divid).innerHTML = http.responseText;
			if(sluit == 1){ hidevenster(); }
			if(sluit == 2){ hidemelding(); }
		  }
		}
	}
	http.send(null);
}
//formulier ivullen
var selektion;

function insertAtCursor(myField, myValue, bbCode1, bbCode2, endOfLine) {
	var bbb;
	if(bbCode1=='[url=null]') { bbCode1=''; bbCode2=''; }
	if(bbCode1=='[imgs]' && myValue==null) { bbCode1=''; bbCode2=''; myValue=''; }

	if (document.selection) {
		//IE support
		var str = document.selection.createRange().text;
		myField.focus();
		sel = document.selection.createRange();
		sel.text = bbCode1 + myValue + bbCode2 + endOfLine;
		if(myValue=='') { bbb=bbCode2.length; sel.moveStart('character',-bbb); sel.moveEnd('character',-bbb); }
		sel.select();
		return;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		var bbb2, bbV, eoll;
		if(myValue=='') myValue = myField.value.substring(startPos, endPos);
		//alert(myValue);
		myField.value = myField.value.substring(0, startPos) + bbCode1 + myValue + bbCode2 + endOfLine + myField.value.substring(endPos, myField.value.length);
		if(myValue=='') { bbb=bbCode1.length; myField.selectionStart=startPos+bbb; myField.selectionEnd=endPos+bbb; }
		else {
			bbb=bbCode1.length;
			bbb2=bbCode2.length;
			bbV=myValue.length;
			eoll=endOfLine.length;
			myField.selectionStart=startPos+bbV+bbb+bbb2+eoll;
			myField.selectionEnd=myField.selectionStart;
		}
		myField.focus();

		return;
	} 
	else {
		myField.value += myValue;
		return;
	}
}

function paste_strinL(strinL, isQuote, bbCode1, bbCode2, endOfLine, User, veld){ 
	if((isQuote==1 || isQuote==2) && strinL=='') alert(l_quoteMsgAlert); 
	else{ 
		if (isQuote==1) { 
			bbCode1='[quote=' + User + ']'; bbCode2='[/quote]'; endOfLine='\n'; 
		} 
		if (isQuote==2) { 
			bbCode1='[b]'; bbCode2='[/b]'; endOfLine='\n'; 
		} 
		var isForm=document.forms["formulier"]; 
		if (isForm) { 
			var input=document.getElementById(veld); 
			insertAtCursor(input, strinL, bbCode1, bbCode2, endOfLine); 
		} 
		else alert("veld onbekend"); 
	} 
}
function pasteSel() {
	selektion='';
	if(window.getSelection) {
	this.thisSel=window.getSelection();
	selektion=this.thisSel.toString();
}
else if(document.getSelection) selektion=document.getSelection();
else if(document.selection) selektion=document.selection.createRange().text;
}

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="(c) 2010, Wiskunde.eu";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
//Drop Down/ Overlapping Content: http://www.dynamicdrive.com
//Last updated: Dec 19th, 07': Added ability to dynamically populate a Drop Down content using an external file (Ajax feature)

var dropdowncontent={
 delaybeforehide: 1000, //set delay in milliseconds before content box disappears onMouseout (1000=1 sec)
	disableanchorlink: true, //when user clicks on anchor link, should it be disabled?
	ajaxloadingmsg: "Gegevens worden geladen. Een ogenblik geduld...", //HTML to show while ajax page is being feched
	ajaxbustcache: true, //Bust cache when fetching pages?

	getposOffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getposOffset(what.offsetParent, offsettype) : what[offsettype]
	},

	isContained:function(m, e){
		var e=window.event || e
		var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
		while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
		if (c==m)
			return true
		else
			return false
	},

	show:function(anchorobj, subobj, e){
		if (!this.isContained(anchorobj, e)){
			var horizontaloffset=(subobj.dropposition[0]=="left")? -(subobj.offsetWidth-anchorobj.offsetWidth-60) : 0 //calculate user added horizontal offset
			var verticaloffset=(subobj.dropposition[1]=="top")? -subobj.offsetHeight : anchorobj.offsetHeight //calculate user added vertical offset
			subobj.style.left=this.getposOffset(anchorobj, "offsetLeft") + horizontaloffset + "px"
			subobj.style.top=this.getposOffset(anchorobj, "offsetTop")+verticaloffset+"px"
			subobj.style.clip=(subobj.dropposition[1]=="top")? "rect(auto auto auto 0)" : "rect(0 auto 0 0)" //hide drop down box initially via clipping
			subobj.style.visibility="visible"
			subobj.startTime=new Date().getTime()
			subobj.contentheight=parseInt(subobj.offsetHeight)
			if (typeof window["hidetimer_"+subobj.id]!="undefined") //clear timer that hides drop down box?
				clearTimeout(window["hidetimer_"+subobj.id])
			this.slideengine(subobj, (subobj.dropposition[1]=="top")? "up" : "down")
		}
	},

	curveincrement:function(percent){
		return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
	},

	slideengine:function(obj, direction){
		var elapsed=new Date().getTime()-obj.startTime //get time animation has run
		if (elapsed<obj.glidetime){ //if time run is less than specified length
			var distancepercent=(direction=="down")? this.curveincrement(elapsed/obj.glidetime) : 1-this.curveincrement(elapsed/obj.glidetime)
			var currentclip=(distancepercent*obj.contentheight)+"px"
			obj.style.clip=(direction=="down")? "rect(0 auto "+currentclip+" 0)" : "rect("+currentclip+" auto auto 0)"
			window["glidetimer_"+obj.id]=setTimeout(function(){dropdowncontent.slideengine(obj, direction)}, 10)
		}
		else{ //if animation finished
			obj.style.clip="rect(0 auto auto 0)"
		}
	},

	hide:function(activeobj, subobj, e){
		if (!dropdowncontent.isContained(activeobj, e)){
			window["hidetimer_"+subobj.id]=setTimeout(function(){
				subobj.style.visibility="hidden"
				subobj.style.left=subobj.style.top=0
				clearTimeout(window["glidetimer_"+subobj.id])
			}, dropdowncontent.delaybeforehide)
		}
	},

	ajaxconnect:function(pageurl, divId){
		var page_request = false
		var bustcacheparameter=""
		if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
			page_request = new XMLHttpRequest()
		else if (window.ActiveXObject){ // if IE6 or below
			try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
			catch (e){
				try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e){}
			}
		}
		else
			return false
		document.getElementById(divId).innerHTML=this.ajaxloadingmsg //Display "fetching page message"
		page_request.onreadystatechange=function(){dropdowncontent.loadpage(page_request, divId)}
		if (this.ajaxbustcache) //if bust caching of external page
			bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
		page_request.open('GET', pageurl+bustcacheparameter, true)
		page_request.send(null)
	},

	loadpage:function(page_request, divId){
		if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(divId).innerHTML=page_request.responseText
		}
	},

 init:function(anchorid, pos, glidetime){
		var anchorobj=document.getElementById(anchorid)
		var subobj=document.getElementById(anchorobj.getAttribute("rel"))
		var subobjsource=anchorobj.getAttribute("rev")
		if (subobjsource!=null && subobjsource!="")
			this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel"))
		subobj.dropposition=pos.split("-")
		subobj.glidetime=glidetime || 1000
		subobj.style.left=subobj.style.top=0
		anchorobj.onmouseover=function(e){dropdowncontent.show(this, subobj, e)}
		anchorobj.onmouseout=function(e){dropdowncontent.hide(subobj, subobj, e)}
		if (this.disableanchorlink) anchorobj.onclick=function(){return false}
		subobj.onmouseout=function(e){dropdowncontent.hide(this, subobj, e)}
	}
}
