//**********************************************************************
var Enquete = new Array();
Enquete[0] = '200902250000.200903250000<>CROSSROAD TOUR FINAL 赤坂 BLITZでプレイして欲しい曲を1曲選んでリクエストしてください。<>Absent In The Spring:0;All You Miss:0;Answer To This Flower:0;Better Believe Me:0;Bittersweet Ending:1;Broken Wings:0;Burn:0;Crazy Train(OZZY OSBOURNE):0;Enemy:0;Englishman In New York(Sting):0;Everlasting Scene:0;Fade in Time:0;Falling In Love With TV Stars:0;Feel More Alive:0;Fighter Pilot:0;Foxwood Valley:0;Get Back:0;Ghost Of a Man:0;Golden Buzz:0;Good Night My Blue Sapphire:0;Haze in Heart:0;Here It Comes:0;House Of The Rising Sun(THE ANIMALS):0;I May Be:0;I´ll Be Around:0;Isn´t She Lovely(STEVIE WONDER):0;Ivory Serenade:0;Last Call:0;Let´s Roll:0;Lights Up My Soul:0;Look Inside the Mirror:0;Love Won´t Last the Night:0;Malibu Coke:0;Marathon High School:0;Million:0;My Wristwatch:0;Name:0;Norwegian Wood(THE BEATLES):0;Pearls:0;Promise:0;Ride The Wave:0;Scent og the air:0;Shine On Me:0;Ships and Stars:0;Sign:0;Smooth Operator(SADE):0;So Alone:0;Standing On My Side:0;Take Me Home:0;Tell Me Why:0;Ten Second Illusion:0;Terminal:0;The Sun:0;Tomo´s Lullaby:1;Tomorrow:0;Velvet Love:0;Walk Along:0;When Did I Say I Had Enough？:0;Where Do We Go？:0;&<>1<>2<>1<>';

//**********************************************************************
var ul_style = ' style="list-style:circle;margin:5px 2px 5px 20px;padding:5px 2px 5px 2px;color:#333333;font-size:10pt;text-align:left;"';
var ol_style = ' style="list-style:none;margin:2px 0px 2px 0px;padding:5px 0px 5px 0px;color:#666666;font-size:8pt;text-align:left;"';
var li_style = ' style="margin:0px 0px 0px 0px;padding:1px 2px 1px 0px;color:text-align:left;"';
var p_style1 = ' style="margin:0px 0px 10px 0px;padding:2px 2px 5px 2px;color:#ffffff;font-size:11pt;font-weight:bolder;text-align:center;background-color:#226699;"';
var p_style2 = ' style="margin:10px 0px 0px 0px;padding:10px 2px 4px 2px;color:#ffffff;font-size:11pt;font-weight:normal;text-align:center;background-color:#226699;font-size:70%;line-height:200%;"';
//**********************************************************************
function score_check(Num,Timer,QuestionNumber,ii){
	//++++++++++++++++++++
	var enq = new Array();
	    enq = Enquete[Num].split('<>');
	//++++++++++++++++++++
	var Item      = enq[2].split('&');
	var Sentakusu = enq[3].split('&');
	//++++++++++++++++++++
	var sentakusu = Sentakusu[QuestionNumber];
	if(!sentakusu){sentakusu = 1;}
	//++++++++++++++++++++
	var Items = Item[QuestionNumber].split(';');
	//++++++++++++++++++++
	var count = 0;
	for(var i=0;i<Items.length;i++){
		if(!Items[i]){continue;}
		if(document.getElementById('id' + Timer + '-' + QuestionNumber + '-' + i).checked == true){
			count++;
			if(count > sentakusu){
				alert('選択数オーバー！');
				document.getElementById('id' + Timer + '-' + QuestionNumber + '-' + ii).checked = false;
			}
		}
	}
	//++++++++++++++++++++
}
//**********************************************************************
function vote_check(time_num){
	var view = new String();
	view += '以下の内容で投票していいですか？';
	var flag = 0;
	for(var e=0;e<Enquete.length;e++){
		//++++++++++++++++++++
		var enq = new Array();
		    enq = Enquete[e].split('<>');
		//++++++++++++++++++++
		if(enq[0] != time_num){continue;}
		//++++++++++++++++++++
		var Question  = enq[1].split('&');
		var Item      = enq[2].split('&');
		var Sentakusu = enq[3].split('&');
		var Hissu     = enq[5].split('&');
		//++++++++++++++++++++
		for(var q=0;q<Question.length;q++){
			var sentakusu = Sentakusu[q];
			if(!sentakusu){sentakusu = 1;}
			var Items = Item[q].split(';');
			//++++++++++++++++++++
			view += '\n\n■' + Question[q] + '\n\n';
			var count = 0;
			if(sentakusu > 1){
				for(var i=0;i<Items.length;i++){
					if(!Items[i]){continue;}
					var item_cou = Items[i].split(':');
					var id = document.getElementById('id' + time_num + '-' + q + '-' + i);
					if(document.getElementById('id' + time_num + '-' + q + '-' + i).checked == true){
						view += '    ' + item_cou[0] + '\n';
						count++;
						if(count > sentakusu){
							alert('『' + Question[q] + '』\n選択数オーバー！');
							flag++;
						}
					}
				}
			}else if(sentakusu == 1){
				for(var i=0;i<Items.length;i++){
					if(!Items[i]){continue;}
					var item_cou = Items[i].split(':');
					var id = document.getElementsByName(time_num + '-' + q)[i];
					if(id.checked == true){
						view += '    ' + item_cou[0] + '\n';
						count++;
					}
				}
			}
			if(Hissu[q] == 1 && count == 0){
				alert('『' + Question[q] + '』\n\n何か選択してください。\n');
				flag++;
				//break;
			}
		}
	}
	if(flag == 0){
		if(confirm(view)){
			document.enquete.submit();
		}
	}
}
//**********************************************************************
function time_num_change(time_num){
	//++++++++++++++++++++
	var ctime  = time_num.substr(0 ,4) + '年';
	    ctime += time_num.substr(4 ,2) + '月';
	    ctime += time_num.substr(6 ,2) + '日';
	    ctime += time_num.substr(8 ,2) + '時';
	    ctime += time_num.substr(10,2) + '分';
	//++++++++++++++++++++
	return ctime;
}
//**********************************************************************
function view(){
	//++++++++++++++++++++
	var nowDate = new Date();
	var year   = new String(nowDate.getFullYear());
	var month  = nowDate.getMonth() + 1;
	var date   = nowDate.getDate();
	var hour   = nowDate.getHours();
	var minute = nowDate.getMinutes();
	if(month  < 10){month   = new String('0' + month);}
	if(date   < 10){date    = new String('0' + date);}
	if(hour   < 10){hour    = new String('0' + hour);}
	if(minute < 10){minute  = new String('0' + minute);}
	var now_time = year + month + date + hour + minute;
	//++++++++++++++++++++
	var StTime;
	var EnTime;
	var stTimeNum;
	var enTimeNum;
	//++++++++++++++++++++
	var vi = new String();
	vi += '<ul' + ul_style + '>';
	var count = 0;
	for(var e=0;e<Enquete.length;e++){
		//++++++++++++++++++++
		var enq = new Array();
		    enq = Enquete[e].split('<>');
		//++++++++++++++++++++
		//年 月 日 時 分
		var s_e_time = new Array();
		    s_e_time = enq[0].split('.');
		var s_time = s_e_time[0];
		var e_time = s_e_time[1];
		if(now_time >= s_time && now_time <= e_time){
			//++++++++++++++++++++
			//アンケート開始期間
			var stTime = time_num_change(s_time);
			var enTime = time_num_change(e_time);
			if(!StTime){
				StTime    = stTime;
				stTimeNum = s_time;
			}
			if(!EnTime || enTime > EnTime){
				EnTime    = enTime;
				enTimeNum = e_time;
			}
			//++++++++++++++++++++
		    var Question  = enq[1].split('&');
		    var Item      = enq[2].split('&');
		    var Sentakusu = enq[3].split('&');
			//++++++++++++++++++++
			for(var q=0;q<Question.length;q++){
				var sentakusu = Sentakusu[q];
				if(!sentakusu){sentakusu = 1;}
				//++++++++++++++++++++
				vi += '<li' + li_style + '>' + Question[q];
				if(sentakusu > 1){
					vi += '<br>(' + sentakusu + '個まで選択可能)';
				}
				//++++++++++++++++++++
				if(sentakusu > 1){
					vi += checkbox(e,enq[0],q,Item[q],sentakusu);
				}else if(sentakusu == 1){
					vi += radio(e,enq[0],q,Item[q]);
				}
				//++++++++++++++++++++
				vi += '</li>';
				//++++++++++++++++++++
			}
			count++;
		}
	}
	var time_num = stTimeNum + '.' + enTimeNum;
	vi += '</ul>';
	//++++++++++++++++++++
	var view_type = new String('2');
	//++++++++++++++++++++
	var alst = ' style="color:#ffffff;text-decoration:none;margin:3px 0px 3px 0px;padding:0px 0px 0px 0px;"';
	var pmst = ' style="color:#446699;font-size:70%;text-align:center;margin:0px;padding:3px;line-height:120%;"';
	var btst = ' style="border:solid 1px #666666;background-color:#ffffff;"';
	var view = new String();
	view += '<div id="waku" style="width:520px;margin:5px;padding:0px;background-color:#eeffff;border:solid 1px #226699;">';
	view += '<p id="waku_text1"' + p_style1 + '>OCEANLANE TOUR FINAL「みんなで決めるセットリスト」大会！！</p>';
	if(count > 0){
		view += '<form action="http://oceanlane.com/booan/booan.cgi" method="post" name="enquete" style="margin:0px;">';
		view += vi;
		view += '<p'+ pmst+ '>アンケート期間 ';
		view += StTime + ' 〜 ';
		view += EnTime;
		view += '</p>';
		view += '<p id="waku_text2"' + p_style2 + '>';
		view += '<input type="hidden" name="mission" value="vote">';
		view += '<input type="hidden" name="time_num" value="' + time_num + '">';
		view += '<input type="button" value="投票する" onclick="vote_check(' + "'" + time_num + "'" + ');"'+ btst+ '>';
		if(view_type != 3){
			view += '<br><a href="http://oceanlane.com/booan/booan.cgi?mission=enq_result_view&time_num=' + time_num + '"'+ alst+ '>アンケートの結果を見る</a>';
			view += '<!-- br><a href="http://oceanlane.com/booan/booan.cgi?mission=enq_past_view"'+ alst+ '>過去の投票結果を見る</a -->';
		}
		view += '</p>';
		view += '</form>';
	}else{
		view += '<p'+ pmst+ '>只今開催中のアンケートはありません。</p>';
		view += '<p id="waku_text2"' + p_style2 + '>';
		view += '<a href="http://oceanlane.com/booan/booan.cgi?mission=enq_past_view"'+ alst+ '>過去の投票結果を見る</a>';
		view += '</p>';
	}
	view += '</div>';
	//++++++++++++++++++++
	document.getElementById('enquete').innerHTML = view;
	if('1' == 1){
		//角丸加工
		maru('waku','520px','#226699','#ffffff','#eeffff');
	}
}
//**********************************************************************
function checkbox(Num,Timer,QuestionNumber,Item,Sentakusu){
	//++++++++++++++++++++
	var item = new Array();
	    item = Item.split(';');
	//++++++++++++++++++++
	var koumoku = new String();
	koumoku += '<ol' + ol_style + '>';
	for(var i=0;i<item.length;i++){
		if(!item[i]){continue;}
		var item_count = item[i].split(':');
		var name = Timer + '-' + QuestionNumber + '-' + i;
		koumoku += '<li' + li_style + '><input type="checkbox" name="' + name + '" id="id' + name + '" value="' + i + '" onclick="score_check(' + Num + ",'" + Timer + "'," + QuestionNumber + ',' + i + ');">' + item_count[0] + '</li>';
	}
	koumoku += '</ol>';
	//++++++++++++++++++++
	return koumoku;
}
//**********************************************************************
function radio(Num,Timer,QuestionNumber,Item){
	//++++++++++++++++++++
	var item = new Array();
	    item = Item.split(';');
	//++++++++++++++++++++
	var koumoku = new String();
	koumoku += '<ol' + ol_style + '>';
	for(var i=0;i<item.length;i++){
		if(!item[i]){continue;}
		var item_count = item[i].split(':');
		koumoku += '<li' + li_style + '><input type="radio" name="' + Timer + '-' + QuestionNumber + '" value="' + i + '"> ' + item_count[0] + '</li>';
	}
	koumoku += '</ol>';
	//++++++++++++++++++++
	return koumoku;
}
//**********************************************************************
function maru(id,Wid,color1,color2,color3){
	id_style(id,color1,Wid);
	//++++++++++++++++++++
	var stBRtOri1 = ' style="';
	    stBRtOri1 += 'background-color:' + color1 + ';';
	    stBRtOri1 += 'display:block;';
	    stBRtOri1 += 'overflow:hidden;';
	//++++++++++++++++++++
	var st_b_rtop     = ' style="';
	    st_b_rtop    += 'background-color:' + color2 + ';';
	    st_b_rtop    += 'display:block;';
	    st_b_rtop    += 'oveflow:hidden;';
	    st_b_rtop    += 'height:5px;';
	    st_b_rtop    += '"';
	var st_b_rbottom  = ' style="';
	    st_b_rbottom += 'background-color:' + color2 + ';';
	    st_b_rbottom += 'display:block;';
	    st_b_rbottom += 'oveflow:hidden;';
	    st_b_rbottom += 'height:5px;';
	    st_b_rbottom += '"';
	var st_b_rt1      = stBRtOri1;
	    st_b_rt1     += 'height:1px;';
	    st_b_rt1     += 'margin:0px 5px 0px 5px;';
	    st_b_rt1     += '"';
	var st_b_rt2      = stBRtOri1;
	    st_b_rt2     += 'height:1px;';
	    st_b_rt2     += 'margin:0px 3px 0px 3px;';
	    st_b_rt2     += '"';
	var st_b_rt3      = stBRtOri1;
	    st_b_rt3     += 'height:1px;';
	    st_b_rt3     += 'margin:0px 2px 0px 2px;';
	    st_b_rt3     += '"';
	var st_b_rt4      = stBRtOri1;
	    st_b_rt4     += 'height:2px;';
	    st_b_rt4     += 'margin:0px 1px 0px 1px;';
	    st_b_rt4     += '"';
	var st_b_rb1      = stBRtOri1;
	    st_b_rb1     += 'height:1px;';
	    st_b_rb1     += 'margin:0px 5px 0px 5px;';
	    st_b_rb1     += '"';
	var st_b_rb2      = stBRtOri1;
	    st_b_rb2     += 'height:1px;';
	    st_b_rb2     += 'margin:0px 3px 0px 3px;';
	    st_b_rb2     += '"';
	var st_b_rb3      = stBRtOri1;
	    st_b_rb3     += 'height:1px;';
	    st_b_rb3     += 'margin:0px 2px 0px 2px;';
	    st_b_rb3     += '"';
	var st_b_rb4      = stBRtOri1;
	    st_b_rb4     += 'height:2px;';
	    st_b_rb4     += 'margin:0px 1px 0px 1px;';
	    st_b_rb4     += '"';
	//++++++++++++++++++++
	var b1  = '<b' + st_b_rtop    + '>';
	    b1 += '<b' + st_b_rt1 + '></b>';
	    b1 += '<b' + st_b_rt2 + '></b>';
	    b1 += '<b' + st_b_rt3 + '></b>';
	    b1 += '<b' + st_b_rt4 + '></b>';
	    b1 += '</b>';
	var b2  = '<b' + st_b_rbottom + '>';
	    b2 += '<b' + st_b_rb4 + '></b>';
	    b2 += '<b' + st_b_rb3 + '></b>';
	    b2 += '<b' + st_b_rb2 + '></b>';
	    b2 += '<b' + st_b_rb1 + '></b>';
	    b2 += '</b>';
	//++++++++++++++++++++
	var wh1 = '<div style="margin:0px 1px 0px 1px;padding:0px 0px 0px 0px;background-color:' + color3 + ';height:100%;">';
	var wh2 = '</div>';
	//++++++++++++++++++++
	var ori = new String();
	    ori = document.getElementById(id).innerHTML;
	//++++++++++++++++++++
	document.getElementById(id).innerHTML = b1 + wh1 + ori + wh2 + b2;
	//++++++++++++++++++++
}
//**********************************************************************
function id_style(id,color,Wid){
	document.getElementById(id).style.width = Wid;
	document.getElementById(id).style.marginTop    = '0px';
	document.getElementById(id).style.marginRight  = '0px';
	document.getElementById(id).style.marginBottom = '0px';
	document.getElementById(id).style.marginLeft   = '0px';
	document.getElementById(id).style.padding      = '0px';
	document.getElementById(id).style.border       = 'none';
	document.getElementById(id).style.backgroundColor  = color;
}
//**********************************************************************

