﻿var normalbgcol   = "#E6E6E6";
var warningbgcol  = "#FFE0E0";
var warningbgcol2 = "#FFF8F8";
var warningmessage = "必須項目に未入力があります。";
var warningmsghtml = "<table style='width:100%;border:dashed 1px #F00;background-color:#FFC;'><tr><td align='center'>"+warningmessage+"</td></tr></table>";
var retry=0;
function input_check(){
	var res=true;chk=0;
	if(retry!=0){ document.getElementById('categorybg1').style.backgroundColor = document.getElementById('categorybg2').style.backgroundColor = document.getElementById('namebg1').style.backgroundColor = document.getElementById('namebg2').style.backgroundColor = document.getElementById('kanabg1').style.backgroundColor = document.getElementById('kanabg2').style.backgroundColor = document.getElementById('corpbg1').style.backgroundColor = document.getElementById('corpbg2').style.backgroundColor = document.getElementById('emailbg1').style.backgroundColor = document.getElementById('emailbg2').style.backgroundColor = document.getElementById('telbg1').style.backgroundColor = document.getElementById('telbg2').style.backgroundColor = document.getElementById('contentsbg1').style.backgroundColor = document.getElementById('contentsbg2').style.backgroundColor = normalbgcol; }
	for(var i=0;i<document.form1.elements['nw--category'].length;i++){ if(document.form1.elements['nw--category'][i].checked) chk=1; }
	if(chk==0){ document.getElementById('categorybg1').style.backgroundColor = document.getElementById('categorybg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--name1'].value=='' || document.form1.elements['nw--name2'].value==''){ document.getElementById('namebg1').style.backgroundColor = document.getElementById('namebg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--kana1'].value=='' || document.form1.elements['nw--kana2'].value==''){ document.getElementById('kanabg1').style.backgroundColor = document.getElementById('kanabg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--corp'].value==''){ document.getElementById('corpbg1').style.backgroundColor = document.getElementById('corpbg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--station'].value==''){ document.getElementById('stationbg1').style.backgroundColor = document.getElementById('stationbg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['ne--email'].value==''){ document.getElementById('emailbg1').style.backgroundColor = document.getElementById('emailbg2').style.backgroundColor = warningbgcol; res=false; }
	//if(document.form1.elements['nr--email'].value==''){ document.getElementById('emailbg3').style.backgroundColor = document.getElementById('emailbg4').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--tel'].value==''){ document.getElementById('telbg1').style.backgroundColor = document.getElementById('telbg2').style.backgroundColor = warningbgcol; res=false; }
	if(document.form1.elements['nw--contents'].value==''){ document.getElementById('contentsbg1').style.backgroundColor = document.getElementById('contentsbg2').style.backgroundColor = warningbgcol; res=false; }
	if(res==false){ document.getElementById('warningmessagetop').innerHTML = document.getElementById('warningmessagebottom').innerHTML = warningmsghtml; window.scroll(0,300); }
	else { document.getElementById('warningmessagetop').innerHTML = document.getElementById('warningmessagebottom').innerHTML = ""; }
	retry++;
	return res;
}
function check(p){
	if(retry==0) return;
	if(p==1){
		var chk=0;
		for(var i=0;i<document.form1.elements['nw--category'].length;i++){ if(document.form1.elements['nw--category'][i].checked) chk=1; }
		if(chk==1){ document.getElementById('categorybg1').style.backgroundColor = document.getElementById('categorybg2').style.backgroundColor = normalbgcol; }
	}
	if(p==2 && document.form1.elements['nw--name1'].value!='' && document.form1.elements['nw--name2'].value!=''){ document.getElementById('namebg1').style.backgroundColor = document.getElementById('namebg2').style.backgroundColor = normalbgcol; }
	if(p==3 && document.form1.elements['nw--kana1'].value!='' && document.form1.elements['nw--kana2'].value!=''){ document.getElementById('kanabg1').style.backgroundColor = document.getElementById('kanabg2').style.backgroundColor = normalbgcol; }
	if(p==4 && document.form1.elements['nw--corp'].value!=''){ document.getElementById('corpbg1').style.backgroundColor = document.getElementById('corpbg2').style.backgroundColor = normalbgcol; }
	if(p==5 && document.form1.elements['ne--email'].value!=''){ document.getElementById('emailbg1').style.backgroundColor = document.getElementById('emailbg2').style.backgroundColor = normalbgcol; }
	if(p==5 && document.form1.elements['nr--email'].value!=''){ document.getElementById('emailbg3').style.backgroundColor = document.getElementById('emailbg4').style.backgroundColor = normalbgcol; }
	if(p==6 && document.form1.elements['nw--tel'].value!=''){ document.getElementById('telbg1').style.backgroundColor = document.getElementById('telbg2').style.backgroundColor = normalbgcol; }
	if(p==7 && document.form1.elements['nw--contents'].value!=''){ document.getElementById('contentsbg1').style.backgroundColor = document.getElementById('contentsbg2').style.backgroundColor = normalbgcol; }
	if(p==8 && document.form1.elements['nw--station'].value!=''){ document.getElementById('stationbg1').style.backgroundColor = document.getElementById('stationbg2').style.backgroundColor = normalbgcol; }
	input_check();
}

