function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cursorhand() {
    if (navigator.userAgent.indexOf('MSIE')>0)
	document.body.style.cursor='hand';
    else
	document.body.style.cursor='pointer';
}

function cursordefault() {
    document.body.style.cursor='auto';
}

function OverVacature(nr)
{
   var el = document.getElementById('vacature'+nr);
   if (el.className.substr(-2) != 'on')
   {
      el.className = el.className+'on';
   }
}

function OutVacature(nr)
{
   if (document.getElementById('Detail'+nr).style.display != 'none') return;
   ResetClass('vacature'+nr);
}

function ResetClass(id)
{
   var el = document.getElementById(id);
   if (el.className.substr(-2) == 'on')
   {
      el.className = el.className.substr(0, el.className.length-2);
   }
}

function ToggleDetail(nr)
{
   var id = 'Detail' + nr
   if (document.getElementById(id).style.display=='none')
   {
      ShowLayerById(id)
      for(var a=1;a<=1000 && document.getElementById('Detail' + a);a++)
      {
         if (id!='Detail'+a)
	 {
            HideLayerById('Detail' + a);
	    ResetClass('vacature' + a);
	 }
      }
      setSessionProperty('showdetails', nr);
   }
   else {
      HideLayerById(id);
      setSessionProperty('showdetails', 0);
   }
}

function CheckUncheckAll(obj)
{
   for(var a=0;a<document.forms[0].elements.length;a++)
   {
      if ( (document.forms[0].elements[a].type=='checkbox')  )
      {
         document.forms[0].elements[a].checked=obj.checked;
      }
   }
}

function ShowLayerById(id)
{
	document.getElementById(id).style.display = '';
}
function HideLayerById(id)
{
	document.getElementById(id).style.display = "none";
}

function HideSearch()
{
   HideLayerById('searchnav')
   HideLayerById('searchopener')
   ShowLayerById('searchcloser')
}

function ShowSearch()
{
   ShowLayerById('searchnav')
   ShowLayerById('searchopener')
   HideLayerById('searchcloser')
}

var xmlhttpreq;

function setSessionProperty(property, value, statechangehandler)
{
    xmlhttpreq = newXMLHttpRequest();
    if (xmlhttpreq) {
	var url = window.location.protocol+'//'+window.location.host+window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1)+'setsessionproperty.php';
	//xmlhttpreq.onreadystatechange = showreqreturn;
	xmlhttpreq.open("POST", url, true);
	if (statechangehandler!=null) {
	    xmlhttpreq.onreadystatechange = statechangehandler;
	}
	xmlhttpreq.setRequestHeader("Content-Type", "text/xml");
	xmlhttpreq.send('<?xml version="1.0" encoding="UTF-8"?>'+"\n"+
		'<request>'+
		'<property>'+property+'</property>'+
		'<value>'+value+'</value>'+
		'</request>');
    }
}

// Sigletos
function getSessionProperty(name, query) {
    xmlhttpreq = newXMLHttpRequest();
    if (xmlhttpreq) {
        var url = window.location.protocol+'//'+window.location.host+window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1)+'getsessionproperty.php';
        xmlhttpreq.open("POST", url, false);
        xmlhttpreq.setRequestHeader("Content-Type", "text/xml");
        var tosend = '<?xml version="1.0" encoding="UTF-8"?>'+"\n"+
		'<request>'+
                '<name>'+name+'</name>'+
                '<query>'+query+'</query>'+
                '</request>';	
	xmlhttpreq.send(tosend);
	return xmlhttpreq.responseText;
    } 
}

// Sigletos
function saveQueryOptions(name, query) {
    xmlhttpreq = newXMLHttpRequest();
    if (xmlhttpreq) {
        var url = window.location.protocol+'//'+window.location.host+window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1)+'savequery.php';
        xmlhttpreq.open("POST", url, false);
        xmlhttpreq.setRequestHeader("Content-Type", "text/xml");
        var tosend = '<?xml version="1.0" encoding="UTF-8"?>'+"\n"+
                '<request>'+
                '<name>'+name+'</name>'+
                '<query>'+query+'</query>'+
                '</request>';
        xmlhttpreq.send(tosend);
	return xmlhttpreq.responseText;
    }
}

// Sigletos
function deleteQuery(name, query) {
   xmlhttpreq = newXMLHttpRequest();
   var url = window.location.protocol+'//'+window.location.host+window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1)+'delquery.php';
   xmlhttpreq.open("POST", url, false);
   xmlhttpreq.setRequestHeader("Content-Type", "text/xml");
   var tosend = '<?xml version="1.0" encoding="UTF-8"?>'+"\n"+
                '<request>'+
                '<name>'+name+'</name>'+
                '<query>'+query+'</query>'+
                '</request>';
   xmlhttpreq.send(tosend);
   return xmlhttpreq.responseText;
}

// Sigletos
function submitIssue(stat, comment, vacid, field) {
   xmlhttpreq = newXMLHttpRequest();
   var url = window.location.protocol+'//'+window.location.host+window.location.pathname.substr(0,window.location.pathname.lastIndexOf('/')+1)+'postissue.php';
   xmlhttpreq.open("POST", url, false);
   xmlhttpreq.setRequestHeader("Content-Type", "text/xml");
   var tosend = '<?xml version="1.0" encoding="UTF-8"?>'+"\n"+
                '<request>'+
		'<status>' +stat+ '</status>'+
		'<comment>'+comment+'</comment>'+
		'<vacid>'+vacid+'</vacid>'+
		'<field>'+field+'</field>'+
		'</request>';
   xmlhttpreq.send(tosend);
   return xmlhttpreq.responseText;
}

function newXMLHttpRequest(){
    var req;
    if (window.XMLHttpRequest) { // Non-IE browsers
	try {
	    req = new XMLHttpRequest();
	} catch(e) {
	    req = false;
	}
    }
    else if (window.ActiveXObject) { // IE
	try {
	    req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
	    req = false;
	}
    }
    return req;
}

function showreqreturn()
{
    if (xmlhttpreq.readyState==4) {
	if (xmlhttpreq.status==200) {
	    alert('Response: '+xmlhttpreq.responseText);
	}
	else {
	    alert('Problem: '+xmlhttpreq.statusText);
	}
    }
}
