 
  function isEmpty(s)
   {
      if( s == null || s.length ==0)
         return true;
   }
   function is_whitespace(s)
   {
      var pattern = /^\s+$/;
      if(isEmpty(s) || pattern.test(s))
           return true;
      else
         return false;
   }
   function check_color(s)
   {
       var color_patter = /^#([0-9]|[a-f]|[A-F]){6}/;
       if(color_patter.test(s))
            return true;
       else
           return false;
  }
  function check_date(s)
  {
       var date_pattern = /(( (0[1-9]{1}) | (1[0-2]{1}) )\/ ( (0[1-9]{1}) | (([1-2]{1})([0-9]{1})) | (3[0-1]{1}) )\/(200[4-6]{1}))/;
       if(date_pattern.test(s))
              return true;
       else
            return false;    
  } 

  function warning_func(mystring)
  {
     var answer=window.confirm(mystring);
     if(answer)
        return true;
     else 
        return false;
 }

 function checkAll(field)
 {
   if(field.checked == false)
      field.checked = true;
   else
   {
     for(i =0; i<field.length; i++)
        field[i].checked = true;
   }
 }

 function uncheckAll(field)
 {
   if(field.checked == true)
      field.checked = false;
       
   else
   {
   for(i =0; i<field.length; i++)
             field[i].checked = false;
   }
 }
 function check_checkbox( msg2)
 {
    warning_func(msg2);
 }
 function is_real(field_value)
 {
    var pattern = /^\d*\.?\d*$/;
   if(pattern.test(field_value))
        return true;
   else
     return false;
    
 }
 function alph_num(field_value)
 {
     var pattern = /^\w+\s?\w+$/;
     if(pattern.test(field_value))
        return true;
     else
     return false;
 }

 function letter_num(field_value)
 {
     var str = "1234567890\'\"$%@&*#()><{}[]!:;?,.|~`^-_+=\\/"; 
     for(i =0; i< str.length; i++)
     {
        if(field_value.indexOf(str.charAt(i)) != -1)
           return false;
     }
     return true;
 }

 function bad_char(field_value)
 {
     var str = "\'\"$%@&*#()><{}[]!:;?,.|~`^_=\\/"; 
     for(i =0; i< str.length; i++)
     {
        if(field_value.indexOf(str.charAt(i)) != -1)
           return false;
     }
     return true;
 }


 function has_no_tags(field_value)
 {
     var str = "<>"; 
     for(i =0; i< str.length; i++)
     {
        if(field_value.indexOf(str.charAt(i)) != -1)
           return false;
     }
     return true;
 }



function checkvalid_date_string(mmddyyyy)
   {
       if(mmddyyyy.length != 10)
           return false;
           
       if(mmddyyyy.charAt(2) != '/' || mmddyyyy.charAt(5) != '/')
           return false;
       return true;
   }

 function get_selected_value(id)
   {
       var obj = document.getElementById(id);
       var index = obj.selectedIndex;
       var value = obj[index].value;
       return value;
   }

  function add_smiley(code)
    {
        var field = document.getElementById('msg');
        if(document.selection)  // this for IE
        {
           field.focus();
           sel = document.selection.createRange();
           sel.text = code;
           
        }
             // this for NS/mollia
        else if(field.selectionStart || field.selectionStart == '0')
        {
            var start_position = field.selectionStart;
            var end_position = field.selectionEnd;
            var cursor_position = end_position;
            var x = field.scrollTop;
            var y = field.scrollLeft;

            field.value = field.value.substring(0, start_position) + code + field.value.substring(end_position, field.value.length);
            cursor_position = start_position + code.length;
            field.focus();
            field.selectionStart = cursor_position; 
            field.selectionEnd =  cursor_position; 
            field.scrollTop = x;
            field.scrollLeft = y;
        }
        else
        {
             field.value += code;
             field.focus();

        }
    }
