var ws_messageContainerID = '';

function ws_validate() {
	
	//get inputs
	var inputs = document.getElementsByTagName('input');
	
	//keeps count of number of invalid inputs
	var invalidCount = 0;
	
	var inputValue = '';
	
	
	for(i = 0; i < inputs.length; i++) {
		//check for inputs with ws_required as one of its css classes
		if(inputs[i].className.indexOf('ws_required') > -1) {
			
			inputValue = inputs[i].value;
			if(inputValue.length == 0) {
			
				//if found, color background		
				inputs[i].style.backgroundColor = '#ff7777';
			
				//set input to clear validation background when field is entered
				inputs[i].onfocus = function() { this.style.backgroundColor = ''; }
			
				//increase invalid count
				invalidCount++;
			}
		}
	}
	
	
	//if form is invalud, invalidCount will be > 0
	if(invalidCount > 0) {
		
		//if a message container has been configured, display it
		if(ws_messageContainerID.length > 0) {
			var messageContainer = document.getElementById(ws_messageContainerID);
			if(messageContainer) {
				messageContainer.style.display = '';
			}
		} else {
			//display javascript alert
			alert('Please be sure to complete all required fields.');
		}
			
		//form not valid, return false;
		return false;
	} else {
		//form value
		return true;
	}

}


function ws_validateConfig(messageContainerID) {
	ws_messageContainerID = messageContainerID
}