//---------------------------------------------
function SubmitContactForm(formID)
{
	var theForm = $("#" + formID);
	
	if(!CheckInput("FieldFirstName", theForm) ||
	   !CheckInput("FieldLastName", theForm) ||
	   !CheckInput("FieldEmail", theForm) ||
	   !CheckInput("FieldPhone", theForm) ||
	   !CheckInput("FieldCellPhone", theForm) ||
	   !CheckInput("FieldStreet", theForm) ||
	   !CheckInput("FieldHouseNumber", theForm) ||
	   !CheckInput("FieldCity", theForm) ||
	   !CheckInput("FieldComments", theForm))
	{
		$(".IncorrectInputMessage").toggle(true);
		return(false);
	}
	
	theForm.submit();
}
//---------------------------------------------

//---------------------------------------------
function SubmitNewsletterForm(formID)
{
	var theForm = $("#" + formID);
	
	if(!CheckInput("FieldFirstName", theForm) ||
	   !CheckInput("FieldLastName", theForm) ||
	   !CheckInput("FieldCompany", theForm) ||
	   !CheckInput("FieldEmail", theForm) ||
	   !CheckInput("FieldApproveRegister", theForm))
	{
		$(".IncorrectInputMessage").toggle(true);
		return(false);
	}
	
	theForm.submit();
}
//---------------------------------------------

//---------------------------------------------
function CheckInput(inputId, theForm)
{
	var field = $("input[id*='" + inputId + "']", theForm);
	
	switch(inputId)
	{
		case "FieldEmail":
			if(!IsValidEmail($(field).attr("value")))
			{
				field.focus();
				return(false);
			}
			break;
		case "FieldApproveRegister":
			if(!$(field).attr("checked"))
			{
				field.focus();
				return(false);
			}
			break;
	}

	if( $(field).hasClass("IsMustField") && $(field).attr("value") == "" )
	{
		field.focus();
		return(false);
	}

	return(true);
}
//---------------------------------------------

//---------------------------------------------
function IsValidEmail(email)
{
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
		return(false);
	return(true);
}
//---------------------------------------------
