﻿// JScript File
var xmlHttp;
var contentDiv;
var id;


function showtime() {
this.contentDiv = 'ctl00_timezones';
var url="/misc/gettime.aspx"
url=url+"?sid="+Math.random();

this.xmlHttp=GetXmlHttpObject();
SendRequest(url,"GET");

this.id=setTimeout("showtime()",60000); 
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}


/*<!-- Hide the script from old browsers --
    //var timerID = null;
   // var timerRunning = false;
    //var id,pause=0,position=0;
    
    function ticker() {
      var i,k,msg;
	  
	   msg = showtime();
	 
	
	   timeZoneDiv = document.getElementById('ctl00_timezones');
	 
	   timeZoneDiv.innerHTML =  msg;
	   
	 
      id=setTimeout("ticker()",60000); 
	  
	  
    }
    function action() {
      if(!pause) {
        clearTimeout(id);
        pause=1; 
      }
      else {
        ticker();
        pause=0; 
      }
    }
    // --end hiding here -->*/
window.onload = function(){
if(showtime){
showtime();
}
/*if (ticker) {
	ticker();
}*/
if(setSearchForm){
setSearchForm();
}
/*if(showRandomTestimonial){
showRandomTestimonial();
}*/
}

//function for processing various formdata
function processForm(formName,valDiv){
	//myDiv = valDiv;
	
	var val_errors_message = "";
	var val_errors = 0;
		
	var theForm =  document.forms[formName];	
	
	if(document.getElementById("__VIEWSTATE")){
	    theForm.removeChild(theForm.childNodes[0]);
	}
	
	document.getElementById("req_E-mail").style.display = "none";
	document.getElementById("req_Naam").style.display = "none";
	document.getElementById("req_Reactie").style.display = "none";
	
	if(!validateEmail(theForm.elements['E-mail'].value)){
	
	    val_errors_message = "E-mail is niet correct ingevuld";
	    document.getElementById("req_E-mail").style.display = "block";
   	   // document.getElementById("req_E-mail").innerHTML=val_errors_message;
   	    
   	    val_errors++;
	}	
	if(theForm.elements['Naam'].value==""){
	
	    val_errors_message = "Naam is niet correct ingevuld";
	    document.getElementById("req_Naam").style.display = "block";
   	   // document.getElementById("req_Naam").innerHTML=val_errors_message;
   	    
   	    val_errors++;
	}	
	if(theForm.elements['Reactie'].value==""){
	
	    val_errors_message = "Bericht is niet correct ingevuld";
	    document.getElementById("req_Reactie").style.display = "block";
   	   // document.getElementById("req_Reactie").innerHTML=val_errors_message;
   	    
   	    val_errors++;
	}	
	
   if(val_errors==0){
    	//Captcha check
		if(jcap()){
	     theForm.action = '/misc/send_form.aspx';
    
        theForm.submit(); 
	}else{
	    alert('De code is niet juist ingevuld!');
	}
   }
  }    

 //Validate emailaddress
 function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(email) == false) {
      return false;
   }
   return true;
}

//Perform a quick site search
function doSearch(){
//Add an iframe to the page
//var Iframe = "<iframe name='search_frame' class='searchFrame' frameborder='0'></iframe>";
//Add Iframe to page
//var contentDiv = document.getElementById("middenkolom");
//var contentDiv = false;
//if(contentDiv){

var theForm =  document.forms["aspnetForm"];	
var keyWord = theForm.key_words.value;

if(keyWord!==""){
//contentDiv.innerHTML = Iframe;
//Submit searchform	
if(document.getElementById("__VIEWSTATE")){
    theForm.removeChild(theForm.childNodes[0]);
}
 //theForm.target = 'search_frame';
 theForm.action = '/misc/search_site.aspx';
 theForm.submit();
//}
}
return false;
}

function setSearchForm(){

var theForm =  document.forms["aspnetForm"];	
var keyWord = theForm.key_words.value;


if(document.getElementById("__VIEWSTATE")){
    theForm.removeChild(theForm.childNodes[0]);
}
 theForm.action = '/misc/search_site.aspx';

}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {

if(xmlHttp.status== 200 || xmlHttp.status== 304){		
		updatePage();
	}else{
		//An error occured
		alert(xmlHttp.statusText);
	}
 }
}

function updatePage(){
document.getElementById(contentDiv).innerHTML = xmlHttp.responseText;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
 if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
return xmlHttp;
}

//Send Ajax request
function SendRequest(url,method,postdata){
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open(method,url,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	if(method=="POST"){
		xmlHttp.send(postdata);
	}else{
		xmlHttp.send(null);
	}
}

