var fteStatus = 0;
var info = new Array();
info["zo_a"] = "Zoeken in toegangen op de archieven van aangesloten archiefdiensten.";
info["zo_a_sub"] = "<a href=\"/pls/m/zk2.html_zk\">uitgebreid zoeken</a>";
info["zo_b"] = "Zoeken naar archiefdiensten in Nederland.";
info["zo_b_sub"] = "<a href=\"/pls/m/zk2.html_ad\">meer over archiefdiensten</a>";
info["zo_c"] = "Zoeken naar historische verenigingen in Nederland.";
info["zo_c_sub"] = "<a href=\"/pls/m/zk2.html_hsv\">meer over historische verenigingen</a>";

var actionArray = new Array();
actionArray[0] = "/pls/m/zk2.zoek?";

var dynForm = "";

function InitZoek()
{
  fteStatus = false;
  var l = document.getElementById("zo_a");
  ChangeZoek(l);
  l.checked = true;
  l = document.getElementById("zoekveld");
  l.value = "vul uw zoekterm(en) in";
  l.focus();
  OutputHistory();
}

function ChangeZoek(e)
{
  l = document.getElementById("zoekinfo");
  l.innerHTML = info[e.id];
  l = document.getElementById("zoekinfosub");
  l.innerHTML = info[e.id+'_sub'];
}

function FirstTimeErase(e)
{
  if (!fteStatus)
  { 
    e.value = "";
    fteStatus = true; 
  }
}

function Submit(myForm)
{
  return false;
/*
  for (var x=0; x<myForm.rb.length; x++)
  {
    if (myForm.rb[0].checked)
    {
      myForm.rb[0].length = 0 ;
      //myForm.p_zk_alle;
    }
  }
*/
}

function BuildForm()
{
  var words = document.getElementById("zoekveld").value;  
  if (fteStatus && words)
  {

  var e = document.getElementById("buildspace");
  var form = '<form style="margin:0px" method="post" name="zoekform" action="/pls/m/zk2.zoek">';

  form += '<input id="zoekveld" name="p_zk_alle" type="hidden" value="'+words+'"></input>';
  
  var l = document.getElementById("zo_b");
  if (l.checked)
  {
    form += '<input name="p_aet_id" type="hidden" value="1001"></input>';
  }

  var l = document.getElementById("zo_c");
  if (l.checked)
  {
    form += '<input name="p_aet_id" type="hidden" value="1001"></input>';
    form += '<input type="hidden" name="p_sat" value="18"></input>';
  }
  
  form += '</form>';
  e.innerHTML = form;
  document.forms["zoekform"].submit();
  } else alert ("Geef a.u.b. uw zoekterm(en) op.");
}

function Contains(word)
{
 var str = document.cookie.split(",");
  for (x=str.length; x>0; x--)
    if (str[x]==word) return true;
  return false;
}

function FillHistory(e)
{
  var optie=e.options[e.options.selectedIndex].value;
  if (optie)
  {
    fteStatus = true;
    document.getElementById("zoekveld").value = optie;
  }
}

function UpdateHistory()
{
  if (fteStatus)
  {
    word = document.getElementById("zoekveld").value;
    if (word && !Contains(word)) document.cookie += word+",";
    OutputHistory();
  }
}

function OutputHistory()
{
 var str = document.cookie.split(",");
 
 var x=0;
 e = document.getElementById("zoekhistorie");
    
 var content = "zoekhistorie ";
 content += '<select onchange="FillHistory(this)" style="vertcal-align: bottom; width:170px; border:1px solid #000; font-family:verdana; font-size:11px; color:000000" id="jar" name="jar">';
 content += '<option value="'+str[x]+'">zoektermen...</option>';

  for (x=str.length-1; x>=0; x--)
    if (str[x]) content += '<option value="'+str[x]+'">'+str[x]+'</option>';
 
// while (str[x++])
 //  if (str[x]) content += '<option value="'+str[x]+'">'+str[x]+'</option>';
 
 content += '</select> <a title=\"zoekhistorie wissen\" style="cursor:pointer" onclick="javascript:document.cookie = \'\';OutputHistory()"><img src="/0/i/x.gif" /></a>';
 e.innerHTML = content;
}

function ShowNieuws(id)
{
  document.location.href =  "th_html.renderitem?p_id=" +id;
}

function pDet(id, url){
  openCenter(id, url, 750, 500, 'scrollbars=yes,status=yes');
}


function openCenter(id, url, width, height, properties)
{
	if (screen)
	{
		x = (screen.availWidth - width) / 2;
		y = (screen.availHeight - height) / 2;
  }

  referentie = window.open(url, id, properties+',width='+width+',height='+height+',screenX='+x+',screenY='+y+',left='+x+',top='+y);
}

function disclaimer()
{
	openCenter('disc','/0/disclaimer.html', 300,415);
}

function sitemap()
{
	openCenter('disc','/0/sitemap.html', 300,300);
}

