String.prototype.trim = function () {
	return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function validatenl(theform) {
	theform.elements['f[name]'].value  = theform.elements['f[name]'].value.trim();
	theform.elements['f[email]'].value = theform.elements['f[email]'].value.trim();
	if (theform.elements['f[name]'].value == '') {
		alert("Naam is verplicht!");
		theform.elements['f[name]'].focus();
		return false;
	}
	if (theform.elements['f[email]'].value == '') {
		alert("E-mail-adres is verplicht!");
		theform.elements['f[email]'].focus();
		return false;
	}
	var response = prompt("Ter voorkoming van automatische spam, graag ter bevestiging 123 invullen...", '');
	if (! response || response.length == 0 || response != '123') {
		alert("Uw aanmelding is niet correct ontvangen.");
		return false;
	}
	else {
		alert("Hartelijke dank voor uw aanmelding!\n\nEr is een bevestiging onderweg naar het door u opgegeven e-mail-adres.");
		return true;
	}
}

/* photo-show-caroussel */
function PhotoShower1(showdiv, interval, maxcycles, shownums, showpauseplay) {
	this.showdiv		= showdiv;	// container div for the show'er
	this.interval		= interval;	// in milliseconds
	this.maxcycles		= maxcycles;	// how many cycles to rotate max
	this.shownums		= shownums;	// do we show the photonumbers or not?
	this.showpauseplay	= showpauseplay;// show pause and play button
	this.photos		= Array();	// array of PhotoObjects is stored here
	this.iV			= null;		// the intervalid is stored here
	this.thecycle		= 0;		// the current cycle number is stored here
	this.addPhoto = function(src, hd, bd) {
		this.photos.push(new Photo1(src, hd, bd));
	}
	this.init = function() {
		this.initsquares();
		this.showPhoto(0);
	}
	this.initsquares = function() {
		var self = this;
		var out = '';
		var navbox = document.getElementById(this.showdiv).getElementsByTagName('div')[2];
		var newdiv = document.createElement('div');
		newdiv.className = 'square squareselected';
		newdiv.style.left = '0px';
		if (this.shownums == 1) {
			newdiv.innerHTML = '1';
		}
		else {
			newdiv.innerHTML = '&nbsp;';
		}
		newdiv.title = 'toon foto 1';
		newdiv.onclick = function() {
			self.showPhoto(0);
		}
		navbox.appendChild(newdiv);
		for (var i = 1; i < this.photos.length; i++) {
			var newdiv = document.createElement('div');
			newdiv.className = 'square';
			newdiv.style.left = (10) + 20*(i) + 'px';
			if (this.shownums == 1) {
				newdiv.innerHTML = (i+1);
			}	
			else {
				newdiv.innerHTML = '&nbsp;';
			}
			newdiv.title = 'toon foto ' + (i+1)
			newdiv.onclick = function(y) {
				return function() {
					self.showPhoto(y);
				}
			} (i);
			navbox.appendChild(newdiv);
		}
		if (this.interval > 0 && this.showpauseplay > 0) {
			var pauseplay = document.createElement('img');
			pauseplay.className = 'pauseplay';
			pauseplay.src = 'images/pause.png';
			pauseplay.title = 'pause';
			pauseplay.onclick = function(y) {
				return function() {
					self.pause(this);
				}
			} (self);
			navbox.appendChild(pauseplay);
		}
	}
	this.showPhoto = function(which) {
		var pbox = document.getElementById(this.showdiv);
		var allimgs = pbox.getElementsByTagName('img');
		var alldivs = pbox.getElementsByTagName('div');
		var pphoto = allimgs[0];
		pphoto.src = this.photos[which].src;
		for (var i = 3; i < this.photos.length+3; i++) {
			alldivs[i].className = alldivs[i].className.replace(new RegExp(" squareselected\\b"), '');
		}
		alldivs[which+3].className += ' squareselected';
		var allps = pbox.getElementsByTagName('p');
		allps[0].innerHTML = this.photos[which].hd;
//		allps[1].innerHTML = this.photos[which].bd;
	}
	this.showNext = function() {
		var pbox = document.getElementById(this.showdiv);
		var alldivs = pbox.getElementsByTagName('div');
		var pphoto = alldivs[0];
		var current = 0;
		for (var i = 3; i < this.photos.length+3; i++) {
			if (alldivs[i].className.indexOf('squareselected') != -1) {
				current = (i-3);
			}
		}
		current++;
		if (current >= this.photos.length) {
			current = 0;
			this.thecycle++;
		}
		if (this.maxcycles > 0 && this.thecycle >= this.maxcycles) {
			clearInterval(this.iV);
		}
		this.showPhoto(current);
	}
	this.pause = function(buttonimage) {
		var self = this;
		buttonimage.src = 'images/play.png';
		buttonimage.title = 'afspelen';
		buttonimage.onclick = function(y) {
			return function() {
				y.play(this);
			}
		} (self);
		clearInterval(this.iV);
	}
	this.play = function(buttonimage) {
		var self = this;
		buttonimage.src = 'images/pause.png';
		buttonimage.title = 'pause';
		buttonimage.onclick = function(y) {
			return function() {
				y.pause(this);
			}
		} (self);
		this.iV = setInterval(function(){self.showNext()}, 4000);
	}
}
function Photo1(src, hd, bd) {
	this.src	= src;
	this.hd		= hd;
	this.bd		= bd;
}

function unobtrusive() {
	if (!document.getElementsByTagName) return false;
	var imgs = document.getElementsByTagName("img");
	for (var i = 0; i < imgs.length; i++) {
		if (imgs[i].className.match("beemail")) {
			var theimage = imgs[i];
			var newanch = document.createElement("a");
			if (theimage.src.indexOf("beesupportathotmailpuntcom") != -1)
				newanch.href = "ma"+"ilt"+"o:"+"beesupport"+"@"+"hotmail"+"."+"com";
			else if (theimage.src.indexOf("infoatbeesupportpuntnl") != -1)
				newanch.href = "ma"+"ilt"+"o:"+"info"+"@"+"beesupport"+"."+"nl";
			else if (theimage.src.indexOf("infoatbeesupportpuntcom") != -1)
				newanch.href = "ma"+"ilt"+"o:"+"info"+"@"+"beesupport"+"."+"com";
			theimage.parentNode.insertBefore(newanch, theimage);
			var imgcopy = theimage.cloneNode(true);
			newanch.appendChild(imgcopy);
			theimage.parentNode.removeChild(theimage);
		}
		if (imgs[i].title == '' && imgs[i].alt != '') {
			imgs[i].title = imgs[i].alt;
		}
	}
}
function showmailform() {
	var newdiv = document.createElement("div");
	newdiv.innerHTML = "SHOWMAILFORM";
	newdiv.style.backgroundColor = "orange";
	newdiv.style.width = "300px";
	newdiv.style.height= "300px";
	newdiv.style.position = "absolute";
	newdiv.style.left = "400px";
	newdiv.style.top = "0";
	document.getElementById("content").style.opacity = "0.1";
	newdiv.style.zIndex = 100;
	newdiv.style.opacity = "1.0";
	document.body.appendChild(newdiv);

  var email = "info@beesupport.nl";
  
  if (!document.getElementById("mailTo")) return false;
  
  var spanobj = document.getElementById("mailTo");
  var anch = document.createElement("a");
  var mailto = "mailto:" + email;
  anch.setAttribute("href",mailto);
  spanobj.appendChild(anch);
  var txt = document.createTextNode(email);
  anch.appendChild(txt);

}
/* debugging and helpers */

function show_props2(obj, obj_name) {
	var result = '';
	for (var i in obj) {
		if (i)
			result += obj_name + '.' + i + ' = ' + obj[i] + '<br />\n';
	}
	return result
}

