
jQuery(document).ready(function(){
    /*jQuery("#main_form").submit(function(){
      	    
	 
    	 //regular expression rules that applies to certain fields.  
    	var alphaNumeric = /[(\*\(\)\[\]\+\.\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/;
   	 	var emailField  =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
   	 	var urlField = '';
   	 	var idNumberLength = 13;
   	 	var dateField = /(0[1-9]|1[012])+\/(0[1-9]|[12][0-9]|3[01])+\/(19|20)\d\d/;
	    
	    
	      // inputs and id from te form 
      	
	     var errorMessage =  document.getElementById("main_form_error");
	     var tBoxInput = this.getElementsByTagName("input"); 
		 var selectMenu = this.getElementsByTagName("select");
		 var tAreaInput = this.getElementsByTagName("textarea");
		 
		 
		 
		 // counter variables. 
		 var countTextbox = 0;
		 var countValidatedTBoxes = 0;

	     var countTextarea = 0;
		 var countValidatedTAreas = 0;

		 var countSelect = 0;
		 var countValidatedSelects = 0;
		 
		
	
		 // looping through textboxes. 
		 
		 for (var i=0; i < tBoxInput.length; i++)
	  	  {
	  			if (tBoxInput[i].className.match("textbox") )
	  			{
	  					    if(tBoxInput[i].getAttribute('id') == 'id_number') {

	    							if( Check_RSA_ID(tBoxInput[i].value) == false) {
	    							    var ruturn_error_message = '1'
	    							    tBoxInput[i].style.border = '1px solid #E76757';
	      					         }
	    							 else {
	    							    tBoxInput[i].style.border = '1px solid #ccc';
	    							    countValidatedTBoxes++;
	    							}

						    }else if (tBoxInput[i].getAttribute('id') == 'email') {

	    							if((tBoxInput[i].value == '') || (emailField.test(tBoxInput[i].value) == false)) {
	                                     var ruturn_error_message = '2';
	    							   tBoxInput[i].style.border = '1px solid #E76757';
	      					         }
	    							 else {
	    							   tBoxInput[i].style.border = '1px solid #ccc';
	    							   countValidatedTBoxes++;
	    							}

						    }else if (tBoxInput[i].getAttribute('id') == 'pass2') {
	                                if( (tBoxInput[i].value == '') || (tBoxInput[i].value != document.getElementById("pass1").value)) {
	                                   var ruturn_error_message = '3';
	    							   tBoxInput[i].style.border = '1px solid #E76757';
	      					         }
	    							 else {
	    							   tBoxInput[i].style.border = '1px solid #ccc';
	    							   countValidatedTBoxes++;
	    							}
	                       }else if (tBoxInput[i].getAttribute('id') == 'passOld') {
	                    	        
	                                if( (tBoxInput[i].value == '') ) {
	                                    var ruturn_allow_processform = '1';
	                                    tBoxInput[i].style.border = '1px solid #ccc';
	    							}else if(tBoxInput[i].value != '') {
	    								new_pass1 = document.getElementById("new_pass1").value;
	    								new_pass2 = document.getElementById("new_pass2").value;
		                                   
	                                   if (new_pass1 == '' || new_pass2 == '' || new_pass1 != new_pass2 ) {
	                                      var ruturn_error_message = '4';
	                                      var ruturn_allow_processform = '0'; 
	                                      document.getElementById("new_pass1").style.border = '1px solid #E76757';
	                                      document.getElementById("new_pass2").style.border = '1px solid #E76757';
	                                      
	                                   }else {
	                                	  
	                                      var ruturn_allow_processform = '1';
	                                   }
	                                    countValidatedTBoxes++;
	    							}
	                             
	                       }else {
	                              if(tBoxInput[i].value == '') {
	    							 tBoxInput[i].style.border = '1px solid #E76757';
	      					        }
	    							else
	    							{
	    							tBoxInput[i].style.border = '1px solid #ccc';
	    							countValidatedTBoxes++;
	    							}

								}

								countTextbox++;

	  			}else if ( tBoxInput[i].className.match("hidden_input")) { 
	  				
	  				
	  			}

	  	  }
		 
		 
		//  alert(new_pass1) 
	  	  
		 
		  
		   // looping through text area; 
		  
		  for (var i=0; i < tAreaInput.length; i++)
	  	  {
	  			if (tAreaInput[i].className.match("textarea"))
	  			{
	  					  if(tAreaInput[i].value == '')
	  					  {
								 tAreaInput[i].style.border = '1px solid #E76757';
	  					  }
								else
								{

								tAreaInput[i].style.border = '1px solid #ccc';
								countValidatedTAreas++;
								}

								countTextarea++;

	  			}

	  	  }

		 
		  // looping through dropdowns or select boxes 
		   
		  for (var i=0; i < selectMenu.length; i++)
	  	  {
	  			if (selectMenu[i].className.match("selectmenu"))
	  			{
	  				if(selectMenu[i].value == "#") 
	  				{
                    	selectMenu[i].style.backgroundColor = '#E76757';
					}
	  				else
	  				{
						selectMenu[i].style.backgroundColor = '#ffffff';
						countValidatedSelects++;
				    }

	  				countSelect++;
	  					
	  			}

	  	  }

		  
//		  alert(countTextbox); 
//		  alert(countValidatedTBoxes); 
//		  
//		  alert(countTextarea); 
//		  alert(countValidatedTAreas);
//		  
//		  alert(countSelect); 
//		  alert(countValidatedSelects);
		  
		  
		   //  return messages 
		 
		   
		
			if((countTextbox == countValidatedTBoxes) && (countTextarea == countValidatedTAreas) && (countSelect == countValidatedSelects)) {
                
			    if (ruturn_allow_processform == '0')   {
			       $("#main_form_error").html("Please fill in all required fields correctly! The Password fields are empty or don't match.").show().fadeOut(10000);
		           window.scrollTo(0,0); 
		          return false;
			    } else { 
				 return true;
			    }
			      
			 }else if (ruturn_allow_processform == '1')   {
			       return true;
			
			 }else if (ruturn_error_message == '1')   {
				   $("#main_form_error").html("Please fill in all required fields correctly! The ID Number is not valid.").show().fadeOut(10000);
		           window.scrollTo(0,0); 
		          return false;
			 }else if (ruturn_error_message == '2')   {
			   $("#main_form_error").html("Please fill in all required fields correctly! The Email Address is not valid.").show().fadeOut(10000);
	          window.scrollTo(0,0); 
	          return false;
			
			 }else if (ruturn_error_message == '3')   {
				  $("#main_form_error").html("Please fill in all required fields correctly! The Password fields are empty or don't match.").show().fadeOut(10000);
		          window.scrollTo(0,0)
		          return false;
			 }else if (ruturn_error_message == '4')   {
				  $("#main_form_error").html("Please fill in all required fields correctly! The Password fields are empty or don't match.").show().fadeOut(10000);
		          window.scrollTo(0,0)
		          return false;
			 }else if (ruturn_error_message == '5')   {
				  $("#main_form_error").html("Please fill in all required fields correctly! No Subcategory selected.").show().fadeOut(10000);
		          window.scrollTo(0,0)
		          return false;
			 }else {
	          $("#main_form_error").html("Please fill in all required fields correctly!").show().fadeOut(10000);
	          window.scrollTo(0,0); 

			return false;
			}
			
			

	   });*/
});