
/***** CHECK THE FORM *****/
function checkForm( form ) 
{
	// General variables
	validateForm 	= 0;
	
	var inputFields = new Array();
	inputFields[0]  = document.forms[1].author;
	inputFields[1]  = document.forms[1].email;
	inputFields[2]  = document.forms[1].comment;
	
	var inputValues = new Array();
	inputValues[0]	= "Je naam";
	inputValues[1]	= "Je e-mail adres";
	inputValues[2]	= "Je bericht";
	
	for(i=0; i<inputFields.length; i++) 
	{

		if ( inputFields[i].value == inputValues[i] || inputFields[i].value == "" || inputFields[i].value == null || !isNaN(inputFields[i].value) || inputFields[i].value.charAt(0) == ' ' )
    	{
    		toggleInputState( inputFields[i], 2 );
    		validateForm = 1;
    	} else {
    		toggleInputState( inputFields[i], 1 );
    	}

	}

	// final check
	if (validateForm == 0) {
	    return true;
	} else {
		return false;
	}
};


/***** CHECK THE INPUT FIELD *****/
function checkField ( inputField, inputString ) 
{

	switch(inputField.value)
	{
		case inputString:
			inputField.value = '';
			toggleInputState( inputField, 1 );
			break;
			
		case '':
			inputField.value = inputString;
			toggleInputState( inputField, 0 );
			break;
			
		default:
			toggleInputState( inputField, 1 );
			break;
	}

};

/***** TOGGLE COLORS FONT AND BORDER *****/
function toggleInputState ( inputField, inputState ) {

	var elementColors = new Array();
	elementColors[0] = '#cccccc'; // inactive
	elementColors[1] = '#666666'; // active
	elementColors[2] = '#ce0f0f'; // error

	inputField.style.color=elementColors[inputState];

	if (inputState == 2) {
			inputField.style.borderColor=elementColors[inputState];
	} else {
		inputField.style.borderColor=elementColors[0];
	}


};


