function showNBArchief() {
 new Effect.toggle('archief_holder' ,'blind', { duration: 1.5  } );  
}
function setCalendar(querys) {
  new Ajax.Updater('calrender', '/renderCalendar',{parameters:querys, onComplete:function(){ reAppearBlock(); } } );
}
function showActivity(glid,gcid,aid) {
 block = document.getElementById("activity_block");
 //onComplete:function(){  updateContactNow();  }
 //new Effect.toggle(block ,'appear', { duration: 0.5 ,afterFinish:function(){  updateContactNow();   } }  );  
 //function updateContactNow() {
  new Ajax.Updater(block, '/updateActivityBlock', {parameters:'glid='+glid+'&gcid='+gcid+'&aid='+aid   }  );
 //}
 function reAppearContactBlock() {
  new Effect.toggle(block ,'appear', { duration: 0.5, onComplete:function(){ resizeBorders();  } } );  
 }
}

function showFoundObjects() {
 querys = getInputValues('search_params');
 new Ajax.Updater('total_for_update','/updateTotalFoundObjects',{parameters:querys ,evalScripts:true}  );
}

function updateGebiedenList(glid,ob_land_id,gebied_container) {
  new Ajax.Updater(gebied_container, '/showObjectGebiedenList', {parameters:'glid=' + glid + '&land_id='+ob_land_id + '&update=1'  }   );
}
function updateLastObjects(last_item_id, obid) {
 new Effect.toggle('fade_c','appear', { duration: 0.5 ,afterFinish:function(){  updateHome();   } }  );  
 
 function updateHome() {
  new Ajax.Updater(obid, '/showLatestObjectsOnHome', {parameters:'last_id:int='+last_item_id , onComplete:function(){ reAppearBlock();  }  }  );
 }
 function reAppearBlock() {
  new Effect.toggle('fade_c','appear', { duration: 0.5 } );  
 }
}

function updateObjectsImages(last_item_id, obid,object_id) {
 new Effect.toggle('fade_c','appear', { duration: 0.5 ,afterFinish:function(){  updateIMG();   } }  );  
 
 function updateIMG() {
  new Ajax.Updater(obid, '/showObjectFotoWidget', {parameters:'last_id:int='+last_item_id + '&object_id='+object_id , onComplete:function(){ reAppearBlockb();  }  }  );
 }
 function reAppearBlockb() { 
  new Effect.toggle('fade_c','appear', { duration: 0.5 } );  
 }
}

function updateObjectsVideos(last_item_id, obid,object_id) {
 new Effect.toggle('fade_cv','appear', { duration: 0.5 ,afterFinish:function(){  updateIMG();   } }  );  
 
 function updateIMG() {
  new Ajax.Updater(obid, '/showObjectVideoWidget', {evalScripts: true, parameters:'last_id:int='+last_item_id + '&object_id='+object_id , onComplete:function(){ reAppearBlockb();  }  }  );
 }
 function reAppearBlockb() { 
  new Effect.toggle('fade_cv','appear', { duration: 0.5 } );  
 }
}

function updateErvaringVideos(last_item_id, obid,ervaring_id) {
 new Effect.toggle('fade_cv','appear', { duration: 0.5 ,afterFinish:function(){  updateIMG();   } }  );  
 
 function updateIMG() {
  new Ajax.Updater(obid, '/showErvaringVideoWidget', {evalScripts: true, parameters:'last_id:int='+last_item_id + '&ervaring_id='+ervaring_id , onComplete:function(){ reAppearBlockb();  }  }  );
 }
 function reAppearBlockb() { 
  new Effect.toggle('fade_cv','appear', { duration: 0.5 } );  
 }
}

function updateErvaringBrowser(last_item_id, obid,land_id) {
 new Effect.toggle('fade_c','appear', { duration: 0.5 ,afterFinish:function(){  updateIMG();   } }  );  
 function updateIMG() {
  new Ajax.Updater(obid, '/showErvaringenBrowser', {evalScripts: true, parameters:'last_id:int='+last_item_id + '&land_id='+land_id , onComplete:function(){ reAppearBlockb();  }  }  );
 }
 function reAppearBlockb() { 
  new Effect.toggle('fade_c','appear', { duration: 0.5,afterFinish:function(){  resizeBorders();   } } );  
 }
}

function showCountryInfo(cid) {
 cur = location.href.split('?');
 window.location=cur[0]+'?land_id='+cid;
}

function updateContactTypeBlock(pid) {
 block = document.getElementById("doelgroepinfo");
 new Effect.toggle(block ,'appear', { duration: 0.5 ,afterFinish:function(){  updateContactNow();   } }  );  
 function updateContactNow() {
  new Ajax.Updater(block, '/updateContactPage', {parameters:'title='+pid , onComplete:function(){ reAppearContactBlock();  }  }  );
 }
 function reAppearContactBlock() {
  new Effect.toggle(block ,'appear', { duration: 0.5, onComplete:function(){ resizeBorders();  } } );  
 }
}

function resizeBorders(){
 var b = document.getElementById('body');
 //var o = document.getElementById('overlay');
 var bw = b.offsetWidth;
 var bl = b.clientHeight;
 if(window.innerHeight){
 if(bl < window.innerHeight){
   bl = window.innerHeight;
 }
}else{
 if(bl <document.documentElement.clientHeight){
   bl = document.documentElement.clientHeight;
 }
}
// var bh = o.offsetHeight;
 border_a = document.getElementById('bb_a');
 border_a.style.height = bl+'px';
 border_b = document.getElementById('bb_b');
 border_b.style.height = bl+'px';
 border_a = document.getElementById('wb_a');
 border_a.style.height = bl+'px';
 border_b = document.getElementById('wb_b');
 border_b.style.height = bl+'px';
 //o.style.top = (bl-bh)+"px";
}
function getInputValues(holderid) {
 holder = document.getElementById(holderid);
 inputs = holder.getElementsByTagName('input');
 selects = holder.getElementsByTagName('select');
 textareas = holder.getElementsByTagName('textarea');
 i = 0;
 querystring = '';
 while (i < inputs.length) { 
  t_input = inputs[i];
  tv = t_input.value;
  tn = t_input.name;
  tt = t_input.type;
  if (tt == 'radio') {
   if (t_input.checked == true) { querystring = querystring + tn + '=' + tv + '&';}
  } else if (tt == 'checkbox') {
    if (t_input.checked == true) { querystring = querystring + tn + '=' + tv + '&';}
  } else if(tt=='text') {
   tv = escape(encodeURI(t_input.value));
   querystring = querystring + tn + '=' + tv + '&';
  }
  else {
   querystring = querystring + tn + '=' + tv + '&'; }
  i++;
 }
 i=0;
 while (i < selects.length) { 
  t_input = selects[i];
  tv = t_input.value;
  tn = t_input.name;
  querystring = querystring + tn + '=' + tv + '&';
  i++;
 }
 i=0;
 while (i < textareas.length) { 
  t_input = textareas[i];
  tv = t_input.value;
  tv = escape(t_input.value);
  tn = t_input.name;
  tv = escape(encodeURI(t_input.value));
  querystring = querystring + tn + '=' + tv + '&';
  i++;
 }
 return querystring;
}
var block_order =new Array();
function closeBlock(id){
  new Effect.Fade('block_'+id,{beforeStart:function(){unsetTabBlockPosition(id);},afterFinish:function(){  unsetBlockPosition(id);new Effect.Appear('block_tab_'+id),{afterFinish:function(){blockslide('in',id);}};} });
}

function blockslide(dir,id){
  obj = 'block_tab_'+id;
  var a = $(obj).getElementsByTagName('A')[0];
  if(dir == 'out'){
    //new Effect.Move(obj,{ x: 100, y: 0, mode: 'relative' });
    $(obj).style.left=(0-($(obj).offsetWidth-a.offsetWidth))+'px';
    $(obj).style.zIndex=3;
    a.style.zIndex=3;
  }
  if(dir == 'in'){
    //new Effect.Move(obj,{ x: -100, y: 0, mode: 'relative'});
    $(obj).style.left=(0-($(obj).offsetWidth-20))+'px';
    $(obj).style.zIndex=1;
    a.style.zIndex=1;
    //alert('done');
  }
}
function showBlock(id){
  new Effect.Fade('block_tab_'+id,{beforeStart:function(t){  setBlockPosition(id);renderBlock(id);},afterFinish:function(){setTabBlockPosition(id);}});
}
function renderBlock(id){
  new Effect.Appear('block_'+id);
}
function setBlockPosition(id){
  $('show_blocks').insert({bottom:$('block_'+id)}); 
}
function setTabBlockPosition(id){
  $('show_blocks').insert({bottom:$('block_tab_'+id)}); 
}
function unsetBlockPosition(id){
  $('blocks').insert({bottom:$('block_'+id)});
}
function unsetTabBlockPosition(id){
  $('blocks').insert({bottom:$('block_tab_'+id)});
}function checkText(el,mes){
	if (el.value == "") {
    alert( mes );
    el.focus(); 
    return false ;
  }
	return true;
}
function checkMail(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_email); // "vul uw email in"
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[a-z]+([.]?[a-z0-9_-]+)*[@]([a-z0-9_-]+[.])+([a-z]{2,4})$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_email); // "Het door uw ingevoerder e-mail adres is ongeldig.\n Gebruik van hoofdletters is niet toegestaan" );
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkPC(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_zip); // "Vul uw postcode in.\n (bv. 1111AA)" 
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[0-9]{4}[a-zA-z]{2}$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_zip); // "Het door uw ingevoerder postcode is ongeldig (bv. 1111AA)." 
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkNum(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_number ); // "Vul uw nummer in.\n(bv. 0206666666)"
			el.focus();
			return false ;
		}
	  //var valid = new RegExp("^[0-9]{10}$").exec(regex);
	  var valid = new RegExp("^[0-9]*$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_phone ); // "Het door u ingevoerde nummer is ongeldig.\n Voer uw nummer als volgt zonder streepjes in: 0206666666"
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkInt(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_number ); // "Vul uw nummer in.\n(bv. 10)"
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[0-9]*$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_number); // "Het door u ingevoerde nummer is ongeldig.\n Voer uw nummer als volgt in: 10" 
	    el.focus();
	    return false;
	  }
	}
	return true;
}function checkContactForm(form){
  if(!checkText(form.firstname,translation.reg_empty_firstname)){return false;}
  if(!checkText(form.lastname,translation.reg_empty_lastname)){return false;}
  if(!checkMail(form.email,true)){return false;}
  if(!checkText(form.about,translation.contact_empty_subject)){return false;}
  if(!checkText(form.bericht,translation.contact_empty_message)){return false;}
  return true;
}