      function CheckDate( date )
      {
         if ( ( ( date.charAt(0) >= "0" ) && ( date.charAt(0) <= "9" ) ) &&
              ( ( date.charAt(1) >= "0" ) && ( date.charAt(1) <= "9" ) ) &&
              ( ( date.charAt(2) >= "0" ) && ( date.charAt(2) <= "9" ) ) &&
              ( ( date.charAt(3) >= "0" ) && ( date.charAt(3) <= "9" ) ) &&
                ( date.charAt(4) == "-" ) && 
              ( ( date.charAt(5) >= "0" ) && ( date.charAt(5) <= "9" ) ) &&
              ( ( date.charAt(6) >= "0" ) && ( date.charAt(6) <= "9" ) ) &&
                ( date.charAt(7) == "-" ) && 
              ( ( date.charAt(8) >= "0" ) && ( date.charAt(8) <= "9" ) ) &&
              ( ( date.charAt(9) >= "0" ) && ( date.charAt(9) <= "9" ) ) )
         {
            return 1;
         }
         else
         {
            return 0;
         }
      }


      function CheckInt( x )
      {
         var i;
         if ( x.length == 0 )
         {
            return 0;
         }
         else
         {
           for ( i = 0; i < x.length; i++ )
           {
             if ( ! ( ( x.charAt( i ) >= "0" ) && ( x.charAt( i ) <= "9" ) ) )
             {
                return 0;
             }
           }
         }
         return 1;
      }


      function CheckFloat( x )
      {
         var i;
         if ( x.length == 0 )
         {
            return 0;
         }
         else
         {
           for ( i = 0; i < x.length; i++ )
           {
             if ( ! ( ( x.charAt( i ) >= "0" ) && ( x.charAt( i ) <= "9" ) || ( x.charAt( i ) == "," ) ) )
             {
                return 0;
             }
           }

           var dots;
           dots = 0;
           for ( i = 0; i < x.length; i++ )
           {
             if ( x.charAt( i ) == "," )
             {
                dots++;
             }
           }
           if ( ( dots > 1 ) || ( x.charAt( 0 ) == "," ) || ( x.charAt( x.length - 1 ) == "," ) )
           {
             return 0;
           }


         }
         return 1;
      }





      function CheckIP( x )
      {
         var i;
         if ( x.length == 0 )
         {
            return 0;
         }
         else
         {
           for ( i = 0; i < x.length; i++ )
           {
             if ( ! ( ( x.charAt( i ) >= "0" ) && ( x.charAt( i ) <= "9" ) || ( x.charAt( i ) == "." ) ) )
             {
                return 0;
             }
           }

           var dots;
           dots = 0;
           for ( i = 0; i < x.length; i++ )
           {
             if ( x.charAt( i ) == "." )
             {
                dots++;
             }
           }
           if ( ( dots > 3 ) || ( x.charAt( 0 ) == "." ) || ( x.charAt( x.length - 1 ) == "." ) )
           {
             return 0;
           }


           for ( i = 0; i < x.length-1; i++ )
           {
             if ( ( x.charAt( i ) == "." ) && ( x.charAt( i + 1 ) == "." ) )
             {
                return 0;
             }
           }


         }
         return 1;
      }





      function CheckString( x )
      {
         var i;
         var s;
         s = 0;
         if ( x.length == 0 )
         {
            return 0;
         }
         else
         {
           for ( i = 0; i < x.length; i++ )
           {
             if ( x.charAt( i ) != " " )
             {
               s++;
             }
           }
           if ( s == 0 )
           {
             return 0;
           }
         }
         return 1;
      }



      function SetToRED( name )
      {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";
      }
      
      function SetToNORMAL( name )
      {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
      }



      function CheckIntAndAlert( name, x, ok, txt )
      {
        if ( CheckInt( x ) == 0 ) 
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }




      function CheckFloatAndAlert( name, x, ok, txt )
      {
        if ( CheckFloat( x ) == 0 ) 
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }






      function CheckListBoxAndAlert( name, x, ok, txt )
      {
        if ( ( x <= 0 ) || ( x == null ) )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }





      function CheckStringAndAlert( name, x, ok, txt )
      {
        if ( CheckString( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            window.alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }



      function CheckDateAndAlert( name, x, ok, txt )
      {
        if ( CheckDate( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }



      function CheckItemAndValue( name, item, value, ok, txt )
      { 
        var new_ok;
        new_ok = 1;

        if ( item < 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";
          if ( ok == 1 )
          {
            alert( txt );
          }
          new_ok = 0; 
        }

        if ( item == 0 )
        {
          if ( ( value > 0 ) || ( value == null ) )
          {
            document.getElementById( name ).style.color = "RED";
            document.getElementById( name ).style.fontWeight = "bold";
            if ( ok == 1 )
            {
              alert( txt );
            }
            new_ok = 0;
          }
          else
          {
            document.getElementById( name ).style.color = "BLACK";
            document.getElementById( name ).style.fontWeight = "normal";
            new_ok = 1;
          }
        }

        if ( item == 1 )
        {
          if ( value > 0 )
          {
            document.getElementById( name ).style.color = "BLACK";
            document.getElementById( name ).style.fontWeight = "normal";
            new_ok = 1;
          }
          else
          {
            document.getElementById( name ).style.color = "RED";
            document.getElementById( name ).style.fontWeight = "bold";
            if ( ok == 1 )
            {
              alert( txt );
            }
            new_ok = 0;

          }
        }

        if ( ok == 0 )
        {
          return 0;
        }
        else
        {
          return new_ok;
        }
      }

/*
        if ( value > 0 )
        {
          if ( item == 1 )
          {
            document.getElementById( name ).style.color = "BLACK";
            document.getElementById( name ).style.fontWeight = "normal";
            if ( ok == 0 )
            {
              return 0;
            }
            return 1;     
          }
          else
          {
            document.getElementById( name ).style.color = "RED";
            document.getElementById( name ).style.fontWeight = "bold";

            if ( ok == 1 )
            {
              alert( txt );
            }
            return 0;
          }
        }
        else
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
*/




      function CheckIPAndAlert( name, x, ok, txt )
      {
        if ( CheckIP( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }





    function sprTel( in_txt )
    {
      // (xx)xxxxxxx lub xxxxxxxxx

  //    var re = /^((\(0\d{2}\) \d{3}-\d{2}-\d{2}[,; ]*)|(\d{3}-\d{3}-\d{3}[,; ]*))+$/;

   //     var re = /^((\(\d{2}\)\d{3}\d{2}\d{2}[,]*)|(\d{3}\d{3}\d{3}[,]*))+$/;


      var re = /^((\(\d{2}\)\d{3}\d{2}\d{2}[,]*)|(\(\d{2}\)\d{3}\d{2}\d{2}\.\.\d{2}[,]*)|(\d{3}\d{3}\d{3}[,]*))+$/;

      if ( re.test( in_txt ) == false )
      {
        return 0;
      }
      return 1;
    }


    function sprEmail( in_txt )
    {
    //var re = /^(([0-9A-Za-z_ ]+\@[0-9A-Za-z_\.]+\.[0-9A-Za-z_]*)||([0-9A-Za-z_]+[0-9A-Za-z_\.]+[0-9A-Za-z_]+\@[0-9A-Za-z_\.]+\.[0-9A-Za-z_]*))+$/;

    var re = /^(([0-9A-Za-z_-]+\@[0-9A-Za-z_\.]+\.[0-9A-Za-z_]*)||([0-9A-Za-z_-]+[0-9A-Za-z_\.]+[0-9A-Za-z_]+\@[-0-9A-Za-z_\.]+\.[-0-9A-Za-z_-]*))+$/;


   //   var re = /^[0-9A-Za-z_\.]+\.[0-9A-Za-z_]+\@[0-9A-Za-z_\.]+\.[0-9A-Za-z_]+$/;

      if ( re.test( in_txt ) == false )
      {
        return 0;
      }
      return 1;
    }


      function CheckTelAndConfirm( name, x, ok, txt )
      {
        if ( sprTel( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";
          if ( ok == 1 )
          {
            if ( confirm( txt ) == true )
            {
              return 1;
            }
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }


      function CheckEmailAndConfirm( name, x, ok, txt )
      {
        if ( sprEmail( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";
          if ( ok == 1 )
          {
            if ( confirm( txt ) == true )
            {
              return 1;
            }
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;     
      }
      
      
      
      
      function CheckEmailAndAlert( name, x, ok, txt )
      {
        if ( sprEmail( x ) == 0 )
        {
          document.getElementById( name ).style.color = "RED";
          document.getElementById( name ).style.fontWeight = "bold";

          if ( ok == 1 )
          {
            alert( txt );
          }
          return 0;
        }
        else
        {
          document.getElementById( name ).style.color = "BLACK";
          document.getElementById( name ).style.fontWeight = "normal";
          if ( ok == 0 )
          {
            return 0;
          }
        }
        return 1;
      }

      
      
