
//Form functies

function Bevestig(DatumTijd) {
	var Vandaag=new Date()
	var Mins=Vandaag.getMinutes()
	if (Mins<10) {Mins="0"+Mins}
	DatumTijd.value=Vandaag.getDate()+"-"+(Vandaag.getMonth()+1)+"-"+Jaartal(Vandaag)+"; "+Vandaag.getHours()+":"+Mins
}

function CheckNaam(Naam,Email) {
	if (Naam.value=="") {alert("Je moet wel eerst even je naam invullen!"); Naam.focus(); return false}
	if (Email.value=="") {alert("Je moet wel eerst even je e-mail adres invullen!"); Email.focus(); return false}
	return true
}

function getCookie(CookieNaam) {
	if (document.cookie.length > 0) {
		var search=CookieNaam+"="
		var offset=document.cookie.indexOf(search)
		if (offset!=-1) {
			offset+=search.length
			var end=document.cookie.indexOf(";",offset)
			if (end==-1) end=document.cookie.length
			return unescape(document.cookie.substring(offset,end)) }
		else return ""
	}
	else return ""
} 

Naam='';From='';Telnr='';SpStE=-1;SpStD=-1;
NaamA=new Array(9); FromA=new Array(9); TelnrA=new Array(9); SpStEA=new Array(9); SpStDA=new Array(9);
NaamS=new Array(9);
cookieTel=0;

function ReadCookie(CookieNaam) {
	var Data=getCookie(CookieNaam)
	if (Data=="") {
	  return false 
	}
	else {
		var eod=Data.lastIndexOf("|")
		if (eod!=-1) {
			var end=Data.length
			var offset=Number(Data.substring(eod+1,end))
			if (offset!=-1) Data=Data.substring(0,offset)+"@"+Data.substring(offset+1,eod)
			offset=Data.indexOf("|")
			if (offset!=-1) {
				Naam=Data.substring(0,offset)
				offset+=1
				end=Data.indexOf("|",offset)
				if (end==-1) end=Data.length
				From=Data.substring(offset,end)
				offset=end+1
				end=Data.indexOf("|",offset)
				if (end==-1) end=Data.length
				Telnr=Data.substring(offset,end)
				offset=end+1
				end=Data.indexOf("|",offset)
				if (end==-1) end=Data.length
				var strSpStE=Data.substring(offset,end)
				if (strSpStE.length==0) SpStE=-1
				else SpStE=parseInt(strSpStE,10)
				offset=end+1
				end=Data.indexOf("|",offset)
				if (end==-1) end=Data.length
				var strSpStD=Data.substring(offset,end)
				SpStD=parseInt(strSpStD,10)
				if (strSpStD.length==0) SpStD=-1
				else SpStD=parseInt(strSpStD,10)
			}
		}
		return true
	}
}

function ReadCookies(CookieNaam) {
  if (!ReadCookie(CookieNaam)) Naam='';
  for (cookieTel=1;cookieTel<10;cookieTel++) {
		NaamA[cookieTel]=Naam;
		NaamS[cookieTel]=Naam+'|'+cookieTel;
		if (Naam!='') {
			FromA[cookieTel]=From;
			TelnrA[cookieTel]=Telnr;
			SpStEA[cookieTel]=SpStE;
			SpStDA[cookieTel]=SpStD;
		}
		if (!ReadCookie(CookieNaam+(cookieTel+1))) Naam='';
  }
  NaamS[0]='';
  NaamS=NaamS.sort();
}

function setCookie(CookieNaam,Inhoud,JaNee) {
	var expires=new Date()
	if (JaNee==0) {
		var AtPos=Inhoud.indexOf("@")
		if (AtPos>-1) Inhoud=Inhoud.replace("@",".")+"|"+AtPos
		expires.setTime(expires.getTime()+60*1000*60*24*183) }
	else {
		if (document.cookie.length==0) return
		Inhoud=""
		expires.setTime(expires.getTime()-60*1000)
	}
	document.cookie=CookieNaam+"="+escape(Inhoud)+"; expires="+expires.toGMTString()
}

function WriteCookie(CookieNaam,Naam,RestGeg,JaNee) {
  cookieTel=NaamA.length;
  for (i=1; i<NaamA.length; i++) {
    if ((NaamA[i]=='' && JaNee==0) || NaamA[i]==Naam) {
      cookieTel=i;
      i=NaamA.length;
    }
  }
  if (cookieTel<2) {
    setCookie(CookieNaam,Naam+RestGeg,JaNee) 
  }
  else {
		if (cookieTel<10) {
			setCookie(CookieNaam+cookieTel,Naam+RestGeg,JaNee) 
		}
  } 
}

