function detectBrowser ()
{
   var element= null;
   navigator.OS= '';
   navigator.version= 0;
   navigator.org= '';
   navigator.family= '';

   // Plateform detection...
   var platform;
   if (typeof(window.navigator.platform) != 'undefined')
   {
      platform = window.navigator.platform.toLowerCase();
      if (platform.indexOf('win') != -1)
         navigator.OS = 'win';
      else if (platform.indexOf('mac') != -1)
         navigator.OS = 'mac';
      else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
         navigator.OS = 'nix';
   }

   // Browser family, organization and version...
   var i = 0;
   var ua = window.navigator.userAgent.toLowerCase();
   
   if (ua.indexOf('opera') != -1)
   {
      i = ua.indexOf('opera');
      navigator.family= 'opera';
      navigator.org= 'opera';
      navigator.version= parseFloat('0' + ua.substr(i + 6), 10);
   }
   else if ((i = ua.indexOf('msie')) != -1)
   {
      navigator.org= 'microsoft';
      navigator.version= parseFloat('0' + ua.substr(i + 5), 10);
      
      if (navigator.version < 4)
         navigator.family= 'ie3';
      else if (navigator.version < 5)
         navigator.family= 'ie4';
      else if (navigator.version < 6)
         navigator.family= 'ie5';
      else
         navigator.family= 'ie6'
   }
   else if (typeof(window.controllers) != 'undefined' && typeof(window.locationbar) != 'undefined')
   {
      i = ua.lastIndexOf('/')
      navigator.version= parseFloat('0' + ua.substr(i + 1), 10);
      navigator.family= 'gecko';

      if (ua.indexOf('netscape') != -1)
         navigator.org= 'netscape';
      else if (ua.indexOf('compuserve') != -1)
         navigator.org= 'compuserve';
      else
         navigator.org= 'mozilla';
   }
   else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
   {
       var is_major= parseFloat(navigator.appVersion);
    
      if (is_major < 4)
         navigator.version= is_major;
      else
      {
         i= ua.lastIndexOf('/')
         navigator.version= parseFloat('0' + ua.substr(i + 1), 10);
      }
      navigator.org= 'netscape';
      navigator.family= 'nn' + parseInt(navigator.appVersion);
   }
   else if ((i = ua.indexOf('aol')) != -1 )
   {
      // aol
      navigator.family   = 'aol';
      navigator.org      = 'aol';
      navigator.version   = parseFloat('0' + ua.substr(i + 4), 10);
   }

   // DOM and CSS support...
   navigator.DOMCORE1= (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined');
   navigator.DOMCORE2= (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined');
   navigator.DOMHTML= (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined');
   navigator.DOMCSS1= ( (navigator.family == 'gecko') || (navigator.family == 'ie4') );

   navigator.DOMCSS2  = false;
   if (navigator.DOMCORE1)
   {
      element= document.createElement('p');
      if (typeof(element) != 'undefined')
        navigator.DOMCSS2 = (typeof(element.style) == 'object');
   }

   navigator.DOMEVENTS   = (typeof(document.createEvent) != 'undefined');
}


function popFrame ()
{
   popTargetFrame (self);
}

function popTargetFrame (target)
{
  if(target != top)
    replaceURL(target.location.href.toString());
}

function replaceURL (url)
{
  top.location.replace(url.toString());
}


function showAll (srcObj)
{
   var output= "Object: ";
   for(var i in srcObj)
      output+=  i + ' = ' + srcObj[i] + '   ';
   alert(output);
}

function launch ( newURL, newName, newFeatures, orgName ) 
{
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}

function showPage ( pageUrl )
{
  // Set the vars
  var newwin= "pcRemote";
  //var features= "height=550,width=750";
  var features= "alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,z-lock=0";
  var thiswin= "APage";

  // Launch it!
  //myPageRemote = launch (pageUrl, newwin, features, thiswin);
  launch (pageUrl, newwin, features, thiswin);
}

function sendMel (name, server, attributes)
{
  // Make URL
  var mailURL= "mailto:" + name + "@" + server;
  if (attributes)
    mailURL+= "?" + attributes;

  // Send
  replaceURL(mailURL);
}

function toPageTop ( url )
{
  // make URL
  newURL= url;
  if (url.indexOf("#", 0) != -1)
    newURL= url.substring (0, url.indexOf("#", 0));
  newURL+= "#sommet";

  // Apply
  replaceURL(newURL);
} // END toPageTop ()

function outHandler ( img )
{
  return img.off.src;
}

function overHandler ( img )
{
  return img.on.src;
}

// Remote window for recycling.
var myImgRemote= null;
var myMapRemote= null;
var myRedacRemote= null;

function showImage ( imgURI, width, height, title, css )
{
  // Set the vars
  var pageUrl= "";
  var newwin= "ImageView";
  var features= "scrollbars=0,height=" + height + ",width=" + width;
  features= features + ",alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=0,location=0,menubar=0,resizable=0,status=0,titlebar=0,toolbar=0,z-lock=0";
  var thiswin= "mainWin";

  // Launch it!
  // close before
  if (myImgRemote != null && !myImgRemote.closed)
    myImgRemote.close();
  myImgRemote= launch (pageUrl, newwin, features, thiswin);

  // Create the HTML data 
  htmlCode= "<html><head><title>--==[ " + title + " ]==--</title><link rel=\"STYLESHEET\" href=\"" + css + "\" type=\"text/css\" />";
  htmlCode+= "<body>";
  htmlCode+= "<div class=\"ImageView\"><img src=\"" + imgURI + "\" alt=\"" + title + "\" width=\"" + width + "\" height=\"" + height + "\" /></div>";
  htmlCode+= "</body></html>";

  // Write the data.
  myImgRemote.document.write (htmlCode); 

  // Move window
  if (navigator.version > 4)
    myImgRemote.moveTo(0, 0);
}


// Check frames.
popFrame ();

// Detect the browser
detectBrowser ();

function HTMLValidator (target)
{
 showPage ("http://validator.w3.org/check?uri=" + target);
} // END HTMLValidator ()

function CSSValidator (target)
{
 showPage ("http://jigsaw.w3.org/css-validator/validator?uri=" + target);
} // END CSSValidator ()

function ICRAValidator (target)
{
 showPage ("http://www.icra.org/cgi-bin/test.cgi?lang=FR&amp;url=" + target);
} // END CSSValidator ()

