/*******************************************************************************

  Name:           No IE Information Bar
  Version:        0.2.8.1
  Date:           December 22, 2004
  Author:         Jedi             http://Jedi.org/blog/
  Original Author:Martin Ng        <http://minghong.webhop.org>
  Contributors:   Ching Yonghan
  Translators:    asteko           [Turkish]
                  Benobi           [Spanish]
                  bogus            [Polish]
                  Ching Yonghan    [Chinese/English/Malay]
                  Dasch            [Danish]
                  dariosc          [Italian]
                  Freya            [Italian]
                  Grauw            [Dutch]
                  indicavia        [Norwegian]
                  jcg              [French]
                  Jedi             [Traditional Chinese]
                  Lim Chee Aun     [English]
                  Marko Burjek     [Slovenian]
                  Needle           [Japan]
                  naylor83         [Swedish]
                  ricki            [German]
                  rjamorim         [Brazilian Portuguese]
                  sergei plaxienko [Russian]
                  Troels Nybo      [Danish]
                  Up North         [Dutch]
                  villep           [Finnish]
                  warhaven         [Dutch]
                  yuku             [Indonesian]
                  ZZZJR            [Czech]

  ------------------------------------------------------------------------------

  Creative Commons Deed
  Attribution-NonCommercial 2.0

  You are free:
  * to copy, distribute, display, and perform the work
  * to make derivative works

  Under the following conditions:
  * Attribution.
    You must give the original author credit.
  * Noncommercial.
    You may not use this work for commercial purposes.
  * For any reuse or distribution, you must make clear to others the license
    terms of this work.
  * Any of these conditions can be waived if you get permission from the
    copyright holder.

  Your fair use and other rights are in no way affected by the above.

  Read full license here:
  http://creativecommons.org/licenses/by-nc/2.0/legalcode

*******************************************************************************/

var tid;

/**
 * No IE Information Bar
 * @author Martin Ng <http://minghong.webhop.org>
 * @author kaneter
 * @version 0.2.8.1
 * @since 0.1
 *
 * @param id The ID of the infobar
 * @param url the URL that the infobar links to
 * @param tooltip The tooltip string
 * @param message The message string
 * @param animated Turn animatation on/off
 */
function InfoBar( id, url, tooltip, message, animated )
{
    // Initialize the infobar
    var infobar = document.getElementById( id );
    for ( var i = 0; i < infobar.children.length; i++ )
    {
        infobar.removeChild( infobar.children[i] );
    }

    // Update the infobar and viewplot
    var textNode = document.createTextNode( message );
    var linkNode = document.createElement( "a" );
    linkNode.href = url;
    linkNode.title = tooltip;
    linkNode.appendChild( textNode );
    infobar.appendChild( linkNode );

    // Move the infobar and viewplot
    if ( animated )
    {
        var inHeight = infobar.offsetHeight;
        var viHeight = viewplot.offsetHeight;
        infobar.runtimeStyle.position = "absolute";
        infobar.runtimeStyle.top = inHeight * -1;
        infobar.runtimeStyle.left = 0;
        viewplot.runtimeStyle.position = "absolute";
        viewplot.runtimeStyle.top = 0;
        viewplot.runtimeStyle.left = 0;
        viewplot.runtimeStyle.height = viHeight + inHeight;
        tid = setInterval( "lowerInfoBar( infobar, viewplot )", 1 );
    }
}

/**
 * Lower the infobar
 * @author Martin Ng <http://minghong.webhop.org>
 * @author kaneter
 * @version 0.2
 * @since 0.2
 *
 * @param infobar The infobar object
 * @param viewplot The viewplot object
 */
function lowerInfoBar( infobar, viewplot )
{
    if ( parseInt( infobar.currentStyle.top ) < 0 )
    {
        infobar.runtimeStyle.top = parseInt( infobar.currentStyle.top ) + 1;
        viewplot.runtimeStyle.top = parseInt( viewplot.runtimeStyle.top ) + 1;
        viewplot.runtimeStyle.height = parseInt( viewplot.runtimeStyle.height ) - 1;
    }
    else
    {
        clearInterval( tid );
    }
}

/**
 * Create Infobar
 * @author Jedi http://Jedi.org/blog/
 * @original author Martin Ng <http://minghong.webhop.org>
 * @version 0.2.8.1
 * @since 0.1
 */
window.onload = function()
{
    // Detect the locale
    var locale = navigator.userLanguage;
    switch ( locale )
    {

    // Traditional Chinese
    case "zh-tw":
    case "zh-hk":
    case "zh-mo":
        locale = "zh-tw";
        break;
    // Simpified Chinese
    case "zh-cn":
    case "zh-sg":
        locale = "zh-cn";
        break;

    // European Portuguese
    case "pt-pt":
        locale = "pt-pt";
        break;
    // Brazilian Portuguese
    case "pt-br":
        locale = "pt-br";
        break;

    // For others, remove country code
    default:
        if ( locale.indexOf("-") > 0 )
        {
            locale = locale.substring( 0, locale.indexOf("-") );
        }
    }

    // Create localized tooltips
    var tooltips = new Array();
    tooltips["cz"] = "Browse Happy — stav připojení. ne trápit se.";
    tooltips["da"] = "Browse Happy — Online. Bekymringsløst.";
    tooltips["de"] = "Browse Happy — Online. Sorgenfrei online.";
    tooltips["at"] = tooltips["de"];
    tooltips["ch"] = tooltips["de"];
    tooltips["el"] = "Browse Happy — Online. καμία ανησυχία.";
    tooltips["en"] = "Browse Happy — Online. Worry-free.";
    tooltips["es"] = "Browse Happy — en línea. sin preocuparse.";
    tooltips["fi"] = "Browse Happy — Verkossa. Huoletta.";
    tooltips["fr"] = "Browse Happy — En ligne. Sans s'inquiéter.";
    tooltips["id"] = "Browse Happy — Online. Tanpa takut.";
    tooltips["it"] = "Browse Happy — in linea. senza pensieri.";
    tooltips["ja"] = "Browse Happy — 心配事なく、ネットしよう。";
    tooltips["ms"] = "Browse Happy — Online. Tak perlu bimbang.";
    tooltips["nl"] = "Browse Happy — Online. zonder zorgen.";
    tooltips["no"] = "Browse Happy — Online. Bekymringsløst";
    tooltips["pl"] = "Browse Happy — serfuj bez obaw!!";
    tooltips["pt-br"] = "Browse Happy — Online. Sem preocupações.";
    tooltips["pt-pt"] = tooltips["pt-br"];    // Temporary
    tooltips["ru"] = "Browse Happy — На связи. Без опасений";
    tooltips["sl"] = "Browse Happy — Na zvezi - brez skrbi.";
    tooltips["sv"] = "Browse Happy - Online, utan bekymmer.";
    tooltips["tr"] = "Browse Happy — Çevrimiçiyken endişeye son.";
    tooltips["zh-cn"] = "Browse Happy — 上网。无忧。";
    tooltips["zh-tw"] = "Mozilla FireFox — 重拾網路快感，既寫意又自然。";

    // Create localized messages
    var messages = new Array();
    messages["cz"] = "Dočasně zhoršený příjem Internetu je zpusoben prohlížečem Internet Explorer. Podrobnější informace najdete zde...";
    messages["da"] = "Internet Explorer forhindrer dig i at få en bedre oplevelse af internettet. Klik her og få mere at vide...";
    messages["de"] = "Internet Explorer verhindert ein besseres Internet-Erlebnis. Klicken Sie hier für weitere Informationen...";
    messages["at"] = messages["de"];
    messages["ch"] = messages["de"];
    messages["el"] = "Ο εξερευνητής Διαδικτύου σας αποτρέπει από την κατοχή μιας καλύτερης εμπειρίας Διαδικτύου. Χτυπήστε εδώ για να μάθετε περισσότερους...";
    messages["en"] = "Internet Explorer is preventing you from having a better Internet experience. Click here to learn more...";
    messages["es"] = "Internet Explorer está impidiendo que disfrutes de una mejor experiencia de Internet. Haz clic aquí para obtener más información...";
    messages["fi"] = "Internet Explorer estää sinua kokemasta nettiä paremmin. Napsauta tästä lisätietoja...";
    messages["fr"] = "Internet Explorer vous empêche d'avoir une meilleure expérience d'Internet. Cliquez ici pour plus d'informations...";
    messages["id"] = "Internet Explorer menghambat Anda merasakan pengalaman ber-Internet yang lebih baik. Klik di sini untuk mengetahui lebih banyak...";
    messages["it"] = "Internet Explorer vi sta impedendo di sfruttare al meglio Internet. Clicca qui per avere ulteriori informazioni...";
    messages["ja"] = "Internet Explorerによって、より良いインターネット体験が妨げられています。詳細を表示するには、ここをクリックしてください...";
    messages["ms"] = "Internet Explorer menghalang anda untuk mendapat pengalaman Internet yang lebih baik. Klik sini untuk mengetahui lebih banyak...";
    messages["nl"] = "Internet Explorer weerhoudt u van een betere internetervaring. Klik hier voor meer informatie...";
    messages["no"] = "Internet Explorer hindrer deg i å ha en bedre opplevelse av internett. Klikk her for mer informasjon...";
    messages["pl"] = "Internet Explorer przeszkodził ci w doświadczeniu lepszego internetu. Aby dowiedzieć się więcej kliknij tutaj...";
    messages["pt-br"] = "Internet Explorer está impedindo você de ter uma melhor experiência na internet. Clique aqui para saber mais...";
    messages["pt-pt"] = tooltips["pt-br"];    // Temporary
    messages["ru"] = "Internet Explorer не позволяет Вам познавать Интернет лучше. Нажмите здесь чтобы узнать больше...";
    messages["sl"] = "Internet Explorer vam preprečuje lepše doživljanje interneta. Kliknite tukaj za več informacij...";
    messages["sv"] = "Internet Explorer hindrar dig från att ha en bättre internetupplevelse. Klicka här för mer information...";
    messages["tr"] = "Internet Explorer sizi daha iyi bir internet deneyiminden alıkoyuyor. Daha fazla bilgi için buraya tıklayın...";
    messages["zh-cn"] = "Internet Explorer 阻止你有更好的网络体验。按此了解更多…";
    messages["zh-tw"] = "Internet Explorer 正在扼殺妳瀏覽網頁的樂趣。請按這裡取得更多協助……";

    // Create localized URL!
    var urls = new Array();
    urls["cz"] = urls["en"];
    urls["da"] = urls["en"];
    urls["de"] = urls["en"];
    urls["at"] = urls["en"];
    urls["ch"] = urls["en"];
    urls["el"] = urls["en"];
    urls["en"] = "http://www.browsehappy.com";
    urls["es"] = urls["en"];
    urls["fi"] = urls["en"];
    urls["fr"] = urls["en"];
    urls["id"] = urls["en"];
    urls["it"] = urls["en"];
    urls["ja"] = urls["en"];
    urls["ms"] = urls["en"];
    urls["nl"] = urls["en"];
    urls["no"] = urls["en"];
    urls["pl"] = urls["en"];
    urls["pt-br"] = urls["en"];
    urls["pt-pt"] = urls["en"];
    urls["ru"] = urls["en"];
    urls["sl"] = urls["en"];
    urls["sv"] = urls["en"];
    urls["tr"] = urls["en"];
    urls["zh-cn"] = urls["en"];
    urls["zh-tw"] = "http://moztw.org/firefox/";

    // Select localized strings
    var tooltip = tooltips[locale] ? tooltips[locale] : tooltips["en"];
    var message = messages[locale] ? messages[locale] : messages["en"];
    var url = urls[locale] ? urls[locale] : urls["en"];

    // Create infobar
    var infobar = new InfoBar(
        "infobar", url, tooltip, message, true );
}

