function load(lang)
{
  //alert("ScanNav: Lang is " + lang);
  if (lang==null || lang=="")
    lang='FR';
  init_messages(lang);
  window.status = local_messages['footer'];
  //if (window.messageshown != 1)
  //  alert(local_messages['vacances']);
  //window.messageshown=1;
  //document.write(local_messages['vacances']); 
  //setTimeout(UpdateMessage,1);
  //UpdateMessage();
}

function UpdateMessage()
{
  alert(local_messages['vacances']);
  var text1 = document.getElementById("message");  
  alert(text1.firstChild);
  text1.firstChild.nodeValue=local_messages['vacances'];
  alert(text1.firstChild.nodeValue);
}
function insertscrollingheaders(lang)
{
  if (lang=='GB')
  {
    message = "ScanNav will be present at the next Paris Boat Show from 4th to 13th December 2009.<br>Come and meet us on our stand n&deg; B42 in Hall 2.1 for a full presentation.";
  }
  else
  {
    message = 'ScanNav sera pr&eacute;sent au prochain Salon Nautique de Paris du 4 au 13 D&eacute;cembre 2009.<br>Venez nous rencontrer sur notre stand n&deg; B42 dans le Hall 2.1 pour une pr&eacute;sentation compl&egrave;te.';
  }
  //  document.write('<div id="Layer1" style="position:absolute; left:6px; top:96px; width:100%; z-index:1;">');
  document.write('<div id="Layer1">');
  document.write('<marquee direction="left" width="100%" scrollamount="5" scrolldelay="100" onmouseover="this.stop()" onmouseout="this.start()">');
  // document.write('<img src="../img/nautic2008tr.png">Hall 2.1 stand B10 - <strong><font color="#0000FF" size="+2">');
  // document.write(message);
  //  document.write('</font></strong></marquee></div>');
  document.write(' <table width="100%" border="0" cellspacing="0" cellpadding="0">');
 document.write('   <tr> ');
 document.write('     <td width="119"><img src="../img/nautic2008tr.png" width="95" height="49">');
 document.write('     </td>');
 document.write('     <td rowspan="2" nowrap> <strong><font color="#0000FF" size="+2">');
 document.write(message);
 document.write('     </font></strong></td>');
 document.write('   </tr>');
 document.write('   <tr>');
 document.write('     <td nowrap>Hall 2.1 stand B42</td>');
 document.write('   </tr>');
 document.write(' </table>');
 document.write('</marquee></div>');
}

function insertlogoheaders(lang)
{
  if (lang=='GB')
  {
    message = "Come and meet us on our stand n&deg; B42 in Hall 2.1 for a full presentation.";
    document.write('<div align="center"><a href="http://www.salonnautiqueparis.com/GB" target=_blank>');
  }
  else
  {
    message = "Venez nous rendre visite sur notre stand n&deg; B42 Hall 2.1 pour une pr&eacute;sentation compl&egrave;te.";
    document.write('<div align="center"><a href="http://www.salonnautiqueparis.com/" target=_blank>');
  }

 document.write(' <img style="border: 0px solid ; width: 728px; height: 90px;"');
 document.write(' alt="Nautic 2009 - Porte de Versailles 5&gt; 13 déc. 2009"');
 document.write(' src="http://www.scannav.com/mailing_nautic2009/nautic2009.gif"></a>');
 document.write('<table align="center" style="text-align: left; width: 727px; height: 35px;"');
 document.write(' border="0" cellpadding="0" cellspacing="0">');
 document.write('  <tbody>');
 document.write('    <tr>');
 document.write('      <td');
 document.write(' style="text-align: center; font-weight: bold; width: 498px;"><big>');
 document.write(message);
 document.write('      </big></td>');
 document.write('      <td style="width: 229px;"><a');
 document.write(' href="http://www.scannav.com/"><img');
 document.write(' style="border: 0px solid ; width: 200px; height: 50px;"');
 document.write(' src="http://www.scannav.com/mailing_nautic2009/stand.gif"');
 document.write(' alt="Hall 2.1 Allée B stand n°42"></a></td>');
 document.write('    </tr>');
 document.write('  </tbody>');
 document.write('</table></div>');
}

function insertheaders(lang)
{
  window.messageshown=1;
  return;
  insertlogoheaders(lang)
  return;
  insertscrollingheaders(lang);
  return;
  var message;
  if (lang=='GB')
  {
	message = "<b>Warning</b>: We will be at sea from <b>July 12th to 21st</b> with unsure access to internet<br>Please forgive us if we have some delays in our replies during this period. We recommend that any order concerning this period be passed before July 10th<br>In case of emergency, please call Gerard at +33 6 19 07 26 21 or Marc at +33 6 14 14 93 50";
  }
  else
  {
    message = "<b>Attention</b>: Nous serons en mer du <b>12 au 21 Juillet</b> avec un accès internet incertain<br>Veuillez nous excuser si nos réponses vous parviennent avec du retard pendant cette periode. Nous vous conseillons de prévoir toute commande pour cette période avant le 10 Juillet.<br>En cas d'urgence, merci d'appeller Gérard au 06 19 07 26 21, ou Marc au 06 14 14 93 50";
  }
  document.write('<table width="812" border="2" align="center" cellpadding="2"> <tr><td bgcolor="#FFFF66">'); 
  document.write('<div id="message" name="message">');
  document.write(message);
  document.write('</div></td></tr></table>');
  window.messageshown=1;
}
//insertheaders('GB');

function init_messages(lang)
{
  local_messages = new Array();
  if (lang=='GB')
  {
    local_messages['vacances'] = "Warning: We will be at sea from August 5th to August 19th with unsure access to internet\nPlease forgive us if we have some delays in our replies during this period\n\nIn case of emergency, please call Gerard at 06 19 07 26 21";
    local_messages['footer'] = 'ScanNav Cartography and Navigation Software';
    local_messages['nomincorrect'] = "  - The \"Last Name\" field must be filled\n"; 
    local_messages['emailincorrect'] = "  - The \"Email\" field must be filled\n";
    local_messages['emptycomment'] = "  - The  \"Comments\" field must be filled\n";
    local_messages['incompleteform'] = "Some required fields are missing:\n";
  }
  else
  {
    local_messages['vacances'] = "Attention: Nous serons en mer du 5 au 19 Aout avec un accès internet incertain\nVeuillez nous excuser si nos réponses ne vous parviennent pas immediatement pendant cette periode\n\nEn cas d'urgence, merci d'appeller Gérard au 06 19 07 26 21";
    local_messages['footer'] = 'ScanNav Logiciel de navigation et de cartographie';
    local_messages['nomincorrect'] = "  - Le champ \"Nom\" doit être renseigné\n"; 
    local_messages['emailincorrect'] = "  - Le champ \"E.mail\" doit être renseigné\n"; 
    local_messages['emptycomment'] = "  - Le champ \"Commentaires\" doit être renseigné\n"; 
    local_messages['incompleteform'] = "Le formulaire est incomplet:\n";
  }
}

function openImage(theURL,winName,W,H)
{
  W += 50;
  H += 100;
  //params = 'scrollbars=yes,resizable=yes,width='+W+',height='+H;
  params = 'scrollbars=no,resizable=yes,width='+W+',height='+H;
  fenetre = window.open(theURL,winName,params);
  fenetre.focus();
  fenetre.resizeTo(W,H);
}

function ShowHTM(htm)
{ 
  var URL = "../maptech/cartes/detail/" + htm + ".htm";
  params = 'scrollbars=yes,toolbars=no,menubars=no,location=no,resizable=yes,width=800,height=600';
  //alert("URL = '"+URL+"'");
  openpopup = window.open(URL,"htm",params);
  openpopup.window.focus();
}
function ShowENC(id)
{ 
  var URL = "Packs/Packs.php?ID=" + id;
  params = 'scrollbars=yes,toolbars=no,menubars=no,location=no,resizable=yes,width=800,height=800';
  //alert("URL = '"+URL+"'");
  openpopup = window.open(URL,"enc",params);
  openpopup.window.focus();
}
function ShowPDF(pdf)
{ 
  var URL = "../maptech/cartes/detail/" + pdf + ".pdf";
  params = 'scrollbars=yes,toolbars=no,menubars=no,location=no,resizable=yes,width=800,height=600';
  //alert("URL = '"+URL+"'");
  openpopup = window.open(URL,"htm",params);
  openpopup.window.focus();
}

function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages() 
{
  if (document.images) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
    //alert('changeImages.arguments[i] =  ' + changeImages.arguments[i] );
   // alert('changeImages.arguments[i] =  ' + document[changeImages.arguments[i]].src );
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}
function StdEncThumb(id) 
{
  if (document.images) {
    packid = 'pack'+id ;
    document[packid].src = 'Packs/Thumb/pack'+id+'.jpg';
  }
}
function AltEncThumb(id) 
{
  if (document.images) {
    packid = 'pack'+id ;
    document[packid].src = 'Packs/Thumb/pack'+id+'bis.jpg';
  }
}


var animation_timers = new Array();
var animation_images = new Array();

function animate(area, i, timeout)
{
  if (i >= animation_images[area].length) i=0;
  URL = animation_images[area][i];
  //alert("changeimage("+i+","+URL+" "+animation_timers[area]+")");
  changeImages( area, URL);
  i++;
  cmd = 'animate("' + area + '",' + i + ',' + timeout + ')';
  animation_timers[area] = setTimeout(cmd,timeout);
}

function toggleanimate(area,timeout)
{
  if (animation_timers[area] == undefined)
  {
    animate (area,0,timeout);
  }
  else
  {
   clearTimeout(animation_timers[area]);
   //alert("Suppression timeout " + animation_timers[area]);
   animation_timers[area] = undefined;   
  }
}

function gomail(User){
  window.location.href="mailto:" + User + "@scannav.com";
}

function CheckValidForm(form)
{
  msg = "";
  if (form.nom.value == "")
  {
    msg += local_messages['nomincorrect'];
  }
  if (form.email.value == "")
  {
    msg += local_messages['emailincorrect'];
  }
  if (form.textarea.value == "")
  {
    msg += local_messages['emptycomment'];
  }

  if (msg == "")
  {
    var date = new Date();
    form.date.value = date;
    /*
    msg += "nom = '" +  form.nom.value + "'\n" ;
    msg += "email = '" +  form.email.value + "'\n" ;
    msg += "Date = '" +  form.date.value + "'\n" ;
    alert("résultat ok\n" + msg );
    */
    form.submit();
    //alert("retour submit ok\n" );
    return false; // pour pas que le submit soit appellé une 2eme fois
  }
  else
  {
    alert(local_messages['incompleteform']+msg);
    return false;
  }
}

function translate(URL, ORIG, DEST)
{
//  window.location.href="http://translate.google.com/translate?u=http%3A%2F%2Fwww.scannav.com%2F" + URL + "&langpair=" + ORIG + "%7C" + DEST;
  window.location.href="http://translate.google.com/translate?u=http%3A%2F%2Fwww.scannav.com%2F" + URL + "&sl=" + ORIG + "&tl=" + DEST;
}

function translatenewwin(URL, ORIG, DEST)
{
//  href="http://translate.google.com/translate?u=http%3A%2F%2Fwww.scannav.com%2F" + URL + "&langpair=" + ORIG + "%7C" + DEST;
  href="http://translate.google.com/translate?u=http%3A%2F%2Fwww.scannav.com%2F" + URL + "&sl=" + ORIG + "&tl=" + DEST;
  openpopup = window.open(href,"translatewin",'');
  openpopup.window.focus();
}

function translateHome(DEST)
{
  translate('GB/home.html','en',DEST);
}
