
//toggleDiv's

function toggleDiv(divname, visibility) {
	MM_changeProp(divname,'','style.visibility',visibility,'DIV');
}

function toggleDiv2(divname, visibility) {
	MM_changeProp(divname,'','style.display',visibility,'DIV');
}

//left en right oa gebruikt in showimg en mid

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function Mid(str, start, len) {
// Make sure start and len are within proper bounds
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}

//showimg, showimg alt, blader en printimg

var pic = new Array()
var alt = new Array()

var loading = new Image;
loading.src = "/sites/00/images/loading.gif"
var geenimg = new Image;
geenimg.src = "/sites/00/images/geenimg.gif"

var huidigindex = 0;

function showImgAlt(imgklein) {
	//id is anders opgebouws bla_1.1:2124
	if (CmsEditorActive !== true) {
		var popup = document.getElementById('popupdiv');

		//alle images
		var img = document.getElementById("onlysite_main").getElementsByTagName("img");
		for (var i = 0; i < img.length; i++) {
			//als class = plaatjemiddel, dan neem gedeelte na . en voor : Van imgklein en img met class
			if (img[i].className == 'grote_foto') {
				//var nr = img[i].id.split("_");
				var nr = Mid(img[i].id, 11, img[i].id.length);
				nr = nr.split(":");
				//var textNr = imgklein.id.split("_")[1];
				var textNr = Mid(imgklein.id, 11, imgklein.id.length);
				textNr = textNr.split(":")[0];
				//als gelijk is, gaat plaatjemiddel in src zetten
				if (nr[0] == textNr) {
					document.getElementById("plaatje_groot_img").src = img[i].src;
					document.getElementById("plaatje_groot_img").alt = img[i].getAttribute("alt");
//					if (document.getElementById("tekst" + textNr)) {
//						document.getElementById("plaatje_groot_tekst").innerHTML = document.getElementById("tekst" + textNr).innerHTML;
//					}
//					else {
//						document.getElementById("plaatje_groot_tekst").innerHTML = "";
//					}
				}
			}
		}
		popup.style.display = 'block';
		popup.style.marginLeft = (document.body.offsetWidth - popup.clientWidth) / 2 + "px";
		popup.style.marginTop = (document.documentElement.clientHeight - popup.clientHeight) / 2 + "px";
		document.getElementById('zwart_transparant').style.height = document.documentElement.scrollHeight;
		document.getElementById('zwart_transparant').style.display = "block";
	}
}

function indexInArray(arr,val){
for(var i=0;i<arr.length;i++) if(arr[i]==val) return i;
return -1;
} 

function printContentDiv(plaatje) {
	var content;
	
	content = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">";
	content += "<html>";
	content += "<head>";
	content += "</head>";
	content += "<body onload=\"window.print ()\"><div class=\"printContainer\">";
	content += "<img src='" + plaatje + "'>";
	content += "</div></body>";
	content += "</html>";
	
	var printWindow = window.open ("", "", "");
	printWindow.document.title = document.title;
	printWindow.document.write (content);
	printWindow.document.close ();
}

function sluitenDiv(deze) {
	deze.parentNode.parentNode.style.display = "none";
	document.getElementById('zwart_transparant').style.display = "none";
}

//openwindow

function openWindow(url){
	window.open(url,"WPopup",'location=yes,scrollbars=yes,resizable=yes,status=yes,menubar=yes,toolbar=yes');
}

//topmenu mouseover

function topmenu(img, uitimg, aanimg) {
	
	if (img.src=="http://"+document.domain+"/"+uitimg) {
		img.src="http://"+document.domain+"/"+aanimg;
	}
	else if (img.src=="http://"+document.domain+"/"+aanimg) {
		img.src="http://"+document.domain+"/"+uitimg;
	}
}

//hoogtecontainer

function hoogteContainer(){
    var hoogtescherm = document.body.offsetHeight;
    var inhoud = document.getElementById('inhoud');
    var container = document.getElementById('container');

    if(container.clientHeight < hoogtescherm){
        container.style.height = hoogtescherm + 'px';
    }
    else{
    
    }
    if(hoogtescherm > (inhoud.clientHeight+201)){
        inhoud.style.height = hoogtescherm - 201 + 'px';
    }
    else{
        
    }
}

//popupdiv

function popupdiv(id) {
	document.getElementById(id).style.display = 'block';
}

//popup met transparante div. allebei height/width met js
function openPopup (element) {
	document.getElementById ("hiderdiv").style.height  = document.documentElement.scrollHeight + "px";
	document.getElementById ("hiderdiv").style.display = "block";
	document.getElementById (element).style.display    = "block";
	
	// ScrollY positie ophalen
	var scrollY = 0;
	if (typeof (window.pageYOffset) == 'number')
	    scrollY = window.pageYOffset;
	else if (document.body && document.body.scrollTop)
	    scrollY = document.body.scrollTop;
	else if (document.documentElement && document.documentElement.scrollTop)
	    scrollY = document.documentElement.scrollTop;
	
	// Hoogte van zichtbaar deel van pagina ophalen
	var winHeight = 0;
	if (typeof (window.innerWidth) == 'number')
	    winHeight = window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
	    winHeight = document.documentElement.clientHeight;
	
	// De popup centreren
	var x = document.body.clientWidth / 2 - document.getElementById (element).clientWidth / 2;
	var y = scrollY + winHeight / 2 - document.getElementById (element).clientHeight / 2;
	
	document.getElementById (element).style.left = x + "px";
	document.getElementById (element).style.top  = y + "px";
}

//CmsEditorActive
try {
	if (CmsEditorActive!==true) {}
}
catch (err) {
	var CmsEditorActive=false
}

function geenmenu() {
	if (CmsEditorActive == true) {
		var div = document.getElementById('hoofdmenu');
		var ul = div.getElementsByTagName('ul');
		for (var i = 0; i < ul.length; i++) {
			if(i>0){
				ul[i].style.display = 'none';
			}
		}
	}
}

//check input
function checkInput(inputid) {
	if (document.getElementById("werkgever").checked) {
		if (document.getElementById(inputid).value == '') {
			alert('Er is geen bedrijfsnaam ingevuld.');
		}
		else {
			if (document.getElementById('security_newpassword').value == '') {
				alert('U heeft geen wachtwoord ingevuld.');
			}
			else {
				if (document.getElementById('algemene_voorwaarden').checked) {
					document.getElementById('registerform').submit();
				}
				else {
					alert('U bent niet akkoord gegaan met de algemene voorwaarden.');
				}
			}
		}
	}
	else {
		if (document.getElementById('security_newpassword').value == '') {
			alert('U heeft geen wachtwoord ingevuld.');
		}
		else {
			if (document.getElementById('algemene_voorwaarden').checked) {
				document.getElementById('registerform').submit();
			}
			else {
				alert('U bent niet akkoord gegaan met de algemene voorwaarden.');
			}
		}
	}
}

function IsValidEmail(email) 
{ 
return !(!/^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/.test (email)) ;
}

//nagaan geldig emailadres
function CheckEmail() {
	if (IsValidEmail(document.getElementById("security_email_reg").value)) {
		return true;
	}
	else {
		alert("ongeldig emailadres");
		return false;
	}
	return false
}

//nagaan geldig emailadres
function CheckEmail2() {
	var val=false;
	var val2=false;
	if (IsValidEmail(document.getElementById("security_email").value)) {
		val = true;
	}
	else {
		alert("ongeldig emailadres");
		val = false;
	}

	if (document.getElementById("security_password").value == "") {
		alert("u heeft geen wachtwoord ingevuld");
		val2 = false
	}
	else {
		val2 = true;
	}

	if (val == true && val2 == true) {
		return true
	}
	else {
		return false;
	}
}



