
bind_ui_contactus();
function bind_ui_contactus(){
	$('contact_us_form').observe('submit', form_check);
}


function form_check(event){
	Event.stop(event);
			var error=false, first_error="";
			
			//setting all the errors to zero
			var inputs= $('contact_us_form').getInputs();
			for (var i=0, arr=inputs.size(); i<arr; i++){
				$(inputs[i]).removeClassName('field_input_error');
				
			}
			
			
			
			if(!validateEmail('email')){
				$('email').addClassName('field_input_error');
					error=true;
					if (first_error==""){
						first_error='em_email';
					}
			}
			
			what_to_check=['msgFrom', 'email','msgSub','msg'];
			what_to_check=$A(what_to_check);
			//check that all date of expiration have been filled out
			what_to_check.each(function(item){
				if ($F(item)==''){
					$(item).addClassName('field_input_error');
					error=true;
					if (first_error==""){
						first_error=item;
					}
				}
			});
			
			
			
			if (error){
				
				alert("You have not filled out all mandatory fields or have entered values that are not valid.\n They are now marked in red.\n Please fill them out and then submit the form")
				$(first_error).focus();
			}else{
				//submit_ajax('reg_form');
				$('contact_us_form').submit();
				
			}
			
		}



function check_contactus(){



}

function CheckingForm()
					{
						
					var FormError;
					var i;
					FormError=0;
					  
					//Checking that there is a subject
						
						//Checking that there is a name
						if(document.MessageForm.msg.value == "" )
						{
							FormError=5;
						};
						
						if(document.MessageForm.msgSub.value == "" )
						{
							FormError=4;
						};
						 
						 
						//Checking that there is a name
						if(document.MessageForm.Email.value != "")
						{
							if (!(validateEmail("Email")))
								{
								FormError=3;
								}
						}
						else
						{
							FormError=2;
						};
						 
						//Checking that there is a name
						if(document.MessageForm.msgFrom.value == "" )
						{
							FormError=1;
						};
						 
						
						
						
						if(FormError != 0 )
						{
							if(FormError==1)
							{
								alert("Please write in your name");
								document.MessageForm.msgFrom.focus();
								FormError=0;
							}	  
							 
							if(FormError==2)
							{
								alert("Please enter your email address so we can get back to you")
								document.MessageForm.Email.focus();
								FormError=0;
							}
							 
							if(FormError==3)
							{
								alert("Please enter a valid email address so we can get back to you")
								document.MessageForm.Email.focus();
								FormError=0;
							}	
							 
							if(FormError==4)
							{
								alert("Please write in a Subject")
								document.MessageForm.msgSub.focus();
								FormError=0;
							}	  
							 
							if(FormError==5)
							{
								alert("Please enter your question ")
								document.MessageForm.msg.focus();
								FormError=0;
							}	  		 
						   
						}
						else  //can submit
						{
							document.MessageForm.submit()	
						}

					}
