//browsercheck
ie = (String(navigator.appName).toLowerCase().indexOf("microsoft") != -1);
ns = (String(navigator.appName).toLowerCase().indexOf("netscape") != -1);
win = (String(navigator.platform).toLowerCase().indexOf("win") != -1);
mac = (String(navigator.platform).toLowerCase().indexOf("mac") != -1);
var bVer = parseFloat(ie ? String(navigator.appVersion).substring(String(navigator.appVersion).indexOf("MSIE") + 4) : String(navigator.appVersion));
var ns4 = (document.layers != null);
var ie4 = (document.all != null);
var ieNOTopera= (document.all&&navigator.userAgent.indexOf("Opera")==-1)
var w3c = (document.getElementById != null && !ie4);
var hasLayers = (w3c || ns4 || ie4);
//screensize
sixbyfour = (bVer >= 4 ? screen.width<800 : true);
eightbysix = (!sixbyfour&&(bVer >= 4 ? screen.width<1000 : false));
tenbyseven = (bVer>=4 ? screen.width>1000 : false);

if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
function queryString(_wich){
	var result = "";
	var s = new Array();
	s = String(document.location).split("?");
	var vars = new Array();
	vars = String(s[1]).split("&");
	for(var n=0;n<vars.length;n++){
		var thisProp = vars[n].split('=');
		if (unescape(thisProp[0]).indexOf(_wich)!=-1) result = unescape(thisProp[1]);
	}
	result = unescape(escape(result).split('%92').join("'"))
	result = result.split("+").join(" ");
	return result;
}

//windowsize on mac ie4
if(queryString("xtra")=="macie4"&&queryString("macie4w")!=""&&queryString("macie4h")!="")self.resizeTo(parseInt(queryString("macie4w")),parseInt(queryString("macie4h")))

if(ie&&bVer<6){
	//ie5 solutions
	var undefined = false;
}else if(ie&&!document.getElementById){
	document.getElementById = function(objID){return document.all[objID];};
}

visible = (ns4)? 'show':'visible';
hidden = (ns4)? 'hide':'hidden';
cursor = new Object();
cursor.x = 0;
cursor.y = 0;

function trim(_string){//string
	var result=_string;
	if(typeof(result)=='string'){
		for(var n=0;n<result.length;n++){
			if(result.substr(n,1)!=' '){
				result = result.substr(n);
				break;
			}
		}
		for(var n=result.length-1;n>-1;n--){
			if(result.substr(n,1)!=' '){
				result = result.substr(0,n+1);
				break;
			}
		}
	}
	return result;
}

function addObjEvent(objId,objEventName,objEventFunction,absLeft,absTop,absRight,absBottom){
	arg = new Array();
	eventArgs = objEventFunction;
	objEventFunction = eventArgs[0];
	for(var n=1;n<eventArgs.length;n++){
		arg[arg.length] = eventArgs[n];
	}
	if(ie4){
		obj=document.all[objId];
		if(typeof(obj)=='object' && obj){
			if(!obj[objEventName]) obj[objEventName] = new Array();
			obj[objEventName][obj[objEventName].length]=[objEventFunction,arg];
			obj[objEventName+'AbsoluteLeft']=absLeft?absLeft:false;
			obj[objEventName+'AbsoluteTop']=absTop?absTop:false;
			obj[objEventName+'AbsoluteRight']=absRight?absRight:false;
			obj[objEventName+'AbsoluteBottom']=absBottom?absBottom:false;
			addObjectListener(obj);
		}
	}else if(w3c){
		obj=document.getElementById(objId);
		if(typeof(obj)=='object' && obj){
			if(!obj[objEventName]) obj[objEventName] = new Array();
			obj[objEventName][obj[objEventName].length]=[objEventFunction,arg];
			obj[objEventName+'AbsoluteLeft']=absLeft?absLeft:false;
			obj[objEventName+'AbsoluteTop']=absTop?absTop:false;
			obj[objEventName+'AbsoluteRight']=absRight?absRight:false;
			obj[objEventName+'AbsoluteBottom']=absBottom?absBottom:false;
			addObjectListener(obj);
		}
	}
}
function addObjectListener(obj){
	if(!document.extraEventListeners){
		document.extraEventListeners = new Array();
	}
	if(typeof(obj)=='object'){
		if(!isExtraEventListener(obj))document.extraEventListeners[document.extraEventListeners.length]=obj;
	}
	return document.extraEventListeners;
}

function isExtraEventListener(obj){
	var result = false
	if(ie4){
		if(typeof(obj)=='object' && document.extraEventListeners){
			for(var n=0;n<document.extraEventListeners.length;n++){
				if(document.extraEventListeners[n]==obj){
					result = true;
					break;
				}
			}
		}
	}else if(w3c){
		if(typeof(obj)=='object' && document.extraEventListeners){
			for(var n=0;n<document.extraEventListeners.length;n++){
				if(document.extraEventListeners[n]==obj){
					result = true;
					break;
				}
			}
		}
	}
	return result;
}

function mouseMove(e){
	if(w3c){
		cursor.x = e.clientX;
		cursor.y = e.clientY;
	}else if(ns4){
		cursor.x = e.pageX;
		cursor.y = e.pageY;
	}else if(ie4){
		cursor.x = event.clientX + document.body.scrollLeft;
		cursor.y = event.clientY + document.body.scrollTop;
	}


	/*
	var regArray = addObjectListener();
	if(typeof(regArray)=='object'){
		for(var n=0;n<regArray.length;n++){
			if(w3c||(ie&&bVer>=4)){
				obj = regArray[n];
				if(obj.onMOver||obj.onMOut){
					if(cursor.x>getOffsetLeft(obj)
						&&cursor.x<getOffsetLeft(obj)+obj.offsetWidth
						&&cursor.y>getOffsetTop(obj)
						&&cursor.y<getOffsetTop(obj)+obj.offsetHeight
						&&(cursor.x>obj.onMOverAbsoluteLeft||!obj.onMOverAbsoluteLeft)
						&&(cursor.y>obj.onMOverAbsoluteTop||!obj.onMOverAbsoluteTop)
						&&(cursor.x<obj.onMOverAbsoluteRight||!obj.onMOverAbsoluteRight)
						&&(cursor.y<obj.onMOverAbsoluteBottom||!obj.onMOverAbsoluteBottom)){
						if(obj.onMOver&&!obj.mouseWithin&&!isHidden(obj)){
							for(var n=0;n<obj.onMOver.length;n++){
								obj.onMOver[n][0](obj.onMOver[n][1]);
							}
						}
						obj.mouseWithin = true;
					}else{
						if(obj.onMOut&&obj.mouseWithin&&!isHidden(obj)){
							for(var n=0;n<obj.onMOut.length;n++){
								obj.onMOut[n][0](obj.onMOut[n][1]);
							}
						}
						obj.mouseWithin = false;
					}
					obj.cursorX = cursor.x-getOffsetLeft(obj);
					obj.cursorY = cursor.y-getOffsetTop(obj);
				}
			}
		}
	}*/
}

function myCursor(obj){
	return {x:cursor.x-getOffsetLeft(obj),y:cursor.y-getOffsetTop(obj)};
}

function myHeight(objID){
	var result = 0;
	if(w3c){
		var scrObj = typeof(objID)=='string' ? document.getElementById(objID):objID;
		if(typeof(scrObj)=='object')result = parseInt(scrObj.offsetHeight);
	}else if(ie4){
		scrObj = typeof(objID)=='string' ? document.all[objID]:objID;
		if(typeof(scrObj)=='object')result = parseInt(scrObj.offsetHeight);
	}
	return result;
}

function myWidth(objID){
	var result = 0;
	if(w3c){
		var scrObj = typeof(objID)=='string' ? document.getElementById(objID):objID;
		if(typeof(scrObj)=='object')result = parseInt(scrObj.offsetWidth);
	}else if(ie4){
		scrObj = typeof(objID)=='string' ? document.all[objID]:objID;
		if(typeof(scrObj)=='object')result = parseInt(scrObj.offsetWidth);
	}
	return result;
}

function getOffsetLeft (el) {
	if(w3c||(ie&&bVer>=4)){
		if(typeof(el)=='string')el=document.getElementById(el);
		var result = el.offsetLeft;
		while ((el = el.offsetParent) != null)
			result += el.offsetLeft;
		return result;
	}
}
function getOffsetTop (el) {
	if(w3c||(ie&&bVer>=4)){
		if(typeof(el)=='string')el=document.getElementById(el);
		var result = el.offsetTop;
		while((el = el.offsetParent) != null)
			result += el.offsetTop;
		return result;
	}
}

function getMarginTop (el) {
	if(w3c||(ie&&bVer>=4)){
		if(typeof(el)=='string')el=document.getElementById(el);

		var result = el.style.border;///margin;//marginTop;//isNaN(parseInt(el.style.marginTop))?0:parseInt(el.style.marginTop);
		return result;
	}
}

function getProperties(obj){
	if(w3c){
		var scrObj = typeof(obj)=='string'?document.getElementById(obj):obj;
		var result=new Array();
		for(n in obj){
			result.push(n+':'+obj[n]);
		}
	}else if(ie4){
		var scrObj = typeof(obj)=='string'?document.all[obj]:obj;
		var result=new Array();
	alert(scrObj)
		for(n in scrObj){
			result[result.length] = n+':'+scrObj[n];
		}
	}
	return result;
}

function isVisible(objID){
	if(!document.styleRules) makeDivStyles();
	var result = true;
	if(ie4){
		var obj=typeof(objID)=='string'?document.all[objID]:objID;
		if(typeof(obj)=='object'){
			if(obj.style){
				if(obj.style.visibility=='hidden'||obj.style.visibility=='visible'){
					result = obj.style.visibility=='visible';
				}else if(obj.parentNode){
					result = isVisible(obj.parentNode);
				}
			}else if(obj.parentNode){
				result = isVisible(obj.parentNode);
			}
		}
	}else if(w3c){
		var obj=typeof(objID)=='string'?document.getElementById(objID):objID;
		if(typeof(obj)=='object'){
			if(obj.style){
				if(obj.style.visibility=='hidden'||obj.style.visibility=='visible'){
					result = obj.style.visibility=='visible';
				}else if(obj.parentNode){
					result = isVisible(obj.parentNode);
				}
			}else if(obj.parentNode){
				result = isVisible(obj.parentNode);
			}
		}
	}
	return result;
}


function isHidden(objID){
	if(!document.styleRules) makeDivStyles();
	var result = false;
	if(ie4){
		var obj=typeof(objID)=='string'?document.all[objID]:objID;
		if(typeof(obj)=='object'){
			if(obj.style){
				if(obj.style.visibility=='hidden'){
					result = true;
				}else if(obj.parentNode){
					result = isHidden(obj.parentNode);
				}
			}else if(obj.parentNode){
				result = isHidden(obj.parentNode);
			}
		}
	}else if(w3c){
		var obj=typeof(objID)=='string'?document.getElementById(objID):objID;
		if(typeof(obj)=='object'){
			if(obj.style){
				if(obj.style.visibility=='hidden'){
					result = true;
				}else if(obj.parentNode){
					result = isHidden(obj.parentNode);
				}
			}else if(obj.parentNode){
				result = isHidden(obj.parentNode);
			}
		}
	}
	return result;
}

function makeDivStyles(){
	var tagsToCheck = new Array();
	for(var n=0;n<arguments.length;n++){
		if(ie4){
			if(document.all.tags(arguments[n]).length!=0){
				tagsToCheck[tagsToCheck.length]=arguments[n];
			}
		}else if(w3c){
			if(document.getElementsByTagName(arguments[n]))tagsToCheck[tagsToCheck.length]=arguments[n];
		}
	}
	if(document.debug) window.status='makeDivStyles()';
	if(!document.styleRules) makeStyleRules();
	if(typeof(tagsToCheck)=='object'){
		if(tagsToCheck.length){
			if(ie4){
				for(var tagNo=0;tagNo<tagsToCheck.length;tagNo++){
					var divCollection = document.all.tags(tagsToCheck[tagNo]);
					for(var n=0;n<divCollection.length;n++){

						if(divCollection[n].className&&divCollection[n].className!=''){
							if(document.styleRules[divCollection[n].className]){
								divCollection[n].style.cssText = document.styleRules[divCollection[n].className];
							}else{
								//alert('css class \'.'+divCollection[n].className+' {}\' is not defined!')
							}
						}else if(divCollection[n].nodeName&&divCollection[n].nodeName!=''){
							if(document.styleRules[divCollection[n].nodeName]){
								divCollection[n].style.cssText = document.styleRules[divCollection[n].nodeName];
							}
						}

					}
				}
			}else if(w3c){
			/*
				for(var tagNo=0;tagNo<tagsToCheck.length;tagNo++){
					var divCollection = document.getElementsByTagName(tagsToCheck[tagNo]);
					for(var n=0;n<divCollection.length;n++){
						if(divCollection[n].className&&divCollection[n].className!=''){
							if(document.styleRules[divCollection[n].className]){
								divCollection[n].setAttribute("style",document.styleRules[divCollection[n].nodeName]);
							}else{
								alert('css class \'.'+divCollection[n].className+' {}\' is not defined!')
							}
						}else if(divCollection[n].nodeName&&divCollection[n].nodeName!=''){
							if(document.styleRules[divCollection[n].nodeName]){
								divCollection[n].setAttribute("style",document.styleRules[divCollection[n].nodeName]);
							}
						}

					}
				}
			*/
			}
		}
	}
	if(document.debug)window.status='';
}

function makeStyleRules(){
	if(document.debug)window.status='makeStyleRules()';
	if(!document.styleRules)document.styleRules = new Object();
	if(ie4){
		for(var ss=0;ss<document.styleSheets.length;ss++){
			for(var ssr=0;ssr<document.styleSheets[ss].rules.length;ssr++){
				var ruleName = String(document.styleSheets[ss].rules[ssr].selectorText);
				if(ruleName.indexOf('.')!=-1){
					ruleName = ruleName.substr(ruleName.indexOf('.')+1);
				}else if(ruleName.indexOf('#')!=-1){
					ruleName = ruleName.substr(ruleName.indexOf('#')+1);
				}
				rule = String(document.styleSheets[ss].rules[ssr].style.cssText);
				if(rule.indexOf('{')!=-1)rule=rule.substr(rule.indexOf('{')+1);
				if(rule.indexOf('}')!=-1)rule=rule.substr(0,rule.indexOf('}')-1);
				document.styleRules[ruleName]=rule;
			}
		}
	}else if(w3c){
		for(var ss=0;ss<document.styleSheets.length;ss++){
			for(var ssr=0;ssr<document.styleSheets.item(ss).cssRules.length;ssr++){
				var ruleName = String(document.styleSheets.item(ss).cssRules.item(ssr).selectorText);
				if(ruleName.indexOf('.')!=-1){
					ruleName = ruleName.substr(ruleName.indexOf('.')+1);
				}else if(ruleName.indexOf('#')!=-1){
					ruleName = ruleName.substr(ruleName.indexOf('#')+1);
				}
				rule = String(document.styleSheets.item(ss).cssRules.item(ssr).style.cssText);
				if(rule.indexOf('{')!=-1)rule=rule.substr(rule.indexOf('{')+1);
				if(rule.indexOf('}')!=-1)rule=rule.substr(0,rule.indexOf('}')-1);
				document.styleRules[ruleName]=rule;
			}
		}
	}
}

// events afvangen
 document.onmousemove = mouseMove;
 if (ns4) document.captureEvents(Event.MOUSEMOVE);
