      var XMLHttpRequestObject = false; 
      var secs;
      var timerID = null;
      var timerRunning = false;
      var delay = 1000;

      if (window.XMLHttpRequest) {
        XMLHttpRequestObject = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
      }

      function getHoofdpagina(dataSource,o,divID) 
      { 
        if(XMLHttpRequestObject) {
          var obj = document.getElementById(divID); 
          XMLHttpRequestObject.open("GET", dataSource); 

          XMLHttpRequestObject.onreadystatechange = function() 
          { 
               if (XMLHttpRequestObject.readyState == 4 && 
                   XMLHttpRequestObject.status == 200 ) 
	       { 
                    obj.innerHTML = XMLHttpRequestObject.responseText; 
               }
          } 
          XMLHttpRequestObject.send(null); 
        }
	checkpagina(currentPanel);
      }

      function SwitchPage(dataSource,o,divID)
      {
        if(XMLHttpRequestObject) {
          var obj = document.getElementById(divID);
          XMLHttpRequestObject.open("GET", dataSource);

          XMLHttpRequestObject.onreadystatechange = function()
          {
            if (XMLHttpRequestObject.readyState == 4 &&
              XMLHttpRequestObject.status == 200) {
                obj.innerHTML = XMLHttpRequestObject.responseText;
            }
          }
          XMLHttpRequestObject.send(null);
        }
        checkpagina(o);
      }

      function checkpagina(url)
      {
	document.getElementById("page").innerHTML="<table id='tblpage' align='left' width='100%' height='100%'><tr> <td id='pagefield' class='td2class' align='left' width='50%' height='33%'>"+url+"</td></tr></table>";
	currentpage = url;
      }

      function Validate(theForm)
      {
       var missing = "";
       var aCharExists = 0;
       if (theForm.Login.value == ""){missing += "Login\n";}
       for (var i=0; i<=theForm.Login.value.length; i++) {
       //spaces don't count as "existence"
       if (theForm.Login.value.charAt(i) == " ") { aCharExists = 1;}
       }
       if (theForm.Password.value == ""){missing += "Password\n";}
       if (theForm.Confirm.value == ""){ missing += "Confirm\n";}
       if (theForm.Email.value == ""){ missing += "Email\n";}
       if (theForm.FirstName.value == ""){missing += "FirstName\n";}
       if (theForm.LastName.value == ""){missing += "LastName\n"};
       if (theForm.Email.value == ""){missing += "Email\n";}
       if (theForm.Company.value == ""){missing += "Company\n";}
       if (theForm.Country.value == ""){missing += "Country\n";}
       if (missing != "") {alert("You have to fill in the following mandatory fields:\n" + missing + "Please complete the form and resubmit"); return false;}
           if (theForm.Password.value != theForm.Confirm.value) {alert("You entered two different passwords !\n" + "Please fill in the same password twice"); return false;}
           if (aCharExists > 0) { alert("Login contains spaces !\n" + "Please do not use spaces"); return false;}
           else{ return true;}
      }

      function Validate2()
      {
       var missing = "";
       if (document.getElementById('category').value == ""){missing += "Category\n";}
       if (document.getElementById('subject').value == ""){missing += "Subject\n";}
       if (document.getElementById('messagetext').value == ""){ missing += "Message\n";}
       if (missing != "") {alert("You have to fill in the following mandatory fields:\n" + missing + "Please complete the form and resubmit");}
           else
		{
		mes = document.getElementById('messagetext').value;
		mes = mes.replace(/(\r\n|\r|\n)/g, "<br />");
                mes = mes.replace(/(#)/g, "");
        	var d=new Date();
        	var pars='&c=' + document.getElementById('category').value + '&s=' + document.getElementById('subject').value + '&m=' + mes + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        	StopTheClock();
        	InitializeTimer();
        	urlo = 'dopostthread.php?login=' +l + pars;
        	url = 'dopostthread.php';
        	getHoofdpagina(urlo,url,'Forumdiv');
        	currentdiv = 'Forumdiv';
                var d=new Date();
                var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
                urlo = 'forum_small.php?' + pars;
                url = 'forum_small.php';
                setTimeout("getHoofdpagina(urlo,url,'Rightpaneltopdiv')",2000);
 		}
      }

      function Validate3(tid)
      {
       var missing = "";
       if (document.getElementById('replytext').value == ""){ missing += "Reply\n";}
       if (missing != "") {alert("You have to fill in the following mandatory fields:\n" + missing + "Please complete the form and resubmit");}
           else
                {
                rep = document.getElementById('replytext').value;
                rep = rep.replace(/(\r\n|\r|\n)/g, "<br />");
                rep = rep.replace(/(#)/g, "");
                var d=new Date();
                var pars='&tid=' + tid + '&r=' + rep + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
                StopTheClock();
                InitializeTimer();
                urlo = 'dopostreply.php?login=' +l + pars;
                url = 'dopostreply.php';
                getHoofdpagina(urlo,url,'Forumdiv');
                currentdiv = 'Forumdiv';
                }
      }

      function CheckLogon()
      {
        l=document.getElementById('Login').value;
        p=document.getElementById('Password').value;
        var d=new Date();
        var pars='&pass=' + p + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        urlo = 'logon.php?login=' +l + pars;
        url = 'logon.php';
        getHoofdpagina(urlo,url,'LogDetailsdiv');
        currentdiv = 'LogDetailsdiv';
        document.getElementById('Login').value = '';
        document.getElementById('Password').value = '';
	setTimeout("AfterLogon()",2000);
        // Update Hits Pane begin
        hits=document.getElementById('nrofvisits').innerHTML;
        var d=new Date();
        var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        url1 = 'update_hits.php?visits=' + hits + pars;
        url2 = 'update_hits.php';
        setTimeout("getHoofdpagina(url1,url2,'Leftpanelbottomdiv')",4000);
        currentdiv = 'Leftpanelbottomdiv';
        // Update Hits Pane end
      }

      function CheckLogout()
      {
        var d=new Date();
        var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        urlo = 'logout.php?' + pars;
        url = 'logout.php';
        getHoofdpagina(urlo,url,'LogDetailsdiv');
        currentdiv = 'LogDetailsdiv';
	document.getElementById('Rightpaneltopdiv').innerHTML = '<BR><BR><BR><img src="Forum_Locked.jpg"></img><BR><BR><BR>Log in first to see this part.';
	document.getElementById('Rightpanelbottomdiv').innerHTML = '<BR><BR><BR><img src="Docs_Locked.jpg"></img><BR><BR><BR>Log in first to see this part.';
	document.getElementById('Newsdiv').innerHTML = '';
	document.getElementById('Docsdiv').innerHTML = '';
	document.getElementById('Scriptsdiv').innerHTML = '';
	document.getElementById('Forumdiv').innerHTML = '';
	document.getElementById('Linksdiv').innerHTML = '';
        document.getElementById('Searchdiv').innerHTML = '';
        document.getElementById('tab4').style.visibility = 'hidden';
        document.getElementById('tab5').style.visibility = 'hidden';
        document.getElementById('tab6').style.visibility = 'hidden';
        document.getElementById('tab7').style.visibility = 'hidden';
        document.getElementById('tab8').style.visibility = 'hidden';
	l = '';
        setTimeout("showPanel(1)",1000);
        // Update Hits Pane begin
	hits=document.getElementById('nrofvisits').innerHTML;
        var d=new Date();
        var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        url1 = 'update_hits.php?visits=' + hits + pars;
        url2 = 'update_hits.php';
        setTimeout("getHoofdpagina(url1,url2,'Leftpanelbottomdiv')",3000);
        currentdiv = 'Leftpanelbottomdiv';
        // Update Hits Pane end
      }

      function ShowReminder()
      {
        var d=new Date();
        var pars='&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        e=document.getElementById('Email_address').value;
        urlo = 'show_reminder.php?e=' +e + pars;
        url = 'show_reminder.php';
        getHoofdpagina(urlo,url,'Reminderdiv');
        currentdiv = 'Reminderdiv';
      }

      function SendPassword()
      {
        var d=new Date();
        var pars='&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        e=document.getElementById('Email_address').value;
        urlo = 'send_password.php?e=' +e + pars;
        url = 'send_password.php';
        getHoofdpagina(urlo,url,'Reminderdiv');
        currentdiv = 'Reminderdiv';
      }


function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 1800 
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        alert("Your session has ended. To continue please log in.")
        var d=new Date();
        var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        urlo = 'kill.php?' + pars;
        url = 'kill.php';
        getHoofdpagina(urlo,url,'LogDetailsdiv');
        currentdiv = 'LogDetailsdiv';
        document.getElementById('Rightpaneltopdiv').innerHTML = '<BR><BR><BR><img src="Forum_Locked.jpg"></img><BR><BR><BR>Log in first to see this part.';
        document.getElementById('Rightpanelbottomdiv').innerHTML = '<BR><BR><BR><img src="Docs_Locked.jpg"></img><BR><BR><BR>Log in first to see this part.';
        document.getElementById('Newsdiv').innerHTML = '';
        document.getElementById('Docsdiv').innerHTML = '';
        document.getElementById('Scriptsdiv').innerHTML = '';
        document.getElementById('Forumdiv').innerHTML = '';
        document.getElementById('Linksdiv').innerHTML = '';
        document.getElementById('Searchdiv').innerHTML = '';
        document.getElementById('tab4').style.visibility = 'hidden';
        document.getElementById('tab5').style.visibility = 'hidden';
        document.getElementById('tab6').style.visibility = 'hidden';
        document.getElementById('tab7').style.visibility = 'hidden';
        document.getElementById('tab8').style.visibility = 'hidden';
        l = '';
        setTimeout("showPanel(1)",1000);
        // Update Hits Pane begin
        hits=document.getElementById('nrofvisits').innerHTML;
        var d=new Date();
        var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        url1 = 'update_hits.php?visits=' + hits + pars;
        url2 = 'update_hits.php';
        setTimeout("getHoofdpagina(url1,url2,'Leftpanelbottomdiv')",3000);
        currentdiv = 'Leftpanelbottomdiv';
        // Update Hits Pane end
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function AfterLogon()
{
    // Unlock Forum Pane begin
    bl = document.getElementById('badlogin').innerHTML;
    if (bl != '')
    {
      l = '';
    }
    else
    {
    var d=new Date();
    var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
    urlo = 'forum_small.php?' + pars;
    url = 'forum_small.php';
    getHoofdpagina(urlo,url,'Rightpaneltopdiv');
    currentdiv = 'Rightpaneltopdiv';
    // Unlock Forum Pane end
    // Unlock Docs Pane begin
    var d=new Date();
    var pars='&login=' + l + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
    urlo = 'docs_small.php?' + pars;
    url = 'docs_small.php';
    setTimeout("getHoofdpagina(urlo,url,'Rightpanelbottomdiv')",1000);
    currentdiv = 'Rightpanelbottomdiv';
    // Unlock Docs Pane end
    setTimeout("document.getElementById('tab4').style.visibility = 'visible'",5000);
    setTimeout("document.getElementById('tab5').style.visibility = 'visible'",5000);
    setTimeout("document.getElementById('tab6').style.visibility = 'visible'",5000);
    setTimeout("document.getElementById('tab7').style.visibility = 'visible'",5000);
    setTimeout("document.getElementById('tab8').style.visibility = 'visible'",5000);
    setTimeout("document.getElementById('loading').innerHTML=''",5000);
    }
}

function ShowDocPage(dp)
{
        var d=new Date();
        nrdocs = document.getElementById('nrofdocs').innerHTML;
        nrdocpages = 1 + Math.floor((nrdocs/10));
        var pars='&nrdocs=' + nrdocs + '&ndp=' + nrdocpages + '&docpage=' + dp + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        if (l != '') {
           StopTheClock();
           InitializeTimer();
           urlo = 'docs.php?login=' +l + pars;
           url = 'docs.php';
           getHoofdpagina(urlo,url,'Docsdiv');
           currentdiv = 'Docsdiv';
        }
        if (l == '') {
           alert("You must log in first in order to see this section");
           showPanel(1);
        }
}

function ShowScriptPage(dp)
{
        var d=new Date();
        nrscripts = document.getElementById('nrofscripts').innerHTML;
        nrscriptpages = 1 + Math.floor((nrscripts/10));
        var pars='&nrscripts=' + nrscripts + '&nsp=' + nrscriptpages + '&scriptpage=' + dp + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        if (l != '') {
           StopTheClock();
           InitializeTimer();
           urlo = 'scripts.php?login=' +l + pars;
           url = 'scripts.php';
           getHoofdpagina(urlo,url,'Scriptsdiv');
           currentdiv = 'Scriptsdiv';
        }
        if (l == '') {
           alert("You must log in first in order to see this section");
           showPanel(1);
        }
}

	function ShowNewThreadForm()
	{
        var d=new Date();
        var pars='&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        StopTheClock();
        InitializeTimer();
        urlo = 'postnewthread.php?login=' +l + pars;
        url = 'postnewthread.php';
        getHoofdpagina(urlo,url,'Forumdiv');
        currentdiv = 'Forumdiv';
	}

        function ReplyThread(threadid)
        {
        var d=new Date();
        var pars='&thread=' +threadid + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        StopTheClock();
        InitializeTimer();
        urlo = 'replythread.php?login=' +l + pars;
        url = 'replythread.php';
        getHoofdpagina(urlo,url,'Forumdiv');
        currentdiv = 'Forumdiv';
        }

function ShowThreadPage(tp)
{
        var d=new Date();
	nrthreads = document.getElementById('nrofthreads').innerHTML;
        nrthreadpages = 1 + Math.floor((nrthreads/34));
        var pars='&nrthreads=' + nrthreads + '&ntp=' + nrthreadpages + '&threadpage=' + tp + '&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        if (l != '') {
           StopTheClock();
           InitializeTimer();
           urlo = 'forum.php?login=' +l + pars;
           url = 'forum.php';
           getHoofdpagina(urlo,url,'Forumdiv');
           currentdiv = 'Forumdiv';
        }
        if (l == '') {
           alert("You must log in first in order to see this section");
           showPanel(1);
        }
}

function ShowForumDetail(id){
        document.getElementById('Rightpaneltop').style.visibility = 'hidden';
        document.getElementById('Rightpanelbottom').style.visibility = 'hidden';
        document.getElementById('panel7').style.visibility = 'visible';
        document.getElementById('Forumdiv').style.visibility = 'visible';
        var d=new Date();
        var pars='&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        urlo = 'forum_details.php?forumid=' +id + pars;
        url = 'forum_details.php';
        getHoofdpagina(urlo,url,'Forumdiv');
        currentdiv = 'Forumdiv';
	searched = 'Forum';
}

function ShowSearchForumDetail(id){
        document.getElementById('scrollseadocdiv').style.visibility = 'hidden';
        document.getElementById('scrollseascriptdiv').style.visibility = 'hidden';
        document.getElementById('scrollseaforumdiv').style.visibility = 'hidden';
        document.getElementById('Rightpaneltop').style.visibility = 'hidden';
        document.getElementById('Rightpanelbottom').style.visibility = 'hidden';
        document.getElementById('panel7').style.visibility = 'visible';
        document.getElementById('Forumdiv').style.visibility = 'visible';
        hidePanel();
        var d=new Date();
        var pars='&t='+d.getFullYear()+d.getMonth()+d.getDay()+d.getHours()+d.getDay()+d.getSeconds();
        urlo = 'forum_details.php?forumid=' +id + pars;
        url = 'forum_details.php';
        getHoofdpagina(urlo,url,'Forumdiv');
        currentdiv = 'Forumdiv';
	searched = 'Yes'
}

function DoSearch()
{
        if (l == '')
        {
          alert("You must be logged in to search this website !");
        }
        if (l != '')
        {
          sea = document.getElementById('Search').value;
          if (sea == '')
          {
            alert("Please fill in a search criteria !");
          }
          if (sea != '')
          {
	    showPanel(10);
	  }
	}
}

function ShowDocSearch() 
{
	document.getElementById('scrollseadocdiv').style.visibility = 'visible';
        document.getElementById('scrollseascriptdiv').style.visibility = 'hidden';
        document.getElementById('scrollseaforumdiv').style.visibility = 'hidden';
        searched = 'Yes';
}

function ShowScriptSearch()
{
	document.getElementById('scrollseadocdiv').style.visibility = 'hidden';
        document.getElementById('scrollseascriptdiv').style.visibility = 'visible';
        document.getElementById('scrollseaforumdiv').style.visibility = 'hidden';
        searched = 'Yes';
}
function ShowForumSearch()
{
        document.getElementById('scrollseadocdiv').style.visibility = 'hidden';
        document.getElementById('scrollseascriptdiv').style.visibility = 'hidden';
        document.getElementById('scrollseaforumdiv').style.visibility = 'visible';
        searched = 'Yes';
}
