
/************************************************************************/
/* Try to give the first relevant field the focus.                      */
/************************************************************************/

function TrySetFocus()
{
  if ( ! document.forms                ) return;
  if ( ! document.forms[0]             ) return;
  if ( ! document.forms[0].elements    ) return;

  var elems = document.forms[0].elements;

  for ( var i = 0 ; i < elems.length ; i++ )
    {
//	if ( elems[i].type == 'text' || elems[i].type == 'password' ) {
	if ( elems[i].type != 'hidden' && elems[i].type != 'select-one' ) 
    {
//	    alert(elems[i].type);
//        alert(elems[i].name);
        elems[i].focus();
	    return;
	}
 }
//  if ( document.all && document.all.enter ) {
//      document.all.enter.focus();
//  }
}

function TrySubmitForm()
{
  if ( ! window.event ) return;
  if ( window.event.keyCode != 13 ) return;

  if ( ! document.forms ) return;
  if ( ! document.forms[0] ) return;

  if ( ! window.hasSave ) {
    // Do not submit if we already have our own handler.
    document.forms[0].submit();
  }
}

/************************************************************************/

function byebye()
{
    alert("Je kunt altijd terugkomen naar deze site om je assessment af te maken.");
}

/************************************************************************/
/* Prevent being framed.                                                */
/************************************************************************/

if ( self != top ) top.location.href = self.location.href;

/************************************************************************/
/* Define the roll over functions.                                      */
/************************************************************************/

function mouse_over(label, count, body1, body2) 
{
    if ( document.images ) {
	if ( count ) {
	    name = 'button_' + count;
	} else {
	    name = label;
	}
	document.images[name].src = over[label].src;
	if ( body1 ) {
	    document.images[body1].src = over[body1].src;
	}
	if ( body2 ) {
	    document.images[body2].src = over[body2].src;
	}
    }
}

function mouse_out(label, count, body1, body2) {
    if ( document.images ) {
	if ( count ) {
	    name = 'button_' + count;
	} else {
	    name = label;
	}
	document.images[name].src = out[label].src;
	if ( body1 ) {
	    document.images[body1].src = out[body1].src;
	}
	if ( body2 ) {
	    document.images[body2].src = out[body2].src;
	}
    }
}

function text_color(label, color)
{
    if ( document.anchors ) {
	for ( var i = 0 ; i < document.anchors.length ; i++ ) {
	    var anch = document.anchors[i];
	    if ( anch.name == label && anch.style ) {
		anch.style.color = color;
	    }
	}
    }
}

function popupPrint(id)
{
  msg = window.open('../home/popup_feedback.php',
		    'feedback',
		    'toolbar=yes,width=770,height=500,directories=no,resizable=yes,status=no,scrollbars=yes,menubar=yes,location=no');
  msg.focus();
}

function myPopup( url, width, height )
{
	var popup = window.open(	url,
												 		"",
												 		"toolbar=no,scrollbars=yes,width="+width+",height="+height+",directories=no,resizable=yes,status=no,menubar=no,location=no" );
	if ( popup.focus ) popup.focus();
}

function addListener(obj, event, func) {
	if (window.addEventListener)
		obj.addEventListener(event, func, false);
	else
		obj.attachEvent('on' + event, func);  
}

function utf8_encode(s) {
  return unescape(encodeURIComponent(s));
}

function utf8_decode(s) {
  return decodeURIComponent(escape(s));
}
