﻿	
	function setDistrictName() {
		// District
		var districtname = $F('districtname');
		if (districtname == "") {
	//		requestDistrictName();
		} else {
			set_district(districtname);
		}
	}
	
	/************************************************************************************************
	 * District情報をinputフィールドに設定する
	 */
	function set_district(name)
	{
		$('districtname').value = name;
		
		//districtを設定するとregionもcountryも設定されることになる
		$('countryname').value = name;
		$('regionname').value = getRegion(name);
		$('countryname').value = LS_COUNTRY_JAPAN;
		
		//場所
		var d = $('placeinfo');
		if (d) {
			var html = '<a class="place" href="javascript:districtSelect(\'' + name + '\')">' + name + '</a>';
			html = html + '<a class="placechange" href="javascript:districtSelect(\'\')">[場所の変更]</a>';
			d.innerHTML = html;
		}
	}
	
	var Region1 = ["北海道"];
	var Region2 = ["青森", "岩手", "宮城", "秋田", "山形", "福島"];
	var Region3 = ["東京", "神奈川", "埼玉", "千葉", "茨城", "栃木", "群馬", "山梨"];
	var Region4 = ["新潟", "長野"];
	var Region5 = ["富山", "石川", "福井"];
	var Region6 = ["愛知", "岐阜", "静岡", "三重"];
	var Region7 = ["大阪", "兵庫", "京都", "滋賀", "奈良", "和歌山"];
	var Region8 = ["鳥取", "島根", "岡山", "広島", "山口"];
	var Region9 = ["徳島", "香川", "愛媛", "高知"];
	var Region10 = ["福岡", "佐賀", "長崎", "熊本", "大分", "宮崎", "鹿児島"];
	var Region11 = ["沖縄"];
	
	var Region2a = ["青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県"];
	var Region3a = ["東京都", "神奈川県", "埼玉県", "千葉県", "茨城県", "栃木県", "群馬県", "山梨県"];
	var Region4a = ["新潟県", "長野県"];
	var Region5a = ["富山県", "石川県", "福井県"];
	var Region6a = ["愛知県", "岐阜県", "静岡県", "三重県"];
	var Region7a = ["大阪府", "兵庫県", "京都府", "滋賀県", "奈良県", "和歌山県"];
	var Region8a = ["鳥取県", "島根県", "岡山県", "広島県", "山口県"];
	var Region9a = ["徳島県", "香川県", "愛媛県", "高知県"];
	var Region10a = ["福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県"];
	var Region11a = ["沖縄県"];
	
	/**
	 * 文字列から都道府県名を探し、見つかった都道府県名を返す
	 */
	function wherePlace(str) {
		var regions = [Region1, Region2, Region3, Region4, Region5, Region6, Region7, Region8, Region9, Region10, Region11];
		for (var j=0; j<regions.length; j++) {
			var region = regions[j];
			for (var i=0; i<region.length; i++) {
				if (str.indexOf(region[i]) != -1)
					return region[i];
			}
		}
		return "";
	}
	
	function getDistricts(regionname) {
		if (regionname == "北海道") {
			return Region1;
		}
		else if (regionname == "東北") {
			return Region2;
		}
		else if (regionname == "関東") {
			return Region3;
		}
		else if (regionname == "信越") {
			return Region4;
		}
		else if (regionname == "北陸") {
			return Region5;
		}
		else if (regionname == "東海") {
			return Region6;
		}
		else if (regionname == "近畿") {
			return Region7;
		}
		else if (regionname == "中国") {
			return Region8;
		}
		else if (regionname == "四国") {
			return Region9;
		}
		else if (regionname == "九州") {
			return Region10;
		}
		else if (regionname == "沖縄") {
			return Region11;
		}
		return null;
	}
	function getRegion(name) {
		var region = "";
		
		if (Region1.join(",").indexOf(name) >= 0) {
			region = "北海道";
		}
		else if (Region2.join(",").indexOf(name) >= 0 || Region2a.join(",").indexOf(name) >= 0) {
			region = "東北";
		}
		else if (Region3.join(",").indexOf(name) >= 0 || Region3a.join(",").indexOf(name) >= 0) {
			region = "関東";
		}
		else if (Region4.join(",").indexOf(name) >= 0 || Region4a.join(",").indexOf(name) >= 0) {
			region = "信越";
		}
		else if (Region5.join(",").indexOf(name) >= 0 || Region5a.join(",").indexOf(name) >= 0) {
			region = "北陸";
		}
		else if (Region6.join(",").indexOf(name) >= 0 || Region6a.join(",").indexOf(name) >= 0) {
			region = "東海";
		}
		else if (Region7.join(",").indexOf(name) >= 0 || Region7a.join(",").indexOf(name) >= 0) {
			region = "近畿";
		}
		else if (Region8.join(",").indexOf(name) >= 0 || Region8a.join(",").indexOf(name) >= 0) {
			region = "中国";
		}
		else if (Region9.join(",").indexOf(name) >= 0 || Region9a.join(",").indexOf(name) >= 0) {
			region = "四国";
		}
		else if (Region10.join(",").indexOf(name) >= 0 || Region10a.join(",").indexOf(name) >= 0) {
			region = "九州";
		}
		else if (Region11.join(",").indexOf(name) >= 0 || Region11a.join(",").indexOf(name) >= 0) {
			region = "沖縄";
		}
		return region;
	}
	
	/**
	 * ログインユーザのDistrictNameをリクエストする
	 * ログインしてない場合はデフォルトの東京になる。
	 */
	function requestDistrictName()
	{
		var userid = sessionid;
		if (userid == null || userid == "") {
			set_district(LS_DEFAULT_DISTRICT_NAME);
		}
		else {
			var url = LS_LIB_DBJSON_URL + 'getDistrictName.php';
			var pars = 'userid=' + userid + "&currenttime=" + new Date().getTime();
			var myAjax = new Ajax.Request(
				url, 
				{
					method: 'get', 
					parameters: pars,
					onComplete: responseDistrictName
				});
		}
	}
	
	/**
	 * 受け取ったDistrictNameを設定する
	 */
	function responseDistrictName(req)
	{
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		set_district(data[0].name);
	}
	
	
	function submitURL(url) {
		if (url.indexOf("../") == 0)
			url = url.replace("..", LS_CONTENTS_URL);
		
		document.maindata.action = url;
		
		//値のないフィールドを削除する
		inputs = $('maindata').getElementsByTagName('input');
		var nodes = $A(inputs);
		nodes.each(function(node){
			if (node.value == null || node.value == "")
				Element.remove(node);
			if (node.name == "offset" && node.value == "0")
				Element.remove(node);
			});
		
		document.maindata.submit();
	}
	
	/**
	 * 値を確認する
	 * ユーザ名、場所
	 */
	function checkValues()
	{
		var res = true;
		
		
		if (sessionid == "" || sessionusername == "")
		{
			//set_user();
			res = false;
		}
		
		//検索値のチェック
		checkSearchValue();
		
		return res;
	}
	
	/*****************************************************
	 * 自分のユーザイメージを設定する
	 */
	function userImage() {
		var userid = sessionid
		if (userid != "") {
			requestUserImage(userid);
		}
	}
	/*****************************************************
	 * ユーザイメージをリクエストする
	 */
	function requestUserImage(userid) {
		var url = LS_LIB_DBJSON_URL + 'getUserInfo.php';
		var pars = 'userid=' + userid + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseUserImage
			});
	}
	/*****************************************************
	 * ユーザイメージを設定する
	 */
	function responseUserImage(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var userid = sessionid;
		
		// イメージ設定
		var imagepath = data.imagepath;
		if (imagepath != "") {
			html = '<a href="javascript:goUserPage(' + userid + ')"><img id="signinuserimage" src="/event/images/' + toSSImagePath(imagepath) + '"/></a>';
			var d = $('userimage');
			if (d) {
				d.innerHTML = html;
			}
		}
		// フルネーム設定
		var fullname = data.fullname;
		if (fullname == null || fullname == "") {
			fullname = sessionusername;
		}
		var html = '<nobr>ようこそ<a href="javascript:goUserPage(' + userid + ')">' + fullname + '</a>さん</nobr>';
		d = $('welcomename');
		if (d) {
			d.innerHTML = html;
		}
		
		//ポジション調整
		$('userimage').setStyle({
			'left': '50%',
			'margin-left': '-440px'
		});
		$('welcomename').setStyle({
			'left': '50%',
			'margin-left': '-410px'
		});
		
		checkCount();
	}
	
	/**
	 * 検索値を確認する
	 */
	function checkSearchValue() {
		if ($('searchwhatvalue')) {
			if ($('searchwhatvalue').value == null || $('searchwhatvalue').value.length == 0) {
				$('fsearchwhat').value = DEFAULT_WHAT_VALUE
			} else {
				$('fsearchwhat').value  = $('searchwhatvalue').value;
			}
		}
	//	if ($('searchwherevalue')) {
	//		if ($('searchwherevalue').value == null || $('searchwherevalue').value.length == 0) {
	//			$('fsearchwhere').value = DEFAULT_WHERE_VALUE;
	//		} else {
	//			$('fsearchwhere').value  = $('searchwherevalue').value;
	//		}
	//	}
	}
	
	function fsearchwhatclick() {
		if ($('fsearchwhat').value == DEFAULT_WHAT_VALUE)
			$('fsearchwhat').value = "";
		else if ($('fsearchwhat').value == "")
			$('fsearchwhat').value = DEFAULT_WHAT_VALUE;
	}
	function fsearchwhereclick() {
		if($('fsearchwhere').value == DEFAULT_WHERE_VALUE)
			$('fsearchwhere').value = "";
		else if ($('fsearchwhere').value == "")
			$('fsearchwhere').value = DEFAULT_WHERE_VALUE;
	}
	
	/************************************************************************************************
	 * ユーザ情報をセッション情報からinputフィールドに設定する
	 */
	function set_user()
	{
		//$('userid').value = sessionid;
		//$('username').value = sessionusername;
	}
	
	/**
	 * 場所を指定してイベントを表示する　or　場所指定する
	 */
	function districtSelect(districtname) {
		
		if (districtname == "") {
			//district指定
			regionselectdialog_show();
		}
		else {
		//	$('districtname').value = districtname;
		//	goHome();
			
			setSearch("district", districtname);
		}
	}
	/***********************************************************************************************
	 * 週イベントViewを作成する
	 */
	function createWeekEventListView() {
		var datelist = new Array();
		var districtname = $F('districtname');
		var date = getTodayString();
		
		var html = "";
		
		html = html + '<table>';
		for (var i=1; i<8; i++) {
			datelist[i-1] = date.substr(0);
			if (i == 1){
				//今日
			} else {
				html = html + '<tr class="cwtevent">';
				html = html + ' <td class="cwtday" id="' + date + 'a"><a href="javascript:goDateSearchPage2(' + date + ', ' + "'daystart'" + ')">' + getDayString(date) + '</a></td>';
				html = html + ' <td class="cwtnone">';
				html = html + '  <div align="left" id="' + date + '"></div>';
				html = html + ' </td>';
				html = html + '</tr>';
				if (i == 7) {
					
				} else {
					html = html + '<tr class="cwtline">';
					html = html + ' <td colspan="3"></td>';
					html = html + '</tr>';
				}
			}
			date = getDateString(i);
		}
		html = html + '</table>';
		
		
		var d = $('comingweektable');
		d.innerHTML += html;
		
		checkcount = 0;
		
		var limit = 6; //本日で表示するイベント数
		
		for (var i=0; i<datelist.length; i++) {
			if (i==0) {
				//今日
				requestTodayEvents(districtname, datelist[i], limit);
			} else {
				requestDateEvents(districtname, datelist[i], limit);
			}
		}
	}
	
	/**
	 * 今日のイベントリストをリクエストする
	 */
	function requestTodayEvents(districtname, date, limit) {
		//console.log("districtname=" + districtname);
		//console.log("date=" + date);
		//console.log("limit=" + limit);
		
		var url = LS_LIB_DBJSON_URL + 'getEventsBySearchKeys.php';
		var pars = 'st1=date&sk1=' + date + '&order=desc&limit=' + limit + "&currenttime=" + new Date().getTime();
		
		
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseTodayEvents
			});
	}
	
	/**
	 * 今日のイベントリストをHTMLとして追記する
	 */
	function responseTodayEvents(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var date = new Date();
		var datestr = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日 イベント" + data[3][0].eventcount + "件";
		var html = '<div id="todayEventstitle"><a href="javascript:goTodayEventsPage()">' + datestr + '</a></div>';
		html += createEventInfoHTMLForUIMultiLine(data[0], 1);
		html += '<table width="100%"><tr><td align="right" class="more"><a href="javascript:goTodayEventsPage()">もっと見る</a></td></tr></table>';
		
		var da = $("todayevents");
		da.innerHTML = html;
		
		setEventInfoWidth(1);
		
		//イメージの見栄え修正Javascript
		addEffect();
		
		checkCount();
		
		//今日始まるイベント数取得
		requestTodayStartEventsCount("", getTodayString(), 1);
	}
	
	/**
	 * 今日のイベントリストの件数をリクエストする
	 */
	function requestTodayStartEventsCount(districtname, date, limit) {
		var url = LS_LIB_DBJSON_URL + 'getDateEvents.php';
		var pars = 'districtname=' + districtname + '&date=' + date + '&limit=' + limit + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseTodayStartEventsCount
			});
	}
	/**
	 * 今日のイベントリストをHTMLとして追記する
	 */
	function responseTodayStartEventsCount(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var html = '&nbsp;(本日始まるイベント ' + data[0][0].eventcount + '件)';
		
		var da = $("todayEventstitle");
		da.innerHTML += html;
		
		checkCount();
	}
	
	function addEffect() {
		//今はなにもしない
		//setTimeout("imageEffect()", 1000);
		//setTimeout("addReflections()", 1000);
	}
	
	function imageEffect() {
		if(glossyOnload) {
			glossyOnload();
			if(isIE){
				addIEGlossy();
			} else {
				addGlossy();
			}
		}
	}
	
	/****************************************************************************************************
	 * 日付チェックする　昨日、今日、明日、明後日の場合、その文字列を返す
	 */
	function hizuke(date) {
		var strdate = date.substring(date.indexOf(",")+1);
		dd = new Date();
		y = dd.getYear();
		m = dd.getMonth() + 1;
		d = dd.getDate();
		if (strdate == m + "/" + d)
			return "今日";
		
		dd.setTime(dd.getTime() + 1000*60*60*24);
		y = dd.getYear();
		m = dd.getMonth() + 1;
		d = dd.getDate();
		if (strdate == m + "/" + d)
			return "明日";
		
		dd.setTime(dd.getTime() + 1000*60*60*24);
		y = dd.getYear();
		m = dd.getMonth() + 1;
		d = dd.getDate();
		if (strdate == m + "/" + d)
			return "明後日";
		
		dd.setTime(dd.getTime() - 3000*60*60*24);
		y = dd.getYear();
		m = dd.getMonth() + 1;
		d = dd.getDate();
		if (strdate == m + "/" + d)
			return "昨日";
		
		
		strdate = strdate.replace("/", "月");
		
		return strdate + "日";
	}
	/****************************************************************************************************
	 * 年が現在の年と異なる場合に年数を返す
	 */
	function getYearStr(date) {
		if (date != null) {
			dd = new Date();
			y = dd.getYear();
			if (y < 2000) { y += 1900; }
			if (date.substr(0, 4) != y) {
				return date.substr(0, 4) + "年";
			}
		}
		return "";
	}
	
	/****************************************************************************************************
	 * UI用のイベントをリスト表示するHTMLを作成して返す]
	 * 結局Tableにした・・・
	 */
	function createEventInfoHTMLForUI(data) {
		return createEventInfoHTMLForUIMultiLine(data, 1);
	}
	
	/**
	 * サイズ調整
	 */
	function setEventInfoWidth(line) {
		
		//css change
		var width = 611;
		var newwidth = Math.round((width - (75 * line)) / line);
		
		var f = $$('p.weekinfo_title');
		if (f != null) {
			for(var i=0; i<f.length; i++){
				f[i].setStyle({
					'width': newwidth
				});
			}
		}
		f = $$('p.weekinfo_content');
		if (f != null) {
			for(var i=0; i<f.length; i++){
				f[i].setStyle({
					'width': newwidth
				});
			}
		}
	}
	
	function createEventInfoHTMLForUIMultiLine(data, line) {
		
		var url = location.href;
		
		var eventposition = 0;
		var moreArray = new Array();
		
		var html = "";
		if (data.length == 0) {
			if ($F('otherkey') == "action" && $F('othervalue') == "watch") {
				if (url.indexOf('/watchlist.php') > 0) {
					html += '<div id="reszero">';
					html += '<br/>';
					html += '<br/>';
					html += 'ウォッチリストにイベントが登録されていません。<br/>';
					html += '<br/>';
					html += 'イベントの期日を過ぎたイベントは表示されません。<br/>';
					html += 'ウォッチリストに登録した過去のイベントを見るには「<a href="javascript:SearchKeyIncludePast()">過去のイベントを含めて検索</a>」をクリックして下さい。';
					html += '<br/>';
					html += '<br/>';
					html += '<br/>';
					html += '<br/>';
					html += 'ウォッチリストにイベントを登録するには、<br/>';
					html += 'ウォッチリストに登録したいイベントを表示し、<img src="/event/images/watch_info2.png"/>をクリックします。<br/>';
					html += '<br/>';
					html += '<img src="/event/images/watch_info1.png"/><br/>';
					html += '</div>';
				}
			} else if ($F('otherkey') == "owner") {
				html += '<div id="reszero">';
				html += '<br/>';
				html += '<br/>';
				html += '投稿したイベントはありません。<br/>';
				html += '<br/>';
				html += 'イベントの期日を過ぎたイベントは表示されません。<br/>';
				html += '登録した過去のイベントを見るには「<a href="javascript:SearchKeyIncludePast()">過去のイベントを含めて検索</a>」をクリックして下さい。';
				html += '</div>';
			} else {
				html += '<div id="reszero">';
				html += "<br/>";
				html += "<br/>";
				html += createBreadcrumbsHTML(false, true) + "で検索しましたが、イベントは見つかりませんでした。<br/>";
				html += "<br/>";
				html += "<br/>";
				html += "<br/>";
				html += "検索のヒント：<br/>";
				html += "<br/>";
				html += "イベント検索は、徐々に絞り込まれていきます。<br/>";
				html += "最初にタグの中から「アート」をクリックして、<br/>";
				html += "次にキーワードに「現代」と入力した場合は、ページ上部に、<br/>";
				html += "<br/>";
				html += "イベント＞タグ「アート」＞キーワード「現代」<br/>";
				html += "<br/>";
				html += "と表示されます。この場合、タグ「アート」を含むイベントで、さらに「現代」も含まれているイベントが表示されます。<br/>";
				html += "検索条件を元に戻すには、ページ上部リンクをクリックして下さい。<br/>";
				html += "タグ「アート」をクリックすると、タグ「アート」が含まれるイベントが表示されます。<br/>";
				html += "「イベント」をクリックすると検索条件はなくなり、トップページに戻ります。";
				html += '</div>';
			}
		} else {
			for (var i=0; i<data.length; i++) {
				if (eventposition == 0) {
					html += '<div class="weekinfo">';
					html += '<table>';
					html += '<tr>';
				}
				
				html += '<td valign="center" width="75" rowspan="2">';
				
				if (data[i].imagepath != null && data[i].imagepath.length > 0) {
					html += '<p class="weekinfo_image"><a href="javascript:goEventPage(' + data[i].id + ')"><img class="glossy" src="/event/images/' + toSmallImagePath(data[i].imagepath) + '"/></a></p>';
				} else {
					html += '<p class="weekinfo_image"><a href="javascript:goEventPage(' + data[i].id + ')"><img class="glossy" src="/event/images/event_noimage_60x60.png"/></a></p>';
				}
				html += '</td>';
				html += '<td valign="top">';
				var eventname = data[i].eventname;
				eventname = getShortString(eventname, 520 - 20, 'ruler20');
				html += '<p class="weekinfo_title">';
				if ($F('otherkey') == "action" && $F('othervalue') == "watch") {
					if (url.indexOf('/watchlist.php') > 0) {
						html += '<a href="javascript:removeWatch(' + data[i].id + ')"><img class="watchdelete" title="ウォッチリストから削除する" src="/event/images/delete.gif"></a>';
					}
				}
				html += '<a href="javascript:goEventPage(' + data[i].id + ')">' + eventname + '</a>';
				html += '</p>';
				html += '<p class="weekinfo_content">';
				
				var contentstr = "";
				
				if (data[i].allday != "1") {
					//console.log("非終日");
					//非終日イベント
					if (data[i].invalidenddate == "0") {
						contentstr += getYearStr(data[i].startdate) + hizuke(data[i].sdate) + "&nbsp;" + data[i].stime;
						contentstr += "&nbsp;-&nbsp;" + getYearStr(data[i].enddate) + hizuke(data[i].edate) + "&nbsp;" + data[i].etime;
					} else {
						contentstr += hizuke(data[i].sdate) + "&nbsp;" + data[i].stime;
					}
				} else {
					//console.log("終日");
					//終日イベント
					var startdate = data[i].sdate;
					var enddate = data[i].edateforallday;
					if (enddate == null || enddate == "") {
						//icsからのイベントの場合とか
						var enddate = data[i].edate;
					}
					
					if (hizuke(startdate) == hizuke(enddate)) {
						contentstr += getYearStr(data[i].startdate) + hizuke(startdate);
					} else {
						if (data[i].invalidenddate == "0") {
							contentstr += hizuke(startdate)
							contentstr += "&nbsp;-&nbsp;" + getYearStr(data[i].enddate) + hizuke(enddate);
						} else {
							contentstr += getYearStr(data[i].startdate) + hizuke(startdate);
						}
					}
				}
				
				var address = "";
				if (data[i].place != "" || data[i].address != "" || data[i].postcode != "") {
					address = "at " + data[i].place + ' ' + data[i].postcode + ' ' + data[i].address;
				}
				
				var datelengthstr = contentstr.replace("&nbsp;", " ");
				while (datelengthstr.indexOf("&nbsp;") >= 0) {
					datelengthstr = datelengthstr.replace("&nbsp;", " ");
				}
				var datelength = getExtent(datelengthstr, 'ruler');
				address = getShortString(address, 520 - datelength, 'ruler');
				
				// Comment or PV or Address
				if (data[i].commentcount != null && data[i].commentcount != "") {
					contentstr += '&nbsp;&nbsp;&nbsp;<font class="bluetext">コメント数 ' + data[i].commentcount + '件</font>';
				} else if (data[i].rank != null && data[i].rank != "") {
					contentstr += '&nbsp;&nbsp;&nbsp;<font class="bluetext">アクセス数 ' + data[i].rank + 'PV</font>';
				} else if (data[i].adddate != null && data[i].adddate != "") {
					contentstr += '&nbsp;&nbsp;&nbsp;<font class="bluetext">' + data[i].adddate + '</font>';
				} else {
					contentstr += '&nbsp;&nbsp;&nbsp;' + address;
				}
				html += contentstr;
				
				html += '</p>';
				
				var description = shortDescription(data[i].description, 100, 1, true);
				description = getShortString(description, 520, 'ruler');
				
				html += '<p class="weekinfo_content">' + description + '</p>';
				html += '</td>';
				
				moreArray[eventposition] = data[i].id;
				
				if (eventposition == line-1 || i == data.length-1) {
					
					if (i == data.length-1) {
						if (moreArray.length < line) {
							html += '<td valign="top" width="75" rowspan="2"></td><td><p class="weekinfo_title"></p></td>';
						}
					}
					
					html += '</tr>';
					html += '<tr>';
					
					for (var m=0; m<moreArray.length; m++) {
						html += '<td align="right" valign="bottom">';
		//				html += '<a class="weekinfo_more" href="javascript:goEventPage(' + moreArray[m] + ')">[more...]</a>';
						html += '</td>';
					}
					
					html += '</tr>';
					html += '</table>';
					html += '</div>';
					
					eventposition = 0;
					moreArray = new Array();
				}
				else {
					eventposition++;
				}
			}
		}
		return html;
	}
	
	
	/**********************
	 * 長い文字列を切る
	 *
	 * 文字列
	 * 最大長
	 * 最大行
	 * 改行削除するか
	 */
	function shortDescription(str, maxlength, maxline, delbr) {
		var description = str;
		if (description != null) {
			if (delbr)
				description = cutBR(description);
			
			if (description.length > maxlength) {
				description = description.substr(0, maxlength) + "...";
			}
			var p=0;
			var line=1;
			var last = description.lastIndexOf("<br/>");
			if (last != -1) {
				while (p < last) {
					p = description.indexOf("<br/>", p) + 4;
					line++;
					if (line > maxline) {
						description = description.substr(0, p-4) + "...";
						break;
					}
				}
			}
		} else {
			description = "";
		}
		return description;
	}
	/************************
	 * 改行をカットする
	 */
	function cutBR(str) {
		var res = str;
		while (res.indexOf("<br/>") >= 0) {
			res = res.replace("<br/>", "");
		}
		return res;
	}
	
	function getOffset() {
		var offset = $F('offset');
		if (offset == null || offset == "")
			offset = 0;//デフォルトは0
		return offset;
	}
	
	
	/****************************************************************************************************
	 * イベントの検索結果でRSSとICSのリンクを出すかどうかを判断する
	 */
	function idNeedLinks() {
		var district = 0;
		var date = 0;
		var tag = 0;
		var word = 0;
		var type = "";
		for (var i=1; i<=10; i++) {
			type = $F('st' + i);
			if (type != null && type != "") {
				if (type == "district") {
					district++;
					if (district > 1)
						return false;
				} else if (type == "date") {
					date++;
					if (date > 1)
						return false;
				} else if (type == "tag") {
					tag++;
					if (tag > 1)
						return false;
				} else if (type == "word") {
					word++;
					if (word > 1)
						return false;
				}
			}
		}
		return true;
	}
	
	/****************************************************************************************************
	 * ウォッチリスト用のリンクを出すかどうかを判断する
	 */
	function isWatchList() {
		var url = location.href;
		if (url.indexOf("/home/watchlist.php") > 0) {
			return true;
		}
		return false;
	}
	
	
	/****************************************************************************************************
	 * UI用のイベントをリスト表示するときのページ番号部分のHTMLを作成して返す
	 *
	 * goDateSearchPageByOffset,goTagPageByOffset
	 */
	function createEventPageCountHTMLForUI(data, scriptname) {
		var eventcount = parseInt(data[0].eventcount);
		
		var limit = $F('limit');
		if (limit == null || limit == "" || limit == 0)
			limit = 10;
		var offset = getOffset();
		var pagecount = Math.ceil(eventcount/limit);
		
		var html = '';
		
		html += "<div id='eventcontents'>";
		
		if (eventcount == 1000) {
			html += "<div id='pagesize'>" + eventcount + "件以上</div>";
		} else {
			html += "<div id='pagesize'>" + "全" + eventcount + "件</div>";
		}
		
		html += '<div id="subscribe">';
		if (eventcount != null && eventcount > 0) {
			if (($F('otherkey') == null || $F('otherkey') == "") && $F('st1') != null && $F('st1') != "" ) {
				if (idNeedLinks()) {
					html += ' <a href="javascript:subscribe(\'rss\')"><img src="/event/images/rss.png"/></a>';
					html += ' <a href="javascript:subscribe(\'ics\')"><img src="/event/images/ics.png"/></a>';
				}
			}
			
			//ウォッチリストの場合
			if (isWatchList()) {
					html += ' <a href="webcal://api.c2talk.net/event/rest?method=watchlist.list&type=ics&rdata=full"><img src="/event/images/c2talk.png" title="ウォッチリストをc2talkに追加"/></a>';
			}
		}
		html += '</div>';
		
		html += "<div id='pages'>";
		if (pagecount > 1) {
			if (offset != 0) {
				var newoffset = parseInt(offset) - parseInt(limit);
				html += "<a href='javascript:" + scriptname + "(0)'><img id='navigateimage' src='/event/images/navigate_left2.png' title='最初のページ'/></a>&nbsp;&nbsp;";
				html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'><img id='navigateimage' src='/event/images/navigate_left.png' title='前のページ'/></a>&nbsp;&nbsp;";
			} else {
				html += "<img id='navigateimageglay' src='/event/images/navigate_left2.png'/>&nbsp;<img id='navigateimageglay' src='/event/images/navigate_left.png'/>&nbsp;&nbsp;";
			}
			
			var frontPlus = 5 - (pagecount - offset / limit - 1);
			if (frontPlus <= 0) {
				frontPlus = 0;
			}
			var viewPageMax = 10;
			for (var i=0; i<pagecount; i++) {
				var newoffset = parseInt(limit) * i;
				var page = parseInt(i) + 1;
				
				if (i==0 && offset > (limit * 4)) {
					if (i==0 && offset > (limit * (5+frontPlus))) {
						html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'>" + page + "</a>&nbsp;&nbsp;...&nbsp;&nbsp;";
					} else {
						html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'>" + page + "</a>&nbsp;&nbsp;";
					}
					viewPageMax--;
				}
				
				else if (offset == newoffset) {
					html += '<font id="selectpage">' + page + '</font>&nbsp;&nbsp;';
					viewPageMax--;
				}
				else if (offset - (limit * (4 + frontPlus)) > newoffset) {
					//何もしない
				}
				else if (offset + (limit * 9) < newoffset) {
					//何もしない
					if (page <= pagecount + 2) {
						if (page != pagecount) {
							html += "...&nbsp;&nbsp;";
						}
						newoffset = parseInt(limit) * (pagecount - 1);
						page = parseInt(pagecount-1) + 1;
						html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'>" + page + "</a>&nbsp;&nbsp;";
					}
					
					break;
				}
				else {
					if (viewPageMax > 0) {
						html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'>" + page + "</a>&nbsp;&nbsp;";
						viewPageMax--;
					} else {
						if (page <= pagecount + 2) {
							if (page != pagecount) {
								html += "...&nbsp;&nbsp;";
							}
							newoffset = parseInt(limit) * (pagecount - 1);
							page = parseInt(pagecount-1) + 1;
							html += "<a href='javascript:" + scriptname + "(" + newoffset + ")'>" + page + "</a>&nbsp;&nbsp;";
						}
						
						break;
					}
				}
			}
			
			
			if (offset != limit * (pagecount-1)) {
				var newoffset = parseInt(offset) + parseInt(limit);
				var lastoffset = parseInt(limit) * (parseInt(pagecount) - 1);
				html += "<a href='javascript:" + scriptname + "(" + newoffset  + ")'><img id='navigateimage' src='/event/images/navigate_right.png' title='次のページ'/></a>&nbsp;&nbsp;";
				html += "<a href='javascript:" + scriptname + "(" + lastoffset + ")'><img id='navigateimage' src='/event/images/navigate_right2.png' title='最後のページ'/></a>&nbsp;&nbsp;";
			} else {
				html += "<img id='navigateimageglay' src='/event/images/navigate_right.png'/>&nbsp;<img id='navigateimageglay' src='/event/images/navigate_right2.png'/></a>&nbsp;&nbsp;";
			}
		}
		html += "</div>";
		
		html += "</div>";
		
		return html;
	}
	
	
	/**
	 * 週イベントリストをリクエストする
	 */
	function requestDateEvents(districtname, date, limit) {
		var url = LS_LIB_DBJSON_URL + 'getDateEvents.php';
		var pars = 'districtname=' + districtname + '&date=' + date + '&limit=' + limit + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseDateEvents
			});
	}
	
	/**
	 * 週イベントリストをHTMLとして追記する
	 */
	function responseDateEvents(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		var dateymd = '';
		var html = '<table id="daytable"><tr>';
		for (var i=0; i<data[1].length; i++) {
			if (i != 0 && i % 2 != 1)
				html += '</tr><tr>';
			html += '<td id="icon"><a class="title" href="javascript:goEventPage(' + data[1][i].id + ')">';
			if (data[1][i].imagepath != null && data[1][i].imagepath != "")
				html += '<img src="/event/images/' + toSSImagePath(data[1][i].imagepath) + '">'
			else 
				html += '<img src="/event/images/event_noimage_20x20.png"/>'
			html += '</a></td><td><a class="title" href="javascript:goEventPage(' + data[1][i].id + ')">';
			html += getShortString(data[1][i].eventname, 212, 'ruler14') + '</a>';
			html += '</td>';
			
			var html2 = "";
			var kaigyou = false;
		/*
		時間は表示しないことにする
			if (data[1][i].allday != "1") {
				if (data[1][i].sdate != data[1][i].edate) {
					html2 += data[1][i].sdate + " " + data[1][i].stime;
					if (data[1][i].invalidenddate == "0")
						html2 += " - " + data[1][i].edate + " " + data[1][i].etime;
				} else {
					html2 += data[1][i].stime;
					if (data[1][i].invalidenddate == "0")
						html2 += " - " + data[1][i].etime;
				}
				kaigyou = true;
			} else {
				if (data[1][i].sdate != data[1][i].edate) {
					html2 += data[1][i].sdate;
					if (data[1][i].invalidenddate == "0")
						html2 += " - " + data[1][i].edate;
					kaigyou = true;
				}
			}
		*/
		/*
		タイトル以外は表示しないことにする
			if (data[1][i].place != "" || data[1][i].address != "" || data[1][i].postcode != "") {
				if (kaigyou)
					html2 += "<br/>";
				html2 += " at " + data[1][i].place + ' ' + data[1][i].address + ' ' + data[1][i].postcode;
			} else {
				var description = shortDescription(data[1][i].description, 80, 2, false);
				if (description != "") {
					if (kaigyou)
						html2 += "<br/>";
					html2 += description;
				}
			}
			if (html2 != "") {
				html += '<span>' + html2 + '</span>';
			}
		*/
			dateymd = data[1][i].dateymd;
		}
		html += '</tr></table>';
		
		if (data.length > 0) {
			var d = $(dateymd);
			d.innerHTML = html;
		}
		checkCount();
	}
	//カウント数
	var checkcount = 0;
	//実行されるカウント
	var checkExecuteCount = 7;
	//実行する回数を設定
	function setCheckExecuteCount(count) {
		checkExecuteCount = count;
		checkcount = 0;
//console.log("setCheckExecuteCount " + count);
	}
	
	//カウント
	function checkCount(){
		checkcount++;
		
		if (viewmode == 2) {
			//Tag読まない
			PlusCount = 0;
		}
		
//console.log(checkcount + "  " + (checkExecuteCount + PlusCount));
		
		if (checkcount == checkExecuteCount + PlusCount) {
			
//console.log("execute");
			if (!isIE6 && !isSAFARI2) {
				// Flushのロゴストップ
				flushLogoStop();
			}
			
			checkcount = 0;
			
			if (!isIE6 && !isSAFARI2) {
				//
				//　マウスのリスナ開始
				//
				mouseListenStart();
			}
		}
	}
	function getTodayString() {
		var dd = new Date();
		var yy = dd.getYear();
		var mm = dd.getMonth() + 1;
		dd = dd.getDate();
		if (yy < 2000) { yy += 1900; }
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		return "" + yy + mm + dd;
	}
	
	function getDateString(plus) {
		var dd = new Date();
		dd.setTime(dd.getTime() + plus * 24 * 3600 * 1000);
		var yy = dd.getYear();
		var mm = dd.getMonth() + 1;
		dd = dd.getDate();
		if (yy < 2000) { yy += 1900; }
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		return "" + yy + mm + dd;
	}
	
	/****************************************************
	 * 文字列から日付オブジェクトにする
	 */
	function toDateFromString(date) {
		var month = 0;
		if (date.substr(4,1) == "0") {
			month = parseInt(date.substr(5,1))-1;
		} else {
			month = parseInt(date.substr(4,2))-1;
		}
		var d = 0;
		if (date.substr(6,1) == "0") {
			d = parseInt(date.substr(7,1));
		} else {
			d = parseInt(date.substr(6,2));
		}
		var dd = new Date(date.substr(0,4), month, d);
		return dd;
	}
	
	function getDateStringPlusDateString(date, plus) {
		var month = 0;
		if (date.substr(4,1) == "0") {
			month = parseInt(date.substr(5,1))-1;
		} else {
			month = parseInt(date.substr(4,2))-1;
		}
		var d = 0;
		if (date.substr(6,1) == "0") {
			d = parseInt(date.substr(7,1));
		} else {
			d = parseInt(date.substr(6,2));
		}
		var dd = new Date(date.substr(0,4), month, d);
		dd.setTime(dd.getTime() + plus * 24 * 3600 * 1000);
		var yy = dd.getYear();
		var mm = dd.getMonth() + 1;
		dd = dd.getDate();
		if (yy < 2000) { yy += 1900; }
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		return "" + yy + mm + dd;
	}
	
	function getDatePlusDateString(dd, plus) {
		dd.setTime(dd.getTime() + plus * 24 * 3600 * 1000);
		var yy = dd.getYear();
		var mm = dd.getMonth() + 1;
		dd = dd.getDate();
		if (yy < 2000) { yy += 1900; }
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		return "" + yy + mm + dd;
	}
	/**
	 * 週イベントの日付の部分で使用
	 */
	function getDayString(date) {
		
		var month = 0;
		if (date.substr(4,1) == "0") {
			month = parseInt(date.substr(5,1));
		} else {
			month = parseInt(date.substr(4,2));
		}
		var d = 0;
		if (date.substr(6,1) == "0") {
			d = parseInt(date.substr(7,1));
		} else {
			d = parseInt(date.substr(6,2));
		}
		var dd = new Date(date.substr(0,4), month - 1, d);
		var english = dd.toString().substr(0,3);
		
		return month + "/" + d + "<br>(" + toJapaneseDay(english) + ")";
	}
	function toJapaneseDay(name) {
		if (name == "Mon" || name == "Monday") {
			return "月";
		}
		else if (name == "Tue" || name == "Tuesday") {
			return "火";
		}
		else if (name == "Wed" || name == "Wednesday") {
			return "水";
		}
		else if (name == "Thu" || name == "Thursday") {
			return "木";
		}
		else if (name == "Fri" || name == "Friday") {
			return "金";
		}
		else if (name == "Sat" || name == "Saturday") {
			return "土";
		}
		else if (name == "Sun" || name == "Sunday") {
			return "日";
		}
	}
	function toMonthNumber(name) {
		if (name == "January" || name == "Jan") {
			return "1";
		}
		else if (name == "February" || name == "Feb") {
			return "2";
		}
		else if (name == "March" || name == "Mar") {
			return "3";
		}
		else if (name == "April" || name == "Apr") {
			return "4";
		}
		else if (name == "May" || name == "May") {
			return "5";
		}
		else if (name == "June" || name == "Jun") {
			return "6";
		}
		else if (name == "July" || name == "Jul") {
			return "7";
		}
		else if (name == "August" || name == "Aug") {
			return "8";
		}
		else if (name == "September" || name == "Sep") {
			return "9";
		}
		else if (name == "October" || name == "Oct") {
			return "10";
		}
		else if (name == "November" || name == "Nov") {
			return "11";
		}
		else if (name == "December" || name == "Dec") {
			return "12";
		}
	}
	
	
	////////////////////////////////////////////////////////////////////////////////////////////
	
	
	/*
	 * placeページの国へ飛ぶ
	 */
	function showCountryPlacesPage() {
		$('regionid').value = "";
		$('districtid').value = "";
		$('placeid').value = "";
		submitURL('../places/place.php');
	}
	
	/*
	 * placeページの地域へ飛ぶ
	 */
	function showRegionPlacesPage() {
		$('districtid').value = "";
		$('placeid').value = "";
		submitURL('../places/place.php');
	}
	
	/*
	 * いらなくなるかも
	 * placeページの地区へ飛ぶ
	 */
	function showDistrictPlacesPage() {
		$('placeid').value = "";
		submitURL('../places/place.php');
		//submitURL('../district/district.php');
	}
	
	function goSelectEventPage() {
		submitURL('../eventinfo/eventinfo.php');
	}
	
	function goEventPage(eventid) {
		//$('eventid').value = eventid;
		//submitURL('../eventinfo/eventinfo.php');
		
		$('eventid').value = "";
		submitURL("../../id/" + eventid);
	}
	
	function goEventPage2(eventid) {
		location.href = LS_EVENT_PAGE_URL + eventid;
	}
	
	function goUserPage(selectuserid) {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('selectuserid').value = selectuserid;
		
		if (selectuserid != sessionid) {
			submitURL(LS_ACCOUNT_URL + 'user.php');
		} else {
			//ログインユーザ自身はSSL
			submitURL('https://' + SERVER_NAME + LS_ACCOUNT_URL + 'user.php');
		}
	}
	
	function goAllTagsPage() {
		$('tagname').value = "";
		submitURL('../tags/tags.php');
	}
	
	function goTagPage(tagname) {
		$('offset').value = "";
		
		setSearch("tag", tagname);
	}
	
	function goTagPageMulti(tagnames) {
		
		//検索キーをすべて削除
		removeKeys(0);
		
		if (tagnames != null) {
			setSearch("tag", tagnames.split(","));
		}
	}
	
	function goTagPageByOffset(offset) {
		$('offset').value = offset;
		
		searchByKeys();
	}
	
	function goDateSearchPage(date) {
		$('offset').value = "";
		
		goDateSearchPage2(date, "");
	}
	function goDateSearchPage2(date, type) {
		$('selecttype').value = type;
		$('selectdates').value = date;
		
		setSearch("date", date);
	}
	
	function goDateSearchPageByOffset(offset) {
		$('offset').value = offset;
		
		searchByKeys();
	}
	
	function goWatchListPage() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('otherkey').value = "action";
		$('othervalue').value = "watch";
		
		$('offset').value = "";
		submitURL('../home/watchlist.php');
	}
	function goWatchListPageByOffset(offset) {
		$('offset').value = offset;
		submitURL('../home/watchlist.php');
	}
	
	function goAttendListPage() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('offset').value = "";
		submitURL('../home/attendlist.php');
	}
	function goAttendListPageByOffset(offset) {
		$('offset').value = offset;
		submitURL('../home/attendlist.php');
	}
	
	function goUserCreateListPage() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('otherkey').value = "owner";
		$('othervalue').value = sessionid;
		
		$('offset').value = "";
		submitURL('../home/userlist.php');
	}
	function goUserCreateListPageByOffset(offset) {
		$('offset').value = offset;
		submitURL('../home/userlist.php');
	}
	
	function goSelectUserCreateListPageByOffset(offset) {
		$('offset').value = offset;
		submitURL('../account/user.php');
	}
	
	function goContactsPage() {
		submitURL('../contacts/contacts.php');
	}
	
	function goAddNewEventPage() {
		if (sessionid != "") {
			submitURL(LS_ADD_NEW_EVENT_URL);
		} else {
			$('nextpage').value = LS_ADD_NEW_EVENT_URL;
			messagedialog_show("サインインするとイベントを追加することができます。");  
		}
	}
	
	function goAddNewEventPageWithValue(title, date, url) {
		if (sessionid != "") {
			$('title').value = title;
			$('date').value = date;
			$('url').value = url;
			submitURL(LS_ADD_NEW_EVENT_URL);
		} else {
			$('title').value = title;
			$('date').value = date;
			$('url').value = url;
			$('nextpage').value = LS_ADD_NEW_EVENT_URL;
			messagedialog_show("サインインするとイベントを追加することができます。");
			
			setTimeout("goHome()", 2000);
		}
	}
	
	function goBlogPartsPage() {
		//ブログパーツページに行く
		submitURL(LS_BLOGPARTSPAGE_URL);
	}
	
	function goHistoryPage() {
		//検索キーをすべて削除
		removeKeys(0);
		$('offset').value = 0;
		
		submitURL(LS_HISTORYPAGE_URL);
	}
	
	function goHome() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('eventid').value = "";
		$('selectdates').value = "";
		$('offset').value = "";
		$('limit').value = "";
		$('calendarid').value = "";
		$('calendarkey').value = "";
		$('includepast').value = "";
		
		submitURL(LS_HOMEPAGE_URL);
	}
	
	function goTodayEventsPage() {
		goDateSearchPage2(getTodayString(), 'daystart');
	}
	
	function accounthome() {
		$('districtname').value = "";
		$('selectdates').value = "";
		
		goHome();
	}
	
	function setSort(type) {
		if (type == "date") {
			$('sort').value = type;
			$('offset').value = 0;
		} else if (type == "rank") {
			$('sort').value = type;
			$('offset').value = 0;
		} else if (type == "comment") {
			$('sort').value = type;
			$('offset').value = 0;
		} else {
			$('sort').value = "";
			$('offset').value = 0;
		}
		
		searchByKeys();
	}
	
	/**
	 * イベントランキングのページへ飛ぶ
	 */
	function goEventRankingPage() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('eventid').value = "";
		$('selectdates').value = "";
		$('offset').value = "";
		$('limit').value = "";
		
		submitURL(LS_RANKING_URL);
	}
	
	/**
	 * 新規登録イベントリストのページへ飛ぶ
	 */
	function goNewEventListPage() {
		//検索キーをすべて削除
		removeKeys(0);
		
		$('eventid').value = "";
		$('selectdates').value = "";
		$('offset').value = "";
		$('limit').value = "";
		
		submitURL(LS_NEWLIST_URL);
	}
	
	/****************************
	 * Calendar
	 */
	function goCalendarHome() {
		$('calendarid').value = "";
		$('offset').value = 0;
		$('searchwherevalue').value = "";
		
		submitURL(LS_CALENDAR_HOMEPAGE_URL);
	}
	
	function changeValueCalendarHome() {
		submitURL(LS_CALENDAR_HOMEPAGE_URL);
	}
	
	function goCalendarInfo(id) {
		$('calendarid').value = id;
		
		// 注：場所情報は削除される
		//calendarid以外のフィールドを削除する
		inputs = $('maindata').getElementsByTagName('input');
		var nodes = $A(inputs);
		nodes.each(function(node){
			if (node.name != "calendarid")
				Element.remove(node);
			});
		
		submitURL('../calendar/index.php');
	}
	
	/****************************
	 * イベントの編集
	 */
	function editEvent(eventid) {
		$('districtname').value = "";
		$('selectdates').value = "";
		
		$('eventid').value = eventid;
		submitURL(LS_EVENT_EDIT_URL);
	}
	
	/****************************
	 * イベントの削除
	 */
	function removeEvent(eventid) {
		var html = "";
		html += '<input type="button" value="削除する" onclick="confirmdialog_hide();requestRemoveEvent(' + eventid + ')">';
		html += '<input type="button" value="キャンセル" onclick="confirmdialog_hide()">';
		
		confirmdialog_show("本当にイベントを削除しますか？", html);
	}
	function requestRemoveEvent(eventid) {
		var url = LS_LIB_DBJSON_URL + 'removeEvent.php';
		var pars = 'eventid=' + eventid + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseRemoveEvent
			});
	}
	
	function responseRemoveEvent(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		
		eval(text);
		
		if (data.result) {
			messagedialog_show("イベントを削除しました。");
		} else {
			messagedialog_show("イベントの削除に失敗しました。");
		}
		
		setTimeout("goNext()", 2000);
	}
	
	function goNext() {
		
		otherkey = $F('otherkey');
		othervalue = $F('othervalue');
		
		if (otherkey == "owner") {
			if ($F('selectuserid') != null && $F('selectuserid') != "") {
				goUserPage($F('selectuserid'));
			} else {
				goUserCreateListPage();
			}
			return;
		} else if (otherkey == "action") {
			submitURL(LS_SEARCH_BY_KEYS_URL);
			return;
		}
		
		st1 = $F('st1');
		if (st1 != null && st1 != "") {
			submitURL(LS_SEARCH_BY_KEYS_URL);
			return;
		}
		
		goHome();
	}
	
	
	function searchEvents(offset) {
	//	$('districtname').value = "";
		$('selectdates').value = "";
		
		$('offset').value = offset;
		
		var what = $F('fsearchwhat');
	//	var where = $F('fsearchwhere');
		var search = false;
		if (what == "" || what == DEFAULT_WHAT_VALUE) {
			what = "";
		} else {
			search = true;
		}
	//	if (where == DEFAULT_WHERE_VALUE) {
	//		where = "";
	//	} else {
	//		search = true;
	//	}
		if (search) {
	//		$('searchwhatvalue').value = what;
	//		$('searchwherevalue').value = where;
	//		submitURL(LS_SEARCH_RESULTPAGE_URL);
			
			setSearch("word", what);
			
		} else {
			messagedialog_show("検索する文字列を入力して下さい。");
		}
	}
	
	/***************************************************************
	 * 検索に入力された文字をチェックする
	 * Enterなら検索を実行する
	 */
	function searchCheck(ev) {
		//console.log(ev.keyCode);
		if (ev.keyCode == 13) {
			searchEvents(0);
		}
	}
	
	/*************************************************************************************************************
	 * イベントの場所指定で、入力された値より、
	 * CSISシンプルジオコーディング実験(CSIS Simple Geocoding Experiment)で住所から緯度経度を取得する
	 */
	function geoSearch() {
		var d = $('placelist');
		d.innerHTML = "";
		
		var addr = $('neplaceaddress').value;
		requestCSISGeocode(addr);
	}
	/**
	 * CSISに緯度経度をリクエストする
	 */
	function requestCSISGeocode(addr) {
		var url = LS_CSIS_GEOCODE_URL;
		var pars = "addr=" + addr + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'GET', 
				parameters: pars,
				onComplete: responseCSISGeocode
			});
	}
	function responseCSISGeocode(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		//ダイアログに追記する
		html = '';
		for (var i=0; i<data.length; i++) {
			html += '<li id="placeitem"><a href=\'javascript:selectGeocode("' + data[i].lat + '", "' + data[i].lon + '", "' + data[i].address+ '", "' + data[i].iLvl + '")\'>' + data[i].address + '</li>';
		}
		var d = $('placelist');
		d.innerHTML += html;
		
		if (data.length == 0) {
			messagedialog_show('住所から緯度経度を検索できませんでした。');
		} else {
			//検索結果をダイアログ表示する
			placeselectdialog_show();
		}
	}
	/**
	 * 選択した緯度経度を設定する
	 */
	function selectGeocode(lat, lon, addr, ilvl) {
		$('neplacelatitude').value = lat;
		$('neplacelongitude').value = lon;
		//ダイアログ隠す
		placeselectdialog_hide();
		
		//地図表示
		mapChange();
	}
	
	/*************************************************************************************************************
	 * イベントの場所指定で、入力された値より、
	 * placedataから検索する
	 *  +
	 * YahooAPIで緯度経度を取得し、regeocodeで住所を取得する
	 */
	function locationCheck() {
		var loc = $('nelocation').value;
		
		var d = $('placelist');
		d.innerHTML = "";
		
		requestPlaceDataSearch(loc);
		
	}
	/**
	 * placedataを検索して、指定した文字列をplacenameに含むものを列挙する
	 */
	function requestPlaceDataSearch(location) {
		//検索したものはリセット
		selectPlaceNames = new Array();
		
		var url = LS_LIB_DBJSON_URL + "getSearchPlaceData.php";
		var pars = "text=" + location + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'GET', 
				parameters: pars,
				onComplete: responsePlaceDataSearch
			});
	}
	function responsePlaceDataSearch(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		//ダイアログに追記する
		html = "";
		if (data != null) {
			for (var i=0; i<data.length; i++) {
				html += '<li id="placeitem"><a href=\'javascript:selectPlaceData("' + data[i].id + '")\'>' + data[i].name + " " + data[i].address + '</li>';
				selectPlaceNames[i] = data[i].name;
			}
		}
		var d = $('placelist');
		d.innerHTML += html;
		
		var loc = $('nelocation').value;
		requestYahooLocalSearch(loc);
	}
	var selectPlaceNames = null;
	
	/**
	 * 指定したidのplacedataを選択する
	 */
	function selectPlaceData(placeid) {
		
		//※
		//requestLocationListByPlaceID(placeid);
		requestLocationdata(placeid);
		
		//ダイアログ隠す
		placeselectdialog_hide();
	}
	
	/**
	 * YahooAPIで緯度経度を取得
	 */
	function requestYahooLocalSearch(location) {
		var url = LS_YAHOO_LOCAL_SEARCH_URL;
		var pars = "p=" + location + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'GET', 
				parameters: pars,
				onComplete: responseYahooLocalSearch
			});
	}
	function responseYahooLocalSearch(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		//ダイアログに追記する
		html = "";
		for (var i=0; i<data.length; i++) {
			exist = false;
			for (var z=0; z<selectPlaceNames.length; z++) {
				if (selectPlaceNames[z] == data[i].title) {
					exist = true;
					break;
				}
			}
			//console.log(exist + " " + data[i].title );
			if (!exist) {
				var title = data[i].title;
				if (title != data[i].address)
					title += " " + data[i].address;
				html += '<li id="placeitem"><a href=\'javascript:searchRGeocode("' + data[i].title + '", "' + data[i].address + '", "' + data[i].lon+ '", "' + data[i].lat + '")\'>' + title + '</li>';
				selectPlaceNames[selectPlaceNames.length] = data[i].title;
			}
		}
		var d = $('placelist');
		d.innerHTML += html;
		
		if (data.length == 0) {
			messagedialog_show('場所の情報が見つかりませんでした。');
		} else {
			//検索結果をダイアログ表示する
			placeselectdialog_show();
		}
	}
	
	var selectTitle = "";
	var selectDistrict = "";
	var selectAddress = "";
	var selectPostCode = "";
	var selectLon = "";
	var selectLat = "";
	
	function searchRGeocode(title, address, lon, lat) {
		selectTitle = title;
		selectAddress = address;
		selectLon = lon;
		selectLat = lat;
		
		//文字列から都道府県を検索
		var res = wherePlace(title + address)
		if (res != "") {
			selectDistrict = res;
		}
		
		//県が取得できる場合は、title,addressをplacedataのplacename,addressに入れる
		//取得できない場合は、locationに突っ込む
	//	requestRGeocode(lon, lat);
		//郵便番号をリクエストする
		requestPostCode(selectAddress);
		//ダイアログ隠す
		placeselectdialog_hide();
	}
	/**
	 * 住所名のリクエスト
	 */
	function requestRGeocode(lon, lat) {
		var script = document.createElement('script');
		script.charset = 'utf-8';
		script.src = "http://refits.cgk.affrc.go.jp/tsrv/jp/rgeocode.php?v=1&jsonp=responseRGeocode&lon=" + lon + "&lat=" + lat;
		//console.log("http://refits.cgk.affrc.go.jp/tsrv/jp/rgeocode.php?v=1&jsonp=responseRGeocode&lon=" + lon + "&lat=" + lat);
		document.body.appendChild(script);
	}
	/**
	 * 住所名のレスポンスJSONP
	 */
	function responseRGeocode(req) {
		//console.log("status=" + req.status);
		//console.log("result1=" + req.result.prefecture.pname);//県
		//console.log("result2=" + req.result.municipality.mname);//市
		//console.log("result3=" + req.result.local.section);//市
		//console.log("meta=" + req.meta[0].content);
		
		if (req.status == true) {
			pname = req.result.prefecture.pname;	//県
			mname = req.result.municipality.mname;	//市
			if (req.result.local) {
				section = req.result.local.section;	//町丁目・字等
			} else {
				section = "";
			}
		//	homenumber = req.result.local.homenumber;//番地 信用ならないのでコメントアウト
			meta = req.meta[0].content;
			
			selectDistrict = pname;
			selectAddress = mname + section;
			
			//郵便番号をリクエストする
			requestPostCode(pname + selectAddress); //sectionまで入れると検索できないようだ。
			
			//ダイアログ隠す
			placeselectdialog_hide();
		}
		else {
			//取得できなかった場合
			messagedialog_show("具体的な住所を取得できません。");
		}
	}
	
	/**
	 * 住所を指定して、郵便番号をリクエストする
	 */
	function requestPostCode(address) {
		//文字はスペース入らないようにする
		var searchAddress = address.replace(" ", "");
		//○丁目以下はカットする
		var i = searchAddress.indexOf("丁目");
		if (i != -1) {
			searchAddress = searchAddress.substr(0, i-1)
		}
		
		var params = "";
		var url = LS_LIB_DBJSON_URL + 'getPostCode.php';
		var pars = 'address=' + searchAddress + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responsePostCode
			});
	}
	/**
	 * 郵便番号リクエストのレスポンスJSONP
	 */
	function responsePostCode(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		if (data.length > 0) {
			var postcode = data[0].code;
			if (postcode != null && postcode != "") {
				selectPostCode = postcode;
			} else {
				selectPostCode = "";
			}
		}
		//Yahooからの設定です。
		fromYahoo();
		// place名とplaceアドレスを表示する
		setUIPlaceData( selectTitle,
				selectDistrict,
				selectAddress,
				selectPostCode,
				"",
				"",
				selectLat,
				selectLon
				);
	}
	
	
	/**
	 * 郵便番号を指定して、住所をリクエストする
	 */
	function requestAddressFromPostCode(code) {
		if (code == "")
			return;
		
		var d = $('placelist');
		d.innerHTML = "";
		
		var url = LS_LIB_DBJSON_URL + 'getAddressFromPostCode.php';
		var pars = 'code=' + code + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseAddressFromPostCode
			});
	}
	/**
	 * 住所リクエストのレスポンスJSONP
	 */
	function responseAddressFromPostCode(req) {
		
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		if (data.length > 25) {
			messagedialog_show('対象が多すぎます。\r\nさらに詳しい郵便番号を入力して下さい。');
			return;
		}
		
		var html = '';
		
		for (var i=0; i<data.length; i++) {
			selectPostCode = data[i].code.substr(0,3) + '-' + data[i].code.substr(3);
			district = data[i].district;
			if (district == null)
				district = "";
			city = data[i].city;
			if (city == null || city == "以下に掲載がない場合")
				city = "";
			street = data[i].street;
			if (street == null || street == "以下に掲載がない場合")
				street = "";
			html += '<li id="placeitem"><a href=\'javascript:selectPostcodeAddress("' + selectPostCode + '", "' + district + '", "' + city + '", "' + street + '")\'>' + selectPostCode + ' ' + district + city + street + '</li>';
			
		}
		
		var d = $('placelist');
		d.innerHTML += html;
		
		if (data.length == 0) {
			messagedialog_show('住所の情報が見つかりませんでした。');
		} else {
			//検索結果をダイアログ表示する
			placeselectdialog_show();
		}
	}
	/**
	 * 選択した住所を設定する
	 */
	function selectPostcodeAddress(postcode, district, city, street) {
		var region = getRegion(district)
		if (region != "") {
			$('eventaddform').regionselect.value = region;
			regionChange(region);
			
			if (district != "北海道")
				district = district.substr(0, district.length-1);
			$('eventaddform').districtselect.value = district;
		}
		$('eventaddform').neplacepostcode.value = postcode;
		$('eventaddform').neplaceaddress.value = city + street;
		placeselectdialog_hide();
	}
	
	function nonMenuContent() {
	}
	
	function isOSX() {
		var str = navigator.userAgent.toUpperCase();
		if (str.indexOf("MAC") >= 0)
			return true;
		return false;
	}
	
	function isIECheck() {
		var ua = navigator.userAgent;
		ua = ua.toUpperCase();
		if (ua.indexOf("SAFARI")	> -1)	return false;
		if (ua.indexOf("FIREFOX")	> -1)	return false;
		if (ua.indexOf("OPERA")		> -1)	return false;
		if (ua.indexOf("NETSCAPE")	> -1)	return false;
		if (ua.indexOf("MSIE")		> -1)	return true;
		if (ua.indexOf("MOZILLA/4")	> -1)	return false;
		if (ua.indexOf("MOZILLA")	> -1)	return false;
		return false;
	}
	
	function isFireFoxCheck() {
		var ua = navigator.userAgent;
		ua = ua.toUpperCase();
		if (ua.indexOf("SAFARI")	> -1)	return false;
		if (ua.indexOf("FIREFOX")	> -1)	return true;
		return false;
	}
	
	function isSAFARICheck() {
		var ua = navigator.userAgent;
		ua = ua.toUpperCase();
		if (ua.indexOf("SAFARI")	> -1)	return true;
		return false;
	}
	
	function no_edit() {
		
		var c0 = $('content0').getHeight();
		var c1 = $('content1').getHeight();
		if (c1 > c0)
			c0 = c1;
		
		var h = Position.positionedOffset($("header"))[1] + $('header').getHeight() + $('menu1').getHeight() + c0 + $('menu2').getHeight() + 70;
		$('dialogbg').setStyle({
			'margin-left': '-465',
			'left': '50%',
			'width': '930',
			'height': h
		});
		hideAllComboBox();
	}
	function clear_no_edit() {
		$('dialogbg').setStyle({
			'left': '-1500',
			'height': '0'
		});
		showAllComboBox();
	}
	
	// mdb = message dialog background
	function show_mdb() {
		
		var c0 = $('content0').getHeight();
		var c1 = $('content1').getHeight();
		if (c1 > c0)
			c0 = c1;
		
		var h = Position.positionedOffset($("header"))[1] + $('header').getHeight() + $('menu1').getHeight() + c0 + $('menu2').getHeight() + 70;
		$('messagedialogbg').setStyle({
			'margin-left': '-465',
			'left': '50%',
			'width': '930',
			'height': h
		});
		hideAllComboBox();
	}
	function clear_mdb() {
		$('messagedialogbg').setStyle({
			'left': '-1500',
			'height': '0'
		});
		showAllComboBox();
	}
	
	
	/*************************************************
	 * タイマー背景
	 */
	function show_timerbg() {
		
		var c0 = $('content0').getHeight();
		var c1 = $('content1').getHeight();
		if (c1 > c0)
			c0 = c1;
		
		var h = Position.positionedOffset($("header"))[1] + $('header').getHeight() + $('menu1').getHeight() + c0 + $('menu2').getHeight() + 70;
		$('timerbg').setStyle({
			'margin-left': '-465',
			'left': '50%',
			'width': '930',
			'height': h
		});
		
		$('timerbg').innerHTML = '<center><div id="timer"></div></center>';
		$('timer').setStyle({
			'margin-top': '200px'
		});
		
		hideAllComboBox();
	}
	
	function clear_timerbg() {
		$('timerbg').setStyle({
			'left': '-1500',
			'height': '0'
		});
		
		$('timerbg').innerHTML = "";
		
		showAllComboBox();
	}
	
	/*************************************************
	 * ログインダイアログ
	 */
	
	function showLoginDialog() {
		$('nextpage').value = location.href;
		goSSLLoginPage();
	}
	function goLoginPage() {
		submitURL("http://www.c2talk.net/event/contents/loginout/login.php");
	}
	function goSSLLoginPage() {
		submitURL("https://www.c2talk.net/event/contents/loginout/login.php");
	}
	function showLoginDialogOLD() {
		no_edit();
		if (isIECheck()) {
			// IE用
			$('logindialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('logindialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		document.loginform.fusername.focus();
	}
	function hideLoginDialog() {
		clear_no_edit();
		$('logindialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
		
		nextpage = $('nextpage').value;
		if (nextpage != null && nextpage != "") {
			location.href = nextpage;
		}
	}
	
	/*************************************************
	 * 登録ダイアログ
	 */
	
	function regist() {
		$('nextpage').value = location.href;
		goSSLRegistPage();
	}
	function goRegistPage() {
		submitURL("http://www.c2talk.net/event/contents/join/regist.php");
	}
	function goSSLRegistPage() {
		submitURL("https://www.c2talk.net/event/contents/join/regist.php");
	}
	function registOLD() {
		no_edit();
		if (isIECheck()) {
			// IE用
			$('registdialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('registdialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		document.registform.newusername.focus();
	}
	function registclear() {
		clear_no_edit();
		$('registdialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
		
		nextpage = $('nextpage').value;
		if (nextpage != null && nextpage != "") {
			location.href = nextpage;
		}
	}
	
	/*************************************************
	 * Confirmダイアログ
	 */
	function confirmdialog_show(message, html) {
		show_mdb();
		if (isIECheck()) {
			// IE用
			$('confirmdialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('confirmdialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		
		var d = $('confirmmessage');
		d.innerHTML = message;
		
		var db = $('confirmbuttons');
		db.innerHTML = html;
	}
	function confirmdialog_hide() {
		clear_mdb();
		$('confirmdialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
	}
	
	/*************************************************
	 * メッセージダイアログ
	 */
	function messagedialog_show(message) {
		messagedialog_showexecute(message, null);
	}
	function messagedialog_show_left(message) {
		messagedialog_showexecute(message, "left");
	}
	// その後のフォーカスを設定する場合用
	function messagedialog_show_focus(message, target) {
		messagedialog_showexecute(message, null);
		focusTarget = target;
	}
	
	// フォーカスのターゲット
	var focusTarget = null;
	
	function messagedialog_showexecute(message, messageposition) {
		show_mdb();
		if (isIECheck()) {
			// IE用
			$('messagedialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('messagedialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		if (messageposition != null) {
			$$('#messagedialog .cc')[0].setStyle({
				'text-align': messageposition
			});
		}
		var d = $('dialogmessage');
		d.innerHTML = message;
	}
	
	function messagedialog_hide() {
		clear_mdb();
		$('messagedialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
		
		if (focusTarget != null) {
			focusTarget.focus();
		}
		focusTarget == null;
	}
	
	/*************************************************
	 * パスワードを忘れた方ダイアログ
	 */
	function passwordlostdialog_show() {
		no_edit();
		if (isIECheck()) {
			// IE用
			$('passwordlostdialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('passwordlostdialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		document.passwordlostform.newpasswordusername.focus();
	}
	function passwordlostdialog_hide() {
		clear_no_edit();
		$('passwordlostdialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
	}
	
	/*************************************************
	 * パスワード変更ダイアログ
	 */
	function passwordchangedialog_show() {
		no_edit();
		if (isIECheck()) {
			// IE用
			$('passwordchangedialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('passwordchangedialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
		document.passwordchangeform.oldpassword.focus();
	}
	function passwordchangedialog_hide() {
		clear_no_edit();
		$('passwordchangedialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
	}
	
	/*************************************************
	 * 場所選択ダイアログ（Yahoo調べ）
	 */
	function placeselectdialog_show() {
		no_edit();
		
		if (isIECheck()) {
			// IE用
			$('placeselectdialog').setStyle({
				'position': 'absolute',
				'left': '50%'
			});
		} else {
			$('placeselectdialog').setStyle({
				'position': 'fixed',
				'left': '50%'
			});
		}
	}
	function placeselectdialog_hide() {
		clear_no_edit();
		$('placeselectdialog').setStyle({
			'position': 'absolute',
			'left': '-1000'
		});
	}
	
	
	function regionselectdialog_show() {
		regionselectdialog_show_plus(false, null);
	}
	
	
		
		
		/*************************************************
		 * 場所変更ダイアログ
		 * selectonly true 選択するだけ / false 移動も
		 */
		function regionselectdialog_show_plus(selectonly, method) {
			DISTRICT_SELECT_ONLY = selectonly;
			DISTRICT_SELECT_CLASS = method;
			
			no_edit();
			
			if (isIECheck() || isSAFARICheck()) {
				// IE用
				$('basyo_hennkou').setStyle({
					'position': 'absolute',
					'left': '50%'
				});
			} else {
				$('basyo_hennkou').setStyle({
					'position': 'fixed',
					'left': '50%'
				});
			}
		}
		function regionselectdialog_hide() {
			clear_no_edit();
			$('basyo_hennkou').setStyle({
				'position': 'absolute',
				'left': '-1000'
			});
			hideAllRegions();
		}
	
	
	function registsend(mustssl) {
		var username = $F('newusername');
		if (username == "") {
			messagedialog_show("ユーザ名を入力して下さい");
			return;
		}
		if (!username.match("[-_0-9a-z]{6,}")) {
			messagedialog_show("ユーザ名には英数字6文字以上を使用して下さい");
			return;
		}
		if (username == "c2talk" ||
		    username == "infoteria" ||
		    username == "admin" ||
		    username == "info" ||
		    username == "webmaster" ||
		    username == "postmaster" ||
		    username == "sales"
		) {
			messagedialog_show("このユーザ名は使用することができません");
			return;
		}
		var password = $F('newpassword');
		if (password == "") {
			messagedialog_show("パスワードを入力して下さい");
			return;
		}
		var repassword = $F('newrepassword');
		var mailaddress = $F('newmailaddress');
		if (mailaddress == "") {
			messagedialog_show("メールアドレスを入力して下さい");
			return;
		}
		if (!mailaddress.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) {
			messagedialog_show("メールアドレスの形式を確認して下さい");
			return;
		}
		if (password == repassword) {
			if (mustssl) {
				//SSL
				$('registform').method = "POST";
				$('registform').action = "https://www.c2talk.net/event/contents/join/ssluseradd.php";
				$('registform').submit();
			} else {
				show_timerbg();
				requestRegist(username, password, mailaddress);
			}
		} else {
			messagedialog_show("２つのパスワードが異なります");
		}
	}
	function requestRegist(username, password, mailaddress) {
		var url = LS_JOIN_URL + 'useradd.php';
		var pars = 'username=' + username + '&password=' + password + '&mailaddress=' + mailaddress + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'POST', 
				parameters: pars,
				onComplete: responseRegist
			});
	}
	function responseRegist(req) {
		
		clear_timerbg();
		
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var response = data[0].response;
		var message = data[0].message;
		
		if (response == 0) {
			//成功
			$('fusername').value = $F('newusername');
			$('fpassword').value = $F('newpassword');
			
			setTimeout("goHome()", 5000);
			//registclear();
			
			messagedialog_show(message);
		} else {
			//失敗
			messagedialog_show(message);
		}
	}
	
	function newpassword() {
		var username = $F('newpasswordusername');
		if (username != "") {
			requestPasswordChange(username);
		} else {
			messagedialog_show("ユーザ名を入力して下さい。");
		}
	}
	function requestPasswordChange(username) {
		var url = LS_ACCOUNT_URL + 'passwordrequest.php';
		var pars = 'username=' + username + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'POST', 
				parameters: pars,
				onComplete: responsePasswordChange
			});
	}
	
	function responsePasswordChange(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var response = data[0].response;
		var message = data[0].message;
		
		if (response == 0) {
			//成功
		} else {
			//失敗
		}
		passwordlostdialog_hide();
		messagedialog_show(message);
		
		setTimeout("goHome()", 5000);
	}
	
	function changepassword2() {
		var username = sessionusername;
		var oldpassword = $F('oldpassword');
		var changepassword = $F('changepassword');
		var changerepassword = $F('changerepassword');
		if (changepassword != "" && changerepassword != "") {
			if (changepassword == changerepassword) {
				
				show_timerbg();
				requestPasswordChangeRealTime(username, oldpassword, changepassword);
			} else {
				messagedialog_show("２つのパスワードが異なります");
			}
		}
		else {
			messagedialog_show("新しいパスワードを入力して下さい。");
		}
	}
	
	function requestPasswordChangeRealTime(username, oldpassword, changepassword) {
		var url = LS_ACCOUNT_URL + 'passwordchangerealtime.php';
		var pars = 'username=' + username + '&oldpassword=' + oldpassword + '&changepassword=' + changepassword + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'POST', 
				parameters: pars,
				onComplete: responsePasswordChangeRealTime
			});
	}
	function responsePasswordChangeRealTime(req) {
		
		clear_timerbg();
		
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var response = data[0].response;
		var message = data[0].message;
		
		if (response == 0) {
			//成功
			passwordchangedialog_hide();
			messagedialog_show(message);
		} else {
			//失敗
			messagedialog_show(message);
		}
	}
	
	/*************************************************
	 * パスワード入力欄でEnterを押したらログイン実行
	 */
	function passwordCheck(ev) {
		if (ev.keyCode == 13) {
			login(false);
		}
	}
	function passwordCheckSSL(ev) {
		if (ev.keyCode == 13) {
			login(true);
		}
	}
	
	function loginlost() {
		$('nextpage').value = "";
		
		hideLoginDialog();
		lostpassword();
	}
	
	function login(mustssl) {
		
		var username = $F('fusername');
		if (username == "") {
			messagedialog_show_focus("ユーザ名を入力して下さい。", document.loginform.fusername);
			return;
		}
		var password = $F('fpassword');
		if (password == "") {
			messagedialog_show_focus("パスワードを入力して下さい。", document.loginform.fpassword);
			return;
		}
		var autologin = "";
		if (document.loginform.fautologin.checked) {
			autologin = "true"
		}
		
		if (mustssl) {
			//SSL
			$('loginform').method = "POST";
			$('loginform').action = "https://www.c2talk.net/event/contents/loginout/ssluserlogin.php";
			$('loginform').submit();
		} else {
			var nextpage = $F('nextpage');
			if (nextpage == null || nextpage == "") {
				nextpage = location.href;
			}
			
			show_timerbg();
			
			requestLogin(username, password, autologin, nextpage);
		}
	}
	
	function requestLogin(username, password, autologin, nextpage) {
		
		$('fusername').value = "";
		$('fpassword').value = "";
		
		var url = LS_LOGIN_URL + 'userlogin.php';
		var pars = 'username=' + username + '&password=' + password + '&autologin=' + autologin + '&nextpage=' + encodeURIComponent(nextpage) + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'POST', 
				parameters: pars,
				onComplete: responseLogin
			});
	}
	
	function responseLogin(req) {
		clear_timerbg();
		var text = req.responseText;
		if (text == null)
			return;
		
		text = text.substring(2, text.length -2);
		eval(text);
		
		var response = data[0].response;
		var message = data[0].message;
		var nextpage = data[0].nextpage;
		
		if (response == 0) {
			//成功
			submitURL(nextpage);
		} else {
			//失敗
			messagedialog_show(message);
		}
	}
	
	function logout() {
		location.href = LS_LOGOUTPAGE_URL;
	}
	
	function lostpassword() {
		passwordlostdialog_show();
	}
	
	
	
	/*******************************************
	 * イベントのWatchとAttend
	 */
	function removeWatch(eventid) {
		$('eventid').value = eventid;
		var url = LS_LIB_DBOTHER_URL + 'eventuseraction.php';
		var pars = 'eventid=' + eventid + "&actiontype=watch&execute=remove" + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars,
				onComplete: responseeventuseraction
			});
	}
	function addWatch(eventid) {
		if (sessionid == null || sessionid == "") {
			$('method').value = "addwatch";
			showLoginDialog();
		} else {
			$('eventid').value = eventid;
			var url = LS_LIB_DBOTHER_URL + 'eventuseraction.php';
			var pars = 'eventid=' + eventid + "&actiontype=watch&execute=add" + "&currenttime=" + new Date().getTime();
			var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: pars,
					onComplete: responseeventuseraction
				});
		}
	}
	function removeAttend(eventid) {
		$('eventid').value = eventid;
		var url = LS_LIB_DBOTHER_URL + 'eventuseraction.php';
		var pars = 'eventid=' + eventid + "&actiontype=attend&execute=remove" + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars,
				onComplete: responseeventuseraction
			});
	}
	function addAttend(eventid) {
		$('eventid').value = eventid;
		var url = LS_LIB_DBOTHER_URL + 'eventuseraction.php';
		var pars = 'eventid=' + eventid + "&actiontype=attend&execute=add" + "&currenttime=" + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				parameters: pars,
				onComplete: responseeventuseraction
			});
	}
	function responseeventuseraction(req) {
		var text = req.responseText;
		
		//location.reload();
		goEventPage($F('eventid'));
	}
	
	
	
	/*******************************************
	 * タグ
	 */
	function createTagView() {
		requestTags();
	}
	
	function requestTags() {
		var d = $('tags_info');
		if (d != null) {
			var url = LS_LIB_DBJSON_URL + 'getTags.php';
			var pars =  "currenttime=" + new Date().getTime();
			var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: pars,
					onComplete: responseTags
				});
		} else {
			checkCount();
		}
	}
	
	function responseTags(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		setTags(data);
	}
	
	/**
	 * Tag描画
	 */
	function setTags(data) {
		var namelist = new Array();
		var goukei = 0;
		var heikin = 0;
		for (var i=0; i<data.length; i++) {
			var counter = data[i].counter;
			goukei = goukei + parseInt(counter);
			//ソート順のために小文字に変換する
			namelist[i] = data[i].name.toLowerCase();
		}
		
		//名前順にするためにソートする
		namelist.sort();
		
		//標準偏差で文字の大きさを3段階に分ける
		heikin = goukei / data.length;
		goukei = 0;
		for (var i=0; i<data.length; i++) {
			var counter = data[i].counter;
			var a = heikin - parseInt(counter);
			a = a * a;
			goukei = goukei + a;
		}
		var hyoujyunhensa = Math.sqrt(goukei/data.length);
		
		var toppage = true;
		if ($F('st1') != "") {
			toppage = false;
		}
		
		
		//HTML作成
		var html = '';
		for (var z=0; z<namelist.length; z++) {
			var name = namelist[z];
			if (!isAlreadySelectedTag(name)) {
				for (var i=0; i<data.length; i++) {
					if (name == data[i].name.toLowerCase()) {
						var counter = data[i].counter;
						var atai = (parseInt(counter) - heikin) * 10 / hyoujyunhensa + 50;
						
						if (atai > 55) {
							// 大
							html += '<a class="top" href="javascript:goTagPage(\'' + escapeTag(data[i].name) + '\')">' + data[i].name;
							if (toppage)
								html += '</a>&nbsp;\n';
							else
								html += '<font class="tagcount">(' + counter + ')</font></a>&nbsp;\n';
						} else if (atai > 45) {
							// 中
							html += '<a class="upper" href="javascript:goTagPage(\'' + escapeTag(data[i].name) + '\')">' + data[i].name;
							if (toppage)
								html += '</a>&nbsp;\n';
							else
								html += '<font class="tagcount">(' + counter + ')</font></a>&nbsp;\n';
						} else {
							// 小
							html += '<a class="lower" href="javascript:goTagPage(\'' + escapeTag(data[i].name) + '\')">' + data[i].name;
							if (toppage)
								html += '</a>&nbsp;\n';
							else
								html += '<font class="tagcount">(' + counter + ')</font></a>&nbsp;\n';
						}
						//console.log("counter=" + counter);
						//console.log("atai=" + atai);
					}
				}
			}
		}
		var d = $('tags_info');
		if (d != null) {
			d.innerHTML = html;
		}
		checkCount();
	}
	
	function isAlreadySelectedTag(name) {
		var name1 = "";
		var name2 = "";
		for (i=1; i<=10; i++) {
			name1 = 'st' + i;
			name2 = 'sk' + i;
			if ($F(name1) != null && $F(name1) != "") {
				if ($F(name1) == "tag" && $F(name2).toLowerCase() == name) {
					return true;
				}
			} else {
				break;
			}
		}
		return false;
	}
	
	/*************************************
	 * 開始日の文字列を返す
	 *
	 * start開始時刻　2007,July,1,Monday -> 2007年7月1日（月）
	 * end	終了時刻　2007,July,1,Monday
	 */
	function getStartDateStr(start, end) {
		var starts = start.split(",");
		var year = starts[0];
		var month = toMonthNumber(starts[1]);
		var date = starts[2];
		var day = toJapaneseDay(starts[3]);
		var now = new Date();
		
		var res = "";
		if (now.getFullYear() == year && year == end.split(",")[0]) {
			//年はいらない
		} else {
			res = year + "年";
		}
		res += month + "月" + date + "日" + "(" + day + ")";
		return res;
	}
	function getEndDateStr(start, end) {
		return getStartDateStr(end, start);
	}
	function getDateStr(date) {
		var dates = date.split(",");
		var year = dates[0];
		var month = toMonthNumber(dates[1]);
		var date = dates[2];
		return year + "年" + month + "月" + date + "日";
	}
	
	
	/*********************************************
	 * イベントのページ作成 まとめたもの
	 */
	function createEventDataHTMLLeft(prev,
					name,
					allday,
					description,
					eventid,
					tags,
					invalidenddate,
					sdate,
					edate,
					stime,
					etime,
					location,
					place_name,
					place_address,
					place_postcode,
					homepage,
					place_latitude,
					imagepath,
					owner_id,
					owner_name,
					adate,
					udate,
					nocomment)
	{
		var html = '<div id="eventdata">';
		
		
		html +=	'<div class="gtop">';
		html +=	'	<p>&nbsp;</p>';
		html +=	'</div>';
		
		
		// タイトル /////////////////////////////////////
		
		html += '<div id="eventtitle"><H1>' + name + '</H1>';
		if (!prev) {
			if (nocomment == 0) {
				if (owner_id != null && owner_id == sessionid) {
					//自分の作成したイベントの場合
					html += '<a id="eventediticon" href="javascript:editEvent(' + $F('eventid') + ')"><img title="編集" src="/event/images/edit.png"/><font class="eventedit">イベント情報を編集</font></a>';
					html += '<a id="eventediticon" href="javascript:removeEvent(' + $F('eventid') + ')"><img title="削除" src="/event/images/remove.png"/><font class="eventedit">イベント情報を削除</font></a>';
				}
			} else {
				//ReadOnly
					html += '<a id="eventediticon" href=""><img title="編集不可" src="/event/images/noedit.png"/></a>';
			}
		}
		html += '</div>';
		
		// イベント情報　左 //////////////////////////////
		
		html += '<div id="eventinfoleft">';
		
		html += '<div id="title">日時</div>';
		
		html += '<div id="bold">' + getStartDateStr(sdate, edate);
		
		if (invalidenddate == 1) {
			html += '</div>';
		} else {
			if (sdate != edate)
				html += ' ～ ' + getEndDateStr(sdate, edate) + '</div>';
			else
				html += '</div>';
		}
		if (allday != 0) {
			
		} else {
			html += stime + ' ～ ';
			if (invalidenddate == 1) {
				html += '<br/>';
			} else {
				html += etime + '<br/>';
			}
		}
		
		if (description != "") {
			description = urlToATag(description);
			html += '<div id="title">説明</div>';
			html += description + '<br/>';
		}
		
		html += '<div id="title">場所</div>';
		html += location + '<br/>';
		html += '<div id="bold">' + place_name + '</div>';
		html += place_postcode + ' ' + place_address + '<br/>';
		if (homepage != "") {
			var homepagetext = homepage;
			if (homepage.length > 50) {
				homepagetext = homepage.substr(0, 50) + " ...";
			}
			html += '<div id="title">URL</div>';
			html += '<a href="' + homepage + '" target="_blank">' + homepagetext + '</a><br/>';
		}
		
		html += '<div id="title">タグ';
		if (!prev) {
			if (sessionid != null && sessionid != "") {
				html += '<a href="javascript:addtag(' + $F('eventid') + ')"><img src="/event/images/tagadd.png"/></a>';
				html += '<a href="javascript:deltag(' + $F('eventid') + ')"><img src="/event/images/tagdel.png"/></a>';
			}
		}
		html += '</div>';
		if (tags != "") {
			var taglinks = "";
			var tagarray = tags.split(" ");
			for (var i=0; i<tagarray.length; i++) {
				taglinks = taglinks + "&nbsp;" + '<a href="javascript:goTagPage(\'' + escapeTag(tagarray[i]) + '\')">' + tagarray[i] + '</a>';
			}
			
			html += taglinks + '<br/>';
		} else {
			html += 'なし<br/>';
		}
		html += '<div id="edittag"></div>';
		html += '<br/>オーナー <a href="javascript:goUserPage(' + owner_id + ')">' + owner_name + '</a> さん<br/>登録日 ' + getDateStr(adate);
		if (adate != udate) {
			html += "<br/>更新日 " + getDateStr(udate);
		}
		
		html += '</div>';
		
		// 画像、地図 ////////////////////////////////////
		
		html += '<div id="eventinforight">';
		
		if (imagepath != "") {
			if (imagepath.indexOf("http") == 0) {
				//TMP画像の場合
				html += '<div id="eventimage"><img src="' + imagepath + '"/></div>';
			} else {
				//通常のイメージ
				largepath = toLargeImagePath(imagepath);
				html += '<div id="eventimage"><img src="/event/images/' + largepath + '"/></div>';
			}
		}
		
		html += '<div id="eventmap"><div id="map" style="height: 220px; width: 250px"></div></div>';
		
		if (typeof DetectFlashVer != 'undefined') {
			// Flash メジャーバージョン
			var requiredMajorVersion = 9;
			// Flash マイナーバージョン
			var requiredMinorVersion = 0;
			// Flash バージョン
			var requiredRevision = 45;
			var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
			if(hasRightVersion) {  // 使用可能なバージョンが検出された場合
				if (nocomment != null) {
					html += '<div id="eventpvgraph">' +
						'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="250" height="100" id="pvgraph" align="middle">' +
						'<param name="allowScriptAccess" value="sameDomain" />' +
						'<param name="allowFullScreen" value="false" />' +
						'<param name="wmode" value="transparent" />' +
						'<param name="movie" value="/event/contents/eventinfo/pvgraph.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />' +
						'<embed wmode="transparent" src="/event/contents/eventinfo/pvgraph.swf" quality="high" bgcolor="#ffff00" width="250" height="100" name="pvgraph" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
						'</object>' +
						'</div>';
				}
			} else {  // Flash が古すぎるか、プラグインを検出できません
				var alternateContent = 'PVグラフを表示するには Adobe Flash Player が必要です。<a href=http://www.macromedia.com/go/getflash/>Flash Player を入手する</a>';
				html += '<div id="eventpvgraph">' + alternateContent + '</div>';
			}
		}
		
		html += '</div>';
		
		html +=	'<div class="gbottom">';
		html +=	'	<p>&nbsp;</p>';
		html +=	'</div>';
		
		html += '</div>';
		
		return html;
	}
	
	/**********************************************
	 * 画パスからSS画像パスに変更する
	 */
	function toSSImagePath(path) {
		if (path == null || path.length == 0) {
			return "";
		}
		p = path.lastIndexOf("/");
		return path.substr(0, p + 1) + "ss" + path.substr(p + 1);
	}	
	/**********************************************
	 * 画パスから小さい画像パスに変更する
	 */
	function toSmallImagePath(path) {
		if (path == null || path.length == 0) {
			return "";
		}
		p = path.lastIndexOf("/");
		return path.substr(0, p + 1) + "s" + path.substr(p + 1);
	}
	/**********************************************
	 * 画パスから中くらい画像パスに変更する
	 */
	function toMiddleImagePath(path) {
		if (path == null || path.length == 0) {
			return "";
		}
		p = path.lastIndexOf("/");
		return path.substr(0, p + 1) + "m" + path.substr(p + 1);
	}
	/**********************************************
	 * 画パスから大きい画像パスに変更する
	 */
	function toLargeImagePath(path) {
		if (path == null || path.length == 0) {
			return "";
		}
		p = path.lastIndexOf("/");
		return path.substr(0, p + 1) + "l" + path.substr(p + 1);
	}
	
	/**********************************************
	 * 全イベント表示モードに変更
	 */
	function fullEventMode() {
		setViewMode(1);
	}
	/**********************************************
	 * 通常表示モードに変更
	 */
	function normalMode() {
		setViewMode(0);
	}
	
	/**********************************************
	 * 表示モード変更テスト
	 */
	function changeMode() {
		if (viewmode == 0) {
			fullEventMode();
		}
		else {
			normalMode();
		}
	}
	
	function changeEventDetailMode() {
		var d = $('contentcenter');
		d.innerHTML = "";
		
		setViewMode(2);
	}
	
	
	
	
	
	var oldSelectRegionName = "";
	/**
	 * 地区指定で地区の上にマウスカーソルが乗った場合
	 */
	function onRegion(no, name, px, py) {
		//console.log("in " + no);
		if (no != 0) {
			$('selectregionname').setStyle({
				'top': py,
				'left': px
			});
			var d = $('selectregionname');
			d.innerHTML = name;
			
			oldSelectRegionName = name;
		} else {
			var d = $('selectregionname');
			d.innerHTML = oldSelectRegionName;
		}
	}
	/**
	 * 地区指定で地区の上からマウスカーソルが出た場合
	 */
	function outRegion(no) {
		var d = $('selectregionname');
		d.innerHTML = "";
	}
	function onRegionSelect(no) {
		if (isFireFoxCheck() && isOSX()) {
			switch (no) {
			case 1:
				//北海道
				onDistrictSelect("北海道");
				break;
			case 2:
				regionJapanAlpha(0.5);
				$('region2').setStyle({
					'visibility': 'visible'
				});
				break;
			case 3:
				regionJapanAlpha(0.5);
				$('region3').setStyle({
					'visibility': 'visible'
				});
				break;
			case 4:
				regionJapanAlpha(0.5);
				$('region4').setStyle({
					'visibility': 'visible'
				});
				break;
			case 5:
				regionJapanAlpha(0.5);
				$('region5').setStyle({
					'visibility': 'visible'
				});
				break;
			case 6:
				regionJapanAlpha(0.5);
				$('region6').setStyle({
					'visibility': 'visible'
				});
				break;
			case 7:
				regionJapanAlpha(0.5);
				$('region7').setStyle({
					'visibility': 'visible'
				});
				break;
			case 8:
				regionJapanAlpha(0.5);
				$('region8').setStyle({
					'visibility': 'visible'
				});
				break;
			case 9:
				regionJapanAlpha(0.5);
				$('region9').setStyle({
					'visibility': 'visible'
				});
				break;
			case 10:
				regionJapanAlpha(0.5);
				$('region10').setStyle({
					'visibility': 'visible'
				});
				break;
			case 11:
				//沖縄
				onDistrictSelect("沖縄");
				break;
			}
		} else {
			switch (no) {
			case 1:
				//北海道
				onDistrictSelect("北海道");
				break;
			case 2:
				regionJapanAlpha(0.5);
				$('region2').setStyle({
					'left': '50%'
				});
				break;
			case 3:
				regionJapanAlpha(0.5);
				$('region3').setStyle({
					'left': '50%'
				});
				break;
			case 4:
				regionJapanAlpha(0.5);
				$('region4').setStyle({
					'left': '50%'
				});
				break;
			case 5:
				regionJapanAlpha(0.5);
				$('region5').setStyle({
					'left': '50%'
				});
				break;
			case 6:
				regionJapanAlpha(0.5);
				$('region6').setStyle({
					'left': '50%'
				});
				break;
			case 7:
				regionJapanAlpha(0.5);
				$('region7').setStyle({
					'left': '50%'
				});
				break;
			case 8:
				regionJapanAlpha(0.5);
				$('region8').setStyle({
					'left': '50%'
				});
				break;
			case 9:
				regionJapanAlpha(0.5);
				$('region9').setStyle({
					'left': '50%'
				});
				break;
			case 10:
				regionJapanAlpha(0.5);
				$('region10').setStyle({
					'left': '50%'
				});
				break;
			case 11:
				//沖縄
				onDistrictSelect("沖縄");
				break;
			}
		}
	}
	
	function regionJapanAlpha(alpha) {
			$('country_japan').setStyle({
				'filter': 'alpha(opacity=' + alpha*100 + ')',
				'-moz-opacity': alpha,
				'opacity': alpha
			});
			$('stringdistrictselect').setStyle({
				'filter': 'alpha(opacity=' + alpha*100 + ')',
				'-moz-opacity': alpha,
				'opacity': alpha
			});
			if (alpha != 1){
				$('cover').setStyle({
					'left': '50%',
					'width': '500px',
					'height': '550px'
				});
			} else {
				$('cover').setStyle({
					'width': '0px',
					'height': '0px'
				});
			}
	}
	
	
	var oldSelectDistrictName = "";
	/**
	 * 県指定で県の上にマウスカーソルが乗った場合
	 * px py は使用していない
	 */
	function onDistrict(no, name, px, py) {
		//console.log("in " + no + " name=" + name);
		if (no != 0) {
			var d = $('selectdistrictname');
			d.innerHTML = name;
			
			oldSelectDistrictName = name;
		} else {
			var d = $('selectdistrictname');
			d.innerHTML = oldSelectDistrictName;
		}
	}
	/**
	 * 県指定で県の上からマウスカーソルが出た場合
	 */
	function outDistrict() {
		var d = $('selectdistrictname');
		d.innerHTML = "";
	}
	function onDistrictSelect(name) {
		regionselectdialog_hide();
		
		$('districtname').value = name;
		
		if (DISTRICT_SELECT_ONLY) {
			DISTRICT_SELECT_CLASS.setName(name);
		} else {
			//setTimeout("goHome()", 10);
			
			$('offset').value = "";
			
			setSearch("district", name)
		}
	}
	function hideAllRegions() {
		if (isFireFoxCheck() && isOSX()) {
			$('region2').setStyle({
				'visibility': 'hidden'
			});
			$('region3').setStyle({
				'visibility': 'hidden'
			});
			$('region4').setStyle({
				'visibility': 'hidden'
			});
			$('region5').setStyle({
				'visibility': 'hidden'
			});
			$('region6').setStyle({
				'visibility': 'hidden'
			});
			$('region7').setStyle({
				'visibility': 'hidden'
			});
			$('region8').setStyle({
				'visibility': 'hidden'
			});
			$('region9').setStyle({
				'visibility': 'hidden'
			});
			$('region10').setStyle({
				'visibility': 'hidden'
			});
		} else {
			$('region2').setStyle({
				'left': '-1000px'
			});
			$('region3').setStyle({
				'left': '-1000px'
			});
			$('region4').setStyle({
				'left': '-1000px'
			});
			$('region5').setStyle({
				'left': '-1000px'
			});
			$('region6').setStyle({
				'left': '-1000px'
			});
			$('region7').setStyle({
				'left': '-1000px'
			});
			$('region8').setStyle({
				'left': '-1000px'
			});
			$('region9').setStyle({
				'left': '-1000px'
			});
			$('region10').setStyle({
				'left': '-1000px'
			});
		}
		regionJapanAlpha(1);
	}
	
	/**
	 * IE6用のコンボボックス隠す
	 */
	function hideAllComboBox() {
		if(isIE){
			inputlist = document.getElementsByTagName("select");
			for (i=0; i<inputlist.length; i++) {
				$(inputlist[i].name).setStyle({
					'visibility': 'hidden'
				});
			}
		}
	}
	/**
	 * IE6用のコンボボックス出す
	 */
	function showAllComboBox() {
		if(isIE){
			inputlist = document.getElementsByTagName("select");
			for (i=0; i<inputlist.length; i++) {
				$(inputlist[i].name).setStyle({
					'visibility': 'visible'
				});
			}
		}
	}
	
	
	function urlToATag(text) {
		if (text != null && text != "")
			return changeURL(text);
		return text;
	}
	function changeURL(text) {
		var data = text;
		var urls = new Array();
		var url = /(\w+):\/\/([-_a-zA-Z0-9\.:\/=\?&%@!#$~\*\+;,\(\)\[\]']*)/;
	//	var url = /(\w+):\/\/([\w.]+)\/([-_a-zA-Z0-9\.:\/=\?&%@!#$~\*\+;,\(\)\[\]']*)/;
		var result = data.match(url);
		var i=0;
		while (result != null) {
			if (result != null) {
			var fullurl = result[0];
			}
			var dd = new Date();
			var urlstr = "[URL" + dd.getTime() + "]";
			data = data.replace(url, urlstr);
			urls.push([urlstr,fullurl]);
			result = data.match(url);
			i++;
			if (i>10) {
				break;
			}
		}
		for (var i=0; i<urls.length; i++) {
			var urldata = urls[i];
			var urlstr = urldata[0];
			var fullurl = urldata[1];
			var fullurlstr = fullurl;
			if (fullurl.length > 50)
				fullurlstr = fullurl.substr(0, 50) + " ...";
			var fullurltext = '<a href="' + fullurl + '">' + fullurlstr + '</a>';
			data = data.replace(urlstr, fullurltext);
		}
		return data;
	}
	
	
	
	
	
	
	/**************************************************************
	 * ランダムにカレンダー情報を取得する
	 */
	function requestRandomCalendars(limit) {
		var url = LS_LIB_DBJSON_URL + 'getRandomCalendars.php';
		var pars = 'limit=' + limit + '&currenttime=' + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseRandomCalendars
			});
	}
	function responseRandomCalendars(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var values = data;
		var html = '';
		html += createHTMLForCalendar2(values, 1, false, "nobg");
		
		var da = $("pickupcalendar");
		if (da) {
			da.innerHTML = html;
		}
		
		checkCount();
		
		setTimeout("addReflections()", 1000);
	}
	
	
	/*******************************************************************************************************
	 * カレンダー用のHTMLを作成する
	 *
	 * 注意：このメソッドを使用する場合PHPで変数定義が必要です。
	 * home/index.php と calendar/index.php
	 */
	function createHTMLForCalendar(data, maxsidecnt, looklink) {
		return createHTMLForCalendar2(data, maxsidecnt, looklink, "withbg");
	}
	function createHTMLForCalendar2(data, maxsidecnt, looklink, bgtype) {
		var max_side_cnt = maxsidecnt;
		var side_cnt = 0;
		
		var html = '<table id="calendars">';
		for (i=0; i<data.length; i++) {
			if (side_cnt == 0) {
				html += '<tr>';
			}
			var width = Math.round(100 / maxsidecnt);
			
			html += '<td width="' + width + '%">';
			html += '<table class="' + bgtype + '">';
			
			calendar_url = CALENDAR_URL;
			calendar_dir = CALENDAR_DIR;
			
			calendar_iconname = data[i].calendar_iconname;
			calendar_id = data[i].calendar_id;
			calendar_name = data[i].calendar_name;
			calendar_name = getShortString(calendar_name, 215, 'ruler10');
			
			download_count = data[i].downloads;
			if (download_count == "")
				download_count = 0;
			upload_date = data[i].upload_date.substr(0, 10);
			update_date = data[i].update_date.substr(0, 10);
			if (upload_date == update_date)
				datetitle = "Upload";
			else
				datetitle = "Update";
			comments_cnt = data[i].commentcounts;
			
			if (comments_cnt == "")
				comments_cnt = 0;
			point_avg = data[i].point;
			creater_nicname = data[i].user_name;
			include_script = data[i].include_script;
			event_tags = data[i].event_tags;
			event_sync_sign = data[i].event_sync_sign;
			
			hyoka = getHyokaImgTag(point_avg);
			
			html += '<tr>';
			html += '<td class="calendarinfo" colspan="2">';
			html += '<p class="calendarname"><a href="javascript:goCalendarInfo(' + calendar_id + ')">' + calendar_name + '</a></p>';
			html += '</td>';
			html += '</tr>';
			
			html += '<tr>';
			html += '<td class="calendarimage"><a href="javascript:goCalendarInfo(' + calendar_id + ')"><img class="reflect rheight33" src="' + calendar_url + calendar_iconname + '"></a></td>';
			html += '<td class="calendarinfo">';
			html += '<p class="creater">by ' + creater_nicname + '</p>';
			html += update_date + ' ' + datetitle + '<br>';
			html += download_count + ' Downloads<br>';
			html += comments_cnt + ' comments<br>';
			html += hyoka;
			html += '</td>';
			html += '</tr>';
			
			html += '<tr>';
			html += '<td class="calendarinfo" colspan="2">';
			var withlink = false;
			if (looklink) {
				if (event_sync_sign != null && event_sync_sign == "1" && event_tags != null && event_tags != "") {
					//オフィシャルのカレンダー
					if (creater_nicname == "Official") {
						//スクリプトが含まれていないカレンダー
						if (include_script != 1) {
							//含まれるイベント検索ボタンを追加
							html += '<p id="lookmore"><a href="javascript:goTagPageMulti(\'' + escapeTag(event_tags) + '\')"><img src="/event/images/event_noimage_20x20.png"/>カレンダーのイベントを見る</a></p>';
							withlink = true;
						}
					}
				}
			}
			if (!withlink && bgtype == "withbg") {
				html += '<p id="lookmore"><img src="/event/images/space_20x20.png"/></p>';
			}
			html += '</td>';
			html += '</tr>';
			
			html += '</table>';
			html += '</td>';
			side_cnt++;
			
			if (side_cnt == max_side_cnt) {
			html += '</tr>';
				side_cnt = 0;
			}
		}
		html += '</table>';
		return html;
	}

	function getHyokaImgTag(point_avg) {
		hyoka = '<IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png">';
		if (point_avg) {
			if (point_avg == 1)
				hyoka = '<IMG SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png">';
			else if (point_avg == 2) 
				hyoka = '<IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png">';
			else if (point_avg == 3)
				hyoka = '<IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png">';
			else if (point_avg == 4)
				hyoka = '<IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG id="halfimg" SRC="/event/images/star.png">';
			else if (point_avg == 5)
				hyoka = '<IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png"><IMG SRC="/event/images/star.png">';
		}
		return hyoka;
	}
	
	function isLoginPage() {
		var url = location.href;
		if (url.indexOf('/loginout/login.php') > 0) {
			return true;
		}
		return false;
	}
	
	function isCalendarWebSite() {
		var url = location.href;
		if (url.indexOf('/calendar/') > 0) {
			return true;
		}
		return false;
	}
	
	function isUserPage() {
		var url = location.href;
		if (url.indexOf('/account/user.php') > 0) {
			return true;
		}
		return false;
	}
	
	/**
	 * イベントのランキング取得
	 */
	function requestEventRanking() {
		var url = LS_LIB_DBJSON_URL + 'getEventRanking.php';
		var pars = 'limit=5&currenttime=' + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseEventRanking
			});
	}
	function responseEventRanking(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var html = '<ul>';
		for (var i=0; i<data.length; i++) {
			html += '<li><a href="javascript:goEventPage2(' + data[i].eventid + ')">' + getShortString(data[i].eventname, 150, 'ruler') + '</a>&nbsp;&nbsp;&nbsp;<font class="bluetext">' + data[i].count + 'PV</font></li>';
		}
		html += '</ul>';
		
		html += '<div id="eventrankmore"><a href="javascript:goEventRankingPage()">もっと見る</a></div>';
		
		var da = $("eventrankbody");
		if (da) {
			da.innerHTML = html;
		}
		
		checkCount();
	}
	
	/**
	 * 最近投稿されたイベント取得
	 */
	function requestNewEventList(size) {
		var limit = 5;
		if (size != null && size > 0) {
			limit = size;
		}
		var url = LS_LIB_DBJSON_URL + 'getNewEventList.php';
		var pars = 'limit=' + limit + '&currenttime=' + new Date().getTime();
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars,
				onComplete: responseNewEventList
			});
	}
	function responseNewEventList(req) {
		var text = req.responseText;
		text = text.substring(2, text.length -2);
		eval(text);
		
		var html = '<ul>';
		for (var i=0; i<data.length; i++) {
			html += '<li><a href="javascript:goEventPage2(' + data[i].eventid + ')">' + getShortString(data[i].eventname, 150, 'ruler') + '</a>&nbsp;&nbsp;&nbsp;<font class="bluetext">' + data[i].adddate + '</font></li>';
		}
		html += '</ul>';
		
		html += '<div id="neweventlistmore"><a href="javascript:goNewEventListPage()">もっと見る</a></div>';
		
		var da = $("neweventlistbody");
		if (da) {
			da.innerHTML = html;
		}
		
		checkCount();
	}
	
	
	
/**
 * 名前に含まれる’と”をエスケープする
 */
function escapeTag(name) {
	var res = "";
	for (var i=0; i<name.length; i++) {
		var c = name.charAt(i);
		switch (c) {
			case '"':
				res += "&quot;";
				break;
			case '\'':
				res += "\\'";
				break;
			default:
				res += c;
				break;
		}
	}
	return res;
}


/**
 * 世界測地系 -> 日本測地系 from http://moyolab.blog57.fc2.com/blog-entry-34.html
 */
function fromWGS84toTokyoLatitude(latitude, longitude){
	res = latitude + 1.0696e-4 * latitude - 1.7467e-5 * longitude - 4.6020e-3;
	return res;
}
function fromWGS84toTokyoLongitude(latitude, longitude){
	res = longitude + 4.6047e-5 * latitude + 8.3049e-5 * longitude - 1.0040e-2;
	return res;
}

/**
 * 日本測地系 -> 世界測地系 from http://moyolab.blog57.fc2.com/blog-entry-34.html
 */
function fromTokyotoWGS84Latitude(latitude, longitude){
	return latitude - 1.0695e-4 * latitude + 1.7464e-5 * longitude + 4.6017e-3;
}
function fromTokyotoWGS84Longitude(latitude, longitude){
	return longitude -4.6038e-5 * latitude - 8.3043e-5 * longitude + 1.0040e-2;
}


/**
 * 以下同様のものがbase_head.phpにもあります。
 */

// RSS & ICS /////////////////////////////////////////////////////////////////////////////////////////////////

/****************************************
 * Subscribeはこのメソッドに統一
 */
function subscribe(type) {
	var district = "";
	var date = "";
	var tag = "";
	var word = "";
	
	var time = 0;
	
	var name1 = "";
	var name2 = "";
	var no = 1;
	for (i=0; i<11; i++) {
		name1 = 'st' + no;
		name2 = 'sk' + no;
		if ($(name1) && $F(name1) != null && $F(name1) != "") {
			
			if ($F(name1) == "district") {
				if (district != "")
					district += ",";
				district += $F(name2);
				
			} else if ($F(name1) == "date") {
				var d = toDateFromString($F(name2));
				if (date != "") {
					if (time > d.getTime()) {
						time = d.getTime();
						date = $F(name2);
					}
				} else {
					date = $F(name2);
					time = d.getTime();
				}
				
			} else if ($F(name1) == "tag") {
				if (tag != "")
					tag += ",";
				tag += $F(name2);
				
			} else if ($F(name1) == "word") {
				if (word != "")
					word += ",";
				word += $F(name2);
			}
			
		} else {
			break;
		}
		no++;
	}
	
	district = encodeURIComponent(district);
	date = toAPIDate(date);//一番古いものを設定
	tag = encodeURIComponent(tag);
	word = encodeURIComponent(word);
	
	var protocol = "http";
	if (type == "ics")
		protocol = "webcal";
	
	var url = protocol + "://api.c2talk.net/event/rest?method=event.list&type=" + type;
	if (district != "")
		url += "&where=" + district;
	if (date != "")
		url += "&startdate=" + date;
	if (tag != "")
		url += "&tags=" + tag;
	if (word != "")
		url += "&words=" + word;
	
	
	location.href = url;
}

/************************
 * APIの日付形式に変更
 * 20070101 -> 2007-01-01
 */
function toAPIDate(date) {
	if (date == null || date == "")
		return "";
	return date.substr(0, 4) + "-" + date.substr(4,2) + "-" + date.substr(6,2);
}

/**
 * Tag用
 */
/*
	function rssTag(tag, type) {
		location.href = getrssTagURL(tag, type);
	}
	function getrssTagURL(tag, type) {
		var word = encodeURIComponent(tag);
		var protocol = "http";
		if (type == "ics")
			protocol = "webcal";
		return protocol + "://api.c2talk.net/event/rest?method=event.list&type=" + type + "&words=" + word;
	}
*/

/**
 * 検索用
 */
/*
	function rssSearch(what, where, type) {
		location.href = rssSearchURL(what, where, type);
	}
	function rssSearchURL(what, where, type) {
		var whatvalue = what;
		var wherevalue = where;
		
		while(whatvalue.indexOf(" ") != -1) {
			whatvalue = whatvalue.replace(" ", ",");
		}
		while(whatvalue.indexOf("　") != -1) {
			whatvalue = whatvalue.replace("　", ",");
		}
		while(wherevalue.indexOf(" ") != -1) {
			wherevalue = wherevalue.replace(" ", ",");
		}
		while(wherevalue.indexOf("　") != -1) {
			wherevalue = wherevalue.replace("　", ",");
		}
		
		whatvalue = encodeURIComponent(whatvalue);
		wherevalue = encodeURIComponent(wherevalue);
		
		var protocol = "http";
		if (type == "ics")
			protocol = "webcal";
		return protocol + "://api.c2talk.net/event/rest?method=event.list&type=" + type + "&what=" + whatvalue + "&where=" + wherevalue;
	}
*/

// 文字列切り詰め /////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * moji 文字列
 * ruler 長さを測るためのElement
 */
function getExtent(moji, ruler) {
	var e = $(ruler);
	var c;
	while (c = e.lastChild)
		e.removeChild(c);
	var text = e.appendChild(document.createTextNode(moji));
	var width = e.offsetWidth;
	e.removeChild(text);
	return width;
}
/**
 * moji 文字列
 * maxWidth 長さ
 * ruler 長さを測るためのElement
 */
function getShortString(moji, maxWidth, ruler) {
	if (moji.length == 0)
		return moji;
	
	if (getExtent(moji, ruler) <= maxWidth)
		return moji;
	
	for (var i=moji.length-1; i>=1; --i)
	{
		var s = moji.slice(0, i) + '...';
		if (getExtent(s, ruler) <= maxWidth)
			return s;
	}
	return moji;
}


var mousePositionX;
var mousePositionY;

function mouseMoveCheck(e) {
	if (e != null) {
		mousePositionX = e.clientX;
		mousePositionY = e.clientY;
		eventBGCheck();
	}
	if (isIECheck()) {
		mousePositionX = window.event.clientX;
		mousePositionY = window.event.clientY;
		eventBGCheck();
	}
}

if (!isIECheck()) {
	window.addEventListener('DOMMouseScroll', wheel, false);
}
window.onmousewheel = document.onmousewheel = wheel;

function wheel(e) {
	eventBGCheck();
}

var weekinfolist = null;

function mouseListenStart() {
	if (weekinfolist == null)
		weekinfolist = $$('.weekinfo');
	if (weekinfolist.length > 0)
		document.onmousemove = mouseMoveCheck;
}

function eventBGCheck() {
	if (!isIE6) {
		if (weekinfolist == null)
			weekinfolist = $$('.weekinfo');
		var s = '';
		var x = 0;
		var y = 0;
		if (isIECheck()) {
			x = document.body.scrollLeft + mousePositionX;
			y = document.body.scrollTop + mousePositionY;
		} else {
			x = window.scrollX + mousePositionX;
			y = window.scrollY + mousePositionY;
		}
		
		for(var i=0; i<weekinfolist.length; i++){
			if (Position.within(weekinfolist[i], x, y)) {
				weekinfolist[i].setStyle({
					'background-image': 'url("/event/images/event_bg_hover.png")'
				});
				
			} else {
				if (weekinfolist[i].getStyle('background-image') != 'url("/event/images/event_bg.png")') {
					weekinfolist[i].setStyle({
						'background-image': 'url("/event/images/event_bg.png")'
					});
				}
			}
		}
	}
}





/// Search ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function setSearch(type, value) {
	if (value != null) {
		if (value instanceof Array) {
			var withsubmit = false;
			for (var i=0; i<value.length; i++) {
				if (i == value.length-1)
					withsubmit = true;
				setSearchValue(type, value[i], withsubmit);
			}
		} else {
			setSearchValue(type, value, true);
		}
	}
	
}
function setSearchValue(type, value, withsubmit) {
	var name1 = "";
	var name2 = "";
	for (i=1; i<=10; i++) {
		name1 = 'st' + i;
		name2 = 'sk' + i;
		if ($F(name1) == null || $F(name1) == "") {
			$(name1).value = type;
			$(name2).value = value;
			break;
		} else if ((type == "date" || type == "district") && $(name1).value == type) {
			//日付と場所なら差し替え
			$(name1).value = type;
			$(name2).value = value;
			break;
		}
	}
	if (withsubmit)
		searchByKeys();
}

function removeKeys(position) {
	var name1 = "";
	var name2 = "";
	for (i=10; i>position; i--) {
		name1 = 'st' + i;
		name2 = 'sk' + i;
		if ($(name1).value != "") {
			$(name1).value = "";
			$(name2).value = "";
		}
	}
	if (position == 0) {
		$('otherkey').value = "";
		$('othervalue').value = "";
	}
}

function SearchKeyPosition(position) {
	removeKeys(position);
	if (position >= 1)
		searchByKeys();
	else
		goHome();
}

function SearchKeyIncludePast() {
	$('includepast').value = "true";
	searchByKeys();
}

function SearchKeyNotIncludePast() {
	$('includepast').value = "";
	searchByKeys();
}

function searchByKeys() {
	setTimeout("submitSearchByKeys()", 10);
}
function submitSearchByKeys() {
	if ($('selectdates').value != "") {
		var dateexist = false;
		var name1 = "";
		for (i=1; i<11; i++) {
			name1 = 'st' + i;
			if ($(name1).value == "date") {
				dateexist = true;
				break;
			}
		}
		if (!dateexist) {
			$('selectdates').value = "";
		}
	}
	var url = location.href;
	if (url.indexOf("index.php") >= 0 || ($('otherkey').value == null || $('otherkey').value == "")) {
		submitURL(LS_SEARCH_BY_KEYS_URL);
	} else {
		submitURL(url);
	}
}

function createBreadcrumbs(lastlink) {
	
	var html = createBreadcrumbsHTML(lastlink, false);
	
	var d = $('breadcrumbs');
	d.innerHTML = html;
}

/**
 * 以下同様のものがbase_head.phpにもあります。
 */

/**************************************************************************************
 * lastlink	最後をリンクにするかどうか
 * nolink	全部をリンクにしないかどうか　イベントがヒットしなかったときの説明用
 */
function createBreadcrumbsHTML(lastlink, nolink) {
	var html = '';
	if (!nolink)
		html += '<a href="javascript:goHome()">イベント</a>';
	else
		html += 'イベント';
	
	if ($F('otherkey') != null && $F('otherkey') != "") {
		html += ' &gt; ';
		if ($F('otherkey') == "action") {
			if ($F('othervalue') == "watch") {
				html += '<a href="javascript:goWatchListPage()">ウォッチリスト </a>';
			}
		} else if ($F('otherkey') == "owner") {
			if (sessionid == $F('othervalue')) {
				html += '<a href="javascript:goUserPage(' + $F('othervalue') + ')">投稿したイベント </a>'
			} else {
				html += '<a href="javascript:goUserPage(' + $F('othervalue') + ')">オーナーID[' + $F('othervalue') + '] </a>'
			}
		}
	}
	
	var lastno = 0;
	var name1 = "";
	var name2 = "";
	for (i=1; i<=10; i++) {
		name1 = 'st' + i;
		name2 = 'sk' + i;
		if ($F(name1) == null || $F(name1) == "") {
			lastno = i - 1;
			break;
		}
	}
	for (i=1; i<=10; i++) {
		name1 = 'st' + i;
		name2 = 'sk' + i;
		if ($F(name1) != "" && $F(name2) != "") {
			
			var title = "";
			var value = $(name2).value;
			
			if ($F(name1) == "date") {
				title = "日付「";
				var month = value.substr(4,2);
				if (month.substr(0,1) == "0")
					month = month.substr(1);
				var date = value.substr(6,2);
				if (date.substr(0,1) == "0")
					date = date.substr(1);
				value = value.substr(0,4) + "年" + month + "月" + date + "日";
			} else if ($F(name1) == "district") {
				title = "場所「";
			} else if ($F(name1) == "word") {
				title = "キーワード「";
			} else if ($F(name1) == "tag") {
				title = "タグ「";
			}
			
			if (lastno == i) {
				if (!nolink && lastlink) {
					html += ' &gt; <a href="javascript:SearchKeyPosition(' + i + ')">' + title + value + '」</a>';
				} else {
					html += ' &gt; ' + title + value + '」';
				}
			} else {
				if (!nolink) {
					html += ' &gt; <a href="javascript:SearchKeyPosition(' + i + ')">' + title + value + '」</a>';
				} else {
					html += ' &gt; ' + title + value + '」';
				}
			}
		}
	}
	
	if (!nolink) {
		if ($F('includepast') == null || $F('includepast') == "") {
			if (!lastlink)
				html += '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:SearchKeyIncludePast()">過去のイベントを含めて検索</a>';
		} else {
			html += '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:SearchKeyNotIncludePast()">過去のイベントを含めないで検索</a>';
		}
	}
	
	return html;
}


function flushLogoStop() {
	$('flashlogo').remove();
}