var opened = new Array(0, 0, 0, 0, 0, 0, 0);
var opac = new Array(100, 100, 100, 100, 100, 100, 100);
var tt = new Array();
var tt2 = new Array();
var req = false;
var notIE = !(navigator.appVersion.indexOf("MSIE") != -1 && navigator.systemLanguage);
var Mozilla = navigator.userAgent.indexOf("Mozilla") != -1;

if (window.XMLHttpRequest) {
	req = new XMLHttpRequest();
	if (req.overrideMimeType) req.overrideMimeType('text/html');
} else if (window.ActiveXObject) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
}

function show(id)
{
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
	return false;
}

function openm(id)
{
	if(document.getElementById('submenu'+id).style.display != 'inline') document.getElementById('submenu'+id).style.display = 'inline';
	document.getElementById('submenu'+id).style.zIndex = 10000;
	clearTimeout(tt[id]);
	if(notIE){
		if(Mozilla) document.getElementById('submenu'+id).style.setProperty('-moz-opacity',1,null);
		else document.getElementById('submenu'+id).style='opacity: 1';
	} else document.getElementById('submenu'+id).style.filter='alpha(opacity=100)';
	opened[id] = 1;
	opac[id] = 100;
	return false;
}

function closem(id)
{
	opened[id] = 0;
	clearTimeout(tt[id]);
	document.getElementById('submenu'+id).style.zIndex = 9999;
	tt[id] = setTimeout("closemnow("+id+")",300);
	return false;
}

function closemnow(id)
{
	if(opened[id] == 0)
	{
		clearTimeout(tt2[id]);
		if(opac[id]>0) opac[id]-=5;
		if(opac[id]<0) opac[id]=0;
		if(notIE){
			if(Mozilla) document.getElementById('submenu'+id).style.setProperty('-moz-opacity',opac[id]/100,null);
				else document.getElementById('submenu'+id).style="opacity: "+opac[id]/100;
		} else document.getElementById('submenu'+id).style.filter="alpha(opacity="+opac[id]+")";
		tt2[id] = setTimeout("closemnow("+id+")",10);
		if(opac[id]<1){ clearTimeout(tt2[id]); document.getElementById('submenu'+id).style.display = 'none'; }
	}
}

function isEmailCorrect(formname, fieldname) { 
	var re = /^[a-zA-Z0-9\-_](([a-z0-9\-_\.\+\&]?)+[a-z0-9])?\@((\w([a-zA-Z0-9\-_]+)?\.[a-z]{2,4})|(([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d |2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5]))|(localhost))$/i;
	if(re.test(eval("document.forms['"+formname+"']."+fieldname+".value"))) return true;
	else {
		alert("電子メールが違います!");
		eval("document.forms['"+formname+"']."+fieldname+".focus()");
		return false; 
	} 
}

function testKeyDig(e){
	var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
	if (e.ctrlKey || e.altKey || key < 32) return true;
	key = String.fromCharCode(key);
	return /[\d]/.test(key);
}

function showphoto(id)
{
	document.getElementById('main_photo').src='/img/models/big/'+id+'.jpg';
	return false;
}

function strelka(id)
{
	var src = document.getElementById('manuals'+id).style.display=='none' ? 'down' : 'right';
	document.getElementById('str'+id).src='/img/str_'+src+'.gif';
}

function checkform()
{
	var error = '';
	if(document.getElementById('fio').value.length<4) error += 'お名前を入れてください!\n';
	if(document.getElementById('femail').value.length<6) error += '電子メール入れてください!\n';
	if(document.getElementById('model').value==0) error += 'モデルを入れてください!\n';
	if(document.getElementById('quest').value==0) error += '質問を書いてください!';
	if(error != ''){ alert(error); return false; } else return true;
}

function two_selected(all)
{
	var sel = 0;
	for(var i = 1; i <= all; i++) if(document.getElementById('comp'+i).checked) sel += 1;
	return (sel > 1) ? true : false;
}
