// JavaScript Document


function mou_over(data) {

	var id = data;
	var obj = document.getElementById(id);
	obj.style.background = "#CC0000";

}



function mou_out(data) {

	var id = data;
	var obj = document.getElementById(id);
	obj.style.background = "#999999";

}


function close_win(data) {
	var num_1 = data;
	var id_1 = "popwindow";
	var obj = document.getElementById(id_1);
	document.getElementById(id_1).style.visibility = "hidden";
}



function PopWinOpen(data,data2) {

//for (i=1; i<=51; i++) {
//	var id_1 = "sumnail" + i;
//	var obj = document.getElementById(id_1);
//	document.getElementById(id_1).style.visibility = "hidden";
//	}

var num_1 = data; // where
var num_2 = data2; //file number
var num_3 = num_1 + num_2; //per number

//--------------------------
//Popup windows name
//--------------------------

var id_1 = "popwindow";
var obj = document.getElementById(id_1);


//Make Page
var txt = "";
txt = txt + '<div id="pop_window">';
txt = txt + '<div><img src="images/common/popwin_top.jpg" alt="" width="540" height="20"></div>';
txt = txt + '<div class="pop_innner">';




if ( num_2 == "info") {

//データGET
var com_txt = ComListData2(num_1);


arytest = new Array;
arytest = com_txt.split("<>");

var name = arytest[0]; //Designer
var comment = arytest[1]; //Comment

obj.style.visibility = "visible";

txt = txt + '<div class="d_name">' + name + '</div>';

if (comment != "") {
	txt = txt + '<div class="d_comment">' + comment + '</div>';
} else {
	txt = txt + '<div class="space clear" style="height:40px;">&nbsp;</div>';
}

txt = txt + '<div class="space clear" style="height:10px;">&nbsp;</div>';

txt = txt + '<div id="pop_close" class="bnt_close" style="margin:auto;cursor:pointer;" onClick="close_win(' + num_1 + ')"><span>Close</span></div>';
txt = txt + '</div>';
txt = txt + '<div><img src="images/common/popwin_bottom.jpg" alt="" width="540" height="10"></div>';
txt = txt + '</div>';

//Data UP
obj.innerHTML = txt;

} else {


txt = txt + '<div class="pop_img">';

//Data GET
var com_txt = ComListData(num_3);

arytest = new Array;
arytest = com_txt.split("#");

var name_com = arytest[0]; //company
var name_item = arytest[1]; //item
var file_name = arytest[2]; //file nake
var name_designer = arytest[3]; //designer
var contents = arytest[4]; //text
var comming = "Coming soon";

if(name_com != ""){
obj.style.visibility = "visible";
}


//Left Text area
if(file_name != "") {
	txt = txt + '<img src="images/img/' + file_name + '.jpg" alt="' + name_item + '"></div>';
	}else{
	txt = txt + '<img src="images/img/noimage.jpg" alt="no-image"></div>';
	}

//Right Text area
txt = txt + '<div class="pop_txt">';
txt = txt + '<div class="pop_txt_upper">';

if ((name_com != "") && (name_com != "none")) {
	txt = txt + '<div class="pop_com">' + name_com + '</div>';
}

if ((name_item != "") && (name_item != "#")) {
		txt = txt + '<div class="pop_item">' + name_item + '</div>';  //item
}
	
if ((name_item != "") && (name_item != "#")) {
		
	if (num_3 == "361") {
		txt = txt + '<div class="pop_designer">' + name_designer + '</div>';  //designer
	} else {
		txt = txt + '<div class="pop_designer">Designer : ' + name_designer + '</div>';  //designer
	}
}

txt = txt + '</div>';


//Data roop check
var name_item2;
var file_name2;
var count = 0;
var name_item2 = new Array;
var file_name2 = new Array;

//Check until 10 images
for (i=1; i<=10; i++) {

	var num_4 = num_1 + i;

	com_txt = ComListData(num_4);

	if(com_txt != "") {
		arytest = com_txt.split("#");

		name_item2[i] = arytest[1];
		file_name2[i] = arytest[2];

		count = count + 1;

	}else{
		break;
	}
}

//Visible unvisible Sumnail  more 2images is visible
if(count > 1) {

	txt = txt + '<div class="pop_txt_under">';

	for (i=1; i<=count; i++) {

		var active_num = "";
		var txt2;
		
		active_num = data + i;

		if (active_num == num_3) {
			
			if (file_name2[i] == "") {
				txt = txt + '<div class="pop_img_s_active"><img src="images/img/noimage.jpg" alt="no-image"></div>';
			} else {
				txt = txt + '<div class="pop_img_s_active"><img src="images/img/' + file_name2[i] + '.jpg" alt="' + name_item2[i] + '"></div>';
			}
			
		}else{
			
			if (file_name2[i] == "") {
			txt = txt + '<div class="pop_img_s" id="popsum' + active_num + '" onMouseOver="mou_over(' + "'" + 'popsum' + active_num + "'" + ');" onMouseOut="mou_out(' + "'" + 'popsum' + active_num + "'" + ');" onClick="PopWinOpen(' + "'" + data + "'" + ',' + "'" +　i + "'" + ');"><img src="images/img/noimage.jpg" alt="no-image"></div>';
			} else {
				txt = txt + '<div class="pop_img_s" id="popsum' + active_num + '" onMouseOver="mou_over(' + "'" + 'popsum' + active_num + "'" + ');" onMouseOut="mou_out(' + "'" + 'popsum' + active_num + "'" + ');" onClick="PopWinOpen(' + "'" + data + "'" + ',' + "'" +　i + "'" + ');"><img src="images/img/' + file_name2[i] + '.jpg" alt="' + name_item2[i] + '"></div>';
			}
			
		}
	}

	txt = txt + '<div class="space clear" style="height:1px;">&nbsp;</div>';
	txt = txt + '</div>';

}

txt = txt + '</div>';
txt = txt + '<div class="space clear" style="height:10px;">&nbsp;</div>';


	if ((contents != "") && (contents != "#")) {
		txt = txt + contents;
	}

txt = txt + '<div id="pop_close" class="bnt_close" style="margin:auto;cursor:pointer;" onClick="close_win(' + num_1 + ')"><span>Close</span></div>';
txt = txt + '</div>';
txt = txt + '<div><img src="images/common/popwin_bottom.jpg" alt="" width="540" height="10"></div>';
txt = txt + '</div>';


	
//Data UP
obj.innerHTML = txt;

if (num_3 == 691 ){
	document.getElementById('pop_window').style.top = "10px";
} else {
	document.getElementById('pop_window').style.top = "100px";
}
	





}

}