jQuery.noConflict();
jQuery(document).ready(function(){

       jQuery("#contactForm").submit(function(){
	   
	   	var countTextbox = 0;
		var countValidatedTextboxes = 0;
		var emailRegEx =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		var textbox = document.getElementsByTagName("input");
		
		  	for (var i=0; i < textbox.length; i++)
		  	{
				if (textbox[i].className.match("required_field"))
				{		
					if(textbox[i].getAttribute('id') == 'name') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';

      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'email') 
					{
    							if((textbox[i].value == '')  || (emailRegEx.test(textbox[i].value) == false))
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'subject') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}					

				}
				countTextbox++;
			}

			if(countValidatedTextboxes == 3)
			{
				return true;			
			}
			else
			{
				jQuery(".error_message#contact_error").html("Please fill in all the required fields");
				jQuery(".error_message#contact_error").show();
				return false;
			}
	
	
	
	
	   });
       jQuery("#registrationForm").submit(function(){
	   
	   	var countTextbox = 0;
		var countValidatedTextboxes = 0;
		var emailRegEx =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		var textbox = document.getElementsByTagName("input");
		
		  	for (var i=0; i < textbox.length; i++)
		  	{
				if (textbox[i].className.match("required_field"))
				{		
					if(textbox[i].getAttribute('id') == 'name') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'email') 
					{
    							if((textbox[i].value == '')  || (emailRegEx.test(textbox[i].value) == false))
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'password') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}					

				}
				countTextbox++;
			}
			
			if(countValidatedTextboxes == 3)
			{
				return true;			
			}
			else
			{
				jQuery(".error_message").html("Please fill in all the required fields");
				jQuery(".error_message").show();
				return false;
			}
	   });	   
	   jQuery("#email_password").submit(function(){
	   
	   	var countTextbox = 0;
		var countValidatedTextboxes = 0;
		var emailRegEx =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		var textbox = document.getElementsByTagName("input");
		
		  	for (var i=0; i < textbox.length; i++)
		  	{
				if (textbox[i].className.match("required_field"))
				{		
					if(textbox[i].getAttribute('id') == 'name') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'email') 
					{
    							if((textbox[i].value == '')  || (emailRegEx.test(textbox[i].value) == false))
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}					

				}
				countTextbox++;
			}
			
			if(countValidatedTextboxes == 2)
			{
				return true;			
			}
			else
			{
				jQuery(".error_message").html("Please fill in all the required fields");
				jQuery(".error_message").show();
				return false;
			}
	   });	
	   jQuery("#member_login").submit(function(){
	   
	   	var countTextbox = 0;
		var countValidatedTextboxes = 0;
		var textbox = document.getElementsByTagName("input");
		
		  	for (var i=0; i < textbox.length; i++)
		  	{
				if (textbox[i].className.match("required_field"))
				{		
					if(textbox[i].getAttribute('id') == 'username') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'password') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}					

				}
				countTextbox++;
			}
			
			if(countValidatedTextboxes == 2)
			{
				return true;			
			}
			else
			{
				jQuery(".error_message#member_error").html("Please fill in all the required fields");
				jQuery(".error_message#member_error").show();
				return false;
			}
	   });
	jQuery("#company_login").submit(function(){
	   
	   	var countTextbox = 0;
		var countValidatedTextboxes = 0;
		var textbox = document.getElementsByTagName("input");
		
		  	for (var i=0; i < textbox.length; i++)
		  	{
				if (textbox[i].className.match("required_field"))
				{		
					if(textbox[i].getAttribute('id') == 'company_username') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}
					if(textbox[i].getAttribute('id') == 'company_password') 
					{
    							if((textbox[i].value == '')) 
								{
    							   
    							   textbox[i].style.backgroundColor = '#FFEB8B';
      					         }
    							 else 
								 {
    							   textbox[i].style.backgroundColor = '#fff';
    							   countValidatedTextboxes++;
    							}
					}					

				}
				countTextbox++;
			}
			
			if(countValidatedTextboxes == 2)
			{
				return true;			
			}
			else
			{
				jQuery(".error_message#company_error").html("Please fill in all the required fields");
				jQuery(".error_message#company_error").show();
				return false;
			}
	   });	 	   
	jQuery("#name").focus(function() {
	
		jQuery("#name").css('backgroundColor', '#fff');
	
	});
	jQuery("#username").focus(function() {
	
		jQuery("#username").css('backgroundColor', '#fff');
	
	});
	jQuery("#company_username").focus(function() {
	
		jQuery("#company_username").css('backgroundColor', '#fff');
	
	});		
	jQuery("#email").focus(function() {
	
		jQuery("#email").css('backgroundColor', '#fff');
	
	});
	jQuery("#subject").focus(function() {
	
		jQuery("#subject").css('backgroundColor', '#fff');
	
	});	
	jQuery("#password").focus(function() {
	
		jQuery("#password").css('backgroundColor', '#fff');
	
	});	
	jQuery("#company_password").focus(function() {
	
		jQuery("#company_password").css('backgroundColor', '#fff');
	
	});		
  
});

