/*document.onkeydown = onEnter;
document.onkeyup = onEnter;
document.onkeypress = onEnter;
*/
function onEnter(event, oo)
{
	var nvKey = "";
	if (0 != event.keyCode)
	{
		// IE用
		nvKey = event.keyCode;
	}
	else
	{
		// FireFox用
		nvKey = event.charCode;
	}
	// リターンキー判定
	if (nvKey == 13)
	{
		// 検索キーのみ有効
		var o = document.getElementsByTagName("input").topbar_txt_Condition;
		if (!o)
		{
			o = document.getElementsByTagName("input").topbar1_txt_Condition;
			if (!o)
			{
				o = document.getElementsByTagName("input").Topbar1_txt_Condition;
				if (!o)
				{
					o = document.getElementsByTagName("input").Topbar_txt_Condition;
				}
			}
		}
		if (o.id == oo.id)
		{
			return true;
		}
		else
		{
			return false;
		}

/*		if((window.event.srcElement.type != 'button') &&
				(window.event.srcElement.type != 'image') &&  
				(window.event.srcElement.type != 'submit') && 
				(window.event.srcElement.type != 'textarea'))
		{
			return false;
		}*/

	} 
	
	return true; 
} 



// EOBのフォーカス移動
function fncOnKeyUp(event, o, svFrom, svTo, svEnd)
{
	var nvKey = "";
	if (0 != event.keyCode)
	{
		// IE用
		nvKey = event.keyCode;
	}
	else
	{
		// FireFox用
		nvKey = event.charCode;
	}
	// 入力可能文字数
	var nLenMax = o.getAttribute("MaxLength");
	// 現在の文字数
	var nLenNow = o.value.length;
	
	// TAB移動は無視
	if ((9 == nvKey) || (16 == nvKey))
	{
	}
	else
	{
//		alert(nvKey);
		// 文字が最大値なら
		if ((nLenMax == nLenNow) && (65 <= nvKey))
		{
			sNextId = o.id.replace(svFrom, svTo);
			document.getElementById(sNextId).focus();
		}
		// Enterなら
		if (13 == nvKey)
		{
			sNextId = o.id.replace(svFrom, svEnd);
			document.getElementById(sNextId).focus();
		}
	}
}

// Enterキーの無効化 + フォーカス移動
function fncOnEnter(e, id)
{
	var nvKey = "";
	if (null == e)
	{
	}
	else
	{
		nvKey = e.keyCode;
	}
	if (13 == nvKey)
	{
		document.getElementById(id).focus();
//		document.getElementById(id).onClick() = onClick();
		return false;
	}
}

// 検索欄の初期値解除
function fncDef(o)
{
	if ("このカテゴリー内で検索" == o.value)
	{
		o.value = "";
	}
}

// 共通ズーム画像
function zoom(id)
{
	var url = window.location.pathname;
	var artno=id.substring(0,6);
	var sub=id.substring(0,2);
	window.open("/" + url.split("/")[1] + "/zoom/product_zoom.aspx?fpx="+ id +"", "zoom","scrollbars=no,resizable=no,top=100,left=250,width=400,height=555");
	//window.open("http://172.16.7.34/zoomify/zoomifyDynamicViewer.php?file=" + artno +"&path=images/"+ sub +"/", "zoom","scrollbars=no,resizable=no,top=100,left=250,width=500,height=555");
}

//ランディングページへ遷移する
function goLanding(strlid) 
{
	var url = window.location.pathname;

	if ( strlid.substring(0,3) == "121" ) {
		location.href = "/" + url.split("/")[1] + "/category/ladies/index.aspx";
	} else if ( strlid.substring(0,3) == "125" ) {
		location.href = "/" + url.split("/")[1] + "/category/mens/index.aspx";
	} else if ( strlid.substring(0,3) == "124" ) {
		location.href = "/" + url.split("/")[1] + "/category/inner/index.aspx";
	} else if ( strlid.substring(0,3) == "122" ) {
		location.href = "/" + url.split("/")[1] + "/category/fashiongoods/index.aspx";
	} else if ( strlid.substring(0,3) == "123" ) {
		location.href = "/" + url.split("/")[1] + "/category/homegoods/index.aspx";
	} else if ( strlid.substring(0,3) == "127" ) {
		location.href = "/" + url.split("/")[1] + "/category/madame/index.aspx";
	} else if ( strlid.substring(0,3) == "311" ) {
		location.href = "/" + url.split("/")[1] + "/category/sale/index.aspx";
	} else if ( strlid.substring(0,3) == "229" ) {
		location.href = "/" + url.split("/")[1] + "/landing/ranking/index.aspx";
	} else if ( strlid.substring(0,3) == "504" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/50400";
	} else if ( strlid.substring(0,3) == "505" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/50500";
	} else if ( strlid.substring(0,3) == "512" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/51202";
	} else if ( strlid.substring(0,3) == "553" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/55301";
	} else if ( strlid.substring(0,3) == "554" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/55400";
	} else if ( strlid.substring(0,3) == "555" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/55501";
	} else if ( strlid.substring(0,3) == "740" ) {
		location.href = "/" + url.split("/")[1] + "/prdlist/cid/74000";
	} else if ( strlid.substring(0,3) == "750" ) {
		location.href = "/" + url.split("/")[1] + "/landing/shop/index.aspx";
	} else if ( strlid.substring(0,3) == "128" ) {
		location.href = "/" + url.split("/")[1] + "/category/sports/index.aspx";
	} else if ( strlid.substring(0,3) == "800" ) {
		location.href = "/" + url.split("/")[1] + "/landing/webonly/index.aspx";
	} else if ( strlid.substring(0,3) == "135" ) {
		location.href = "/" + url.split("/")[1] + "/category/cosme/index.aspx";
	} else if ( strlid.substring(0,3) == "754" ) {
		location.href = "/" + url.split("/")[1] + "/landing/hc/index.aspx";
	} else if ( strlid.substring(0,3) == "752" ) {
		location.href = "/" + url.split("/")[1] + "/landing/webalog/index.aspx";
	} else if ( strlid.substring(0,3) == "761" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	} else if ( strlid.substring(0,3) == "763" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	} else if ( strlid.substring(0,3) == "765" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	} else if ( strlid.substring(0,3) == "767" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	} else if ( strlid.substring(0,3) == "769" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	} else if ( strlid.substring(0,3) == "773" ) {
		location.href = "/" + url.split("/")[1] + "/cataloguelist_n/index.aspx";
	}
	
}

// 郵便番号検索
function search_zip()
{
	window.open("http://www.post.japanpost.jp/zipcode/index.html","zip","scrollbars=yes,resizable=yes,top="+ (screen.height- 500)/2 +",left="+ (screen.width- 785)/2 +",width=785,height=500");
}

// 住所検索
function pop_addr()
{
	var zip = document.getElementById("uc_Addr_txt_zip1").value + document.getElementById("uc_Addr_txt_zip2").value;
	var url;
	if (window.location.pathname.split("/").length  == 3 ) {
		url = "";
	} else {
		url = "../";
	}
	window.open(url + 'addr_pop.aspx?zip=' + zip ,'addr',"scrollbars=no,toolbar=no,menubar=no,status=no,resizable=no,Width=400,Height=400,left="+ (screen.width- 400)/2 +",top=50");
}

// 自動テキスト挿入
// メールパーツでtype=id_setを指定すると実行される
function id_set(o)
{
	// ログイン入力があり、値が空なら文字をコピーする
	if (document.getElementById("Login1_txt_id"))
	{
		if ("" == document.getElementById("Login1_txt_id").value)
		{
			document.getElementById("Login1_txt_id").value = o.value;
		}
	}
}

// 不要コード：ログインパーツでtype=add2を指定すると実行される
function hasChange(){;}

// テキストBOXの値をコピーする
function copyValue(from, to)
{
	document.getElementById(to).value = document.getElementById(from).value;
}

//URLエンコード
  function URLencode(str){
    // Unicode to URL encoded UTF-8
    var i, encoded_str, char_code, padded_str;
    encoded_str = "";
    for (i = 0; i < str.length; i++){
      char_code = str.charCodeAt(i);
      if (char_code == 0x20){
        // space -> "+"
        encoded_str += "+";
      }
      else { // else 1
        if (((0x30 <= char_code) && (char_code <= 0x39)) || ((0x41 <= char_code) && (char_code <= 0x5a)) || ((0x61 <= char_code) && (char_code <= 0x7a))){
          // [0-9a-z-A-Z]
          // no escape
          encoded_str += str.charAt(i);
        }
        else if ((char_code == 0x2a) || (char_code == 0x2e) || (char_code == 0x2d) || (char_code == 0x5f)) {
          // [.-_]
          // no escape
          encoded_str += str.charAt(i);
        }
        else { // else 2
          // for internal unicode to UTF-8
          // Ref. http://homepage3.nifty.com/aokura/jscript/utf8.html
          // Ref. http://homepage1.nifty.com/nomenclator/unicode/ucs_utf.htm
          if ( char_code > 0xffff ) {
            encoded_str += "%" + ((char_code >> 18) | 0xf0).toString(16).toUpperCase();
            encoded_str += "%" + (((char_code >> 12) & 0x3f) | 0x80).toString(16).toUpperCase();
            encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();
            encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
          }
          else if ( char_code > 0x7ff ) {
            encoded_str += "%" + ((char_code >> 12) | 0xe0).toString(16).toUpperCase();
            encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();
            encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
          }
          else if ( char_code > 0x7f ) {
            encoded_str += "%" + (((char_code >> 6) & 0x1f) | 0xc0).toString(16).toUpperCase();
            encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();
          }
          else {
            // for ascii
            padded_str = "0" + char_code.toString(16).toUpperCase();
            encoded_str += "%" + padded_str.substr(padded_str.length - 2, 2);
          }
        } // else 2
      } // else 1
    } // for
    return encoded_str;
  }

//ページ遷移
function pageLink(url) {
	//URLパスからプロジェクトを取得
	var prj  = "/" + window.location.pathname.split("/")[1] + "/";
	//画面遷移
	location.href = "http://" + window.location.host + prj + url;
}

