﻿function switchLang(lang) {
    document.cookie = "UserLang=" + lang + "; expires=" + (function () {
        var d = +new Date();
        d += 30 * 24 * 60 * 60 * 1000;
        return new Date(d).toGMTString();
    })() + "; path=/;";

    //location.reload(true);
}

jQuery(function ($) {
    var currentLang = location.pathname.match(new RegExp('^(?:(?:/([a-z]{2}-[A-Z]{2,3}))|(?:/\\w+/([a-z]{2}-[A-Z]{2,3})))?/.*', 'i'));

    currentLang = currentLang[1] || currentLang[2]; //先从url中取语言设置
    
    //    if (typeof (currentLang) == 'undefined') { //如果不存在则从cookie中取
    //        currentLang = getCookie('UserLang');
    //    }

    if (/zh-TW/gi.test(currentLang)) { //繁体中文的实现
        currentEncoding = 2;
        targetEncoding = 1;
        try{
            translateBody();
        }catch(ex){}
    }
    /*
    var list = $('.topbar .language .language-switcher .language-list');

    $('.topbar .language .language-switcher').hover(function () { //语言选择悬停弹出
        list.stop(true, true).fadeIn();
    }, function () {
        list.fadeOut('fast').queue(function () { $(this).stop(true, true); });
    });
    list.find('li').hover(function () { //语言列表项悬停
        $(this).addClass('language-hover');
    }, function () {
        $(this).removeClass('language-hover');
    });
    */
});
