// JavaScript Document

function validateEmail(email_str){

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	if (reg.test(email_str) == false) return false; else return true;

}

function onsubmit_contact(){	

	name_input = document.getElementById('contact_name');
	name_value = name_input.value;
	
	email_input = document.getElementById('contact_email');
	email_value = email_input.value;

	subject_input = document.getElementById('contact_subject');
	subject_value = subject_input.value;	
	comment_input = document.getElementById('contact_comment');
	
	comment_value = comment_input.value;
	
	var error_mess = "";
	
	if(name_value.length>2 && email_value.length>2 && subject_value.length>2 && comment_value.length>2 &&  validateEmail(email_value)==true){

		return true;

	} else {

		if(name_value.length<3){
			
			$("#contact_name").effect("pulsate", { times:2 }, 400);
			
			name_input.style.backgroundColor = "#FFB3B3";

		} else {		

			name_input.style.backgroundColor = "#fff";		

		}

		if(validateEmail(email_value)==false){

			$("#contact_email").effect("pulsate", { times:2 }, 400);
			
			email_input.style.backgroundColor = "#FFB3B3";			

		} else {

			email_input.style.backgroundColor = "#fff";

		}

		if(subject_value.length<3){

			
			$("#contact_subject").effect("pulsate", { times:2 }, 400);
			
			subject_input.style.backgroundColor = "#FFB3B3";

		} else {

			subject_input.style.backgroundColor = "#fff";		
		}

		if(comment_value.length<3){
		
			$("#contact_comment").effect("pulsate", { times:2 }, 400);
			
			comment_input.style.backgroundColor = "#FFB3B3";

		} else {

			comment_input.style.backgroundColor = "#fff"
		}

		return false;
	}	

}
