﻿
/**
 *displays an error under an element.
 */
function displayError(element, msg){
	var parent = $j( element ).parent();

	if( empty.test(msg) ){
		$j( parent ).children("#error").remove();
	} else {
		$j( parent ).children("#error").remove();
		$j( parent ).append( "<div id='error'>"+msg+"</div>");
		$j( element ).focus();
	}   
}

/**
 *outlines an element if it has error
 */
function hasError(element){
	//for some reason chaning field class didn't have
	//any effect so i had to do this
	element.addClass("input_error");
}

/**
 * removes the red outline
 */
function clearError(element){
	element.removeClass("input_error");
}

/**
 *shows the flashMessage box with a predefined error message in it 
 */
function showError(){
	showFlashMessage("error","Sorry!","We found some issues with your submission. All fields outlined in red must be fixed.");
}

/**
 *hides the flashMessage box
 */
function hideError(){
	hideFlashMessage();
}
