/* $Id: shared.js,v 1.4 2011/09/24 18:44:14 sap Exp $ */


$(document).ready(function () {
    
    // menus
    $('#topnav li').hover(
        function(){
            var m = $(this);
            m.children('div').children('ul').addClass('snav_on');
        },
        function(){
            var m = $(this);
            m.children('div').children('ul').removeClass('snav_on');
        }
    );
    
    $('#topnav li').hover(
        function(){
            var m = $(this);
            $(this).addClass('hover');
        },
        function(){
            var m = $(this);
            $(this).removeClass('hover');
        }
    );
    
    
    
    // translate
    $('#translate_link a').click(function(){
        $('.jq-translate-ui').show();
        return false;
    });

    $('#wrapper').click(function(){
        $('.jq-translate-ui').hide();
    });
if (true) {
    
    // http://code.google.com/p/jquery-translate/wiki/General
    $.translate(function(){  //when the Google Language API is loaded
  
        $.translate.getLanguages = function(){return{
            'ENGLISH' : 'en',
            'SPANISH' : 'es',
            'ITALIAN' : 'it',
            'GERMAN' : 'de',
            'FRENCH' : 'fr',
            'JAPANESE' : 'ja',
            'CHINESE_SIMPLIFIED' : 'zh-CN',
            'KOREAN' : 'ko',
            'URDU' : 'ur',
            //'AKAN' : 'ak',
            'VIETNAMESE' : 'vi',
            'PERSIAN' : 'fa',
            'FILIPINO' : 'tl',
            'RUSSIAN' : 'ru',
            'POLISH' : 'pl',
            'ARABIC' : 'ar'
        }};    
      
        function translateTo( destLang ){ // this can be declared in the global scope too if you need it somewhere else
            $('body').translate( 'english', destLang, {   // translate from english to the selected language
                not: '.jq-translate-ui, .notranslate', // by default the generated element has this className
                fromOriginal: true // always translate from english (even after the page has been translated)
                // unnecessary in v1.4, the default value is true
            });
        }

        // you can generate other controls as well, not just a dropdown:
        // there are new features in v1.4: http://code.google.com/p/jquery-translate/wiki/Extensions
        $.translate.ui('ul', 'li', 'span')  
            .appendTo('body')    //insert the element to the page
            // .css({'color':'blue', 'background-color':'white'})
            .find('span')
            .css('cursor','pointer')
            .click(function(){   //when selecting another language

                // in v1.4 $(this).val() or $(this).attr("value") 
                // is always the exact language code!
                translateTo( $(this).text() );
                $.cookie('destLang', $(this).text() ); 
                // set a cookie to remember the selected language
                // see: http://plugins.jquery.com/project/Cookie
                $('.jq-translate-ui').hide();
                return false; //prevent default browser action
            })

        var destLang = $.cookie('destLang'); // get previously translated language
        if (destLang)  // if it was set then
            translateTo(destLang);
            
        $($.translate.getBranding()).appendTo('.jq-translate-ui');

    }); //end of Google Language API loaded
}

});


