// needed for superquiz
this.name = "youXme";

function checkLoginForm(inCMS) {

	if(inCMS) {
		return false;
	}

	if (document.getElementById("user").value == "") {
		alert("Vul je gebruikersnaam in."); 
		document.getElementById("user").focus(); 
		return false;
	};
	if (document.getElementById("pass").value == "") {
		alert("Vul je wachtwoord in."); 
		document.getElementById("pass").focus(); 
		return false;
	};
	return true;
}

function checkSearchForm() {
	if (document.getElementById("keyword").value == "") {
		alert("Vul een zoekterm in."); 
		document.getElementById("keyword").focus(); 
		return false;
	};
	
	if (document.getElementById("keyword").value.length <= 2) {
		alert("Je zoekterm moet minimaal 3 karakters bevatten."); 
		document.getElementById("keyword").focus(); 
		return false;
	};
	
	if (document.getElementById("keyword").value.indexOf("<") > -1 || document.getElementById("keyword").value.indexOf(">") > -1) {
		alert("Je zoekterm bevat 1 of meer ongeldige karakters."); 
		document.getElementById("keyword").focus(); 
		return false;
	};
	return true;
}


function checkPanels() {
	/* 1st panel */
	var count = 0;
	var ul = document.getElementById("articleAdditionalLinks").getElementsByTagName("UL");
	if(!ul || !ul.length) {
		hidePanel(1);
	} else {
		//check every UL for LI's
		for (var i=0;i<ul.length;i++) {
			var lis = ul[i].getElementsByTagName("li");
			if(lis.length) count++;
		}
		if (count == 0) hidePanel(1);
	}
	
	/* 2nd panel */				
	var ul2 = document.getElementById("articleMoreInfo").getElementsByTagName("UL");
	if(!ul2 || !ul2.length) {
		hidePanel(2);
	} else {
		var lis2 = ul2[0].getElementsByTagName("LI");
		if (!lis2.length) {
			hidePanel(2);
		}
	}
}

function hidePanel(p) {
	switch (p) {
		case 1:
			document.getElementById("ulHead").style.display = "none"; document.getElementById("articleAdditionalLinks").style.display = "none";
			break;
		case 2:
			document.getElementById("ulHead2").style.display = "none"; document.getElementById("articleMoreInfo").style.display = "none";
			break;					
	}
}



function showHand(obj) {
	if(navigator.appVersion.indexOf("MSIE") != -1) {
		obj.style.cursor = 'hand';
	} else {
		obj.style.cursor = 'pointer';
	}
}


 function js_in_array(the_needle, the_haystack){
        var the_hay = the_haystack.toString();
        if(the_hay == ''){
            return false;
        }
        var the_pattern = new RegExp(the_needle, 'g');
        var matched = the_pattern.test(the_haystack);
        return matched;
    }

	
function ndPopup(aTag, pWidth, pHeight) {
	//This function is supposed to be called from the a-tag with valid href-attribute
	//If pWidth and pHeight are given, the popup will assume them as width and height
	if (!pWidth) pWidth=600; if (!pHeight) pHeight=500;
	if (top.ndCMSPopup && !top.ndCMSPopup.closed && top.ndCMSPopup.close) top.ndCMSPopup.close();
	top.ndCMSPopup = top.open(aTag.href, "ndCMSPopup", "width="+pWidth+",height="+pHeight+",resizable=1,menubar=1");
	top.ndCMSPopup.focus();
	return false;
}



// popup
	function doPopup(url,width,height,bool_scrollbars) {
		var posLeft = (screen.availWidth - width) / 2;
		var posTop  = (screen.availHeight - height) / 2;
		var parameter3 = "width=" + width + ",height=" + height + ",resizable=0,left=" + posLeft + ",top=" + posTop;
		if (bool_scrollbars) parameter3 = parameter3 + ",scrollbars";
		if ((top.pmPopup) && (!top.pmPopup.closed)) top.pmPopup.close();
		top.pmPopup = window.open(url,"pmPopup",parameter3);	
		top.pmPopup.focus();
	}
	
	
	function logoutVisitor() {
		document.getElementById("logout").submit();
	}
	
	
	
	
	
function checkPollForm() {
		if (inCMS) {
			return false;
		} else {
			//check aangetickte opties
			inputs = document.getElementById("pollForm").getElementsByTagName("INPUT");
			count = 0;
			for (i=0; i<inputs.length; i++) {
				if (inputs[i].type.toLowerCase() == "radio" && inputs[i].checked == true) {
					count++;
				}
			}
			if (count > 0) {
				document.getElementById('pollForm').submit();
			} else {
				alert("Kies a.u.b. een optie");
				return false;
			}
		}
}

function setMenuItem(pid) {
	if (document.getElementById("topleftmenu") && document.getElementById("topleftmenu").getElementsByTagName("a")) {
		
		var aTags = document.getElementById("topleftmenu").getElementsByTagName("a");
		
		for (var i=0; i<aTags.length; i++) {
			if (aTags[i].href.indexOf("_"+pid+".html") != -1) {
				//alert(0);		
				aTags[i].className = aTags[i].className + " active";
			}
			
		}
	}
}