window.addEvent('domready', function()
{
	$$('a.tipz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});
	
	var tipz = new Tips('.tipz',{
		className: 'tipz',
		fixed: true,
		hideDelay: 50,
		showDelay: 50
	});
	
	$$( '.entry_text' ).each(function(item)
	{
		if (item.getElement( '.moreText' ))
		{
			var thisSlider = new Fx.Slide( item.getElement( '.moreText' ), { duration: 20 } );
			item.thisSlider = thisSlider;
			thisSlider.hide();
			
			thisSlider.t = item.getElement( '.divToggle' );
			thisSlider.t.addEvent( 'click', function()
			{
				thisSlider.toggle();
				
				if (thisSlider.t.get('html') == '<a href=""><b>Verbergen</b></a>')
				{
					thisSlider.t.set('html', '<a href=""><b>Lees meer</b></a>');
				}
				else if (thisSlider.t.get('html') == '<a href=""><b>Lees meer</b></a>')
				{
					thisSlider.t.set('html', '<a href=""><b>Verbergen</b></a>');
					
					$$( '.entry_text' ).each(function(item2)
					{
						t2 = item2.getElement( '.divToggle' );
						if (t2)
						{
							if (t2.get('id') != thisSlider.t.get('id'))
							{
								item2.thisSlider.hide();
								item2.thisSlider.t.set('html', '<a href=""><b>Lees meer</b></a>');
							}
						}
					});
				}
				return false;
			});
		}
	});
});

function e(n) {
	return document.getElementById(n);
}

// Sets mouseX and mouseY variables continously
if (document.layers) { document.captureEvents(Event.MOUSEMOVE); document.onmousemove = cmp; } else if (document.all) { document.onmousemove = cmp; } else if (document.getElementById) { document.onmousemove = cmp; }
function cmp(e) { if(document.layers) {mouseX=e.pageX;mouseY=e.pageY;} else if(document.all) {mouseX=window.event.x+document.body.scrollLeft;mouseY=window.event.y+document.body.scrollTop;} else if(document.getElementById) {mouseX=e.pageX;mouseY=e.pageY;}}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
@else
	xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp = false;
	}
}

function countKeywords() {
}

function loadDoc(docname, id) {
	if (xmlhttp) {
		xmlhttp.open("GET",docname,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				if(e(id)) e(id).innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.send(null)
	}
}

function loadDocValue(docname, id) {
	if (xmlhttp) {
		xmlhttp.open("GET",docname,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				if(e(id)) e(id).value=xmlhttp.responseText;
			}
		}
		xmlhttp.send(null)
	}
}
function confirmDialog(urllink, text){
    var retval=confirm(text);
    if(retval==true){
        window.location=urllink;
    } else {
        return;
    }
} 

function pop_img(src){
	if (src){
		d_txt = "<a href=\"#\" onclick=\"document.getElementById('popup').style.display = 'none'\">";
		d_txt += "<img src='"+src+"'></a>";	
	}
	if(e('popup_content')) {
		e('popup_content').innerHTML=d_txt;
		p = e('popup');
		if(e('popup_content').innerHTML == '') {
			p.style.display = 'none';
			} else if(p.style.display != 'block') {
			p.style.display = 'block';
			p.style.left = mouseX+'px';
			p.style.top = mouseY+'px';
		}
	}
}
function setPopup(text, script, value) {
	if(!script) script = 'getText';
	
	if (xmlhttp) {
		xmlhttp.open("GET",'/site/popup/'+script+'.php?code='+text+'&value='+value,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				if(e('popup_content')) {
					e('popup_content').innerHTML=xmlhttp.responseText;
					p = e('popup');
					if(e('popup_content').innerHTML == '') {
						p.style.display = 'none';
					} else if(p.style.display != 'block') {
							p.style.display = 'block';
							p.style.left = mouseX+'px';
							p.style.top = mouseY+'px';
					}
				}
			}
		}
		xmlhttp.send(null)
	}
}

function checkemail() {
	p = e('email').value;
	c1 = p.indexOf('@');
	c2 = p.lastIndexOf('.');
	if (c1<1 || c1==(p.length-1) || c2<c1 || c2>=(p.length-2)) {
		icon = 'notok.gif';
		e('emailexists').value = 0;
		e('emailok').src = '/site/gfx/'+icon;
	} else {
		loadEmailValue('/site/popup/checkemail?code='+p,'emailexists');
	}
}

function loadEmailValue(docname, id) {
	if (xmlhttp) {
		xmlhttp.open("GET",docname,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				if(e(id)) {
					e(id).value=xmlhttp.responseText;
					if(e(id).value == '1') e('emailok').src = '/site/gfx/notok.gif'; else e('emailok').src = '/site/gfx/ok.gif'; 
				}
			}
		}
		xmlhttp.send(null)
	}
}

function checkeditpass() {
	p1 = e('editpass1').value;
	p2 = e('editpass2').value;
	if(p1.length == 0 && p2.length == 0) {
		e('editpassok1').src = '/site/gfx/alpha.gif';
		e('editpassok2').src = '/site/gfx/alpha.gif';
		return;
	}
	if(p1.length > 5) {
		icon1 = 'ok.gif';
		if(p1==p2) {
			icon2 = 'ok.gif';
		} else {
			icon2 = 'notok.gif';
		}
	} else {
		icon1 = 'notok.gif';
		icon2 = 'notok.gif';
	}
	e('editpassok1').src = '/site/gfx/'+icon1;
	e('editpassok2').src = '/site/gfx/'+icon2;
}

function MM_validateForm() { //v4.0
	if (document.getElementById) {
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		for (i=0; i<(args.length-2); i+=3) { 
			test=args[i+2]; 
			val=e(args[i]);
			if (val) { 
				nm=val.name;
				if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) { 
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1)) errors+='- '+nm+' is geen geldig adres.\n';
					} else if (test!='R' && test!='S') { 
						num = parseFloat(val);
						if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
						if (test.indexOf('inRange') != -1) { 
							p=test.indexOf(':');
							min=test.substring(8,p); max=test.substring(p+1);
							if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
						} 
					} 
				} else if (test.charAt(0) == 'R') {	
					nm2 = nm;
					if(nm2=='titel') nm2 = 'Onderwerp'; 
					if(nm2=='comment') nm2 = 'Bericht';
					errors += '- Het veld '+nm2+' moet verplicht worden ingevuld.\n'; 
				} 
				if (test.charAt(0) == 'S') {
					if (e(args[i]).selectedIndex == 0) {
						errors += '- '+nm+' is verplicht.\n';
					}
				}
			}
		} 
		if(e('passok1')) {
			p1 = e('passok1').src;
			p2 = e('passok2').src;
			if(p1.indexOf('notok') > 0) errors+='- het wachtwoord is niet lang genoeg.\n';
			if(p2.indexOf('notok') > 0) errors+='- het wachtwoord moet twee keer worden opgegeven.\n';
		}
		if(e('editpassok1')) {
			p1 = e('editpassok1').src;
			p2 = e('editpassok2').src;
			if(p1.indexOf('notok') > 0) errors+='- het wachtwoord is niet lang genoeg.\n';
			if(p2.indexOf('notok') > 0) errors+='- het wachtwoord moet twee keer worden opgegeven.\n';
		}
		if(e('emailok')) {
			p = e('emailok').src;
			ee = e('emailexists').value;
			if(ee=='1') {
				errors+='- dit emailadres is al aangemeld.\n';
			} else if(p.indexOf('notok') > 0) {
				errors+='- het emailadres is niet correct.\n';
			}
		}
		if(e('rekensom')) {
			if (!checkCaptcha(e('rekensom').value))	{
				errors += '- de rekensom is niet goed ingevuld.\n';
			}
		}
		
		if (errors) alert(errors);
		document.MM_returnValue = (errors == '');
	} 
}

