function openWindow(){
	var newwindow = window.open('', 'popup', 'top=150,left=100,height=475,width=850,toolbar=no,personalbar=no,locationbar=no,statusbar=no,scrollbars=yes,resizable=yes'); newwindow.focus();
	
	newwindow;	
}

function openOutBound(url){
	window.open(url);	
}

function setStatus(evt){
	evt = (evt) ? evt : ((window.event) ? window.event : "")
    if (evt) {
        var elem = getTargetElement(evt);
        if(elem.tagName== "IMG"){
			elem = elem.parentNode;
		}
        if (elem.href) {
            url = extractUrlFromTag(elem);
        }
		window.status = url;
		return true;
    }
}

function removeStatus(evt){
	window.status = '';
	return true;
}

function setEvents(){
	linkTable = document.getElementById("links");
	anchorArr = linkTable.getElementsByTagName("A");

	for(i=0; i<anchorArr.length; i++){
		var a = anchorArr[i];
		url = extractUrlFromTag(a);
		
		//cross browser... although firefox is buggy...
		a.setAttribute("onMouseOver", "window.status='" + url + "';return true;");
		a.setAttribute("onMouseOut", "window.status='';return true;");
		
		if (a.addEventListener){
			a.addEventListener("mouseover", setStatus, false);
			a.addEventListener("mouseout", removeStatus, false);
			continue;
		}
		else if (a.attachEvent){
			a.attachEvent("onmouseover", setStatus);
			a.attachEvent("onmouseout", removeStatus);
			continue;
		}
		else {
		    continue;
		}
		
	}
}

function getTargetElement(evt) {
    var elem
    if (evt.target) {
        elem = (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target
    } else {
        elem = evt.srcElement
    }
    return elem;

}

function onInFrameSet(){
	try{
		//will throw an error if parent body exists (when not on same domain).
		var test = parent.document.body;
	}
	catch(evt){
		//if error is thrown, rewrite all inbound anchor tags with an additional target="_top"
		var anchorArr = document.getElementsByTagName("A");
		
		for(i=0; i<anchorArr.length; i++){
			var a = anchorArr[i];
			
			if(a.href.indexOf("javascript:") == -1 && a.href.indexOf("dsshonkbal.nl") != -1 && a.target == ""){
				a.setAttribute("target", "_top");
			}
		}
	}
}

function extractUrlFromTag(obj){
	
	onClickAtt = obj.getAttribute("onclick");
	
	if(onClickAtt && onClickAtt.toString().indexOf("function") != -1 && document.all){
		//regExp1 = /function anonymous\(\)\n{\n/;
		//regExp2 = /\n}$/;
		onClickAtt = onClickAtt.toString().replace("function anonymous()\n{\n","").replace("\n}", "");
		//alert(onClickAtt);
	}
	else if(onClickAtt){
		onClickAtt.toString();	
	}
	
	
	//alert(onClickAtt)
	if(onClickAtt && onClickAtt.indexOf("openOutBound") != -1){
		url = onClickAtt.substring(onClickAtt.indexOf("'")+1, onClickAtt.lastIndexOf("'"));
	}
	else if(obj.href.indexOf("javascript:") != -1){
		url = obj.href.substring(obj.href.indexOf("'")+1, obj.href.lastIndexOf("'"));
		//url = '';
	}
	else {
		url = obj.href;	
	}

	return url;
}

function openWindowForForum(){
	var newwindow = window.open('', 'popup', 'top=150,left=100,height=350,width=370,toolbar=no,personalbar=no,locationbar=no,statusbar=no,scrollbars=no,resizable=no'); newwindow.focus();
	
	newwindow;	
}
