// this function is to make the form more active
/*
+-------------------------------------------------------------------------------------
| Function List
+-------------------------------------------------------------------------------------
	checkAll()			// check the all forms
	collectValue()			// collect value
*/

function forms()
{
	
	// the required form in the system
	this.checkAll = function()
	{
		$x = document.getElementsByTagName("form");				// get forms
		for($count = 0;$count < $x.length;$count++)
		{
			if($x[$count].title == "ajax")
			{
				$x[$count].onsubmit = function ()
				{
					return this.collectValue();
				} // end of the submit function
				
				
				$x[$count].process = function ()
				{
					KOOLPHP_hideloading();
				}
				
				$x[$count].collectValue = function()
				{
					KOOLPHP_cloading();

					// now first we have to process the input field
					$input = this.getElementsByTagName("INPUT");		// collecting the input value
					
					$db = new database();
					for($_f_count = 0;$_f_count < $input.length;$_f_count++)
					{
						if($input[$_f_count].type == "text" 
							|| $input[$_f_count].type == "hidden" 
							|| $input[$_f_count].type == "password" 
							|| $input[$_f_count].type == "image"  
							|| $input[$_f_count].type == "submit"
						)
						{
							$db.data($input[$_f_count].name,$input[$_f_count].value);
						}
						else if ($input[$_f_count].type == "checkbox")
						{							
							if($input[$_f_count].checked)
							{
								$db.data($input[$_f_count].name,$input[$_f_count].value);
							}
						
						}
						else if ($input[$_f_count].type == "radio")
						{
							if($input[$_f_count].checked)
							{
								$db.data($input[$_f_count].name,$input[$_f_count].value);
							}
						}					
						
					} // end of the loop
					
					
					$input = this.getElementsByTagName("TEXTAREA");		// collecting the input value
					for($_f_count = 0;$_f_count < $input.length;$_f_count++)
					{
						$db.data($input[$_f_count].name,$input[$_f_count].value);					
						
					} // end of the for loop					
					
					$input = this.getElementsByTagName("SELECT");		// collecting the input value
					for($_f_count = 0;$_f_count < $input.length;$_f_count++)
					{
						for($_o_count = 0;$_o_count < $input[$_f_count].options.length;$_o_count++)
						{
							if($input[$_f_count].options[$_o_count].selected == true)
							{
								$db.data($input[$_f_count].name,$input[$_f_count].options[$_o_count].value);
							}
						} // end of the for loop
					}// end of the for loop	
					
					$db.custom(this.action,this.process);			
					
					
					return false;

				}
				
				
			}
		} // end of the for loop
		
	}; // end of the for looop
	
	
}
