function retrieveCookie( cookieName ) {
	/* retrieved in the format
	cookieName4=value; cookieName3=value; cookieName2=value; cookieName1=value
	only cookies for this domain and path will be retrieved */
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}


function check_behavioural_competency(form){
  checked = false;
  count = 0
  for (x=0;x<form.code.length;x++)
  {  
    if (form.code[x].checked) {
      count +=1
    }
  }
  if ( count < 3) {
    alert('Select a minimum of 3 items.');
    return false;
  } else {
    if ( count > 15) {
      alert('Select a maximum of 15 items.');
      return false;
    } else {
      return true;
    }
  }
}

function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
	if( !cookieName ) { return false; }
	if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.
	/* This next line sets the cookie but does not overwrite other cookies.
	syntax: cookieName=cookieValue[;expires=dataAsString[;path=pathAsString[;domain=domainAsString[;secure]]]]
	Because of the way that document.cookie behaves, writing this here is equivalent to writing
	document.cookie = whatIAmWritingNow + "; " + document.cookie; */
	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
		( isSecure ? ";secure" : "");
	//check if the cookie has been set/deleted as required
	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
}

function disableButton(theButton)
{
 theButton.value="Processing...";
 theButton.disabled = true;
 theButton.form.submit();
}

function check_searchtext(){
  if (document.searchform.searchtext.value.length < 3 ) {
    alert('Fill in a minimum of three characters.');
    return false;
  } else {
    return true;
  }  
}

function open_profession_explanation(pk) {
  window.open('profession_explanation.html?pk='+pk,'info','height=415,width=500,toolbar=no,scrollbars=yes,resizable=yes',true);
}

function remove_client(client_pk,client_name) {
  if (confirm("Note! This way all details of this client will be erased from the system. Do you wish to continue?")) {
    document.remove_client_form.client_pk.value = client_pk;
    document.remove_client_form.submit();
  }
}

function make_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the Professions Interest Test will be overwritten! Do you wish to continue? ")) {
    document.make_test_form.client_pk.value = client_pk;
    document.make_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the Professions Interest Test?")) {
    document.make_test_form.client_pk.value = client_pk;
    document.make_test_form.submit();
  } else if (active_test == 0) {
    document.make_test_form.client_pk.value = client_pk;
    document.make_test_form.submit();
  }
}
function make_capaz_study_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the CAPAZ-Education test will be overwritten. Do you wish to continue? ")) {
    document.make_capaz_study_test_form.client_pk.value = client_pk;
    document.make_capaz_study_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the CAPAZ-Study test?")) {
    document.make_capaz_study_test_form.client_pk.value = client_pk;
    document.make_capaz_study_test_form.submit();
  } else if (active_test == 0) {
    document.make_capaz_study_test_form.client_pk.value = client_pk;
    document.make_capaz_study_test_form.submit();
  }
}
function make_taco_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Warning! Previous results of the TaCo questionnaire will be overwritten. Do you wish to continue?")) {
    document.make_taco_test_form.client_pk.value = client_pk;
    document.make_taco_test_form.submit();
  } else if (active_test == 1 && confirm("Do you wish to continue the Talents & Competences test procedure?")) {
    document.make_taco_test_form.client_pk.value = client_pk;
    document.make_taco_test_form.submit();
  } else if (active_test == 0) {
    document.make_taco_test_form.client_pk.value = client_pk;
    document.make_taco_test_form.submit();
  }
}
function make_pm_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Let op! Eerdere resultaten worden overschreven! Wilt u doorgaan?")) {
    document.make_pm_test_form.client_pk.value = client_pk;
    document.make_pm_test_form.submit();
  } else if (active_test == 1 && confirm("Weet u zeker dat u het wilt vervolgen?")) {
    document.make_pm_test_form.client_pk.value = client_pk;
    document.make_pm_test_form.submit();
  } else if (active_test == 0) {
    document.make_pm_test_form.client_pk.value = client_pk;
    document.make_pm_test_form.submit();
  }
}
function make_oasez_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Let op! Eerdere resultaten van OASE-Z worden overschreven! Doorgaan?")) {
    document.make_oasez_test_form.client_pk.value = client_pk;
    document.make_oasez_test_form.submit();
  } else if (active_test == 1 && confirm("De OASE-Z testafname vervolgen?")) {
    document.make_oasez_test_form.client_pk.value = client_pk;
    document.make_oasez_test_form.submit();
  } else if (active_test == 0) {
    document.make_oasez_test_form.client_pk.value = client_pk;
    document.make_oasez_test_form.submit();
  }
}
function make_capaz_work_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the CAPAZ-Profession test will be overwritten. Do you wish to continue? ")) {
    document.make_capaz_work_test_form.client_pk.value = client_pk;
    document.make_capaz_work_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the CAPAZ-Profession test?")) {
    document.make_capaz_work_test_form.client_pk.value = client_pk;
    document.make_capaz_work_test_form.submit();
  } else if (active_test == 0) {
    document.make_capaz_work_test_form.client_pk.value = client_pk;
    document.make_capaz_work_test_form.submit();
  }
}
function make_vasev_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the VaSEV test will be overwritten. Do you wish to continue? ")) {
    document.make_vasev_test_form.client_pk.value = client_pk;
    document.make_vasev_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the VaSEV test?")) {
    document.make_vasev_test_form.client_pk.value = client_pk;
    document.make_vasev_test_form.submit();
  } else if (active_test == 0) {
    document.make_vasev_test_form.client_pk.value = client_pk;
    document.make_vasev_test_form.submit();
  }
}

function make_glts94_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the GLTS'94 test will be overwritten. Do you wish to continue? ")) {
    document.make_glts94_test_form.client_pk.value = client_pk;
    document.make_glts94_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the GLTS'94 test?")) {
    document.make_glts94_test_form.client_pk.value = client_pk;
    document.make_glts94_test_form.submit();
  } else if (active_test == 0) {
    document.make_glts94_test_form.client_pk.value = client_pk;
    document.make_glts94_test_form.submit();
  }
}

function make_mpt_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the MPT test will be overwritten. Do you wish to continue? ")) {
    document.make_mpt_test_form.client_pk.value = client_pk;
    document.make_mpt_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the MPT test?")) {
    document.make_mpt_test_form.client_pk.value = client_pk;
    document.make_mpt_test_form.submit();
  } else if (active_test == 0) {
    document.make_mpt_test_form.client_pk.value = client_pk;
    document.make_mpt_test_form.submit();
  }
}

function make_neopir_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of NEO-PIR will be overwritten! Do you wish to continue?")) {
    document.make_neopir_test_form.client_pk.value = client_pk;
    document.make_neopir_test_form.submit();
  } else if (active_test == 1 && confirm("Continue NEO-PIR?")) {
    document.make_neopir_test_form.client_pk.value = client_pk;
    document.make_neopir_test_form.submit();
  } else if (active_test == 0) {
    document.make_neopir_test_form.client_pk.value = client_pk;
    document.make_neopir_test_form.submit();
  }
}

function make_pmt_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of PMT will be overwritten! Do you wish to continue?")) {
    document.make_pmt_test_form.client_pk.value = client_pk;
    document.make_pmt_test_form.submit();
  } else if (active_test == 1 && confirm("Continue PMT?")) {
    document.make_pmt_test_form.client_pk.value = client_pk;
    document.make_pmt_test_form.submit();
  } else if (active_test == 0) {
    document.make_pmt_test_form.client_pk.value = client_pk;
    document.make_pmt_test_form.submit();
  }
}

function make_npv_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of NPV will be overwritten! Do you wish to continue?")) {
    document.make_npv_test_form.client_pk.value = client_pk;
    document.make_npv_test_form.submit();
  } else if (active_test == 1 && confirm("Continue NPV?")) {
    document.make_npv_test_form.client_pk.value = client_pk;
    document.make_npv_test_form.submit();
  } else if (active_test == 0) {
    document.make_npv_test_form.client_pk.value = client_pk;
    document.make_npv_test_form.submit();
  }
}

function make_dat_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of DAT will be overwritten! Do you wish to continue?")) {
    document.make_dat_test_form.client_pk.value = client_pk;
    document.make_dat_test_form.submit();
  } else if (active_test == 1 && confirm("Continue DAT?")) {
    document.make_dat_test_form.client_pk.value = client_pk;
    document.make_dat_test_form.submit();
  } else if (active_test == 0) {
    document.make_dat_test_form.client_pk.value = client_pk;
    document.make_dat_test_form.submit();
  }
}

function make_gtest_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the G-test will be overwritten. Do you wish to continue? ")) {
    document.make_gtest_test_form.client_pk.value = client_pk;
    document.make_gtest_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the Gtest?")) {
    document.make_gtest_test_form.client_pk.value = client_pk;
    document.make_gtest_test_form.submit();
  } else if (active_test == 0) {
    document.make_gtest_test_form.client_pk.value = client_pk;
    document.make_gtest_test_form.submit();
  }
}

function make_sis_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the SIS test will be overwritten. Do you wish to continue? ")) {
    document.make_sis_test_form.client_pk.value = client_pk;
    document.make_sis_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the SIS test?")) {
    document.make_sis_test_form.client_pk.value = client_pk;
    document.make_sis_test_form.submit();
  } else if (active_test == 0) {
    document.make_sis_test_form.client_pk.value = client_pk;
    document.make_sis_test_form.submit();
  }
}

function make_bktm_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the B-KTM test will be overwritten. Do you wish to continue? ")) {
    document.make_bktm_test_form.client_pk.value = client_pk;
    document.make_bktm_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the B-KTM test?")) {
    document.make_bktm_test_form.client_pk.value = client_pk;
    document.make_bktm_test_form.submit();
  } else if (active_test == 0) {
    document.make_bktm_test_form.client_pk.value = client_pk;
    document.make_bktm_test_form.submit();
  }
}

function make_abiv_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the ABIV test will be overwritten. Do you wish to continue? ")) {
    document.make_abiv_test_form.client_pk.value = client_pk;
    document.make_abiv_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the ABIV test?")) {
    document.make_abiv_test_form.client_pk.value = client_pk;
    document.make_abiv_test_form.submit();
  } else if (active_test == 0) {
    document.make_abiv_test_form.client_pk.value = client_pk;
    document.make_abiv_test_form.submit();
  }
}

function make_bit_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the BIT test will be overwritten. Do you wish to continue? ")) {
    document.make_bit_test_form.client_pk.value = client_pk;
    document.make_bit_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the BIT test?")) {
    document.make_bit_test_form.client_pk.value = client_pk;
    document.make_bit_test_form.submit();
  } else if (active_test == 0) {
    document.make_bit_test_form.client_pk.value = client_pk;
    document.make_bit_test_form.submit();
  }
}

function make_hit_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the HIT test will be overwritten. Do you wish to continue? ")) {
    document.make_hit_test_form.client_pk.value = client_pk;
    document.make_hit_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the HIT test?")) {
    document.make_hit_test_form.client_pk.value = client_pk;
    document.make_hit_test_form.submit();
  } else if (active_test == 0) {
    document.make_hit_test_form.client_pk.value = client_pk;
    document.make_hit_test_form.submit();
  }
}

function make_kit_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of the KIT test will be overwritten. Do you wish to continue? ")) {
    document.make_kit_test_form.client_pk.value = client_pk;
    document.make_kit_test_form.submit();
  } else if (active_test == 1 && confirm("Are you sure you wish to continue the KIT test?")) {
    document.make_kit_test_form.client_pk.value = client_pk;
    document.make_kit_test_form.submit();
  } else if (active_test == 0) {
    document.make_kit_test_form.client_pk.value = client_pk;
    document.make_kit_test_form.submit();
  }
}

function make_cube8_photo_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of CUBE8 (picture album) will be overwritten! Do you wish to continue?")) {
    document.make_cube8_photo_test_form.client_pk.value = client_pk;
    document.make_cube8_photo_test_form.submit();
  } else if (active_test == 1 && confirm("Do you wish to continue this test: picture album?")) {
    document.make_cube8_photo_test_form.client_pk.value = client_pk;
    document.make_cube8_photo_test_form.submit();
  } else if (active_test == 0) {
    document.make_cube8_photo_test_form.client_pk.value = client_pk;
    document.make_cube8_photo_test_form.submit();
  }
}

function make_cube8_story_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of CUBE8 (stories) will be overwritten! Do you wish to continue?")) {
    document.make_cube8_story_test_form.client_pk.value = client_pk;
    document.make_cube8_story_test_form.submit();
  } else if (active_test == 1 && confirm("Do you wish to continue this test: stories?")) {
    document.make_cube8_story_test_form.client_pk.value = client_pk;
    document.make_cube8_story_test_form.submit();
  } else if (active_test == 0) {
    document.make_cube8_story_test_form.client_pk.value = client_pk;
    document.make_cube8_story_test_form.submit();
  }
}

function make_cube8_blackboard_test(client_pk,client_name,active_test) {
  if (active_test == 2 && confirm("Note! Former results of CUBE8 (blackboard) will be overwritten! Do you wish to continue?")) {
    document.make_cube8_blackboard_test_form.client_pk.value = client_pk;
    document.make_cube8_blackboard_test_form.submit();
  } else if (active_test == 1 && confirm("Do you wish to continue this test: blackboard?")) {
    document.make_cube8_blackboard_test_form.client_pk.value = client_pk;
    document.make_cube8_blackboard_test_form.submit();
  } else if (active_test == 0) {
    document.make_cube8_blackboard_test_form.client_pk.value = client_pk;
    document.make_cube8_blackboard_test_form.submit();
  }
}

function flip_children(pk){
  var ie4 = (document.all)? true:false
  var agt=navigator.userAgent.toLowerCase() 
  var mac = (agt.indexOf("mac")!=-1) 
  if (ie4 && mac) {
    var aChildren = document.all['children_'+pk];
  } else {
    var aChildren = document.getElementsByName('children_'+pk);
  }
  for (var i=0;i<aChildren.length;i++) {
    if (aChildren[i].style.display == 'none') {
      if (ie4) {
        aChildren[i].style.display = '';
      }
      else {
        aChildren[i].style.display = 'table-row';
      }
    }
    else {
      aChildren[i].style.display = 'none';
    }
  }
  if (document.getElementById('koepel_'+pk).src.indexOf('closed.gif') > -1)
    document.getElementById('koepel_'+pk).src = 'open.gif';
  else document.getElementById('koepel_'+pk).src = 'closed.gif';
}

function flip_children_report(pk){
  var ie4 = (document.all)? true:false
  var agt=navigator.userAgent.toLowerCase() 
  var mac = (agt.indexOf("mac")!=-1) 
  if (ie4 && mac) {
    var aChildren = document.all['children_'+pk];
  } else {
    var aChildren = document.getElementsByName('children_'+pk);
  }
  for (var i=0;i<aChildren.length;i++) {
    if (aChildren[i].style.display == 'none') {
      if (ie4) {
        aChildren[i].style.display = '';
      }
      else {
        aChildren[i].style.display = 'table-row';
      }
    }
    else {
      aChildren[i].style.display = 'none';
    }
  }
}

function open_help(value)
{
  window.open(value,"help",'height=470,width=480,scrollbars=yes,resizable=yes',true);
}

function open_aspect_help(value)
{
  window.open(value,"help",'height=470,width=680,scrollbars=yes,resizable=yes',true);
}


function open_taco_help(value)
{
  window.open(value,"help",'height=600,width=850,scrollbars=yes,resizable=yes',true);
}

function open_print_results(page, client_pk,test_pk) {
  window.open('print_results.html?client_pk=' + client_pk + '&test_pk=' + test_pk + '&page=' + page,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}

function open_print_results_category(page, client_pk,test_pk,category) {
  window.open('print_results_category.html?client_pk=' + client_pk + '&test_pk=' + test_pk + '&category=' + category + '&page=' + page,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}

function open_print_questions(client_pk,test_pk) {
  window.open('print_questions.html?client_pk=' + client_pk + '&test_pk=' + test_pk,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}

function open_print_sector(client_pk,test_pk) {
  window.open('print_sector.html?client_pk=' + client_pk + '&test_pk=' + test_pk,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}


function open_print_aspects(pk,client_pk,test_pk) {
  window.open('print_aspects.html?client_pk=' + client_pk + '&test_pk=' + test_pk + '&pk=' + pk,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}
function open_print_taco(pk,client_pk,test_pk) {
  window.open('print_taco.html?client_pk=' + client_pk + '&test_pk=' + test_pk + '&pk=' + pk,'info','height=415,width=661,toolbar=no,scrollbars=yes,resizable=yes',true);
}
function open_remark(url)
{
    window.open("http://www.icaresprofessional.com/professional/remark.html?field_url=" + url,"Opmerking","height=400,width=560,scrollbars=no");
}

var time_out;
var previous_menu = '';
var slowdown = false;
var DOM = (document.getElementById) ? true : false;
var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;

function getOffsetLeft (el) {
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}

function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
    ot += el.offsetTop;
  return ot;
}

function showmenu(object,elmnt) {
 if (previous_menu != '' && previous_menu != null) {
    if (previous_menu != elmnt) {
	    document.getElementById(previous_menu).style.visibility = "hidden";
    }
  }
  previous_menu = elmnt;
  clearTimeout(time_out);
  var x = getOffsetLeft(object);
  var y = getOffsetTop(object);
  var w = object.offsetWidth;
  obj = document.getElementById(elmnt)
  obj.style.width = w + 2
  obj.style.left = getOffsetLeft(object) - 2
  obj.style.top = y + 66;
  obj.style.visibility = "visible";
}

function hidemenu(elmnt) {
  element = document.getElementById(elmnt)
  time_out = setTimeout("element.style.visibility = 'hidden'",500);
}