/* google analytics */
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17410822-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
/* google analytics */

function languageChange() {
    var url = document.location.href;

    if (url.search('.php') == -1) {

        if (url.charAt(url.length - 1) == '/') {
            url += "index.php";
        }
        else {
            url += "/index.php";
        }
    }

    if (url.length > 1) {

        // .php consume 4 characters
        if (url.substr(url.length - 1 - 1 - 4, 2) == "_c") {

            // Chinese -> English
            if (url.length > 6) {
                var destUrl = url.substring(0, url.length - 6) + ".php"
                window.location.href = destUrl;
            }
        }
        else
        {
            // English -> Chinese
            if (url.length > 4) {
                var destUrl = url.substring(0, url.length - 4) + "_c.php"
                window.location.href = destUrl;
            }
        }
    }
}
