var Max_List = 20;
function loadEvent(){
	loadeventDBMenu('crewcrew', encodeURL('event_db ED LEFT JOIN eventsupport_db ESD ON (ED.f_eventnumber = ESD.f_eventnumber or ED.f_sscode = ESD.f_creator)'),encodeURL('WHERE (BIN_AND(ED.f_flags,1)=0) and (ED.f_visibleflags != 8) and (f_publishdate &lt;= CURRENT_DATE) and (ESD.f_sscode = \''+ crewcrewcode + '\') and (ED.f_enddate >= CURRENT_DATE)'), '<a href="http://www.crewcrew.net/" target="_blank">くるくる</a>のオススメ');
	loadeventDBMenu('event', encodeURL('event_db ED LEFT JOIN eventsupport_db ESD ON (ED.f_eventnumber = ESD.f_eventnumber or ED.f_sscode = ESD.f_creator)'),encodeURL('WHERE (BIN_AND(ED.f_flags,1)=0) and (ED.f_visibleflags != 8) and (f_publishdate &lt;= CURRENT_DATE) and ((ED.f_sscode = \''+ stationcode + '\') or (ESD.f_sscode = \''+ stationcode + '\')) and (ED.f_enddate >= CURRENT_DATE)'), 'イベント･セミナー');
}

function loadeventDBMenu(id, tableName, Where, Title){
	var xmlhttp = createXMLHttp();
	if (xmlhttp){
		xmlhttp.onreadystatechange = function () {
			geteventDB(xmlhttp, id, Title);
		};
   	if ( typeof ActiveXObject!="undefined" ) {
			xmlhttp.open('POST', 'cgi/selectwsdl.cgi', true);
		} else {
			xmlhttp.open('POST', 'cgi/selectwsdl.cgi');
		}
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send('table=' + tableName + '&field=DISTINCT ED.f_eventnumber,ED.f_title,ED.f_catch,ED.f_startdate,ED.f_enddate&order=' + encodeURL('ED.f_enddate ASC') + '&where=' + Where + '&quot="');
	}else{
		alert("サーバーにアクセスできませんでした");
	}
}
function geteventDB(xmlhttp, id, Title){
	var hMes = '';
	var i, listData, Line, Count = 0;
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
		listData = xmlhttp.responseText.substr(0, xmlhttp.responseText.lastIndexOf('"')).substr(1).split('"\n"');
		hMes += '<table width="100%" align="center" border="0" cellpadding="2" cellspacing="0" class="waku">';
		hMes += '<tr><td valign="middle" align="center" class="wakutitle">';
		hMes += Title;
		hMes += '</td></tr>';
		hMes += '<tr><td valign="top">';
		hMes += '<dl>';
		for (i = 0; (i < Max_List) && (i < listData.length); i++){
			if (listData[i] != ''){
				Line = listData[i].split('","');
				if (Line[3] == Line[4]){
					hMes += '<dt>・<a href="http://www.crewcrew.net/cgi/wsdb_temp.cgi?template=temp_event_data.html&f_eventnumber=' + Line[0] + '" target="sub" class="link">' + Line[3].substr(5) + ':' + Line[1] + '</a></dt>';
				} else {
					hMes += '<dt>・<a href="http://www.crewcrew.net/cgi/wsdb_temp.cgi?template=temp_event_data.html&f_eventnumber=' + Line[0] + '" target="sub" class="link">' + Line[3].substr(5) + '-' + Line[4].substr(5) + ':' + Line[1] + '</a></dt>';
				}
				if (Line[2] != ''){
					hMes += '<dd class="comment">' + Line[2].replace(/\n/g, '<br>') + '</a></dd>';
				}
				Count++;
			}
		}
		hMes += '</dl>';
		hMes += '</td></tr>';
		hMes += '</table>';
		if (Count == 0){
			hMes = '';
		}
		DispHTML(id, hMes);
	}
}

