// JavaScript Document
var	IntervalID = null;

function selectTeamOpstelling(oObj,n){
	oDiv = oObj.parentNode.parentNode;
	oDiv.childNodes[((n) ? 0 : 1)].className = 'unselected';
	oDiv.childNodes[n].className = 'selected';
}
	
function selectCompetitieType(n){
	oDiv = document.getElementById('StandHolder');
	for(var i=0;i<oDiv.childNodes.length;i++){
		if(i == n)
			oDiv.childNodes[i].className = 'selected';
		else
			oDiv.childNodes[i].className = 'unselected';
	}

	oDiv = document.getElementById('compButtons');
	for(var i=0;i<oDiv.childNodes.length;i++){
		if(i == n)
			oDiv.childNodes[i].className = 'slbtn';
		else
			oDiv.childNodes[i].className = 'btn';
	}
}
function loopAgenda(n,p){
	oAgenda = document.getElementById('agendaHolder');
	aAgenda = oAgenda.getElementsByTagName('table');
	for(var i=0;i<aAgenda.length;i++){
		if (aAgenda[i].style.display == 'block'){
			aAgenda[i].style.display = 'none';
			break;
		}
	}
	if (n==1){
		if ((i==1)||(i==0))
			p.parentNode.firstChild.firstChild.src= "img/btn_prev_grey.png"
		else
			p.parentNode.childNodes[2].firstChild.src= "img/btn_next.png"
		if (i>0){
			aAgenda[(i-1)].style.display = 'block';
			p.innerHTML = aAgenda[(i-1)].className;
		}
		else 
			aAgenda[i].style.display = 'block';
	}
			
	if (n==2){
		if ((i == aAgenda.length-2)||(i == aAgenda.length-1))
			p.parentNode.childNodes[2].firstChild.src= "img/btn_next_grey.png"
		else
			p.parentNode.firstChild.firstChild.src= "img/btn_prev.png"

		if (i != aAgenda.length-1){
			aAgenda[i+1].style.display = 'block';
			p.innerHTML = aAgenda[i+1].className;
		}
		else 
			aAgenda[i].style.display = 'block';
	}
}
function scrollFotos(direction,oBtn){
	oDiv = document.getElementById('fotolist');
	oMask = document.getElementById('fotomask');
	//document.getElementsByTagName('DIV')[0].appendChild(document.createTextNode((oDiv.offsetWidth-oMask.offsetWidth)+'px<br>'))
	//document.getElementsByTagName('DIV')[0].appendChild(document.createTextNode((oDiv.offsetWidth-oMask.offsetWidth)+'px<br>'))
	
	//alert(((oDiv.style.left.substr(0,oDiv.style.left.length-2)) ? parseInt(oDiv.style.left.substr(0,oDiv.style.left.length-2)) + eval(direction) : eval(direction)));
	//alert(oDiv.offsetWidth);
	//alert(oMask.offsetWidth);
	//alert(oBtn.className);
	IntervalID = setInterval(function() { 
									if(oDiv.style.left == '0px' || oDiv.style.left == 0)
										document.getElementById('prevbtn').src = 'img/previous.jpg';
									else
										document.getElementById('prevbtn').src = 'img/previous_red.jpg';
									if(Math.abs(oDiv.style.left.substr(0,oDiv.style.left.length-2)) > (oDiv.offsetWidth-oMask.offsetWidth))
										document.getElementById('nextbtn').src = 'img/next.jpg';
									else
										document.getElementById('nextbtn').src = 'img/next_red.jpg';
									
									if((oDiv.style.left == '0px' || oDiv.style.left == 0) && (oBtn.className == 'previous' || oBtn.className == 'previousdis')){
										if(IntervalID)
											clearInterval(IntervalID);
									}
									else if((Math.abs(oDiv.style.left.substr(0,oDiv.style.left.length-2)) > (oDiv.offsetWidth-oMask.offsetWidth)) && (oBtn.className == 'next' || oBtn.className == 'nextdis')){
										if(IntervalID)
											clearInterval(IntervalID);
									}
									else
										oDiv.style.left = ((oDiv.style.left.substr(0,oDiv.style.left.length-2)) ? parseInt(oDiv.style.left.substr(0,oDiv.style.left.length-2)) + eval(direction) : eval(direction)) + 'px';
										
							 },1);
}
function stopScroll(){
	if(IntervalID)
		clearInterval(IntervalID);
}
function emptyInput(sObj,sDefault,aInput){
oObj = document.getElementById(sObj)
	if (oObj.value == sDefault)
		for(var i=0;i<aInput.length;i++)
			document.getElementById(aInput[i]).value = "";
}

function switchBanner(oOld,oNew){
	oOld.style.display="none";
	oNew.style.display="block";
}
function GotoOnEnter(e,location,oForm){
	if(window.event)
		keyNum = e.keyCode;
	else if(e.which)
		keyNum = e.which;
	if (keyNum == 13){
		if (location!=null)
			window.document.location.href = location;	
		else 
			oForm.submit();
	}
}
function searchCheckboxes(oDiv){
	var aInput = oDiv.getElementsByTagName('INPUT');
	var sSearch= ''
	for(var i=0;i<aInput.length;i++){
		if (aInput[i].type == "checkbox")
			if (aInput[i].checked)
				sSearch += '&t[]=' + aInput[i].value;
	}
	return sSearch;
}

function fChangeWedSelectBox(oObject)
{
		window.location.href='layout.php?p=5&Start=' + 
				$(oObject).children('option:selected').val() + 
				'&Einde='+ $(oObject).children('option:selected').attr('name');
}