// Verander class na bv. een mouseover effect
function NewClass(obj, new_style) {
    obj.className = new_style;
}

//Image Rollover
function imageRollover (id, img, doc){
	if (! (doc)){doc= window.document;}
	if (doc.images){doc.images[id].src= img;}
}
//Rollover Image
function rolloverImage (id, img, doc){
	imageRollover (id, img, doc);
}


//Image Rollover
function imageRollover2 (id, img, p, doc){
	if (! (doc)){doc= window.document;}
	if (doc.images){
  doc.images[id].src= img;
  if (p==1) {
   doc.images[id].width= '170';
  }
  else {
   doc.images[id].width= '420';
  }
 }
}
//Rollover Image
function rolloverImage2 (id, img, p, doc){
	imageRollover2 (id, img, p, doc);
}

function pulldown_menu()	{
	var url = document.pulldown.selectname.options[document.pulldown.selectname.selectedIndex].value
	window.location.href = url 
}

//Open window in midden van het beeldscherm
var win = null;
function NewWindow(mypage,myname,w,h,r,s){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',resizable='+r+',scrollbars='+s+',status=false'
win = window.open(mypage,myname,settings)
}
function NewWindow2(mypage,myname,w,h){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars'
win = window.open(mypage,myname,settings)
}

//Controle of veld niet leeg is
function fldEmpty (fld, msg) {
	function stripSpaces(x) {while (x.substring(0,1) == ' ') x = x.substring(1); return x;}
	function empty(x) { if (x.length > 0) return false; else return true; }
	function stripSpaces(x) { return x.replace(/^\W+/,''); }
	if (empty(stripSpaces(fld.value))) {
  document.getElementById('txt').innerHTML=msg;
		fld.focus();
		fld.select();
		return false;
	}
}



//Controle of veld niet leeg is
function FieldNotEmpty (formelement, message,txt) {
	function stripSpaces(x) {while (x.substring(0,1) == ' ') x = x.substring(1); return x;}
	function empty(x) { if (x.length > 0) return false; else return true; }
	function stripSpaces(x) { return x.replace(/^\W+/,''); }
	if (empty(stripSpaces(formelement.value))) {
  document.getElementById(txt).innerHTML=message;
		formelement.focus();
		formelement.select();
		return false;
	}
}
//Check if message exceeds defined length
function CheckLength (formelement, countmin, countmax, message) {
		if (formelement.value.length < countmin || formelement.value.length > countmax ) {
			count = formelement.value.length;
			alert(message+"\r\n\Het aantal ingevoerde karakters is: "+count);
			formelement.focus();
			formelement.select();
			return false;
		}
}
//Controle op geldig e-mailadres
function ValidEmail (formelement, message,txt) {
	if (formelement.value == "" ) {return true;}
	else {
	    if  (formelement.value.search(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/) == -1){
			document.getElementById(txt).innerHTML=message;
			formelement.focus();
			formelement.select();
			return false;
		}
	}
}


//Check if field is empty. If not value must be in valid dateformat.
function ValidDateRequired (formelement, message,txt) {
	//Check if dateformat is valid; Dutch format is dd-mm-yyyy
	var dateStr = formelement.value;
	var strErr=0;
	var datename = new Date();
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = dateStr.match(datePat);
	if (matchArray == null) {
		document.getElementById(txt).innerHTML=message;
		strErr=1;
		formelement.select();
		return false;
	}
	month = matchArray[3];
	day = matchArray[1];
	year = matchArray[4];
	if (month < 1 || month > 12) {
		document.getElementById(txt).innerHTML=message;
		strErr=1;
		formelement.select();
		return false;
	}
	if (day < 1 || day > 31) {
		document.getElementById(txt).innerHTML=message;
		strErr=1;
		formelement.select();
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		document.getElementById(txt).innerHTML=message;
		strErr=1;
		formelement.select();
		return false;
	}
	if (month == 2) {
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			document.getElementById(txt).innerHTML=message;
			strErr=1;
			formelement.select();
			return false;
		}
	}
}


// reorder function with 2 multiple dropdownboxes
function deleteOption(object,index) {
 object.options[index] = null;
}

function addOption(object,text,value) {
 var defaultSelected = true;
 var selected = true;
 var optionName = new Option(text, value, defaultSelected, selected)
 object.options[object.length] = optionName;
}

function copySelected(fromObject,toObject) {
 for (var i=0, l=fromObject.options.length;i<l;i++) {
  if (fromObject.options[i].selected)
  addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
 }
 for (var i=fromObject.options.length-1;i>-1;i--) {
  if (fromObject.options[i].selected)
  deleteOption(fromObject,i);
 }
}
function selectAll(fromObject) {
    for (var i=0, l=fromObject.options.length;i<l;i++) {
			fromObject.options[i].selected = true;			
    }
}





