/*-----------------------------------------------------------------------------
Flow Interactive Validation Script

version:   1.0
author:    Flow Interactive
/*----------------------------------------------------------------------------
COPYRIGHT, ALL RIGHTS RESERVED. THIS FILE MAY NOT BE COPIED OR ALTERED IN ANY WAY
-----------------------------------------------------------------------------*/

function validate(thisform) {
	with (thisform) {
		if ($("#contactform")) {
			//check all form values completed
			$("input.val").each(function(i){
				if ($(this).attr("id") == "email") { 
					if (! validateEmail(this)) {
						$("span", this).show(); 
						$(this).css({ border: "1px solid #f00 !important" });
						$("#errMess").html("Invalid or missing email address!");
						$("#errMess").show();
						this.focus();
						subfrm = 'false';
						return false;
					}
				}
				
				if (this.value == ""){ 
					$("span", this).show(); 
					$(this).css("border:", "1px solid #f00 !important");
					$("#errMess").html("Missing information, please check and try again!");
					$("#errMess").show();
					this.focus();
					subfrm = 'false';
					return false;
				} else {
					$("span", this).hide();
					$("#errMess").hide();
					$(this).css("border:", "1px solid #f00 !important");
					subfrm = 'true';
				}
			});
			
			
		}
		if (subfrm == 'false') {
			return false;
		}else{
			return true;
		}		
	}
 }

function validateEmail(field) {
    //Validating the email field
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    if (! field.value.match(re)) {
        return (false);
    }
    return(true);
}