// JavaScript Document
// Followings will redirect users want to use time2speak calendar
// for testing:
// document.write("\n"+testurl);

  var testurl = (location.href).toLowerCase();
  urlstring = "time2speak.com";
  if (testurl.search(urlstring) != -1 )
  {
     //document.write("\n yes found ! " + urlstring);
     /*
     // mac force redirect without judging the time
    window.location.href = 'http://www.time2speak.com/time2speak/index.html';
     */
    var today = new Date();
    var hourUTC = today.getUTCHours();
    if ((hourUTC >= 16) && (hourUTC <= 21))
        {
          window.location.href   = 'http://www.time2speak.com/time2speak/csw/';
        }
    else
        {
         //window.location.href = 'http://time2speak.servehttp.com/system/cc/';
         window.location.href = 'http://www.time2speak.com/time2speak/';

         /* Mac remarked this ***

         var langcode1=eval('navigator.userLanguage');
         switch(langcode1) {
                case "zh-sg":
                  window.location.href = 'http://time2speak.servehttp.com/reg123/index.php?currency=AUD';
                break;
           case "zh-cn":
                  window.location.href = 'http://time2speak.servehttp.com/reg123/index.php?currency=CNY';
                break;
           case "zh-hk":
                  window.location.href = 'http://time2speak.servehttp.com/reg123/index.php?currency=TWD';
                break;
           case "zh-tw":
                  window.location.href = 'http://time2speak.servehttp.com/reg123/index.php?currency=TWD';
                break;
           case "en-us":
           case "en-au":
           case "en-ca":
           case "en":
                window.location.href = 'http://www.time2speak.com/time2speak/csw/index.html';
                break;
           default:
                  window.location.href = 'http://time2speak.servehttp.com/reg123/';
                break;

           }
         *** Mac remarked above */
     }
  }
  else
  {
     // document.write("\n not found ! " + urlstring);
     urlstring2 = "chinesestudyweb.com";
     if (testurl.search(urlstring2) != -1 )
     {
         window.location.href = 'http://www.time2speak.com/time2speak/csw/';
     } else  {
        urlstring3 = "welcome2australia.com";
        if (testurl.search(urlstring3) != -1 )
        {

              /*
              // Followings will redirect different browsers to their localized page
                var langcode1=eval('navigator.userLanguage');
               // document.write('<BR>userlangauge ='+ langcode1);
               switch(langcode1) {
                  case "zh-sg": window.location.href = 's/index.html'; break;
                  case "zh-cn": window.location.href = 's/index.html'; break;
                  case "zh-hk": window.location.href = 't/index.html'; break;
                  case "zh-tw": window.location.href = 't/index.html'; break;
                  default: window.location.href = 't/index.html'; break;
                }
             */
             window.location.href = 'aus/'

        } else {
            urlstring4 = "payhalf.com.au";
            if (testurl.search(urlstring4) != -1 )
            {
                window.location.href = 'http://www.payhalf.com.au/order/';
             } else {
                urlstring5 = "austintaiwan.com";
                if (testurl.search(urlstring5) != -1 )
                {
                    window.location.href = 'http://www.austintaiwan.com/austin/';
                } else {
                window.location.href = 'http://www.time2speak.com/time2speak/csw/';
                }
             }
        } 
     }
  }