var data_array = new Object();
data_array["all"] = new Array(1,65);
data_array["shiki"] = new Array(1,32);
data_array["seki"] = new Array(33,48);
data_array["pattern"] = new Array(49,59);
data_array["wa"] = new Array(60,65);
data_array["toughtype"] = new Array(1,11,new Array(1,2,10,33,42,43,58,59,61,62,63));	// 画像番号指定方式(常に1,画像数,番号配列)番号配列に追加したら、画像数も追加してください。

function setHTML(id, html){
	if (document.getElementById) {
		document.getElementById(id).innerHTML = html;
	}else if (document.layers) {
	    document.layers[id].document.open();
	    document.layers[id].document.write("<div>");
	    document.layers[id].document.write(html);
	    document.layers[id].document.write("</div>");
	    document.layers[id].document.close();
	}else if (document.all) {
		//document.getElementById(id).innerHTML = html;
		document.all.item(id).innerHTML = html;
	}
}
function aboutItem(page){
	var alt_msg = ["商品について","タフタイプクロス商品","壁紙見本帳のご紹介","QuickJoiner","品番対応表","メンテナンス情報"];
	var tmp_about = '<img src="./img/about/'+page+'.gif" alt='+alt_msg[page-1]+' />';
	tmp_about += '<div id="changeBtn">';

//------ ページ固有の記述
	switch( alt_msg[page-1] ){
	case "商品について":
		tmp_about += '<br /><br /><br />';
		tmp_about += '<img src="./img/about/'+page+'-2.gif" alt='+alt_msg[page-1]+' />';
		break;
	case "タフタイプクロス商品":
		tmp_about += changePage('toughtype',0);
		break;
	}
//----------------------

	tmp_about += '<br /><a href="#" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("top","","img/button/top_o.gif",1); title="pre"><img name="top" src="img/button/top.gif" width="110" height="24" border="0" alt="このページの先頭へ" /></a>';
	tmp_about += '<br /><a href="javascript:window.close()" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("quit","","img/button/quit_o.gif",1); title="終了する"><img name="quit" src="img/button/quit.gif" width="110" height="24" border="0" alt="終了する" /></a>';
	tmp_about += '</div>';
	//document.all.insertPage.innerHTML = tmp_about;
	setHTML("insertPage", tmp_about);
}

function viewDetail(cate, num){
	var tmp_detail = '<div id="info"><img src="./img/sl/info/SL_'+(600+num)+'.gif" border=0 alt="SL-'+(600+num)+'" /></div>';
	tmp_detail += '<div id="download"><a href="javascript:download('+(600+num)+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("download","","img/button/download_o.gif",1); title="download"><img name="download" src="./img/button/download.gif" border=0 width=100 height=16 alt="画像ダウンロード"></a></div>'
	tmp_detail += '<div id="SL"><img src="./img/sl/l/SL_'+(600+num)+'.jpg" border=0 width=293 height=376 alt="SL-'+(600+num)+'" /></div>';
	tmp_detail += '<div id="mapping"><img src="./img/sl/mapping/SL-'+(600+num)+'.jpg" border=0 width=293 height=376 alt="SL-'+(600+num)+'"></div>';
	tmp_detail += '<div id="changeBtn">';
	var tmp_cate;
	var tmp_page = 1;

	//一覧ページ
	if(cate == "all"){
		tmp_cate = "all";
		tmp_page = Math.floor( (num-1) / 25 );
	}else if (cate=='toughtype') {
		tmp_cate = "toughtype";
		tmp_page = Math.floor( (num-(data_array["toughtype"][0]-1)) / 25 );

	}else if(num >= data_array["shiki"][0] && num <= data_array["shiki"][1]){
		tmp_cate = "shiki";
		tmp_page = Math.floor( (num-(data_array["shiki"][0]-1)) / 25 );

	}else if(num >= data_array["seki"][0] && num <= data_array["seki"][1]){
		tmp_cate = "seki";
		tmp_page = Math.floor( (num-(data_array["seki"][0]-1)) / 25 );

	}else if(num >= data_array["pattern"][0] && num <= data_array["pattern"][1]){
		tmp_cate = "pattern";
		tmp_page = Math.floor( (num-(data_array["pattern"][0]-1)) / 25 );

	}else if(num >= data_array["wa"][0] && num <= data_array["wa"][1]){
		tmp_cate = "wa";
		tmp_page = Math.floor( (num-(data_array["wa"][0]-1)) / 25 );
	}

	MM_nbGroup('down','navbar1','menu_'+tmp_cate,'img/menu/menu_'+tmp_cate+'_d.gif',1);

	if ( tmp_cate == "toughtype" ) {
		var pic_num = 0;
		var img_list = data_array["toughtype"][2];
		for ( var i = 0; i < img_list.length; i++ ) {
			if ( img_list[i] != num ) continue;
			pic_num = i;
			break;
		}
		if(pic_num>0){
			tmp_detail += '<a href="javascript:viewDetail(\''+cate+'\', '+(data_array["toughtype"][2][pic_num-1])+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("preitem","","img/button/preitem_o.gif",1); title="pre"><img name="preitem" src="img/button/preitem.gif" width="80" height="24" border="0" alt="前の商品へ" /></a>';
		}else{
			tmp_detail += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
		}
		tmp_detail += ' <a href="javascript:aboutItem(2);" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("list","","img/button/list_o.gif",1); title="list"><img name="list" src="img/button/list.gif" width="80" height="24" border="0" alt="一覧へ戻る" /></a> ';
		if(pic_num<data_array["toughtype"][2].length-1){
			tmp_detail += ' <a href="javascript:viewDetail(\''+cate+'\', '+(data_array["toughtype"][2][pic_num+1])+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("nextitem","","img/button/nextitem_o.gif",1); title="next"><img name="nextitem" src="img/button/nextitem.gif" width="80" height="24" border="0" alt="次の商品へ" /></a>';
		}else{
			tmp_detail += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
		}

	}
	else {
		if(num>1){
			tmp_detail += '<a href="javascript:viewDetail(\''+cate+'\', '+(num-1)+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("preitem","","img/button/preitem_o.gif",1); title="pre"><img name="preitem" src="img/button/preitem.gif" width="80" height="24" border="0" alt="前の商品へ" /></a>';
		}else{
			tmp_detail += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
		}
		tmp_detail += ' <a href="javascript:changePage(\''+tmp_cate+'\', '+tmp_page+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("list","","img/button/list_o.gif",1); title="list"><img name="list" src="img/button/list.gif" width="80" height="24" border="0" alt="一覧へ戻る" /></a> ';
		if(num<65){
			tmp_detail += ' <a href="javascript:viewDetail(\''+cate+'\', '+(num+1)+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("nextitem","","img/button/nextitem_o.gif",1); title="next"><img name="nextitem" src="img/button/nextitem.gif" width="80" height="24" border="0" alt="次の商品へ" /></a>';
		}else{
			tmp_detail += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
		}

	}


	tmp_detail += '</div>';
	//document.all.insertPage.innerHTML = tmp_detail;
	setHTML("insertPage", tmp_detail);
}

function changePage(cate, page){
	var num=data_array[cate][0]+(page*25); // 画像ID

	var init_num=num;		// 画像番号指定 の時
	var sp_num=0;			// 画像番号指定 の時

	var tmp_table = '<!--<div id="click">商品画像をクリックすると詳細説明が見られます。</div>-->';
	tmp_table += '<table border="0" cellspacing="0" cellpadding="0">';

/*デバッグ	tmp_table += 'デバッグ＜'+page+'＞';*/

	for(var i=0;i<5;i++){
		tmp_table += '<tr>';
		for(var j=0;j<5;j++){
			tmp_table += '<td class="thumb">';
			// 末端チェック（超えたら、<td>の余りに空白をつめる）
			if(num<=data_array[cate][1]){
				// 第三要素がある（画像番号指定方式）の場合
				if ( data_array[cate][2] ) {
					sp_num = data_array[cate][2][(num-init_num)+page];
					tmp_table += '<a href="javascript:viewDetail(\''+cate+'\', '+sp_num+')" title="SL-'+(600+sp_num)+' 詳細へ">';
					tmp_table += '<img src="./img/sl/s/SL_'+(600+sp_num)+'.jpg" border=0 width=113 height=88 alt="SL-'+(600+sp_num)+'" />';
					tmp_table += '<p class="item_name">SL-'+(600+sp_num)+'</p></a>';
				}
				else {
					tmp_table += '<a href="javascript:viewDetail(\''+cate+'\', '+num+')" title="SL-'+(600+num)+' 詳細へ">';
					tmp_table += '<img src="./img/sl/s/SL_'+(600+num)+'.jpg" border=0 width=113 height=88 alt="SL-'+(600+num)+'" />';
					tmp_table += '<p class="item_name">SL-'+(600+num)+'</p></a>';
				}
			}else{
				tmp_table += '&nbsp;';
			}
			tmp_table += '</td>';
			num++;
		}
		// 末端チェック(まだなら続くよ）
		if(num>data_array[cate][1])break;
		tmp_table += '</tr>';
	}
	tmp_table += '</table>';
	tmp_table += '<div id="changeBtn">';
	if(page>0){
		tmp_table += '<a href="javascript:changePage(\''+cate+'\', '+(page-1)+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("preview","","img/button/preview_o.gif",1); title="前のページへ"><img name="preview" src="img/button/preview.gif" width="80" height="24" border="0" alt="前のページへ" /></a>';
	}else{
		tmp_table += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
	}
	if(num<=data_array[cate][1]){
		tmp_table += '<a href="javascript:changePage(\''+cate+'\', '+(page+1)+')" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("next","","img/button/next_o.gif",1); title="次のページへ"><img name="next" src="img/button/next.gif" width="80" height="24" border="0" alt="次のページへ" /></a>';
	}else{
		tmp_table += '<img src="./img/button/bb.gif" width="80" height="24" border="0" alt="" />';
	}

	// 'タフタイプ'の場合はHTMLを返す
	if (cate=='toughtype') {
		return tmp_table;
	}
	else {
		tmp_table += '<br /><a href="javascript:window.close()" onMouseOut=MM_swapImgRestore(); onMouseOver=MM_swapImage("quit","","img/button/quit_o.gif",1); title="終了する"><img name="quit" src="img/button/quit.gif" width="110" height="24" border="0" alt="終了する" /></a>';
		tmp_table += '</div>';
		//document.all.insertPage.innerHTML = tmp_table;
		setHTML("insertPage", tmp_table);
	}
}

function download(num){
	window.open('./img/zip/SL-'+num+'.zip');
}


changePage("all", 0);

