﻿numberform=0;
tpaffiche=1000;
readytop=false;


// ROLL EN FADE. IE 5.5 & 6.0 ONLY !!!!!

//identification de IE 5.5 et 6.0
if (document.all && (navigator.appVersion.indexOf('5.5') != -1 || navigator.appVersion.indexOf('6.0') != -1 )) varfilter=true;
else varfilter=false;

tempofade=false;
timetempofade=50;
// valeur alpha
Tfade=new Array(new Array(),new Array(),new Array(0,90,90,90,90,90,90),new Array(0,90,90,90),new Array(0,90,90,90),new Array(0,90,90),new Array(0,90,90,90,90),new Array(0,90,90,90),new Array(0,90,90));
// sens du fade
Tsensfade=new Array(new Array(),new Array(),new Array(0,10,10,10,10,10,10),new Array(0,10,10,10),new Array(0,10,10,10),new Array(0,10,10),new Array(0,10,10,10,10),new Array(0,10,10,10),new Array(0,10,10));

function fadeit(m,n){
	Tfade[m][n]+=Tsensfade[m][n];
	objimgtop=eval("document.navtop"+m+"_"+n+";");
	objimgtop.style.filter="alpha(opacity="+Tfade[m][n]+")";	
	if (Tfade[m][n] !=0 && Tfade[m][n] !=100) tempofade=setTimeout('fadeit('+m+','+n+')',timetempofade);
	else {
		if (Tsensfade[m][n]==10)Tfade[m][n]=90;
		else Tfade[m][n]=10;
	}
}
// FIN ROLL EN FADE.

function IS_top(m,n,o) {
	if(readytop){
		if (!varfilter){
		objimgtop=eval("(document.layers)?document.forms[0].navtop"+m+"_"+n+":document.navtop"+m+"_"+n+";");
		objimgtop.src = eval("'/img/_jp/_jp/nav/nav_top/jp_jp_nav_"+m+"_"+n+"_"+o+".gif'");
		}
		else {
			if (o=="off")Tsensfade[m][n]=10;else Tsensfade[m][n]=-10;
			fadeit(m,n);
		}
	}
}

function gosearch(n,numberform){

	var mf = GetMainFormName();
	if (!mf) return;
	
	var n2 = "";
	var str2 = "";
	var cat = "";
	if (numberform) {

		str=eval ("document.forms[mf].search"+numberform);
		var cptspace = 0;
		for (i=0;i<str.value.length;i++) {
			if(str.value.charAt(i)==" ") {
				str2+="%20";
				cptspace++;
			}
			else {
				str2+=str.value.charAt(i);
			}
		}
		if (str.value.length==cptspace || str.value.length==1) {
			str2="キーワード検索%20";	
		}
		n2 = n + str2 + '&catcode=&page=1';		
	} else {
		var str = document.getElementById('search-box');
		var cptspace = 0;
		for (i=0; i<str.value.length; i++) {
			if(str.value.charAt(i) == " ") {
				str2 += "%20";
				cptspace++;
			} else {
				str2+=str.value.charAt(i);
			}
		}
		if (str.value.length==cptspace || str.value.length==1) {
			str2="キーワード検索%20";
		}
		n2 = n + str2 + '&catcode=&page=1';	
	}
	
    if(str2=='キーワード検索%20')
	{
	}
	else
	{
	location.href = n2;
	}
}	
function search_onfocus(el){
	var mf = GetMainFormName();
	if (mf==null) return;
	el.value = '';
}



tmp2=false;
lay_top_current=0;


function init2(){
	for(i=1; i<9; i++){
		eval("navhoff"+i+"=new Image();");
		eval("navhoff"+i+".src='/img/_jp/_jp/nav/nav_top/jp_jp_nav_"+i+"_off.gif';");
		eval("navhroll"+i+"=new Image();");
		eval("navhroll"+i+".src='/img/_jp/_jp/nav/nav_top/jp_jp_nav_"+i+"_roll.gif';");
	}
	if (navhaut){
		eval("navhoff"+navhaut+".src='/img/_jp/_jp/nav/nav_top/jp_jp_nav_"+navhaut+"_roll.gif';");
		objnh = eval("document.navh"+navhaut);
		objnh.src = eval("navhoff"+navhaut+".src");
	}
	readytop=true;
}

function affiche(x){
	if(readytop){
		if (tmp2) clearTimeout(tmp2);
		if (x!= lay_top_current) cache();
		if (x!=1){
			objlaynavh = eval("(document.all)?document.all.laynavh"+x+".style:(document.layers)?document.laynavh"+x+":document.getElementById(\"laynavh"+x+"\").style");
			objlaynavh.visibility="visible";
		}
		objnh = eval("document.navh"+x);
		objnh.src = eval("navhroll"+x+".src");	
		lay_top_current=x;
	}
}

function cache(){
	if(readytop){
	for(i=2; i<9; i++){
		objlaynavh = eval("(document.all)?document.all.laynavh"+i+".style:(document.layers)?document.laynavh"+i+":document.getElementById(\"laynavh"+i+"\").style");
		objlaynavh.visibility="hidden";
	}
	for(i=1; i<9; i++){
		objnh = eval("document.navh"+i);
		objnh.src = eval("navhoff"+i+".src");
	}
	lay_top_current=0;
	}
}

function hide(n){tmp2=setTimeout('cache()',tpaffiche);}

function GetMainFormName()
	{
		var i;
		for (i=0;i<document.forms.length;i++)
		{
			if ((document.forms[i].name.indexOf("_aspnetForm") != -1) || (document.forms[i].name.indexOf("__aspnetForm") != -1) || (document.forms[i].name.indexOf("_ServerForm") != -1))
				return document.forms[i].name;
		}
		return null;
	}
	
function GetElementName(n, mf)
	{
		if (n==null || n=="") return null;
		var i, s, j;
		for (i=0;i<document.forms[mf].elements.length;i++)
		{
			if (document.forms[mf].elements[i].name.toLowerCase().indexOf(n.toLowerCase()) != -1)
				return document.forms[mf].elements[i].name;
		}
		return null;
	}	
	
function setProductCount(count)
	{
		if(!document.images) return;
		var counter = document.images["prodcount"];
		if(counter)
		{
			counter.src = "/img/_jp/_jp/00nav/b_top_articles_" + count + ".gif";
		}
	}
	
function setBagCount(count)
	{
		if(!document.images) return;
		var counter = document.images["bag"];
		if(counter)
		{
			counter.src = "/img/_ja/_ja/bag_" + count + ".gif";
		}
	}
	

	function QueryStringtop( param )
	{
		var begin,end;
		if(self.location.search.length>1)
		{
			begin=self.location.search.indexOf(param) +param.length+1;
			end=self.location.search.indexOf("&",begin);
			if(end==(-1)) end=self.location.search.length;
			//return(self.location.search.substring(begin,end));
			strl1=self.location.search.substring(begin+1,end-1);
			strl2="";
			
			for (i=0;i<strl1.length;i++) {
				if(strl1.charAt(i)=="%" && strl1.charAt(i+1)=="2" && strl1.charAt(i+2)=="0"){
				strl2+=" ";
				i++;
				i++;
				}
				else {
					strl2+=strl1.charAt(i);
				}
			}
			
			console.log(document.getElementById('search-box'));
			document.getElementById('search-box').value = strl2;
			// document.forms[0].search.value=strl2;
			document.forms[0].search2.value=strl2;
		}
		else if(self.location.hash.length>1)
		{
			begin=self.location.hash.indexOf(param) +param.length+1;
			end=self.location.hash.indexOf("&",begin);
			if(end==(-1)) end=self.location.hash.length;
			//return(self.location.hash.substring(begin,end));
			strl1=self.location.hash.substring(begin+1,end-1);
			strl2="";
			
			for (i=0;i<strl1.length;i++) {
				if(strl1.value.charAt(i)=="%" && strl1.value.charAt(i+1)=="2" && strl1.value.charAt(i+2)=="0"){
				strl2+=" ";
				i++;
				i++;
				}
				else {
					strl2+=strl1.value.charAt(i);
				}
			}
			console.log(document.getElementById('search-box'));
			document.getElementById('search-box').value = strl2;
			//document.forms[0].search.value=strl2;
			document.forms[0].search2.value=strl2;
		}
		//else return("");
	}
	
	
/***** ERROR ******/
	
// hide the error layer	
function hideerror(n){
	if(n=="")n=0;
	document.getElementById('errorpopup'+n).style.visibility='hidden';
	if (navigator.appName=='Microsoft Internet Explorer') document.getElementById("framemessage").style.visibility = "hidden";
}
// show the error layer	
function showerror(){
	document.getElementById('errorpopuphidden').style.visibility='visible';
}
// hide the error layer	
function hideerrorhidden(){
	document.getElementById('errorpopuphidden').style.visibility='hidden';
}


// build the error layer	
function writeerror(txt,n){
	if(n=="")n=0;
	output = [
		"<div id=\"errorpopup"+n+"\" style=\"POSITION:absolute;TOP:100px; LEFT:300px;width:281px;visibility: visible;z-index:10"+n+"\">",
		"<table width=\"281\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">",
		"<tr bgcolor=\"#c96597\">",
		"	<td colspan=\"3\"><img src=\"/img/_jp/_jp/error/error_top.jpg\" width=\"281\" height=\"42\" alt=\"\"></td>",
		"</tr>",
		"<tr bgcolor=\"#c96597\">",
		"	<td width=\"40\" nowrap></td>",
		"	<td style=\"font-size:12px;font-family: arial;color:#FFFFFF;font-weight:600;\">"+txt+"</td>",
		"	<td width=\"20\" nowrap></td>",
		"</tr>",
		"<tr bgcolor=\"#c96597\">",
		"	<td colspan=\"2\" align=\"right\" height=\"33\"><a href=\"javascript:hideerror("+n+");\"><img src=\"/img/_jp/_jp/error/error_bt_close.jpg\" alt=\"\" width=\"132\" height=\"13\" vspace=\"10\" border=\"0\"></a></td>",
		"	<td></td>",
		"</tr>",
		"</table>",
		"</div>"
	]
	//if(txt.length>2) 
	document.write(output.join('\n'));
	
	if (navigator.appName=='Microsoft Internet Explorer') {
  	document.write("<iframe id='framemessage' frameborder='0' scrolling='no' style=\"position:absolute;top:100px;left:300px;width:281px;z-index:0;filter:alpha(opacity=0);\" src='about:blank'></iframe>");
	document.getElementById("framemessage").style.height = document.getElementById("errorpopup"+n).offsetHeight;
  }
}	
// build the error layer (visible=hidden)	
function writeerrorhidden(txt){
	output = [
		"<div id=\"errorpopuphidden\" style=\"POSITION:absolute;TOP:100px; LEFT:300px;width:281px;visibility: hidden;z-index:100\">",
		"<table width=\"281\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">",
		"<tr bgcolor=\"#c96597\">",
		"	<td colspan=\"3\"><img src=\"/img/_jp/_jp/error/error_top.jpg\" width=\"281\" height=\"42\" alt=\"\"></td>",
		"</tr>",
		"<tr bgcolor=\"#c96597\">",
		"	<td width=\"40\" nowrap></td>",
		"	<td style=\"font-size:12px;font-family: arial;color:#FFFFFF;font-weight:600;\">"+txt+"</td>",
		"	<td width=\"20\" nowrap></td>",
		"</tr>",
		"<tr bgcolor=\"#c96597\">",
		"	<td colspan=\"2\" align=\"right\" height=\"33\"><a href=\"javascript:hideerrorhidden();\"><img src=\"/img/_jp/_jp/error/error_bt_close.jpg\" alt=\"\" width=\"132\" height=\"13\" vspace=\"10\" border=\"0\"></a></td>",
		"	<td></td>",
		"</tr>",
		"</table>",
		"</div>"
	]
	//if(txt.length>2) 
	document.write(output.join('\n'));
}