var isIE = false ;
var isNav = false ;
var oldColor ;

function checkBrowser()
{
 if( navigator.appName.indexOf("Netscape") != -1 )
                isNav = true ;
          else 
                isIE = true ;

// alert( isIE + " " + isNav ) ;
}


// -------- Dynamic elements color:

var oldColor, oldWhat = null ;

function changeColor( what, clr )
{
 oldColor = eval("document.getElementById('" + what + "').style.color" ) ;
 oldWhat = what ;
 eval("document.getElementById('" + what + "').style.color='" + clr + "'" ) ;
}

function restoreColor()
{
 if( oldWhat != null )
  {
   changeColor( oldWhat, oldColor) ;
   oldWhat = null ;
  } 
}


// ------- Control of the spin-windows input:          

function WinIncr( w, min, max )
{
 var n = w.value ;

 n ++ ;
  if( n > max ) 
               n = min ;

 w.value = n ;
}

function WinDecr( w, min, max )
{
 var n = w.value ;

 n -- ;
  if( n < min ) 
               n = max ;

 w.value = n ;
}

// ------- Check if a given date string is correct:

function CheckDateFormat( string, title )
{
 a = string.split(" ") ;

 b = a[0].split(".") ;
  if( b.length != 3 )
   {
    alert("Bad 'DATE' value in" + title ) ;
                      return null ;
   }

 t = new Date() ;
 d = new Number( b[ 0 ] ) ;
 m = new Number( b[ 1 ] ) ;
 y = new Number( b[ 2 ] ) ;
  if( d < 1 || d > 31 || d.toString().search("NaN") != -1 )
   {
    alert("Bad 'DATE' field in" + title ) ;
                      return null ;
   }
  if( m < 1 || m > 12 || m.toString().search("NaN") != -1 )
   {
    alert("Bad 'MONTH' field in" + title ) ;
                      return null ;
   }
  if( y < 0 || y > t.getFullYear() || y.toString().search("NaN") != -1 )
   {
    alert("Bad 'YEAR' field in" + title ) ;
                      return null ;
   }

 t.setMonth( 0 ) ;  // sic!
  
 t.setDate( d ) ; 
 t.setMonth( m - 1 ) ; 
 t.setFullYear( y ) ;
 t.setHours( 0 ) ;
 t.setMinutes( 0 ) ;
 t.setSeconds( 0 ) ;
 return t ;                            
}
