/*
	Zowelnn.js
	aangemaakt op 23/4/2009 door Keloid Media  -   www.keloidmedia.nl
	
	-----------------------------------------------------------------
	
	KELOID MEDIA - bedenkt, ontwerpt en ontwikkelt voor op het scherm

	www.keloidmedia.nl
	
	-----------------------------------------------------------------

*/

function zowelnn_init( ){
	fontsize_init();
	tinyScrolling.init();
}


// ZOWELNN FUNCTIONS

function contact_form_submit( ){
	
	var error_txt = '';
	
	// check last name
	var contact_lastname = document.getElementById('contact_lastname').value;
	if( contact_lastname == '' ){
		error_txt = 'Vul een achternaam in.<br/>';
	}else if( ( contact_lastname != '' ) && ( contact_lastname.length < 2 ) ){
		error_txt = 'Vul een geldige achternaam in.<br/>';	
	}
	
	// check emailaddress
	var contact_email = document.getElementById('contact_email').value;
	if( contact_email == '' ){
		error_txt += 'Vul een emailadres in.<br/>';		
		
	}else if( form_input_is_emailaddress( contact_email ) == false ){
		error_txt += 'Het emailadres is ongeldig.<br/>';	
	}
	
	// check message	
	var contact_message = document.getElementById('contact_message').value;
	if( contact_message == '' ){
		error_txt += 'Stel uw vraag of geef een opmerking in het veld <i>bericht</i>.<br/>';
	}else if( ( contact_message != '' ) && ( contact_message.length < 10 ) ){
		error_txt += 'Vul een geldige bericht in.<br/>';	
	}
	
	// show notification
	document.getElementById('contact_form_notification').innerHTML = error_txt;
	
	if( error_txt == '' ){
		document.getElementById('contact_form').submit();	
	}
}


function login_form_submit( ){

	var error_txt = '';

	// check username
	var login_username = document.getElementById('login_username').value;
	if( login_username == '' ){
		error_txt = 'Vul een gebruikersnaam in.<br/>';
	}else if( ( login_username != '' ) && ( login_username.length < 3 ) ){
		error_txt = 'Vul een geldige gebruikersnaam in.<br/>';	
	}
	
	// check password
	var login_password = document.getElementById('login_password').value;
	if( login_password == '' ){
		error_txt += 'Vul een wachtwoord in.';
	}else if( ( login_password != '' )  && ( login_password.length < 3 ) ){
		error_txt += 'Vul een geldig wachtwoord in.';
	}
	
	// show notification
	document.getElementById('login_form_notification').innerHTML = error_txt;
	
	if( error_txt == '' ){
		document.getElementById('login_form').submit();	
	}
}


function newsletter_form_submit( ){
	var el 	= document.getElementById('newsletter_email');
	var txt = '';
	
	if( el.value == '' ){
		txt = 'Vul een emailadres in.';		
		
	}else if( form_input_is_emailaddress( el.value ) == false ){
		txt = 'Het emailadres is ongeldig.';	
	}
	
	document.getElementById('newsletter_form_notification').innerHTML = txt;

	if( txt == '' ){
		document.getElementById('newsletter_form').submit();
	}	
}






// COMMON FUNCTIONS

function form_input_is_emailaddress( emailaddress ){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if( !filter.test( emailaddress ) ) {
		// not a valid email address		return false;	}
	
	return true;
}

function form_inputfield_click( el_id, el_value ){
	var el = document.getElementById( el_id );
	if( el.value == el_value ){
		el.value = '';
	}
}

function form_inputfield_blur( el_id, el_value ){
	var el = document.getElementById( el_id );
	if( el.value == '' ){
		el.value = el_value;
	}
}
