function changeCohort(value){
 if(document.searchresults){
    document.searchresults.page.value='';
    document.searchresults.activecohort.value=value;
    document.searchresults.submit();
 }
 else{
    //this is a hardcoded bypass in order to redirect to format2004 when cohort 2005-2006 is selected
    //in the body of format2004 pages is also a code added in order to switch back to format2007
    try{if(format2004){}}catch(e){format2004=false}
    if(value==743){
       document.frmcohort.action='?id=HOME_2004'
    }
    else{
       if(format2004){
         document.frmcohort.action='?id=HOME_2007'
       }
    }
    document.frmcohort.submit()
 }
}

var w;
function viewSearchComponent(gotourl){
  // jf height added  check;
  var options='width=1024,height=800,menubar=no,toolbar=no,location=no,resizable=yes,directories=no,status=yes,scrollbars=no';
  if(w){
     try{
        w.document.location.replace(gotourl);
     }
     catch(e){
       w = window.open(gotourl,'dbrowser',options);
     }
  }
  else{
    w = window.open(gotourl,'dbrowser',options);
  }
  w.focus();
}

function convertToPdf(url,att){
  url = url.replace(/&/g,'_amp_') + '_amp_renderpdf=1';
  if(att=='1'){
    document.location.href='http://pdf.kwalificatiesmbo.nl/asp_net/pdfcreator.aspx?url='+url+'&att=1';
  }
  else{
    document.location.href='http://pdf.kwalificatiesmbo.nl/asp_net/pdfcreator.aspx?url='+url;
  }
  return true;
}

function loadOpleidingData(id) {
  // Welke DIV wil je vullen?
  var myDiv = document.getElementById("opleiding_ajax");
  executeHTTPRequest("?id=SYS_KWALIFICATIESTRUCTUUR_CALLBACK&mode=opleiding&item=" + id, myDiv, 5000);
  return;
}

function loadUitstroomData(id) {
  // Welke DIV wil je vullen?
  var myDiv = document.getElementById("uitstroomdifferentiatie_ajax");
  executeHTTPRequest("?id=SYS_KWALIFICATIESTRUCTUUR_CALLBACK&mode=uitstroom&item=" + id, myDiv, 5000);
  return;
} 

var doCompSearch = false
function checkCT(cb){
   for (var i=0;i<document.advancedsearchform.elements.length;i++) {
     if(document.advancedsearchform.elements[i].name=='searchct'){
        if(cb.value=='alles'){
           document.advancedsearchform.elements[i].checked=false;
           doCompSearch = false
        }
     }
   }
}

function uncheckMain(cb){
  document.advancedsearchform._dummy[1].checked=true;
  doCompSearch = true;
}

function valAdvancedSearch(defvalue){
  var mode = document.advancedsearchform.searchmode.value

  switch(mode){
    case 'compsearch':
      if(document.getElementById('searchterms').value.replace(/^\s*|\s*$/g,"")=='' || document.getElementById('searchterms').value.replace(/^\s*|\s*$/g,"")==defvalue){
         alert('Geef een zoekterm op')
         return false;
      }
      if(document.advancedsearchform._dummy[1].checked && !doCompSearch){
         alert('Selecteer een component')
         return false;
      }
      break;   

   case 'advancedNameCode':
      if(document.getElementById('searchname').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchcrebocode').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchdossiercode').value.replace(/^\s*|\s*$/g,"")==''){
         alert('Geef een zoekterm op')
         return false;
      }
      break;
         
   case 'advancedProfile':
      if(document.getElementById('searchkc').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchsector').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchbranche').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchtyp').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchniveau').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchstatus').value.replace(/^\s*|\s*$/g,"")==''){
         alert('Geef een zoekterm op')
         return false;
      }
      break;
       
   case 'advancedKeywords':
      if(document.getElementById('searchcomp').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchkt').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchuitstroom').value.replace(/^\s*|\s*$/g,"")=='' && document.getElementById('searchce').value.replace(/^\s*|\s*$/g,"")==''){
         alert('Geef een zoekterm op')
         return false;
      }
      break;

   default:
     alert('Error: Invalid mode')
     return false;
  } 
  return true;
}  

function valSearch(formid, fieldid, defvalue){
   var frm = document.getElementById(formid)
   var fld = document.getElementById(fieldid)
   if(fld.value.replace(/^\s*|\s*$/g,"")=='' || fld.value==defvalue){
     alert('Geef een zoekterm op.');
     return false;
   }
   frm.submit();
}


function changeTitle(msg) {
  // alert(msg);
  top.frames[1].document.getElementById("kruimelpadtext").innerHTML = msg;
}