/*
 * Copyright © 2007 Manfred Stienstra <manfred@fngtps.com>, Fingertips
 *
 * The $ function is borrowed from the Prototype JavaScript framework.
 * Copyright © 2005 Sam Stephenson <sam@conio.net>
 */


// Element finding helper
function $() {
  var results = [], element;
  for (var i = 0; i < arguments.length; i++) {
    element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    results.push(element);
  }
  return results.length < 2 ? results[0] : results;
}

// Class for managing the language options in a form
var SignupLocation = {
  languages: [["Arabic", "ar"], ["German", "de"], ["English", "en"], ["Spanish", "es"], ["French", "fr"], ["Greek", "gre"], ["Italian", "it"], ["Dutch", "nl"], ["Polish", "pl"], ["Portuguese", "pt"], ["Russian", "ru"]],
  signupLanguageRestrictions: {mx: [["Spanish", "es"], ["English", "en"]], lb: [["Arabic", "ar"], ["English", "en"]], it: [["Italian", "it"], ["English", "en"]], gr: [["Greek", "gre"], ["English", "en"]], dz: [["Arabic", "ar"], ["English", "en"]], ye: [["Arabic", "ar"], ["English", "en"]], kw: [["Arabic", "ar"], ["English", "en"]], de: [["German", "de"], ["English", "en"]], fr: [["French", "fr"], ["English", "en"]], mo: [["Arabic", "ar"], ["English", "en"]], ly: [["Arabic", "ar"], ["English", "en"]], eg: [["Arabic", "ar"], ["English", "en"]], km: [["Arabic", "ar"], ["English", "en"]], es: [["Spanish", "es"], ["English", "en"]], sa: [["Arabic", "ar"], ["English", "en"]], ru: [["Russian", "ru"], ["English", "en"]], ps: [["Arabic", "ar"], ["English", "en"]], be: [["Dutch", "nl"], ["French", "fr"], ["English", "en"]], ae: [["Arabic", "ar"], ["English", "en"]], tn: [["Arabic", "ar"], ["English", "en"]], ch: [["German", "de"], ["French", "fr"], ["English", "en"]], mr: [["Arabic", "ar"], ["English", "en"]], jo: [["Arabic", "ar"], ["English", "en"]], br: [["Portuguese", "pt"], ["English", "en"]], sy: [["Arabic", "ar"], ["English", "en"]], sd: [["Arabic", "ar"], ["English", "en"]], pl: [["Polish", "pl"], ["English", "en"]], dj: [["Arabic", "ar"], ["English", "en"]], bh: [["Arabic", "ar"], ["English", "en"]], ar: [["Spanish", "es"], ["English", "en"]], om: [["Arabic", "ar"], ["English", "en"]], nl: [["Dutch", "nl"], ["English", "en"]], iq: [["Arabic", "ar"], ["English", "en"]], at: [["German", "de"], ["English", "en"]], lu: [["French", "fr"], ["English", "en"]], cl: [["Spanish", "es"], ["English", "en"]]},
  
  updateLanguageOptionsFor: function(countryElement, languageElement) {
    if ($(countryElement).value) {
      var newLanguages = this.signupLanguageRestrictions[$(countryElement).value];
      if (newLanguages) {
        this.resetOptionsTo(languageElement, newLanguages);
      } else {
        this.resetOptionsTo(languageElement, [['English', 'en']]);
      }
    } else {
      this.resetOptionsTo(languageElement, this.languages);
    }
  },
  
  resetOptionsTo: function(languageElement, newLanguages) {
    var selected = $(languageElement).value;
    $(languageElement).options.length = 0;
    $(languageElement).options[0] = new Option('', '');
    for (var i = 0; i < newLanguages.length; i++) {
      var option = new Option(newLanguages[i][0], newLanguages[i][1]);
      if (selected == newLanguages[i][1]) {
        option.selected = true;
      }
      $(languageElement).options[i+1] = option;
    }
  }
};

/*
 * Copyright © 2007 Manfred Stienstra <manfred@fngtps.com>, Fingertips
 *
 */
var Embed = {
  embedCSS: function(url) {
    var head = document.getElementsByTagName('head')[0];
    var style = document.createElement('link');
    style.type = 'text/css';
    style.rel = 'stylesheet';
    style.href = url;
    head.appendChild(style);
  },
  
  embedHTML: function(html) {
    var embed = document.getElementById('rhubarb');
    if (embed != null) {
      embed.innerHTML = html;
    } else {
      document.write("<div id=\"rhubarb\">");
      document.write(html);
      document.write("</div>");
    }
  }
}

Embed.embedCSS("http://write-a-letter.greenpeace.org/stylesheets/public.css");
Embed.embedCSS("http://write-a-letter.greenpeace.org/462/inline_stylesheet.css");
Embed.embedHTML("<h1>Scandale sur la viande de baleine</h1>\n\n<p>Nous avons besoin de toute urgence de votre aide.</p>\n\n<p>Greenpeace a r&#233;v&#233;l&#233; le 15 mai dernier &#224; Tokyo un scandale impliquant le programme de chasse scientifique. Apr&#232;s quatre mois d&#8217;investigation, un vaste march&#233; noir de viande de baleine vol&#233;e, qui implique l&#8217;ensemble des acteurs de la chasse &#224; la baleine, a &#233;t&#233; mis en &#233;vidence.</p>\n\n<p>Suite aux r&#233;v&#233;lations de Greenpeace, le procureur de Tokyo a entam&#233; une proc&#233;dure d&#8217;enqu&#234;te. L&#8217;ampleur et l&#8217;&#233;chelle de ce scandale pose de nombreuses questions sur l&#8217;implication des op&#233;rateurs du programme de chasse dans l&#8217;oc&#233;an austral.</p>\n\n<p>Nous vous demandons donc d&#8217;envoyer cette lettre en anglais au Premier ministre japonais et au ministre japonais des affaires &#233;trang&#232;res pour manifester notre soutien &#224; cette proc&#233;dure judiciaire, mais surtout r&#233;affirmer le fait que les autorit&#233;s judiciaires doivent poursuivre l&#8217;ensemble des acteurs impliqu&#233;s dans ce trafic et ne sauraient se contenter de poursuivre quelques membres de l&#8217;&#233;quipage du Nisshin Maru alors que ce scandale r&#233;v&#232;le un syst&#232;me organis&#233; de march&#233; noir &#171; couvert &#187; par les diff&#233;rentes agences gouvernementales impliqu&#233;es dans le programme de chasse dite scientifique dans l&#8217;oc&#233;an austral.</p>\n\n<p>Nos demandes sont les suivantes :</p>\n\n<p>- arr&#234;t des subventions au programme de chasse dit scientifique;</p>\n\n<p>- refus d&#8217;accorder tout nouveau permis de chasse &#224; la baleine &#224; l&#8217;Institut de Recherche des C&#233;tac&#233;s et &#224; la Kyodo Senpaku;</p>\n\n<p>- Enfin, nous demandons au gouvernement japonais, durant la p&#233;riode de l&#8217;enqu&#234;te et en amont de la prochaine r&#233;union de la CBI (Commission baleini&#232;re internationale) &#224; Santiago du Chili, de ne pas se lancer dans la pr&#233;paration d&#8217;une nouvelle exp&#233;dition dans l&#8217;oc&#233;an austral et de prendre contact avec le gouvernement australien pour lancer un programme scientifique commun et non-l&#233;thal. En utilisant &#224; bon escient les moyens scientifiques de l&#8217;Institut de Recherche sur les C&#233;tac&#233;s et les navires de la Kyodo Senpaku, le Japon pourrait apporter une aide r&#233;elle &#224; la protection de la biodiversit&#233; marine dans l&#8217;oc&#233;an austral et se dans une position de leader dans la d&#233;fense de la biodiversit&#233; marine.</p>\n\n<p>C&#8217;est d&#233;sormais &#224; vous d&#8217;agir en relayant nos demandes aupr&#232;s du gouvernement japonais, comme plus de 40 000 personnes l&#8217;ont d&#233;j&#224; fait dans d&#8217;autres pays. Merci d&#8217;avance !</p>\n\n<script type=\"text/javascript\">try{urchinTracker('/outbound/#{CGI::escape(@appeal.title)}');}catch(e){};</script>\n\n<form action=\"http://write-a-letter.greenpeace.org/462/messages\" method=\"post\" onsubmit=\"try{urchinTracker('/outbound/Scandale+sur+la+viande+de+baleine');}catch(e){};return true;\">\n    <fieldset>\n    <div>\n      <div><label for=\"message_name\">Votre nom</label></div>\n      <input class=\"text small\" id=\"message_name\" maxlength=\"100\" name=\"message[name]\" size=\"40\" type=\"text\" />\n    </div>\n    \n    <div>\n      <div><label for=\"message_email\">Votre adresse e-mail (sert &#224; confirmer l'envoi du message)</label></div>\n      <input class=\"text small\" id=\"message_email\" maxlength=\"100\" name=\"message[email]\" size=\"40\" type=\"text\" />\n    </div>\n    \n    <div>\n      <div><label for=\"message_subject\">Sujet</label></div>\n      \n        <input class=\"text\" id=\"message_subject\" maxlength=\"200\" name=\"message[subject]\" size=\"60\" type=\"text\" value=\"Whaling scandal: a full investigation please\" />\n      \n    </div>\n    \n    <div>\n      <div><label for=\"message_body\">Message</label></div>\n      \n        <textarea cols=\"60\" id=\"message_body\" name=\"message[body]\" rows=\"15\">Dear Ministers,\n\nThe Tokyo District Public Prosecutor has begun an investigation into allegations made by Greenpeace of  embezzlement involving smuggled whale meat which raise serious questions about the scale and extent of the abuse of taxpayers' money by the operators of the Southern Ocean whaling programme. \n\nI am delighted that the investigation has begun, but I am writing to you again to urge you to support an investigation into every allegation made and pressure is not brought to bear on the Prosecutor to only  take action against individual crewmembers.\n\nThe allegations cast another huge shadow over the reputation of the entire whaling programme sponsored by your government and only a transparent and thorough enquiry can help lift that.\n\nIn addition I urge you to take the following actions:\n\n-Immediately suspend the tax payer subsidy to the whaling programme\n-Refuse any new whaling permits for Kyodo Senpaku\n-Refuse any new whaling permits for the Institute of Cetacean Research.\n\nFinally,  during the period of the investigation and as part of the preparation for the meeting of the International Whaling Commission in Santiago Chile, I would also request that instead of preparing for another whaling expedition to the Southern Ocean Whale Sanctuary, your government agree to work with the government of Australia on a non-lethal research programme.\n\nBy using the scientific resources of the Institute for Cetacean Research and the vessels from Kyodo Senpaku to collaborate on a mission that could bring real benefit to the marine environment of Antarctica which is increasingly threatened by the impacts of climate change, the government of Japan could lead the way in presenting a new way forward for marine protection and scientific collaboration.\n\n\nYours sincerely,\n\n</textarea>\n      \n    </div>\n    \n      </fieldset>\n  \n  <div class=\"submit\">\n    <input name=\"commit\" type=\"submit\" value=\"Envoyer\" />\n  </div>\n</form>\n");

