function strpos (haystack, needle, offset) {
// *     example 1: strpos('Kevin van Zonneveld', 'e', 5);    // *     returns 1: 14
var i = (haystack+'').indexOf(needle, (offset || 0));
return i === -1 ? false : i;
} 

function getcords(e){
mouseX = Event.pointerX(e);
mouseY = Event.pointerY(e);
}
Event.observe(document, 'mousemove', getcords);

cht = new Ajax.PeriodicalUpdater('chat1','chat1.php?vn=1',{frequency:5, decay: 1.1});
cht.stop();
prg = new Ajax.PeriodicalUpdater('prog','prog.php?vn=1',{frequency:60, decay: 1.0});
prg.stop();
vrz = new Ajax.PeriodicalUpdater('verzoek1','verzoek1.php?vn=1',{frequency:20, decay: 1.0});
vrz.stop();

var lu=0;
var ch=0;
var gb=0;
var vz=0;
var wk=1;
var hi=0;
var bt=0;
var ag=0;
var ld=0;
var fo=0;
var ln=0;

function titels(){
sponsor();
var ot=$('titel1').innerHTML;
var sto=ot.substr(80,8);
new Ajax.Updater($('titel1'), 'titel1.php?vn='+ new Date().getTime(), {method:'get', onComplete: newtitel});
new Ajax.Updater('status','status.php?vn=34');
}

var chknw=0;
function newtitel(){
var nt=$('titel1').innerHTML;
/*
var nw=strpos(nt,'Nachtwaker',0);
if (nw){
Effect.Fade('verzoek2',{duration:1.0});
} else {
Effect.Appear('verzoek2',{duration:1.0});
} 
*/

new Ajax.Updater('history','history.php?vn=34');
}

function klein(){
if (wk){
Effect.Squish('welkom',{duration:1.0});
wk=0;
}
if (ch){
Effect.Squish('chat',{duration:1.0});
ch=0;
cht.stop();
}
if (lu){
Effect.Squish('prog',{duration:1.0});
Effect.Squish('progtip' ,{duration:0.5});
lu=0;
prg.stop();
}
if (gb){
Effect.Squish('gboek',{duration:1.0});
gb=0;
}
if (vz){
Effect.Squish('verzoek',{duration:1.0});
vz=0;
vrz.stop();
}
if (hi){
Effect.Squish('history',{duration:1.0});
hi=0;
}
if (bt){
Effect.Squish('btnl',{duration:1.0});
bt=0;
}
if (ag){
Effect.Squish('agenda',{duration:1.0});
ag=0;
}
if (ld){
Effect.Squish('leden',{duration:1.0});
ld=0;
}
if (fo){
Effect.Squish('foto',{duration:1.0});
fo=0;
}
if (ln){
Effect.Squish('links',{duration:1.0});
ln=0;
}
}

function btnl(){
if (!bt){
klein();
Effect.Grow('btnl',{duration:1.0});
bt=1;
}
}

function welkom(){
new Ajax.Updater('welkom','welkom.php?vn=34');
if (!wk){
klein();
Effect.Grow('welkom',{duration:1.0});
wk=1;
}
}

function agenda(){
new Ajax.Updater('agenda','agenda.php?vn=34');
if (!ag){
klein();
Effect.Grow('agenda',{duration:1.0});
ag=1;
}
}

function prog(){
new Ajax.Updater('prog','prog.php?vn=34');
if (!lu){
klein();
Effect.Grow('prog',{duration:1.0});
lu=1;
prg.start();
}
}

function chat(){
new Ajax.Updater('chat1','chat1.php?vn=34');
Effect.Squish('chat3',{duration:1.0});
if (!ch){
klein();
Effect.Grow('chat',{duration:1.0});
ch=1;
cht.start();
}
}

function gboek(){
new Ajax.Updater('gboek1','gboek1.php');
if (!gb){
klein();
Effect.Grow('gboek',{duration:1.0});
gb=1;
}
}

function verzoek(){
new Ajax.Updater('verzoek1','verzoek1.php?vn=34');
if (!vz){
klein();
Effect.Grow('verzoek',{duration:1.0});
vz=1;
vrz.start();
}
}

function leden(){
new Ajax.Updater('leden','leden.php?vn=34');
if (!ld){
klein();
Effect.Grow('leden',{duration:1.0});
ld=1;
}
}

function history(){
new Ajax.Updater('history','history.php?vn=34');
if (!hi){
klein();
Effect.Grow('history',{duration:1.0});
hi=1;
}
}

function foto(fd){
new Ajax.Updater('foto','foto.php?fd='+fd);
if (!fo){
klein();
Effect.Grow('foto',{duration:1.0});
fo=1;
}
}

function links(){
new Ajax.Updater('links','links.php?vn=34');
if (!ln){
klein();
Effect.Grow('links',{duration:1.0});
ln=1;
}
}

function savechat(){
var cnaam=encodeURIComponent(document.chat.cnaam.value);
var cbericht=encodeURIComponent(document.chat.cbericht.value);
cbericht=cbericht.replace("'", "`");
if (checkveld(cnaam)){
if (cnaam && cbericht){
new Ajax.Request('chat2.php',{method:'post',parameters:'cnaam='+cnaam+'&cbericht='+cbericht});
setTimeout("new Ajax.Updater('chat1','chat1.php?d=34');",1000);
document.chat.cbericht.value = '';
} else {
alert('Geen bericht ingetypt');
}
}
}

function chatwis(bw){
var bev = confirm('Dit bericht wissen ?');
if (bev==true){
new Ajax.Request('chat3.php',{method:'post',parameters:'bw='+bw});
document.chat.cbericht.value="";
$('chat1').innerHTML='Bericht is verwijderd.';
setTimeout("new Ajax.Updater('chat1','chat1.php?d=34');",3000);
}
}

function chatreaktie(cr){
Effect.Appear('chat3',{duration:1.0});
$('chat4').innerHTML=cr;
}

function savereaktie(){
var rid=$('chat4').innerHTML;
var rnaam=encodeURIComponent(document.rchat.rnaam.value);
var rbericht=encodeURIComponent(document.rchat.rbericht.value);
rbericht=rbericht.replace("'", "`");
if (checkveld(rnaam)){
if (rnaam && rbericht){
new Ajax.Request('chat5.php',{method:'post',parameters:'rid='+rid+'&rnaam='+rnaam+'&rbericht='+rbericht});
new Ajax.Updater('chat1','chat1.php?d=34');
document.chat.cbericht.value = '';
document.rchat.rbericht.value = '';
Effect.Fade('chat3',{duration:1.0});
} else {
alert('Geen \"Naam\" of \"Reaktie\" ingetypt...');
}
}
}

function Invoegen(Smiley){ 
var edit;
var HuidigeTekst = document.chat.cbericht.value;
edit = HuidigeTekst+Smiley+" ";
document.chat.cbericht.focus();
document.chat.cbericht.value=edit;
document.chat.cbericht.focus();
return;
}

function Invoeg1(Smiley){ 
var edit;
var HuidigeTekst = document.rchat.rbericht.value;
edit = HuidigeTekst+Smiley+" ";
document.rchat.rbericht.focus();
document.rchat.rbericht.value=edit;
document.rchat.rbericht.focus();
return;
}

function invoeg3(Smiley){ 
var edit;
var HuidigeTekst = document.gboekr.gbericht.value;
edit = HuidigeTekst+Smiley+" ";
document.gboekr.gbericht.focus();
document.gboekr.gbericht.value=edit;
document.gboekr.gbericht.focus();
return;
}

function invoeg2(Smiley){ 
var edit;
var HuidigeTekst = document.gastboek.gbericht.value;
edit = HuidigeTekst+Smiley+" ";
document.gastboek.gbericht.focus();
document.gastboek.gbericht.value=edit;
document.gastboek.gbericht.focus();
return;
}

function inlog(){
var lnaam=document.login.lnaam.value;
var lwoord=document.login.lwoord.value;
if (lnaam && lwoord){
new Ajax.Updater('inlog','login.php?lnaam='+lnaam+'&lwoord='+lwoord);
Effect.Grow('inlog',{duration:1.0});
} else {
alert('U heeft geen \"naam\" en/of \"wachtwoord\" ingetypt !');
}
}

function loguit(){
Effect.Squish('inlog',{duration:1.0});
Effect.Squish('inlog1',{duration:1.0});
Effect.Squish('inlog2',{duration:1.0});
document.login.lwoord.value="";
}

var spo=1;
var st=24;

function sponsor(){
new Effect.SlideUp('spon'+spo ,{duration:5.0});
spo++;
if (spo>st){
spo=2;
for(i=2; i<=st; i++){
new Effect.SlideDown('spon'+i ,{duration:0.5});
}
}
}

function verzwis(wisv){
new Ajax.Request('verzoek3.php',{method:'get',parameters:'wis='+ wisv});
$('verzoek1').innerHTML = "<b>Het verzoekje is gewist.</b>";
setTimeout("new Ajax.Updater('verzoek1','verzoek1.php?d=34');",1000);
}

function saveVerzoek(){
var vnaam=encodeURIComponent(document.verzoek.vnaam.value);
var vplaats=encodeURIComponent(document.verzoek.vplaats.value);
var vvoor=encodeURIComponent(document.verzoek.vvoor.value);
var vnummer=encodeURIComponent(document.verzoek.vnummer.value);
if (checkveld(vnaam)){
if (vnaam && vvoor){
new Ajax.Request('verzoek3.php',{method:'post',parameters:'vnaam='+vnaam+'&vplaats='+vplaats+'&vvoor='+vvoor+'&vnummer='+vnummer});
$('verzoek1').innerHTML = "<b>Uw verzoek is verstuurd en verschijnt binnen enkele seconden.</b>";
setTimeout("new Ajax.Updater('verzoek1','verzoek1.php?d=34');",2000);
document.verzoek.vvoor.value='';
document.verzoek.vnummer.value='';
} else {
alert('U heeft geen \"naam\" en/of \"Bestemd Voor\" ingetypt !');
}
}
}

function wisverzk(){
var bev = confirm('Alle verzoekjes wissen ?');
if (bev==true){
new Ajax.Request('verzoek4.php',{method:'post',parameters:'bev='+bev});
$('verzwis').innerHTML = "<b>Alle verzoekjes zijn gewist.</b>";
}
}

function saveinstel(){
var iid=document.instel.id.value;
var istation=document.instel.station.value;
var istation2=document.instel.station2.value;
var istation3=document.instel.station3.value;
var iaantal=document.instel.aantal.value;
var iplaatje=document.instel.plaatje.value;
var idivnaam=document.instel.divnaam.value;
var iwebsite=document.instel.website.value;
var iplaats=document.instel.plaats.value;
var ivastdag=document.instel.vastdag.value;
var inaam=document.instel.naam.value;
var iwachtwoord=document.instel.wachtwoord.value;
var iip=document.instel.ip.value;
var imail=document.instel.mail.value;
var imobiel=document.instel.mobiel.value;
var ijarig=document.instel.jarig.value;

new Ajax.Request('login1.php',{method:'post',parameters:'id='+iid+'&station='+istation+'&station2='+istation2+'&station3='+istation3+'&aantal='+iaantal+'&plaatje='+iplaatje+'&divnaam='+idivnaam+'&vastdag='+ivastdag+'&website='+iwebsite+'&plaats='+iplaats+'&naam='+inaam+'&wachtwoord='+iwachtwoord+'&ip='+iip+'&mail='+imail+'&mobiel='+imobiel+'&jarig='+ijarig});
$('inlog').innerHTML = "<br /><br /><b>De gegevens zijn verstuurd.</b>";
setTimeout("loguit();",2000);
}

function pinstel(){
new Ajax.Updater('inlog1','pinstel.php?vn=34');
Effect.Grow('inlog1',{duration:1.0});
}

function saveinst(){
var inaam=encodeURIComponent(document.instel.instnaam.value);
var iplaats=encodeURIComponent(document.instel.instplaats.value);
var imail=encodeURIComponent(document.instel.instmail.value);
var isite=encodeURIComponent(document.instel.instsite.value);
var iplay=encodeURIComponent(document.instel.player.value);
if (!inaam){
alert('U heeft geen naam ingevuld.');
} else {
new Ajax.Request('instelsave1.php',{method:'post',parameters:'inaam='+inaam+'&iplaats='+iplaats+'&imail='+imail+'&isite='+isite+'&iplay='+iplay});
$('inlog1').innerHTML = "<br /><br /><b>De gegevens zijn verstuurd.</b>";
setTimeout("loguit();",2000);
}
}

function gbhoog(gp){
new Ajax.Updater('gboek1','gboek1.php?gp='+gp);
}

function gastsave(){
var gnaam=encodeURIComponent(document.gastboek.gnaam.value);
var gmail=encodeURIComponent(document.gastboek.gmail.value);
var gsite=encodeURIComponent(document.gastboek.gsite.value);
var gplaats=encodeURIComponent(document.gastboek.gplaats.value);
var gbericht=encodeURIComponent(document.gastboek.gbericht.value);
if (checkveld(gnaam)){
if (gnaam && gbericht){
new Ajax.Request('gboek2.php',{method:'post',parameters:'gnaam='+gnaam+'&gmail='+gmail+'&gsite='+gsite+'&gplaats='+gplaats+'&gbericht='+gbericht});
$('gboek1').innerHTML = "<br />Uw bericht is verstuurd en verschijnt binnen enkele seconden.";
setTimeout("new Ajax.Updater('gboek1','gboek1.php?gp=1');",2000);
} else {
alert('U heeft geen bericht ingetypt !');
}
}
}

function gbreaktie(cr){
Effect.Appear('gboek3',{duration:1.0});
$('gboek4').innerHTML=cr;
}

function gastreakt(){
var rid=$('gboek4').innerHTML;
var gnaam=encodeURIComponent(document.gboekr.gnaam.value);
var gbericht=encodeURIComponent(document.gboekr.gbericht.value);
if (checkveld(gnaam)){
if (gnaam && gbericht){
new Ajax.Request('gboek5.php',{method:'post',parameters:'gnaam='+gnaam+'&gbericht='+gbericht+'&rid='+rid});
document.gboekr.gbericht.value = '';
Effect.Fade('gboek3',{duration:1.0});
new Ajax.Updater('gboek1','gboek1.php?gp=1');
} else {
alert('U heeft geen \"naam\" en/of bericht ingetypt !');
}
}
}

function gbwis(bw){
var bev = confirm('Dit bericht wissen ?');
if (bev==true){
new Ajax.Request('gboek4.php',{method:'post',parameters:'bw='+bw});
$('gboek1').innerHTML='<br />Bericht is verwijderd.';
setTimeout("new Ajax.Updater('gboek','gboek.php?gp=1');",2000);
}
}

function ledenmo(mo){
new Ajax.Updater('leden1','leden1.php?vn='+mo);
}

function dtitel(){
var ttitel=encodeURIComponent(document.dbtitel.titel.value);
new Ajax.Updater('dbtitel2', 'sdtitel.php?vnummer='+ttitel);
}

function dbtwis(dbt){
var bev = confirm('wissen ?');
if (bev==true){
new Ajax.Request('sdtitel1.php',{method:'post',parameters:'dbt='+dbt});
setTimeout("dtitel();",1000);
}
}

function dbtdub(dbt){
new Ajax.Updater('dbtitel2', 'sdtitel2.php?dbt='+dbt);
}

function fotgr(fg){
var ft1=document.images[fg].src;
document.fotor.src = ft1;
}

function video1(vd){
if (vd!=0){
new Ajax.Updater('foto1','video1.php?vn='+vd);
}
}

function tubetest(tt){
var ek=tt.indexOf("v=");
tt=tt.substr((ek+2));
var et=tt.indexOf("&");
if (et!=-1){
tt=tt.substr(0,et);
}
if (tt){
$('video').innerHTML='<object width=\"640\" height=\"385\"><param value=\"http://www.youtube.com/v/'+tt+'&fs=1&egm=1&showsearch=0&rel=0&autoplay=1&amp;ap=%2526fmt%3D18\" name=\"movie\" /><param value=\"window\" name=\"wmode\" /><param value=\"true\" name=\"allowFullScreen\" /><embed width=\"640\" height=\"385\" wmode=\"window\" allowfullscreen=\"true\" type=\"application/x-shockwave-flash\" src=\"http://www.youtube.com/v/'+tt+'&fs=1&egm=1&showsearch=0&rel=0&autoplay=1&amp;ap=%2526fmt%3D18\"></embed></object>';
}
}

function savetube(){
var tekst=document.tubebij.tekst.value;
var tt=document.tubebij.tube.value;
var ek=tt.indexOf("v=");
tt=tt.substr((ek+2));
var et=tt.indexOf("&");
if (et!=-1){
tt=tt.substr(0,et);
}
if (!tt){
alert('geen link ingevuld.');
}
if (!tekst){
alert('geen omschrijving ingevuld.');
}
if (tt && tekst){
new Ajax.Request('tubebij1.php',{method:'post',parameters:'tube='+tt+'&tekst='+tekst});
document.tubebij.tube.value='';
document.tubebij.tekst.value='';
setTimeout("foto();",1000);
}
}

function progtip(id,y){
if (y>520){
y=520;
}
new Ajax.Updater('progtip', 'progtip.php?id='+id);
document.getElementById("progtip").style.top = y+'px';
Effect.Appear('progtip' ,{duration:0.5});
setTimeout("Effect.Fade('progtip' ,{duration:1.0});",15000);
setTimeout("Effect.Fade('progtip1' ,{duration:1.0});",15000);
}

function ptipbij(vn,sid){
new Ajax.Updater('inlog2','ptipbij.php?vn='+vn+'&sid='+sid);
Effect.Grow('inlog2',{duration:1.0});
}

function pvoeg(txt){ 
var edit;
var HuidigeTekst = document.ptip.pbericht.value;
edit = HuidigeTekst+txt+" ";
document.ptip.pbericht.focus();
document.ptip.pbericht.value=edit;
document.ptip.pbericht.focus();
return;
}

function ptipsave(id){
var pkop=document.ptip.pkop.value;
var pbericht=document.ptip.pbericht.value;
if (pkop && pbericht){
new Ajax.Request('ptipbij1.php',{method:'post',parameters:'pkop='+pkop+'&pbericht='+pbericht+'&id='+id});
$('inlog2').innerHTML='De gegevens zijn verstuurd.';
setTimeout("loguit();",1000);
} else {
alert('U heeft geen \"kop\" en/of bericht ingetypt !');
}
}

function link(lk){
new Ajax.Updater('links1','links1.php?lk='+lk);
}

function checkveld(vl) {
if (vl.match(/^.+$/)){
return true;
} else {
alert('Alleen letters en cijfers bij een naam.');
return false;
} 
}

