// JavaScript Document

var imgOn  = new Array();
var imgOff = new Array();


function init() {

	document.getElementById('style').value  = '';
	
	for (i=1; i<style.length; i++) {
		imgOn['style'+i]  = "/img/up/style_over/"+ style[i] + ".gif";
		imgOff['style'+i] = "/img/up/style_top/"+ style[i] + ".gif";
	}
	for (i=1; i<area.length; i++) {
		imgOn['area'+i]  = "/img/top/area" + i + "-on.gif";
		imgOff['area'+i] = "/img/top/area" + i + "-off.gif";
	}

	return false;

}


function selectBtn(type, no, init) {

	if (type == 'style') { name = 'style';   ar = style; }
	if (type == 'area')  { name = 'area_id'; ar = area;  }

	// FFでF5を押すとform値がなぜか残る。その対応。
	if (init)
		val = '';
	else
		val = document.getElementById(name).value;

	// 選択解除
	if (ar[no] == val) {

		obj = document.getElementById(type + no);
		obj.src = imgOff[obj.id];
		obj.onmouseover = function () {this.src=imgOn[this.id];}
		obj.onmouseout = function () {this.src=imgOff[this.id];}

		document.getElementById(name).value  = '';

	// 選択
	} else {

		for (i=1; i<ar.length; i++) {
			obj = document.getElementById(type + i);

			if (i == no) {
				obj.src = imgOn[obj.id];
				obj.onmouseover = '';
				obj.onmouseout = '';
				document.getElementById(name).value  = ar[i];

			// 他は未選択画像セット
			} else {
				obj.src = imgOff[obj.id];
				obj.onmouseover = function () {this.src=imgOn[this.id];}
				obj.onmouseout = function () {this.src=imgOff[this.id];}
			}
		}

	}

	return false;

}


function mOver(obj, fname) {
	obj.src = fname;
	return false;

}

function mOut(obj, fname) {
	obj.src = fname;
	return false;

}
