function trim(str){
	return str.replace(/^\s+|\s+$/, '');
}
function isstring(val){
var pat=/[0-9]/;
	  if(val.match(pat)>0){return false;};
      if(val==null){return false;}
      if (val.length==0){return false;}
    
      return true;
}
function check_r(form_obj)
{ 

var message = '';
var validation_message = true;
error_color='#FFF9E7';
form_inputs = new Array();
inputs=new Array();
	try {
	form_inputs = document.getElementById(form_obj).elements;
	for( i=0;i<form_inputs.length;i++ )
		{
		
		inputs[inputs.length] = form_inputs[i];
		}
	
	for( i=0;i<inputs.length;i++ ){
		input = inputs[i];
		
		input_check = input.getAttribute('check');
		input_message = input.getAttribute('message');
		
		
		if( input_check!=null ){ 	
			validation_message = false;
			switch( input_check.toLowerCase() ){
				case 'required':
					if( trim(input.value)=='' ){
						validation_message = true;
						input.style.backgroundColor=error_color;
						input.style.backgroundImage='none';
						}else input.style.backgroundColor='#ffffff';
					break;
			
				case 'email':
					if ( trim(input.value)=='' ||  !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(input.value)) ){
						validation_message = true;
						input.style.backgroundColor=error_color;
						input.style.backgroundImage='none';
					}else input.style.backgroundColor='#ffffff';
					break;
				case 'password':  
					
					if(input.value.length <4 ){
						validation_message = true;
						input.style.backgroundColor=error_color;
						input.style.backgroundImage='none';
					}
					else input.style.backgroundColor='#ffffff';
					break;
				case 'age':
					if ( trim(input.value)=='' || !(/^[0-9]{1,2}$/.test(input.value)) )
						validation_message = true;
					break;
				case 'text':
					if ( trim(input.value)=='' || !(isstring(input.value)) )
						validation_message = true;
					break;
					case 'number':
					if ( trim(input.value)=='' || !(/^[0-9]{6,}$/.test(input.value)) )
						validation_message = true;
					break;
					
			}///////////////switch
			if( validation_message )
				{ 
				var error=true;
				//message += '<li>' + input_message + '</li>';
				message +=   input_message + '\n\r';

				}
		}////////////for
		//alert(message);
		//document.getElementById('action_result_2').innerHTML=message;
		}/////////////if
		
		if(error==true){alert(message) ;return false}
	}catch(e) {return false; };return true;
}

