
	 function stripleadingspaces(astring)
	 {
	      while(''+astring.charAt(0)==' ')
		    {
		   	astring = astring.substring(1,astring.length); }
				 
		   return astring;
	 } 
	 
	function strip_leading_spaces(astring)
	 {
	      while(''+astring.charAt(0)==' ')
		    {
		   	astring = astring.substring(1,astring.length); }
				 
		   return astring;
	 } 
	 
	 function strip_trailing_spaces(astring)
	 {
	          while(''+astring.charAt(astring.length-1)==' ')
			  {  astring = astring.substring(0,astring.length-1); }
			
			  return astring;
	 }
	 
	 function trim_string(astring)
	 {
	    astring = stripleadingspaces(astring);
	
		astring = strip_trailing_spaces(astring);
		
		return astring;
	 }
	 
	 
	function contains_spaces(astring) {
		var ok = false;
		var temp;
		for (var i=0; i<astring.length; i++) 
		    {
		      temp =  astring.substring(i, i+1);
			  if (temp == ' ')
			     ok = true;
		}
		 return ok;
	}
	 
		function string_contains(astring,character) {
		var ok = false;
		var temp;
		for (var i=0; i<astring.length; i++) 
		    {
		      temp =  astring.substring(i, i+1);
			  if (temp == character)
			     ok = true;
		}
		 return ok;
	} 
	function isnumeric(field) {
		var valid = "0123456789."
		var ok = true;
		var temp;
 
		field.value=field.value.replace(/,/g,"");
		field.value=field.value.replace(/\s/g,"");
 	 		for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = false;
		}
		 return ok;
	}
	
	function is_string_numeric(astring) {
		var valid = "0123456789.-,";
		var ok = true;
		var temp;
		for (var i=0; i<astring.length; i++) {
		temp = "" + astring.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = false;
		}
		 return ok;
	}
    
    function default_zero(field){
    	//alert('add_zero');
    	if(trim_string(field.value) == '' || isNaN(field.value)){
    		field.value = 0;
    	}
     } 
	 
	function stripNonNumeric( str )
	{  str += '';  
		var rgx = /^\d|\.|-$/;  
		var out = '';  
		for( var i = 0; i < str.length; i++ )
		{    if( rgx.test( str.charAt(i) ) )
		{      if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) ||   
					  ( str.charAt(i) == '-' && out.length != 0 ) ) )
		{        out += str.charAt(i);      }    }  }  
		
		return out;
	}	 
	 
	function numberFormat(nStr)
	{  nStr += '';  
	   x = nStr.split('.');  
	   x1 = x[0];  
	   x2 = x.length > 1 ? '.' + x[1] : '';  
	   var rgx = /(\d+)(\d{3})/;  
	   while (rgx.test(x1))    
	   	x1 = x1.replace(rgx, '$1' + ',' + '$2');  
		
		return x1 + x2;
	} 
	
	
	
	function rereplace(string,reg_expression,sub_string){
	 	myString = new String(string);
	 	rExp = new RegExp(reg_expression, "gi") ;
	 	newString = new String (sub_string);
	 	results = myString.replace(rExp, newString);
	 	return results;
    }
	
	function checkbox_check_one_selected(field_name)
	{  if (field_name)
	   {
 		 if (field_name.length)
		 {
			 for (i = 0; i < field_name.length; i++)
			 {   if (field_name[i].checked == true)
					 return true;
			 }
		 }
		 else
		 {   if (field_name.checked == true)
				return  true;
		 }		
		 return false;
	  }
	  else
	     return false;
	}
	
	function checkbox_contains_value(field_name,field_value)
	{  if (field_name)
	   { 
 		 if (field_name.length)
		 {
			 for (i = 0; i < field_name.length; i++)
			 {   if (field_name[i].value == field_value &&
			         field_name[i].checked == true)
			     {    
					 return true; }
			 }
		 }
		 else
		 {   if (field_name.value == field_value &&
		         field_name.checked == true)
				return  true;
		 }		
		 return false;
	  }
	  else
	     return false;
	}
	
	function checkbox_select_value(field_name,field_value)
	{   
	   if (field_name)
	   {  
 		 if (field_name.length)
		 {
			 for (i = 0; i < field_name.length; i++)
			 {    
			     if (field_name[i].value == field_value &&
			         field_name[i].checked == false)
			     {    
 					field_name[i].checked = true }
			 }
		 }
		 else
		 {   if (field_name.value == field_value &&
		         field_name.checked == false)
				field_name.checked = true;
		 }		
	   }
	   
	      	 
	}
 

	function radio_get_seleted_value(field_name)
	{    if (field_name)
	     {
			 if (field_name.length)
			 {
				 for (i = 0; i < field_name.length; i++)
				 {   if (field_name[i].checked == true)
						 return field_name[i].value;
				 }
			 }
			 else
			 {   if (field_name.checked == true)
					return  field_name.value;
			 }		
			 return '';
		}
		else
		   return '';
	}
	
	function checkbox_select_all(field_name)
	{   
	   if (field_name)
	    {
			if (field_name.length)
			{	
				for (i = 0; i <  field_name.length; i++)
				 {   field_name[i].checked = true;
				 }
			}
			else
				field_name.checked = true;
	    }
	}
		
	function checkbox_deselect_all(field_name)
	{   if (field_name)
	    {
			if (field_name.length)
			{	
				for (i = 0; i <  field_name.length; i++)
				 {   field_name[i].checked = false;
				 }
			}
			else
				field_name.checked = false;
		}
	}
	
	
   function change_single_multiple_selection(selection_type,field_name)
    { 
       if (document.getElementById) 
	   {   v_single_selection = document.getElementById(field_name + '_single_selection');
	       v_multiple_selection = document.getElementById(field_name + '_multiple_selection');
	       v_from_to_selection = document.getElementById(field_name + '_from_to_selection');
 	    }
  	    else if (document.all) 
  		 {  v_single_selection = document.all[field_name + '_single_selection'];
		  v_multiple_selection = document.all[field_name + '_multiple_selection'];
		  v_from_to_selection = document.all[field_name + '_from_to_selection'];
		  }
	    else if (document.layers) 
  		 {  v_single_selection = document.layers[field_name + '_single_selection'];
		    v_multiple_selection = document.layers[field_name + '_multiple_selection'];
		    v_from_to_selection = document.layers[field_name + '_from_to_selection'];
		}
 	  if (selection_type == 'A')
	   {	v_single_selection.style.display = 'none';
	        v_multiple_selection.style.display = 'none';
	        v_from_to_selection.style.display = 'none';
		}
	
	  if (selection_type == 'S')
	   {	v_single_selection.style.display = 'block';
	        v_multiple_selection.style.display = 'none';
	        v_from_to_selection.style.display = 'none';
		}
	
	  if (selection_type == 'M')
	   {	v_single_selection.style.display = 'none';
	        v_multiple_selection.style.display = 'block';
	        v_from_to_selection.style.display = 'none';
		}
	
	  if (selection_type == 'F')
	   {	v_single_selection.style.display = 'none';
	        v_multiple_selection.style.display = 'none';
	        v_from_to_selection.style.display = 'block';
		}
 	 
   }
   

	