// check browsertype
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
var isNS6 = (navigator.userAgent.indexOf("Gecko")    > 0) ? 1 : 0;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);

//if (isMinNS4) {alert ('isMinNS4');};
//if (isMinIE4) {alert ('isMinIE4');};
//if (isMinIE5) {alert ('isMinIE5');};
//if (isNS6) {alert ('isNS6');};
//if (this.opera) {alert ('isOpera');}; 

// bepaald variabelen voor later gebruik
if (isMinNS4 || isNS6) {
	doc="document.";				// document
	val = ".value";					// waarde
	stijl="";						// stijl
	horz=".left";					// horizontale afstand
	vert=".top";					// vertikale afstand
	innerW="window.innerWidth";		// breedte scherm
	innerH="window.innerHeight";	// hoogte scherm
	offsetX="window.pageXOffset";	// offset breedte
	offsetY="window.pageYOffset";	// offset hoogte
};
if (isMinIE4){
	doc="";
	val = ".value";
	stijl=".style";
	horz=".pixelLeft";
	vert=".pixelTop";
	innerW="document.body.clientWidth";
	innerH="document.body.clientHeight";
	offsetX="document.body.scrollLeft";
	offsetY="document.body.scrollTop";
};
 
// functie om form te submitten + verplichte velden controle +disable submitknop
// getest: ie5.5 ok, ie6.0 ok, ns4.7 ok, ns6.2 ok, opera5.12 ok,
// gebruik: in form tag: onSubmit="return checkverplicht('formuliernaam','naam van 
// velden','titel van velden');" 
function checkverplicht(formulier,reqlijstveld,reqlijstnaam) {
var Checkveld = reqlijstveld;
var Checknaam = reqlijstnaam;
var isok ='ja';
form = formulier;
var buttontekst = eval(doc+form+".verstuur"+val);
eval(doc+form+".verstuur"+val+"='Verstuurd'");
eval(doc+form+".verstuur.disabled=true");
if (Checkveld != '') {
var CheckveldArray = Checkveld.split(",");
var ChecknaamArray = Checknaam.split(","); 
for (var i=0; i<CheckveldArray.length; i++)
	{
	var naam = ChecknaamArray[i];
	var waarde = document.getElementById(CheckveldArray[i]).value;
   	if (typeof document.getElementById(CheckveldArray[i]).length != 'undefined') {
	isChecked = false;
      for (bi = 0; bi < document.getElementById(CheckveldArray[i]).length; bi++) {
         if (document.getElementById(CheckveldArray[i])[bi].checked) {
            isChecked = true;
         }
      }
	  if (isChecked==false) {
		 alert(naam+' is een verplicht veld!');
         var isok = 'nee';
      }
   	} else {
    	if (document.getElementById(CheckveldArray[i]).type == 'checkbox') {
			var le = eval(doc+form+"."+CheckveldArray[i]+".length");
			isChecked = false;
			for (l = 0; l < le; l++) {
				ch=eval(doc+form+"."+CheckveldArray[i]+"["+l+"].checked");
				if (ch==true) {
				isChecked = true;
 		 		}
			}
			if (isChecked == false) {
			alert(naam+' is een verplicht veld!');
            var isok = 'nee';
         	}
		} else {
			if (waarde == ''|| waarde == null) {
			alert(naam+' is een verplicht veld!');
			var isok = 'nee';
			};
		};
   	}
	};
};
if (isok == 'nee') {
eval(doc+form+".verstuur"+val+"='"+buttontekst+"'");
eval(doc+form+".verstuur.disabled=false");
return false;
} else {
return true};
};




function PopIt(filename, w, h, s){  
	var wp = (screen.width/100)*w;
	var hp = (screen.height/100)*h;
	var midw = (screen.width/2)-(wp/2);
	var midh = (screen.height/2)-(hp/2);
	popup = window.open(filename,"popDialog","left="+midw+" top="+midh+" height="+hp+",width="+wp+",scrollbars=yes resizable=1")  
	if ( popup.document.close() ) {
		popup.document.close()
	}
};

function PopItpx(filename, w, h, s){  
	var wp = w;
	var hp = h;
	var midw = (screen.width/2)-(wp/2);
	var midh = (screen.height/2)-(hp/2);
	popup = window.open(filename,"popDialog","left="+midw+" top="+midh+" height="+hp+",width="+wp+",scrollbars=yes resizable=1")  
	if ( popup.document.close() ) {
		popup.document.close()
	}
};

function validemail(field) {
  var str = field.value;
  if (str == "") {
return true;
}
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str =
"^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,4})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }
    field.focus();
    alert('Geen geldig emailadres.');
    return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    field.focus();
    alert('Geen geldig emailadres.');
    return false;
  }
};

function ChangeClass(id,classpassed){
	document.getElementById(id).className=classpassed;
};


/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=30

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function confirmDelete(URL) 
{
   if(confirm('Verwijderen?')) {
      location.href = URL;
   }
};


// functie om datum te valideren
function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
datefield.select();
alert("Datum moet in dd/mm/yyyy formaat ingegeven worden.\nvb. 31/12/2004");
datefield.focus();
return false;
}
else {
return true;
}
};

// functie om datum te controleren en aan te vullen tot 01/12/2001
function chkdate(objName) {
var runTime = new Date();
var strCurrentYear = runTime.getYear();
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if ((strDateArray.length < 2) || (strDateArray.length > 3)) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
if (strDay.length == 1) {
strDay = '0' + strDay;
}
strMonth = strDateArray[1];
if (strMonth.length == 1) {
strMonth = '0' + strMonth;
}
if (strDateArray.length == 2) 
strYear = strCurrentYear
else
strYear = strDateArray[2];
}
booFound = true;
}
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}
if (strYear == null) {
  return false;
}
if (strYear.length == 1) {
strYear = '0' + strYear
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
err = 3;
return false;
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
datefield.value = strDay + "/" + strMonth + "/" + strYear;
return true;
};

//functie om schrikkeljaar te vinden
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
};






