﻿	var index=0;
	var huidigindex='';

	PT.Sites.Dubent = {
		onLoad: function() {
			PT.Sites.Dubent.createBackground();
		},
		indexInArray: function(arr, val) {
			for (var i = 0; i < arr.length; i++) if (arr[i] == val) return i;
			return -1;
		},
		Blader: function(richting) {
			index = PT.Sites.Dubent.indexInArray(Pic, huidigindex);
			if (index == -1) {
				index = 0;
			}
			// volgende of vorige; loopt door array
			if (richting == 'volgende') {
				if (index + 1 >= Pic.length) {
					index = 0;
				}
				else {
					index++;
				}
			}
			else if (richting == 'vorige') {
				if (index - 1 < 0) {
					index = Pic.length - 1;
				}
				else {
					index--;
				}
			}
			//image veranderen
			var img = get$('liedtegels').getElementsByTagName('img')[0];
			img.src = Pic[index];
			huidigindex = Pic[index];
		},
		BladerRep: function(richting) {
			index = PT.Sites.Dubent.indexInArray(Pic, huidigindex);
			if (index == -1) {
				index = 0;
			}
			// volgende of vorige; loopt door array
			if (richting == 'volgende') {
				if (index + 1 >= Pic.length) {
					index = 0;
				}
				else {
					index++;
				}
			}
			else if (richting == 'vorige') {
				if (index - 1 < 0) {
					index = Pic.length - 1;
				}
				else {
					index--;
				}
			}
			//image veranderen
			var liedid = Pic[index];
			get$('rep_lied').getElementsByTagName('h2')[0].innerHTML = get$(liedid).innerHTML;
			huidigindex = liedid;
		},
		ShowImgAlt: function(nr) {
			var imgbron = Pic[nr];
			get$('fotopopup_img').src = imgbron;
			//get$('fotopopup').alt = img[i].getAttribute("alt");
			get$('fotopopup').style.display = 'block';
		},
		SluitPopup: function(id) {
			get$(id).style.display = 'none';
		},
		OpenGastenboek: function(id) {
			get$(id).style.display = 'block';
			get$('gastenboek').style.display = 'none';
		},
		SluitGastenboek: function(id) {
			get$(id).style.display = 'none';
			get$('gastenboek').style.display = 'block';
		},
		ClearGastenboek: function() {
			PT.Sites.Dubent.CheckInput('naam');
			PT.Sites.Dubent.CheckInput('bericht');
			PT.Sites.Dubent.CheckEmail('e-mail');			
		},
		CheckInput: function(id) {
			if (get$(id).value == 'Naam' || get$(id).value == 'Uw bericht' || get$(id).value == 'Emailadres') {
				get$(id).value = '';
				}				
		},
		CheckEmail: function(id) {
			var valid = PT.Sites.Dubent.IsValidEmail((get$(id).value));
			if (!valid) {
				get$(id).value = '';
			}
		},
		IsValidEmail: function(text) {
			if (!/^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/.test(text)) {
				return false;
			}
			return true;
		},
		createBackground: function() {
		var bodyheight = 0;
		if (typeof (window.innerWidth) == 'number') {
			bodyheight = window.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			bodyheight = document.documentElement.clientHeight;
		}
		if (bodyheight >= 914) {
			get$('onderbg').style.display = "inline";
		}
		else {
			get$('onderbg').style.display = "none";
		}
	}

		/*onLoad : function (){
		}*/
	}
	
PT.Sites.General.RegisterEvent(window, "resize", function() {PT.Sites.Dubent.createBackground();} );
//PT.Sites.General.RegisterEvent(window, "load", function() {PT.Sites.Linders.onLoad();} );

