function cOn(td, color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	  td.style.cursor = 'pointer';
	}
}
function cOut(td,color) {
    if(document.getElementById||(document.all && !(document.getElementById))) {
	  td.style.backgroundColor= color;
	}
}		 

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
function isReady(form) {
    if (isEmail(form.email.value) == false) {
        alert("Het ingevoerde emailadres is geen geldig adres.");
        form.email.focus();
        return false;
    }
    return true;
}

function checkImage() {
	document.getElementById('DivImage').style.display = 'none';
}

function showPopup(URL,w,h,resize,scr)
{  
 l = (screen.availWidth-w) / 2;
 t = (screen.availHeight-h) / 2;
 window.open(URL, "Mail", "height=" + h + ",width=" + w + ",top=" + t + ",left=" + l + ",toolbar=no,status=no,resizable=" + resize + ",scrollbars=" + scr +"");
}

function showZoomPopup(URL,name,w,h,resize,scr)
{  
 l = (screen.availWidth-w) / 2;
 t = (screen.availHeight-h) / 2;
 window.open(URL, name, "height=" + h + ",width=" + w + ",top=" + t + ",left=" + l + ",toolbar=no,status=no,resizable=" + resize + ",scrollbars=" + scr +"");
}


function addFileInput(input_name,container_id)
{ 
  var container = document.getElementById(container_id); 
  var newInput = document.createElement("input"); 
  newInput.setAttribute('type','file'); 
  newInput.setAttribute('name',input_name); 
  newInput.setAttribute('size',29); 
  var random = Math.random(); 
  var random = random * 10; 
  newInput.setAttribute('id','file_' + random); 
  window.inputId = 'file_' + random; 
  container.appendChild(newInput); 
} 
     
function hideInput(listbox_id)
{ 
  var input = document.getElementById(window.inputId); 
  if (input.value != "")
  { 
    input.style.display = 'none'; 
    addFileToList(listbox_id); 
    return true; 
  }
  else
  { 
    return false; 
  } 
} 
     
function addFileToList(listbox_id)
{ 
  var input = document.getElementById(window.inputId); 
  var container = document.getElementById(listbox_id); 
  var newOption = document.createElement("option"); 
  var newOptionText = document.createTextNode(input.value); 
  newOption.appendChild(newOptionText); 
  container.appendChild(newOption); 
} 
     
function attachFile(listbox_id, input_name, container_id)
{ 
  if (hideInput('files'))
  { 
    addFileInput('files[]','file_attach'); 
  } 
} 

function delFileToList()
{
  var sel=frmReview.files.selectedIndex;
  if (sel==-1) return
	frmReview.files.options.remove(sel);
}

function checkformOnId(obj,rdprefix){
	var form=document.getElementById(obj);
	var rdGroup;
	var rdTitle='';
	var msg='';
	var radioresult=false;
	for(i=0;i<form.elements.length;i++){
		if(form.elements[i].id!=''){
			if(form.elements[i].id.indexOf(rdprefix) != -1){
				if (form.elements[i].getAttribute('type') == 'radio'){					
					if (form.elements[i].checked){ 
						radioresult = true;
					}
					else{
						rdTitle = form.elements[i].title;
					}
				}
			}
		}
	}
	for(i=0;i<form.elements.length;i++){
		if(form.elements[i].id!=''){
			if(form.elements[i].value==''){
				msg = msg + "- " + form.elements[i].title + "\n";
				form.elements[i].style.backgroundColor = "#DDDDDD";
				form.elements[i].style.color = "#333333";
		    }
			else {
				if (form.elements[i].getAttribute('type') != 'radio'){
					form.elements[i].style.backgroundColor = "#FFFFFF";
					form.elements[i].style.color = "#333333";
				}
			}
		}
	}
	if (rdTitle !='' && radioresult == false){
		msg = msg + "- " + rdTitle + "\n";
	}
	if(obj == 'frmRegistreren') {
		if(document.getElementById('password').value!=document.getElementById('passwordBis').value){
			msg = msg + "- " + 'Wachtwoorden zijn niet aan elkaar gelijk' + "\n";
			document.getElementById('password').style.backgroundColor = "#DDDDDD";
			document.getElementById('password').style.color = "#333333";
			document.getElementById('passwordBis').style.backgroundColor = "#DDDDDD";
			document.getElementById('passwordBis').style.color = "#333333";
		}
	}
	if(msg!='') {
		alert("De volgende velden zijn verplicht:\n" + msg);
		return false;
	}
	else {
	 	form.submit();
	}
}

function checkform_reaction() { 
	var formOK = 1;
	var msg = '';
	if (document.getElementById('naam').value == '' || document.getElementById('naam').value == 'Naam') {
		formOK = 0;
		msg = msg + "- Naam verzender\n";
	}
	if (document.getElementById('email').value == '' || document.getElementById('email').value == 'E-mail') {
		formOK = 0;
		msg = msg + "- E-mailadres verzender\n";
	}
	if (document.getElementById('bericht').value == '' || document.getElementById('email').value == 'Reactie') {
		formOK = 0;
		msg = msg + "- Reactie\n";
	}
	if (formOK == 1) {
		document.getElementById('form').submit();
	}
	if (formOK == 0) {
		msg = 'Vult u a.u.b. de volgende velden in:\n\n' + msg;
		alert(msg);
	}
	
}

function ChangeImage(obj,img)
{
if (obj != '' && img != '')
	{
	obj.src = img;
	}	
}

function preLoader()
{ 
  var args = preLoader.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function CatchReturnToSubmit(e){
	if (e.keyCode){
		keycode=e.keyCode;
	} 
  else{
		keycode=e.which;
  } 
  char=String.fromCharCode(keycode); 
  xCode=char.charCodeAt(0); 	
	if (xCode == 13){
		document.getElementById('frmSearch').submit();
	}
}
function showHideMag() {
	var arrDiv = document.getElementsByTagName("div");
	var aL = arrDiv.length;
	for(i=0; i < aL; i ++){
		if(arrDiv[i].id=='nextMagImage'){
			if(document.getElementById('nextMagImage').style.display=='block') {
				document.getElementById('nextMagImage').style.display='none';
				document.getElementById('nextMagText').style.display='block';
			}else{
				document.getElementById('nextMagImage').style.display='block';
				document.getElementById('nextMagText').style.display='none';
			}
		}
	}
	t=setTimeout("showHideMag()",5000)
}

function toggleItem() {
	var arrTI = document.getElementsByTagName("div");
	var aL = arrTI.length;
	var currentId,nextId;
	j=0
	for(i=0; i < aL; i ++){
		if(arrTI[i].id.indexOf('sportItem')!=-1){
			if(arrTI[i].style.display=='block'){
				currentId=j
			}
			j++
		}
	}
	if(currentId==undefined){
		currentId=0
		nextId=0
	}else{
		nextId = currentId + 1;
		if(nextId == j) {
			nextId=0
		}
	}
	j=0
	for(i=0; i < aL; i ++){
		if(arrTI[i].id.indexOf('sportItem')!=-1){
			if(j!=nextId){
				arrTI[i].style.display='none'
			}else{
				arrTI[i].style.display='block'
			}
			j++
		}
	}
	t=setTimeout("toggleItem()",3000)
}

function PrintOutAgenda(url){
window.open(url,'Agenda','scrollbars=yes,width=600,height=550,left=0,top=0')
}
function go(urLL,target,w,h) {
	if (target == 1) {
		if (w>0 && h>0) {
			window.open(urLL,'_blank','toolbar=no,location=no,resizable=no,status=no,scrollbars=no,menubar=no,width='+w+',height='+h+',left=0,top=0');
		} else {
			window.open(urLL,'_blank','toolbar=no,location=no,resizable=no,status=no,scrollbars=no,menubar=no,width=794,height=550,left=0,top=0');
		}
	} else {
		window.location = urLL;
	}
}
function isNumberKey(e) {
	var k;
	document.all ? k = e.keyCode : k = e.which;
	return ((k > 47 && k < 58 || k == 44 || k == 46));
}
function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}