<!--

///---------- Login Check -----------///

function loginCheck(){
	//ログイン判別のキー
	key = "wmt_login";
	//ログイン中の値
	login1 = "781B1001061A";          //S
	login2 = "04585018746C40";        //N
	//クッキーの値取得
	val = getCookie(key);
	//alert(val);

	if(val==login1){
		return true;
	}else if(val==login2){
	    return true;
	}else{
		return false;
	}
}

///---------- Login Site Check -----------///

function loginSiteCheck(){
	//ログイン判別のキー
	key = "wmt_login";
	
	//ログイン中の値
	login1 = "781B1001061A";          //S
	login2 = "04585018746C40";        //N

	//クッキーの値取得
	val = getCookie(key);
	//alert(val);

	if(val==login1){
		return 1;
	}else if(val==login2){
		return 2;
    }else{
	    return ;
	}
}

///---------- get Cookie -----------///

function getCookie(name){
	var search = name + '=';
	//document.write("test"+document.cookie);
	if (document.cookie.length>0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1){
			offset += search.length;
			end     = document.cookie.indexOf(';',offset);
			if(end == -1){
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(offset,end));
		}
	}
	//return null;
	return "";
}

///-------- get SiteInfo ---------///

function getSiteInfo(){
    if (loginSiteCheck()==1) { //Smash
      document.write("<strong>&nbsp;クレジットカードでログイン中&nbsp;</strong>");
    } else
    if (loginSiteCheck()==2) { //NetCash
      document.write("<strong>&nbsp;NET CASH でログイン中&nbsp;</strong>");
    } else {
      document.write("");
    }
}

///----------- getSite ------------///
//site=getCookie('wmt_login');
function getSite(){
   site=getCookie('wmt_login');
   return site;

}

///-------- get NickName Cookie ---------///

function getNickNameCookie(){
    name = "wmt_nickname";
	var search = name + '=';
	if (document.cookie.length>0) {

		offset = document.cookie.indexOf(search);

		if (offset != -1){
			offset += search.length;
			end     = document.cookie.indexOf(';',offset);

			if(end == -1){
				end = document.cookie.length;

			}
			return decodeURL(document.cookie.substring(offset,end));
		}
	}
	return null;
}

///-------- get NickName ---------///

/*function getNickName(){
  val =  getNickNameCookie();
  if(val!=null){
    document.write("サインイン中&nbsp;&nbsp;&nbsp;ようこそ！<strong>"+val+"&nbsp;</strong>さん ");
  }else{
    if (!loginCheckMorawin()) {
      document.write("ようこそ<strong>&nbsp;ゲスト&nbsp;</strong>さん&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;サインインしてスタート");
    }
  }
}*/

function link(){
	location.href="http://mora.jp/moratouch/";
}

function getNickName(){
 

///------------ Android 対応追加 2010.3.29 -------------///
var strUA = "";
strUA = navigator.userAgent;

if(strUA.indexOf("SonyEricssonSO-01B") != -1){

	document.write('<strong><font color="#ff0000">mora touch対応端末からアクセスしていますね？</font></strong><br>');
	document.write('<strong><font color="#ff0000">5秒後に mora touch 紹介ページに自動的に移動します。</font></strong><br>');
	setTimeout("link()", 5000);

}


 var modori_url = encodeURIComponent(document.URL);
 if(!(modori_url)){
   modori_url = encodeURIComponent("http://morawin.jp/");
 }
 
 val =  getNickNameCookie();
 if(val!=null){
   document.write("ようこそ、<strong>"+val+"&nbsp;</strong>さん。ご本人でない場合は"+"<a href='https://ams.morawin.jp/f/signin/logout.api?done="+modori_url+"'>サインアウト</a>"+"して下さい");
 }else{
   if (!loginCheckMorawin()) {
     document.write("ようこそ、<strong>&nbsp;ゲスト&nbsp;</strong>さん&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"<a href='https://ams.morawin.jp/f/signin/c_signin.view?done="+modori_url+"'>サインイン</a>"+"してスタート");
   }
 }
}

///------------ decode URL -------------///

function decodeURL(str){

    var s0, i, j, s, ss, u, n, f;
    s0 = "";                // decoded str

    for (i = 0; i < str.length; i++){   // scan the source str

        s = str.charAt(i);

        if (s == "+"){
            s0 += " ";    // "+" should be changed to SP

        } else {
            if (s != "%"){
                s0 += s;    // add an unescaped char
            } else {               // escape sequence decoding
                u = 0;          // unicode of the character
                f = 1;          // escape flag, zero means end of this sequence

                while (true) {
                    ss = "";        // local str to parse as int

                    for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse

                        sss = str.charAt(++i);
                        if (((sss >= "0") && (sss <= "9")) 
                        || ((sss >= "a") && (sss <= "f"))  
                        || ((sss >= "A") && (sss <= "F"))) {

                            ss += sss;      // if hex, add the hex character

                        } else {
                            --i; break;
                        }    // not a hex char., exit the loop

                   }
                   n = parseInt(ss, 16);           // parse the hex str as byte
                   if (n <= 0x7f){
                       u = n; f = 1;
                   }   // single byte format
                   if ((n >= 0xc0) && (n <= 0xdf)){
                       u = n & 0x1f; f = 2;
                   }   // double byte format
                   if ((n >= 0xe0) && (n <= 0xef)){
                       u = n & 0x0f; f = 3;
                   }   // triple byte format
                   if ((n >= 0xf0) && (n <= 0xf7)){
                       u = n & 0x07; f = 4;
                   }   // quaternary byte format (extended)
                   if ((n >= 0x80) && (n <= 0xbf)){
                       u = (u << 6) + (n & 0x3f); --f;
                   }         // not a first, shift and add 6 lower bits
                   if (f <= 1){
                       break;
                   }         // end of the utf byte sequence
                   if (str.charAt(i + 1) == "%"){
                       i++ ;    // test for the next shift byte
                   } else {
                       break;
                   }                   // abnormal, format error
               }

               s0 += String.fromCharCode(u);           // add the escaped character
           }

       }

    }

    return s0;

}

///-------- Login Check mora win ---------///

function loginCheckMorawin(){
  //ログイン判別のキー
  key = "sign_in";

  //クッキーの値取得
  val = getCookie(key);

  if(val == null || val == ""){
    return false;
  }else{
    return true;
  }
}

///----------- Display SigninDialog ------------///
/*
 * サインインダイアログを表示する
 * 書式 : displaySigninDialog()
 * 戻り値 : なし
 */
function displaySigninDialog(){
  try{
    window.external.attemptLogin();
  }catch(e){
  }
}

// -->


