// set focus to first field on page
var bFound = false;

  // for each form
  for (f=0; f < document.forms.length; f++)
  {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden")
      {
        // and it's not disabled
        if (document.forms[f][i].disabled != true)
        {
            // set the focus to it
            document.forms[f][i].focus();
            var bFound = true;
        }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
  
function toggleDiv(divid){
if(document.getElementById(divid).style.display == 'none'){
  document.getElementById(divid).style.display = 'block';
}else{
  document.getElementById(divid).style.display = 'none';
}
}


function toggle(toggleId, e)
{
 if (!e) {
  e = window.event;
 }
 if (!document.getElementById) {
  return false;
 }
 var body = document.getElementById(toggleId);
 if (!body) {
  return false;
 } 
 var im = toggleId + "_toggle";
 if (body.style.display == 'none') {
  body.style.display = 'block';
  if (document.images[im]) {
   document.images[im].src = "/images/icons/icon-minus.gif";
  }
 } else {
  body.style.display = 'none';
  if (document.images[im]) {
   document.images[im].src = "/images/icons/icon-plus.gif";
  }
 }
 if (e) {
  // Stop the event from propagating, which
  // would cause the regular HREF link to
  // be followed, ruining our hard work.
  e.cancelBubble = true;
  if (e.stopPropagation) {
   e.stopPropagation();
  }
 }
}

  
//<SCRIPT LANGUAGE=javascript>
<!--
//----------------------
// uses:	overlib.js	
//----------------------

//-- Open centered popup
//-- <a href="file.asp" onClick="NewWindow(this.href,'Reageer','700','500','yes');return false">link</a>
//  onClick="window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200,toolbar=yes, 
//  location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, 
//  resizable=yes')"
var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

//-------------------------------------------------
//This script is written by Eric (Webcrawl@usa.net)
//For full source code, installation instructions,
//100's more DHTML scripts, and Terms Of
//Use, visit dynamicdrive.com
//---------------------------
function showPrintDialogbox()
{
	//var NS = (navigator.appName == "Netscape");
	var nBrowserVersion = parseInt(navigator.appVersion);
	if (nBrowserVersion > 3)
	{
		if (window.print)
		    window.print();  
		else
		{
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
		}
	}
}


//--------------------------
// Ordinaire trim functie	
//--------------------------
function trim(s)
{ 
	while (s.substring(0,1)==' ')					s=s.substring(1,s.length);
	while (s.substring(s.length-1,s.length)==' ')	s=s.substring(0,s.length-1);
	return s;
}




//----------------------------------
// Code voor gebruiken Overlib.js	
// for mouseovers					
// werkt op netscape 4 pas na herladen???
//----------------------------------


function insertTextLayerDiv()
{
	document.write('<div ID="overDiv" STYLE="position:absolute; visibility:hide; z-index:1000;"></div>');
}

function showTextLayer(sTekst)
{
	return overlib(sTekst);
	//return overlib(sTekst, WIDTH, '180', FGCOLOR, '#ffffff', BGCOLOR, 'black', TEXTCOLOR, 'black', CAPCOLOR, 'white', BORDER, 1, SNAPX, 3, SNAPY, 3, TEXTFONT, 'Tahoma', CAPTIONFONT, 'Tahoma', TEXTSIZE, 2, CAPTIONSIZE, 2, ABOVE, LEFT);
}

function hideTextLayer()
{
	return nd();
}


//----------------------------------
// Delay functies					
//----------------------------------

function wait(delay)
{
	setTimeout('pauseforalert('+delay+')',delay);
}
		
function pauseforalert(delay)
{
	alert("Ok "+delay/1000+" seconds have elapsed");
}

//----------------------------------
// hoover over regels en verander achtergrond					
//----------------------------------

function tr_onmouseover(element) {
    var oTR = getElement(element, "TR");
    if (oTR != null && !eval(oTR.active)) {
        oTR.style.backgroundColor = "silver";
    }
}
function tr_onmouseout(element) {
    var oTR = getElement(element, "TR");
    if (oTR != null && !eval(oTR.active)) {
        oTR.style.backgroundColor = "";
    }
}
function tr_onclick(element) {
    var oTR = getElement(element, "TR");
    var oTABLE = getElement(oTR, "TABLE");
    if (oTABLE != null) {
        if (typeof(oTABLE.activeRow) != "undefined" && oTABLE.activeRow !=
 null) {
            oTABLE.activeRow.style.backgroundColor = "";
            oTABLE.activeRow.style.color = "";
            oTABLE.activeRow.active = "false";
        }
        if (oTR != null) {
            oTR.style.backgroundColor = "highlight";
            oTR.style.color = "highlighttext";
            oTR.active = "true";
            oTABLE.activeRow = oTR;
        }
    }
}
function getElement(src, tagName) {
    var obj = src;
    while (obj != null && obj.tagName != tagName) {
        obj = obj.parentElement;
    }
    return obj;
}
//---------------------------------------------------------------------


// showhide() ---------------------------------------------------------------------

function showhide(layer_ref) { 
	var state = 'none'; 
	if (state == 'block') { 
		state = 'none'; 
	} 
	else { 
		state = 'block'; 
	} 
	if (document.all) { //IS IE 4 or 5 (or 6 beta) 
		eval( "document.all." + layer_ref + ".style.display = state"); 
	} 
	if (document.layers) { //IS NETSCAPE 4 or below 
		document.layers[layer_ref].display = state; 
	} 
	if (document.getElementById &&!document.all) { 
		hza = document.getElementById(layer_ref); 
		hza.style.display = state; 
	} 
} 
//---------------------------------------------------------------------
function setfocus(a_field_id) {
	$(a_field_id).focus()
}

//---------------------------------------------------------------------
// geen een id aan een item
function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
	else { document.getElementById(d).style.display = "none"; }
}
//---------------------------------------------------------------------


// show hide bepaalde elementen per id naam
// <div onClick="toggle('<? print "$row[klantnr]"; ?>', event)">
function toggle(toggleId, e)
{
 if (!e) {
  e = window.event;
 }
 if (!document.getElementById) {
  return false;
 }
 var body = document.getElementById(toggleId);
 if (!body) {
  return false;
 } 
 var im = toggleId + "_toggle";
 if (body.style.display == 'none') {
  body.style.display = 'block';
  if (document.images[im]) {
   document.images[im].src = "/images/close.png";
  }
 } else {
  body.style.display = 'none';
  if (document.images[im]) {
   document.images[im].src = "/images/open.png";
  }
 }
 if (e) {
  // Stop the event from propagating, which
  // would cause the regular HREF link to
  // be followed, ruining our hard work.
  e.cancelBubble = true;
  if (e.stopPropagation) {
   e.stopPropagation();
  }
 }
}



