function alternate(id){
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");  
   for(i = 0; i < rows.length; i++){       
     if(i % 2 == 0){
       rows[i].className = "first";
     }else{
       rows[i].className = "second";
     }
     highlight(rows[i]);
   }
 }
}
function highlight(elt) {
  if (elt.parentNode.nodeName!="THEAD" || elt.parentNode.nodeName!="TFOOT") {
    elt.onmouseover=function(){addCSSClass(this, 'highlight'); return false}
    elt.onmouseout=function(){deleteCSSClass(this, 'highlight'); return false}
  }
}
function deleteCSSClass(el, cssClass) {
  var c = el.className;
  var re = new RegExp('\\b' + cssClass + '\\b','g');
  if (c) el.className = cleanClassWhitespace( c.replace(re, '') );
}
function addCSSClass(el, cssClass){
  el.className += ' ' + cssClass;
}
function cleanClassWhitespace(s){
  return s.replace(/^\s+/,'').replace(/\s+/g,' ').replace(/$\s+/,'');
}

// la fonction javascript qui demande la confirmation
function confirmation(Formulaire)
{
   var rep;
   // on demande la confirmation
   rep = confirm("Etes-vous certain de vouloir supprimer ce bateau ?");
   // si réponse positive on envoi le formulaire sinon rien
   if (rep)
   {
      // on indique le formulaire a été validé
      document.forms("" + Formulaire + "").action="bateaumaj.asp?etape=suppr"
      // on valide le formulaire
      document.forms("" + Formulaire + "").submit();
   }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function chg2go(source){
    if (typeof(source) == 'object' && source.options[source.selectedIndex].value!='')
        window.location=source.options[source.selectedIndex].value
}

// menu deroulant
sfHover = function() {
  if(document.getElementById("menutop")) {
    var sfEls = document.getElementById("menutop").getElementsByTagName("LI");
  	for (var i=0; i<sfEls.length; i++) {
  	   if(sfEls[i].parentNode.className!='sub') {
  		   sfEls[i].onmouseover = function() {
               var sfOther = document.getElementById("menutop").getElementsByTagName("LI");
  			   for (var i=0; i<sfOther.length; i++) {
  			      sfOther[i].className = '';
  			   }
  			   this.className+=" sfhover";
  		   }
  	   }
    }
  }
}

// page base
contentsLayers = function() {
  if (document.getElementById('base')) {
    // get all childs IDs
    var aItems = new Array();
    var oLayers = document.getElementById('base').getElementsByTagName('div');
    for(var i=0; i<oLayers.length; i++) {
      if ( oLayers[i].id!='' ) {
        aItems.push(oLayers[i].id);
        document.getElementById(oLayers[i].id).style.display = 'none';
      }
    }
    var sfEls = document.getElementById("menubottom").getElementsByTagName("a");
  	for (var i=0; i<sfEls.length; i++) {
	   sfEls[i].onclick = function() {
		   for (var i=0; i<aItems.length; i++) {
          document.getElementById(aItems[i]).style.position = 'static';
		      document.getElementById(aItems[i]).style.display = 'none';
			  //alert(aItems[i]);
       }
		   if (this.href.indexOf('#')!=-1) // get ID of target
          var target = this.href.substr(this.href.indexOf('#')+1, this.href.length);
       else
          var target = this.href;
		   document.getElementById(target).style.display = 'block';
		   document.getElementById(target).style.position = 'relative';
		   return false;
	   }
    }
    document.getElementById(aItems[0]).style.position = 'relative';
    document.getElementById(aItems[0]).style.display = 'block';
  }
}

visitvirt = function(link) {
    if (link!='') {
        window.open(link,null,'width=590,height=313, status=no, directories=no, toolbar=no, location=no, menubar=no, scrollbars=no, resizable=no');
        //return false;
    }
}

ratioImage = function(obj) {
  if (obj.tagName == 'IMG') {
    // get image size
    orig_width = obj.width;
    orig_height = obj.height;
    // get container size
    width = obj.parentNode.offsetWidth;
    height = obj.parentNode.offsetHeight;
    // get fine ratio to fit max lengths of container
    ratio = Math.max((orig_width/width), (orig_height/height));
    return ratio;
  }
  else
    return null;
}

function zoomIllust(obj) {
  // zoom on rollover
  obj.onmouseover = function() {
    this.style.width = this.style.height = 'auto';
    this.parentNode.style.zIndex = '1';
    this.style.border = '1px solid #aaa';
  }
  // fit container on rollout
  obj.onmouseout = function() {
    this.style.width = this.offsetWidth/ratioImage(this)+'px';
    this.style.height = this.offsetHeight/ratioImage(this)+'px';
    this.parentNode.style.zIndex = '0';
    this.style.border = '1px solid #fff';
  }
  obj.onmouseout();
}

function fitImages(container) {
  if (typeof(container)!='object')
    container = document.getElementById(container);
  if (container) {
    oImgs = container.getElementsByTagName('IMG');
    for(var i=0; i<oImgs.length; i++) {
      zoomIllust(oImgs[i]);
      oImgs[i].style.position = 'absolute';
    }
  }
}

if (window.attachEvent) {
    window.attachEvent('onload', sfHover);
    window.attachEvent('onload', contentsLayers);
    window.attachEvent('onload', function(){ fitImages('vente') });
    window.attachEvent('onload', function(){ fitImages('boatviews') });
    /*window.attachEvent('onload', function(){ fitImages('boatcuts') });*/
}
else if (window.addEventListener) {
    window.addEventListener('load', sfHover, true);
    window.addEventListener('load', contentsLayers, true);
    window.addEventListener('load', function(){ fitImages('vente') }, true);
    window.addEventListener('load', function(){ fitImages('boatviews') }, true);
    /*window.addEventListener('load', function(){ fitImages('boatcuts') }, true);*/
}
/*
 * XMLHTTP
 */
var xmlhttp = false;
/*@cc_on
@if (@_jscript_version >= 5)
   try
   {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
      try
      {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (E)
      {
         xmlhttp = false;
      }
   }
@else
   xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
   try
   {
      xmlhttp = new XMLHttpRequest();
   }
   catch (e)
   {
      xmlhttp = false;
   }
}
if (xmlhttp)
{
   xmlhttp.onreadystatechange=function()
   {
      if (xmlhttp.readyState == 4)
      {
         if (xmlhttp.status == 200)
         {
            return xmlhttp.responseText;
         }
      }
   }
}

function vroom(){ window.location = 'http://www.nicols.com' }
