

function onfocusinput()
{
  var tables = document.getElementsByTagName('table');
  for (var j=0; j<tables.length; j++)
  {
    if (tables[j].className == 'form')
    {
      var inputs = tables[j].getElementsByTagName('input');
      for (var i=0; i<inputs.length; i++)
      {
        if (inputs[i].className.slice(0, 4) == 'text')
        {
          inputs[i].onfocus=function() {this.className += ' focus'}
          inputs[i].onblur=function() {this.className=this.className.replace('focus','');}
        }
      }
      var textareas = tables[j].getElementsByTagName('textarea');
      for (var i=0; i<textareas.length; i++)
      {
        textareas[i].onfocus=function() {this.className += ' focus'}
        textareas[i].onblur=function() {this.className=this.className.replace('focus','');}
      }
      var selects = tables[j].getElementsByTagName('select');
      for (var i=0; i<selects.length; i++)
      {
        selects[i].onclick=function() {
          if (this.className.match('focus') != 'focus')
          {
            this.className += ' focus'
          }
        }
        selects[i].onblur=function() {this.className=this.className.replace('focus','');}
      }
    }
  }
}

function isValidEmail(str) {
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function uitlezen(id){
        var s=location.search.match('(?:\\?|\&)'+id+'=([^\&]*)');
        return s?unescape(s[1].replace(/\+/g," ")):false;
}

function hideFunctionDetails()
{
        $('aantal_div').style.display = 'none';
        $('func_details').style.display = 'none';
        $('sub_menu').style.display = 'block';
}

var tmp_var =id;
var parent = parent;

if(tmp_var == '300' || tmp_var == '400' || tmp_var == '210' || tmp_var == '250' || tmp_var == 'uitleg' && parent == 'kandidaat' || tmp_var == '201' && parent == 'kandidaat')
        id_var = 1;
else if( tmp_var == '480' ||tmp_var == '500' || tmp_var == '450' || tmp_var == '100' && parent == 'werkgever' || tmp_var == '201' && parent == 'werkgever' || tmp_var == 'uitleg' && parent == 'werkgever')
        id_var = 2;
else if( tmp_var == '201' && parent == 'overons' || tmp_var == '204' || tmp_var == '211' || tmp_var == '100' && parent == 'overons' || tmp_var == 'uitleg' && parent == 'overons')
        id_var = 3;
else if( tmp_var == false)
        id_var = 4;
else
        id_var = 0;


var button_array = new Array('Kandidaat', 'Werkgever', 'Over_ons'/*, 'Home',, 'English'*/);
window.button_link = new Array('', '', '', 'http://www.x-equo.nl/index.php');        // Menu links
var dropdown_timeout = 200;
window.timerId = 0;

window.button_links = new Array();
// Kandidaat
button_links[0] = '<div onmouseover="hideFunctionDetails();" style="text-align: right;"><div class="myBR"></div><a href="http://www.x-equo.nl/inschrijven">Inschrijven</a><strong>|</strong> <a href="http://www.x-equo.nl/alle_vacatures">Vacatures</a><strong>|</strong> <a href="http://www.x-equo.nl/opleidingen">Opleidingen</a><strong>|</strong> <a href="http://www.x-equo.nl/career_corner">Careercorner</a> <strong>|</strong> <a href="http://www.x-equo.nl/uitleg">Uitleg diensten</a> <strong>| </strong> <a href="http://www.x-equo.nl/informatie">Informatie</a><strong>| </strong> </div>';
// Werkgever
button_links[1] = '<div onmouseover="hideFunctionDetails();" style="text-align: right;"><div class="myBR"></div><a href="http://www.x-equo.nl/vacature_plaatsen"';

button_links[1] += ' >Vacature plaatsen</a><strong>|</strong> <a href="http://www.x-equo.nl/detacheringkrachten">Detacheringaanbod</a><strong>| </strong><a href="http://www.x-equo.nl/onze_kandidaten">Kandidatenaanbod</a><strong>|</strong> <a href="http://www.x-equo.nl/uitleg_werkgever">Uitleg diensten</a> <strong>| </strong> <a href="http://www.x-equo.nl/informatie_werkgever">Informatie</a><strong>| </strong> <a href="http://www.x-equo.nl/informatie_werkgever_aanvragen">Informatie aanvragen</a> <strong>|</strong> <a href="http://www.x-equo.nl/mailinglist_werkgever">Mailinglist</a></div>';
// Over ons
button_links[2] = '<div onmouseover="hideFunctionDetails();" style="text-align: right;"><div class="myBR"></div></strong> <a href="http://www.x-equo.nl/voordelen">Onze voordelen</a><strong>| </strong> <a href="http://www.x-equo.nl/informatie_over_ons">Informatie</a><strong>| </strong> <a href="http://www.x-equo.nl/informatie_over_ons_aanvragen">Informatie aanvragen</a><strong>| </strong><a href="http://www.x-equo.nl/uitleg_over_ons">Uitleg diensten</a> <strong>| </strong><a href="http://www.x-equo.nl/routebeschrijving">Routebeschrijving</a><strong>|</strong> <a href="http://www.x-equo.nl/mailinglist_over_ons">Mailinglist</a></div>';
// Home
//button_links[3] = '<div class="myBR"></div>';

/*
 *        Init the main buttons
 *
 *         @return void                
 */
var init = function () {
        var len = button_array.length + 1;
        
        for(i=1; i<len; i++)
        {
                var button = document.createElement('img');
                button.setAttribute('id', button_array[(i - 1)]+'_');
                button.className = 'button';
                if(tmp_var < 1)    <!-- tmp_var is id of uri string, so only applies to homepage -->
                button.className += ' homebutton';
                button.title = button_array[(i-1)];
                button.setAttribute('num', (i - 1));
                
                button.onmouseover = function () {
                        hideFunctionDetails();
                        for(ii = 0; ii < button_array.length; ii++) {
                                document.getElementById(button_array[ii]+'_').src = path+'/img/buttons/00'+(ii + 1)+'_normal.gif';
                        }
                        
                        if(window.button_links[this.getAttribute('num')]) {
                                document.getElementById('sub_menu').innerHTML = window.button_links[this.getAttribute('num')];
                        }
                        
                        var num = eval(this.getAttribute('num')) + 1;        // Convert to integer
                        this.src = path+'/img/buttons/00'+num+'_active.gif';
                        this.style.borderWidth = 0;
                }
                button.onmouseout = function () {

                }
                
                button.onclick = function () {
                        var num = eval(this.getAttribute('num'));        // Convert to integer
                        if(window.button_link[num] && window.button_link[num] != '') {
                                window.location = window.button_link[num];
                        }
                }
                
                if(i == id_var) {
                        button.src = path+'/img/buttons/00'+i+'_active.gif';
                        document.getElementById('sub_menu').innerHTML = window.button_links[(i - 1)];
                }
                else {
                        button.src = path+'/img/buttons/00'+i+'_normal.gif';
                }
                
                var preload = new Image();
                preload.src = path+'/img/buttons/00'+i+'_active.gif';
                preload.onload = function () { void(0); };
                
                $('inserted_buttons').appendChild(button);
        }
}

/*
 *        Dropdown
 *
 *         @return void
 *         @action display dropdown and culculate offset                
 */
var dropdown = function (el, dropId) {
        if($(dropId).style.display == 'block')
        {
                $(dropId).style.display = 'none';
                return;
        }

        var pos = findPos(el);
        
        $(dropId).onmouseover = function () { clearTimeout(window.timerId); };
        
        $(dropId).style.left = pos[0]+'px';
        $(dropId).style.top = (pos[1] + 19)+'px';
        $(dropId).style.display = 'block';
}

/*
 *        Dropup
 *
 *         @return void
 *         @action display dropdown and culculate offset                
 */
var dropup = function (dropId) {
        window.timerId = setTimeout("hideDropdown('"+dropId+"')", dropdown_timeout);
}

var hideDropdown = function (dropId) {
        $(dropId).style.display = 'none';
}

/*
 *        Dropdown
 *
 *         @return void
 *         @action display dropdown and culculate offset                
 */
var setDetails = function (len) {
        $('aantal_div').style.display = 'none';
         $('func_details').style.paddingLeft = '300px';
        $('func_details').innerHTML = "<div class=\"myBR\"></div>" + job_desription[len];
}

/*
 *        @return position element                
 */
var findPos = function (obj) {
        obj = $(obj);
        var curleft = curtop = 0;
        if (obj.offsetParent) {
                curleft = obj.offsetLeft
                curtop = obj.offsetTop
                while (obj = obj.offsetParent) {
                        curleft += obj.offsetLeft
                        curtop += obj.offsetTop
                }
        }
        return [curleft,curtop];
}

/*
 *        @return element                
 */
var $ = function (el) {
        return document.getElementById(el);
}


// HTTP request
function GetXmlHttpObject() {
        objXMLHttp = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
            try {
                        objXMLHttp = new XMLHttpRequest();
        } catch(e) {
                        objXMLHttp = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
               try {
                objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
              } catch(e) {
                try {
                          objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch(e) {
                          objXMLHttp = false;
                }
                }
    }
        return objXMLHttp;
}

/*
 *  Get result from a sector
 */   
var fetch_functie = function (el) {
    if(el.value == '')
      return;
    // Create AJAX call:
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp != null) {
        var url = path+"/pages/401.php?id="+el.value;
        
        xmlHttp.onreadystatechange = function()
        {   
            if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {                
                document.getElementById('res_functie').innerHTML = xmlHttp.responseText;
            }                      
        }        
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
}

/*
 *  Send user to location
 */ 
var myLocation = function (url) {
  window.location = url;
}

/*
 *  Like submit
 */ 
var search = function (el,title,place) {
  var sector = document.getElementById('sector_id_').value;
  alert(el);
  var functie = el.value;
  
  window.location = path+"vacatures/"+sector;
}

/*
 *  Email to friend, under construction
 *  See pages/403.php 
 */ 
var send_to_friend = function (id) {
  var to = document.getElementById('email_forward').value;
  var from = document.getElementById('email_van').value;
  var msg = document.getElementById('email_tekst').value;
  
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp != null) {
        var url = "pages/403.php?message="+msg+"&amp;from="+from+"&amp;to="+to+"&amp;vacature_id="+id;
        
        xmlHttp.onreadystatechange = function()
        {   
            if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {                
                if(xmlHttp.responseText == '1')
                  document.getElementById('email_result').innerHTML = 'Uw e-mail is verzonden!';
                else
                  document.getElementById('email_result').innerHTML = 'Uw e-mail is <b>NIET</b> verzonden!';
            }                      
        }        
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
}

/*
 *  Popup
 */ 
function MM_openBrWindow(theURL,winName) { //v2.0
  window.open(theURL,winName,'width=770,height=500,statusbar=yes,scrollbars=yes');
}

function showKandidaten(kandidaatID, rowIndex){
  new Ajax.Request('pages/ajaxjson.php', {
     method:'get',
     parameters: 'sector='+kandidaatID,
     onSuccess: function(transport, json){
        eval( 'var result = ' + transport.responseText );
        var sector_table = document.getElementById('table_kandidaten');
        var sector = document.getElementById('sector'+kandidaatID);

        var total = result.length;
        for( var i = 0; i < total; i++ ){

                new_row = document.createElement('<div>');
                td_inhoud = document.createTextNode(result[i].kandidaat_ID);
                new_td.appendChild(td_inhoud);
                new_row.appendChild(new_td);
                sector.appendChild(new_row);


                
        }
     }
   });
}
/* page 300 */
function checkData()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
                
        if (document.forms['inschrijf_form'].naam.value == "") {text = text + "\n* Je hebt geen achternaam ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].voornaam.value == "") {text = text + "\n* Je hebt geen voornaam ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].recipient.value == "") {text = text + "\n* Je hebt geen emailadres ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].telefoon.value == "") {text = text + "\n* Je hebt geen telefoonnummer ingevuld!"; check=false}
        if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['inschrijf_form'].submit();              
}

/* page 300 */ Engels
function checkDataEnglish()
{
        var check = true;
        var text = "ERROR:";
                
        if (document.forms['inschrijf_form'].naam.value == "") {text = text + "\n* Je hebt geen achternaam ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].voornaam.value == "") {text = text + "\n* Je hebt geen voornaam ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].recipient.value == "") {text = text + "\n* Je hebt geen emailadres ingevuld!"; check=false}
        if (document.forms['inschrijf_form'].telefoon.value == "") {text = text + "\n* Je hebt geen telefoonnummer ingevuld!"; check=false}
        if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['inschrijf_form'].submit();              
}

function checkNieuwsbriefform()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
                
        if (document.forms['nieuwsbrief'].bedrijf.value == "") {text = text + "\n* Je hebt geen bedrijf ingevuld!"; check=false}
        if (document.forms['nieuwsbrief'].voornaam.value == "") {text = text + "\n* Je hebt geen voornaam ingevuld!"; check=false}
        if (document.forms['nieuwsbrief'].achternaam.value == "") {text = text + "\n* Je hebt geen achternaam ingevuld!"; check=false}
        if (document.forms['nieuwsbrief'].email.value == "") {text = text + "\n* Je hebt geen emailadres ingevuld!"; check=false}
        if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['nieuwsbrief'].submit();              
}

function checkNieuwsbriefformE()
{
        var check = true;
        var text = "ERROR:";
                
        if (document.forms['nieuwsbrief'].bedrijf.value == "") {text = text + "\n* Company name is empty!"; check=false}
        if (document.forms['nieuwsbrief'].voornaam.value == "") {text = text + "\n* Surname is empty!"; check=false}
        if (document.forms['nieuwsbrief'].achternaam.value == "") {text = text + "\n* First name is empty!"; check=false}
        if (document.forms['nieuwsbrief'].email.value == "") {text = text + "\n* Email address is empty!"; check=false}
        if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['nieuwsbrief'].submit();              
}

function checkSendSelectie()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
        if (document.forms['send_selectie'].achternaam.value == "") {text = text + "\n* Je hebt geen achternaam ingevuld!"; check=false}
        if (document.forms['send_selectie'].bedrijfsnaam.value == "") {text = text + "\n* Je hebt geen bedrijfsnaam ingevuld!"; check=false}
        if (document.forms['send_selectie'].telefoon.value == "") {text = text + "\n* Je hebt geen telefoonnummer ingevuld!"; check=false}
               if (document.forms['send_selectie'].email.value == "") {text = text + "\n* Je hebt geen emailadres ingevuld!"; check=false}
        if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['send_selectie'].submit();              
}

function check_send_vacature_door()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
        if (document.forms['send_vacature_door'].email_forward.value == "") {text = text + "\n* Je moet het emailadres van de ontvanger invullen!"; check=false}
        if (document.forms['send_vacature_door'].email_van.value == "") {text = text + "\n* Je moet je eigen emailadres invullen!"; check=false}
          if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['send_vacature_door'].submit();              
}

function check_send_vacature_door_en()
{
        var check = true;
        var text = "ERROR:";
        if (document.forms['send_vacature_door'].email_forward.value == "") {text = text + "\n* Je moet het emailadres van de ontvanger invullen!"; check=false}
        if (document.forms['send_vacature_door'].email_van.value == "") {text = text + "\n* Je moet je eigen emailadres invullen!"; check=false}
          if (check == false)
        {
                alert (text);
                return check;                        
        }  
        else
                document.forms['send_vacature_door'].submit();              
}

function check_add_vacature()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
        if (document.forms['vac'].bedrijf.value == "") {text = text + "\n* Je moet het bedrijf opgeven!"; check=false}
        if (document.forms['vac'].voorletter.value == "") {text = text + "\n* Je moet de voorletter invullen!"; check=false}
        if (document.forms['vac'].adres.value == "") {text = text + "\n* Je moet het adres invullen!"; check=false}
        if (document.forms['vac'].adres.telefoon == "") {text = text + "\n* Je moet je telefoonnummer invullen!"; check=false}
        if (document.forms['vac'].email.value == "") {text = text + "\n* Je moet een emailadres invullen!"; check=false}

        if (check == false)
        {
                alert (text);
                return check;
        }
        else
                document.forms['vac'].submit();
}

function checkRouteForm()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";
        if (document.forms['routeform'].street_start.value == "") {text = text + "\n* Je moet je straat & huisnummer opgeven!"; check=false}
        if (document.forms['routeform'].city_start.value == "") {text = text + "\n* Je moet je woonplaats invullen!"; check=false}
        if (document.forms['routeform'].postcode_start.value == "") {text = text + "\n* Je moet je postcode invullen!"; check=false}

        if (check == false)
        {
                alert (text);
                return check;
        }
        else
               document.forms['routeform'].submit();
}

function checkEmailRouteForm()
{
        var check = true;
        var text = "De volgende gegevens zijn niet ingevuld:";

        if (! isValidEmail(document.forms['email_route'].email.value) ) {text = text + "\n* Je moet een geldig emailadres opgeven!"; check=false}


        if (check == false)
        {
                alert (text);
                return check;
        }
        else
               document.forms['email_route'].submit();
}




