/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function getCookie(c_name)
        {
        if (document.cookie.length>0)
          {
          var c_start=document.cookie.indexOf(c_name + "=");
          if (c_start!=-1)
            {
            c_start=c_start + c_name.length+1;
            var c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
            }
          }
        return "";
        }

        function detectCookie(){
            var countrycode = getCookie('countrycode');
            var languagecode = getCookie('languagecode');
            if((countrycode == null || countrycode == '')||(languagecode == null || languagecode == '')){
                window.location.href='http://www.shuanghor.com.my/select_country.jsp';
            }
            if(languagecode == null || languagecode == ''){
                window.location.href='http://www.shuanghor.com.my/select_country.jsp';
            }
            if(countrycode == 'my'){
                if(languagecode == 'zh'){
                    window.location.href='http://www.shuanghor.com.my/shweb_my/Language?tid=cl&lang=zh&pagename=/index.jsp'
                } else if(languagecode == 'en'){
                    window.location.href='http://www.shuanghor.com.my/shweb_my/Language?tid=cl&lang=en&pagename=/index.jsp'
                } else if(languagecode == 'ms'){
                    window.location.href='http://www.shuanghor.com.my/shweb_my/Language?tid=cl&lang=ms&pagename=/index.jsp'
                } else{
                    window.location.href='http://www.shuanghor.com.my/select_country.jsp';
                }

            } else if(countrycode == 'id'){
                window.location.href='http://www.shuanghor.com.my/shweb_indo';
            } else {
                window.location.href='http://www.shuanghor.com.my/select_country.jsp';
            }
        }

        function setCookie(c_name,value,expiredays)
        {
        var exdate=new Date();
        exdate.setDate(exdate.getDate()+expiredays);
        document.cookie=c_name+ "=" +escape(value)+
        ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
        return true;
        }

        function checkCookie(location)
        {
        var countrycode=getCookie('countrycode');
        if (countrycode!=null && countrycode!="") {
            setCookie('countrycode',countrycode,7);
          return true;
          }
        else
          {
          countrycode=location;

          if (countrycode!=null && countrycode!="")
            {
            setCookie('countrycode',countrycode,7);
            return true;
            }
          }
        }
