var tmpimg = new Array();

function init() {
	preloadImages();
}

function preloadImages() {
	tel = 0;
	for(i = 0; i < document.all.length; i++){
		if (document.all[i].tagName == 'IMG') {
			tmpimg[tel] = new Image();
			tmpimg[tel].src = document.all[i].src;
			tel = tel + 1;
		}
		if (document.all[i].tagName == 'TD' || document.all[i].tagName == 'TABLE') {
			if (document.all[i].background) {
				tmpimg[tel] = new Image;
				tmpimg[tel].src = document.all[i].background;
				tel = tel + 1;
			}
		}
	}
}

function CMSPopUp(url, wi, he, winm) {
	if (winm == 0) {
		window.open(url, '', 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=no,width=' + wi + ',height=' + he);
	} else {
		window.open(url, '', 'toolbar=1,location=1,directories=1,menubar=1,scrollbars=1,resizable=yes,width=' + (wi + 16) + ',height=' + he);
	}
}

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		if (string.search(/.com/) != -1 | string.search(/.nl/) != -1 | string.search(/.net/) != -1 | string.search(/.org/) != -1 | string.search(/.nu/) != -1 | string.search(/.biz/) != -1 | string.search(/.info/) != -1 | string.search(/.be/) != -1) {
			return true;
		}
	else
		return false;
}

function checkForm(formname) {
	elems = document.all(formname).elements;
	tel= 0;
	document.all(formname).fields.value = '';
	for(i = 0; i < elems.length; i++) {
		element = null;
		element = document.getElementById(elems[i].name + '_');
		document.all(formname).fields.value = document.all(formname).fields.value + elems[i].name + ',';
		if (element) {
			element.style.display = 'none';
			if (elems[i].value == '') {
				tel = tel + 1;
				element.style.display = '';
			} 
			else {
				if (elems[i].type == 'checkbox') {//fix this; need to NOT display >> AND if one of both is filled in (taalned or taaleng) needs to allow submit
					if ((elems[i].checked == false)&&(elems[i+1].checked == false)) {
						tel = tel + 1;
						if(elems[i].name.substr(4,4)=='jaar'){
							taaljaarverslagNL_.style.display = '';
						}
						if(elems[i].name.substr(4,4)=='pers'){
							taalpersberichtNL_.style.display = '';
						}
					} 
					else {
						if(elems[i].name.substr(4,4)=='jaar'){
							taaljaarverslagNL_.style.display = 'none';
						}
						if(elems[i].name.substr(4,4)=='pers'){
							taalpersberichtNL_.style.display = 'none';
						}						
					}
					i++;
					element = null;
					element = document.getElementById(elems[i].name + '_');
					document.all(formname).fields.value = document.all(formname).fields.value + elems[i].name + ',';
				}


				if (elems[i].type == 'radio') {//this function wil only work with 2 radiobuttons
				
					if ((elems[i].checked == false)&&(elems[i+1].checked == false)) {
						tel = tel + 1;
						element.style.display = '';
			//			element.style.color = '#FA6507';
					} 
					else {
						element.style.display = 'none';
			//			element.style.color = '#000000';
					}
				i++;
				}
				
				if (elems[i].name.substr(0,5) == 'email') {
					if (!isEmail(elems[i].value)) {
						tel = tel + 1;
						elems[i].value = 'geen geldige e-mail';
						element.style.display = '';
					}
				}
			}
		}
	}
	element = document.getElementById('showcheck');
	if (tel == 0) {
		document.all(formname).submit();
	} 
	else {
		element.innerHTML = '<font color="#FA6507"><b>* Vul alle verplichte velden in [' + tel + ']</b></font>';
	}
}

function checkFormENG(formname) {
	elems = document.all(formname).elements;
	tel= 0;
	document.all(formname).fields.value = '';
	for(i = 0; i < elems.length; i++) {
		element = null;
		element = document.getElementById(elems[i].name + '_');
		document.all(formname).fields.value = document.all(formname).fields.value + elems[i].name + ',';
		if (element) {
			element.style.display = 'none';
			if (elems[i].value == '') {
				tel = tel + 1;
				element.style.display = '';
			} 
			else {
				if (elems[i].type == 'checkbox') {//fix this; need to NOT display >> AND if one of both is filled in (taalned or taaleng) needs to allow submit
					if ((elems[i].checked == false)&&(elems[i+1].checked == false)) {
						tel = tel + 1;
						if(elems[i].name.substr(4,4)=='jaar'){
							taaljaarverslagNL_.style.display = '';
						}
						if(elems[i].name.substr(4,4)=='pers'){
							taalpersberichtNL_.style.display = '';
						}
					} 
					else {
						if(elems[i].name.substr(4,4)=='jaar'){
							taaljaarverslagNL_.style.display = 'none';
						}
						if(elems[i].name.substr(4,4)=='pers'){
							taalpersberichtNL_.style.display = 'none';
						}						
					}
					i++;
					element = null;
					element = document.getElementById(elems[i].name + '_');
					document.all(formname).fields.value = document.all(formname).fields.value + elems[i].name + ',';
				}

				if (elems[i].type == 'radio') {//this function wil only work with 2 radiobuttons
				
					if ((elems[i].checked == false)&&(elems[i+1].checked == false)) {
						tel = tel + 1;
						element.style.display = '';
			//			element.style.color = '#FA6507';
					} 
					else {
						element.style.display = 'none';
			//			element.style.color = '#000000';
					}
				i++;
				}
				
				if (elems[i].name.substr(0,5) == 'email') {
					if (!isEmail(elems[i].value)) {
						tel = tel + 1;
						elems[i].value = 'not a valid email address';
						element.style.display = '';
					}
				}
			}
		}
	}
	element = document.getElementById('showcheck');
	if (tel == 0) {
		document.all(formname).submit();
	} 
	else {
		element.innerHTML = '<font color="#FA6507"><b>* Fill in all obliged fields [' + tel + ']</b></font>';
	}
}



function showSubmenu(m_id, show) {
	element = document.getElementById('m_' + m_id);
	if (element) {
		if (show == 1) {
			element.style.display = '';
		} else {
			element.style.display = 'none';
		}
	}
}