// JavaScript Document



//You can adjust this bit here to suit your purposes.

function someFunctionYouCreated( theForm ) {
	if( !isValidType( theForm.name, 'name' ) ) {
		window.alert( 'Please fill in your full name.' );
		return false;
	}
		if( !isValidType( theForm.company, 'name' ) ) {
		window.alert( 'Please tell us the name of your Company.' );
		return false;
	}
	if( !isValidType( theForm.position, 'name' ) ) {
		window.alert( 'Please tell us your position in the Compnay.' );
		return false;
	}
	if( !isValidType( theForm.email, 'email' ) ) {
		window.alert( 'Please check that your Email address is correct.' );
		return false;
	}
	/*if( !isValidType( theForm.themessage, 'name' ) ) {
		window.alert( 'Please write your message' );
		return false;
	}*/
	return true; //don't forget this line
}



function isValidType( oInput, oType ) {
	switch( oType.toLowerCase() ) {
		case 'select':
			return oInput.selectedIndex;
		case 'number':
			if( !oInput.value ) { return false; }
			for( var mXi = 0; mXi < oInput.value.length; mXi++ ) {
				if( oInput.value.charAt( mXi ) != '' + parseInt( oInput.value.charAt( mXi ) ) + '' ) { return false; }
			} return true;
		case 'name':
			return ( oInput.value && !oInput.value.replace( /[a-záàäçéèêñóòôöüæøå]+( ?[-']?[a-záàäçéèêñóòôöüæøå]+)*/i, "" ) );
		case 'email':
			return ( oInput.value && !oInput.value.replace( /[\w\-\+]+(\.[\w\-\+]+)*@([\w\-áàäçéèêñóòôöüæøå]+\.)+[a-z]+/i, "" ) );
	}
}

