function opslaan()
{
  if (document.getElementById)
  {
    x = document.getElementById('opslaan');
    x.innerHTML = '<b><font color=red>Gegevens zijn gewijzigd. Druk op [Opslaan] om de gegevens definitief op te slaan.</font></b>';
    document.getElementById('select_ronde').disabled = true;
    document.getElementById('button_teamscores').style.display="none";
  }
}

function popup(url) {
  naam = window.open(url, "popupmail", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=400,height=240,left=200,top=200")

  b = 448;
  h = 400;
  x = (screen.width / 2) - (b / 2);
  y = (screen.height / 2) - (h / 2);
  naam.moveTo(x, y);
  naam.resizeTo(b, h);
  if (!naam.opener) naam.opener = self;
  naam.focus();
}

function toonFaq(div) {
  var faq = document.getElementById(div);  
  if (faq.style.display == "none") { faq.style.display = "block"; }
  else { faq.style.display = "none"; } 
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
// Found at (and credit goes to): http://www.somacon.com/p143.php
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 150;
  var opacity = options.opacity || 75;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#FFFFFF';
  var dark=document.getElementById('darkenScreenObject');
  scroll(0,0);
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block'; 
    dark.innerHTML = '<center><br><br><br><br><br><br><br><br><br><br><br><b>Een ogenblik geduld alstublieft<br><br><img src="blok.gif" alt="Busy..." border=0 heigth=73 width=75><br><br>Bezig met verwerken van gegevens</b></center>';
  } else {
     dark.style.display='none';
     dark.innerHTML = '';
  }
}

function disable_links() {
// This function disables all links on a page.
	for(var i=0; i < document.links[i].lenght; i++ )
	{
		document.links[i].onclick=function () { return false; }
		document.links[i].title= "Bezig met Opslaan....";
	}
	return true;
}

function navigateScoreForm(Event){

//var inputElement = Event.target;
Event = Event || window.event; // IE doesn't pass event as argument.
var key = Event.keyCode;
var tgt = Event.target || Event.srcElement; // IE doesn't use .target
var strid = tgt.id;
var col = parseInt(strid);
var row = parseInt(strid.subStr(2));

//var row = 2;

// if the up arrow has been pressed and we're not in the first row
if( key == 38 && row != 1) {
document.getElementById(row-1 + "--" + col).focus();
return false;
}
// if the down arrow has been pressed and we're not in the last row
else if( key == 40) {
document.getElementById(row+1 + "--" + col).focus();
return false;
}
// if the left arrow has been pressed and we're not in the leftmost column
else if( key == 37 && col != 1) {
document.getElementById(row + "--" + col-1).focus();
return false;
}
// if the right arrow has been pressed and we're not in the rightmost column
else if( key == 39 && col != 7) {
document.getElementById(row + "--" + col+1).focus();
return false;
}
// don't allow any of non-numeric characters but do allow the tab key
else if ( (key<48||key>57) && key != 9)
{
return false;
}

return true;

} // end checkKey function

