function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 10;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
              div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
							div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
							
							div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
							div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
            
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}


function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		 return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
			return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
			return false
	 }
	
	 if (str.indexOf(" ")!=-1){
			return false
	 }

	 return true					
}

function isValidEmail(email) {
   return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
}

function checkContactForm(form) {	
	error = '';
	erroremail = '';
//	fields = $(form).getInputs();
	fields = $(form).getElements(); // Ook o.a. Textarea, Select
	for(i = 0; i < fields.length; i++) {
		required = fields[i].readAttribute('required');
		
		
		if (required == 'true' && fields[i].value == '') {
			$(fields[i]).className  = 'form_error';
			error = 'Vul alle verplichte velden in';
			if($(fields[i]).type == 'textarea'){
				$(fields[i]).className  = 'textarea_pas_error';
			}
		}else{
			//$(fields[i]).style.backgroundColor  = '#FFFFFF';
		}
		
	
	}
	
	if (!echeck($('email').value)) {
		
				$('email').style.backgroundColor  = '#FFCCCC';
				error = 'Vul een geldig emailadres in.';
			
	}
	
	
	if (error == '') {
		error = erroremail;
	}
	
	if (error != '') {
		$('foutmelding').innerHTML = error;
	} else {	
		$(form).submit();
		
	}
}
