/*
 *1	初期処理
 */
aulta.init.cookieDays(365);
aulta.data.loadSetting();

aulta.data.saveCookie('state', '', -1);
aulta.data.saveCookie('ckcuc', '', -1);
aulta.data.saveCookie('ckcun', '', -1);
aulta.data.saveCookie('ckcup', '', -1);
aulta.data.saveCookie('ckcus', '', -1);
aulta.data.saveCookie('ckcook', '', -1);


function showLoadingCover(cx,  cy, cw, ch, ix, iy){
	jQuery('#conter_form_loading img')
		.css('left', ix)
		.css('top', iy);
	jQuery('#conter_form_loading div')
		.width(cw)
		.height(ch);
	jQuery('#conter_form_loading')
		.css('left', cx)
		.css('top', cy)
		.width(cw)
		.height(ch)
		.show();
}
function hideLoadingCover(){
	jQuery('#conter_form_loading').hide();
}



window.sc = {
	dc : function(tagName){
		return document.createElement(tagName);
	}
	//, jc : function(tagName){
	//	return jQuery(document.createElement(tagName));
	//}
};

/*
 *1	window.me
 */
window.me = {
	/*
	 *2	val
	 */
	val : {
		/*
		 *3	location
		 */
		location : {
			/*
			 *4	contentId
			 */
			contentId : function(){
				var buf = document.location + '';
				buf = buf.split('/');
				return buf[buf.length - 2].substr(1).replace('game', '');
			},
			/*
			 *4	topicsId
			 */
			topicsId : function(){
				var buf = document.location + '';
				buf = buf.split('/');
				buf = buf[buf.length - 1];
				if (buf.substring(0,3) == 'all'){
					return buf.substr(3).replace('view.html', '');
				} else {
					return buf.substr(1).split('b')[0];
				}
			}
		}
	}
	/*
	 *2	bbs
	 */
	, bbs : {
		/*
		 *3	setLatest
		 */
		setLatest : function(text){
			jQuery('.view_list:eq(1)').append(text);
			//	サブウィンドウ 投稿者情報
			me.userInfo.createLink();
			
			//	修正・削除・報告
			me.bbs.createEditLink();
			
			var newid = jQuery(text).filter('dt:first').attr('id');
			aulta.event.scroll(newid, -100);
		}
		/*
		 *3	createEditLink
		 */
		, createEditLink : function(){
			jQuery('.view_list dd div.edit[link_edit!="on"]')
			.attr('link_edit', 'on')
			.each(function(){
				var keys;
				eval('keys = ' + jQuery(this).html());
				jQuery(this).html('');
				if (keys['tid']){
					if (keys['bid']){
						var bid = keys['bid']
							, arr = {
								3 : new Array('修正', function(){me.bbs.editControl(3, bid);})
								, 4 : new Array('削除', function(){me.bbs.editControl(4, bid);})
								, 5 : new Array('管理者に報告', function(){me.bbs.editControl(5, bid);})
							}
							, max = (me.ses.get('bbsAuth') == 1 ? 6 : 5);
							;
						for (var i = 3; i < max; i++){
							if (keys[i]){
								jQuery(this)
								.append(
									jQuery(document.createElement('span'))
									.attr('bid', bid)
									.html(arr[i][0])
									.addClass('out')
									.click(arr[i][1])
									.hover(
										function(){jQuery(this).addClass('in').removeClass('out')}
										, function(){jQuery(this).addClass('out').removeClass('in')}
									)
								);
							}
						}
						jQuery(this)
						.append(
							jQuery(document.createElement('div'))
							.hide()
							.attr('id', 'edit_area_' + keys['bid'])
							.attr('mode', '0')
							.css('text-align', 'left')
						)
						.prev()
						.attr('id', 'res' + keys['bid'])
						;
					}
				}
			});
		}
		/*
		 *3 editControl
		 */
		, editControl : function(mode, bid){
			var jq = jQuery('#edit_area_' + bid)
			, oldMode = jq.attr('mode')
			, func;
			if (oldMode == mode){
				jq.attr('mode', '0');
				jq.hide(500, function(){jq.html('');});
				return;
			}
			switch (mode){
				case 3:
					func = me.bbs.edit(mode, bid, jq);
					break;
				case 4:
					func = me.bbs.del(mode, bid, jq);
					break;
				case 5:
					func = me.bbs.vandal(mode, bid, jq);
					break;
			}
			if (oldMode == 0){
				func();
			} else {
				jq.hide(500, func);
			}
		}
		/*
		 *3	edit
		 */
		, edit : function(mode, bid, jq){
			return function(){
				var value = jQuery(document.getElementById('res' + bid)).html() + ''
				, bbssex = (jQuery('#bbs' + bid + ' span:eq(1)').text() == '女性')
				;
				value = value
					.replace(/<span.+<\/span>/ig, '')
					.replace(/<br[^>]*>/ig, "\n")
					.replace(/<\/p>[^<]*<p[^>]*>/ig, "\n\n")
					.replace(/<\/p>/ig, "")
					.replace(/<p[^>]*>/ig, "")
					.replace(/<a href[^>]*>/ig, "")
					.replace(/<\/a[^>]*>/ig, "")
					.replace(/&lt;/g, '<')
					.replace(/&gt;/g, '>')
					.replace(/&quot;/g, '"')
					.replace(/&amp;/g, '&')
					;
				jq
				.html('')
				.append(
					jQuery(document.createElement('form'))
					.append(
						jQuery(document.createElement('div'))
						.html('↑↑↑ この投稿を<span style="color:red;margin:5px;">修正</span>します。')
						.css('color', 'green')
					)
					.append(
						jQuery('<textarea name="cnote"></textarea>')
						//.attr('name', 'cnote')
						.width(450)
						.height(250)
						.val(value)
					)
					.append(
						jQuery(document.createElement('div'))
						.html(
							'性別　<select name="cus">'
								+ '<option value="0"' + (!bbssex ? ' selected="selected"' : '') + '>男性</option>'
								+ '<option value="1"' + (bbssex ? ' selected="selected"' : '') + '>女性</option></select>'
						)
						.css('padding', '8px')
					)
					.append(
						jQuery(document.createElement('dl'))
						.addClass('cont_user_info')
						.addClass('cbox')
						.append(
							jQuery(document.createElement('dt')).html('名前')
						)
						.append(
							jQuery(document.createElement('dd')).html('<input type="text" size="15" name="cun" value="' + me.ses.get('bbsName') + '"/>（10文字以内）')
						)
						.append(
							jQuery(document.createElement('dt')).html('パスワード')
						)
						.append(
							jQuery(document.createElement('dd')).html('<input type="password" size="15" name="cup" value="' + me.ses.get('bbsPass') + '"/>（英数３文字以上）')
						)
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.val('修正する')
						.width(120)
						.height(32)
						.click(function(){
							var form = document.getElementById('edit_area_' + bid).getElementsByTagName('form')[0];
							var ret = me.cont.check(form);
							
							if (ret[1].length > 0){
								alert(ret[1]);
								return false;
							} else {
								if ( ! confirm('この内容で修正してもよろしいですか？' + "\n"
									+ "\n"
									+ '【OK】ボタンを押すと、通信を行います。' + "\n"
									+ "\n"
									+ '※名前とパスワードは、投稿時のものを入力してください。' + "\n"
									+ '※①やⅢのような一部の文字は、似たような文字に置き換わります。' + "\n"
									+ '※入力内容に不安がある方はキャンセルを押して、再確認をしてください。' + "\n"
								)){
									return false;
								}
								me.cont.send('/ajax/bbs/conter.a'
									, param = ret[0] + '&bbsId=' + bid + '&act=edit'
									, function(text){
										if (text.substr(0,2) == 'ok'){
											jq.hide(500, function(){
												jq.html('').attr('mode', 0);
											});
											document.getElementById('conter').cnote.value = '';
											setTimeout(function(){
												alert('修正が完了しました。');

												jQuery('#res' + bid).html(
													aulta.string.replaceText(form.cnote.value, 1)
													+ '<br /><span style="color: darkgreen;">修正しました。</span>'
												);
												if (form.cus.value == 0){
													jQuery('#bbs' + bid + ' span:eq(1)')
													.html('男性')
													.css('color', 'blue');
												} else {
													jQuery('#bbs' + bid + ' span:eq(1)')
													.html('女性')
													.css('color', 'red');
												}
												aulta.event.scroll('bbs' + bid);
											}, 1000);
										} else {
											alert(text);
										}
									}
									, 100, 100
									, 'edit_area_' + bid
									, 'edit_area_' + bid
								);
							}
							return false;
							
						})
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.attr('value', '閉じる')
						.width(120)
						.height(32)
						.css('margin-left', '15px')
						.click(function(){
							jq.hide(500, function(){
								jq.html('').attr('mode', 0);
							});
						})
					)
				)
				.show(500);
				jq.attr('mode', mode);
			};
		}
		/*
		 *3	del
		 */
		, del : function(mode, bid, jq){
			return function(){
				jq
				.html('')
				.append(
					jQuery(document.createElement('form'))
					.append(
						jQuery(document.createElement('div'))
						.html('↑↑↑ この投稿を<span style="color:red;margin:5px;">削除</span>します。')
						.css('color', 'green')
					)
					.append(
						jQuery(document.createElement('dl'))
						.addClass('cont_user_info')
						.addClass('cbox')
						.append(
							jQuery(document.createElement('dt')).html('名前')
						)
						.append(
							jQuery(document.createElement('dd')).html('<input type="text" size="15" name="cun" value="' + me.ses.get('bbsName') + '"/>（10文字以内）')
						)
						.append(
							jQuery(document.createElement('dt')).html('パスワード')
						)
						.append(
							jQuery(document.createElement('dd')).html('<input type="password" size="15" name="cup" value="' + me.ses.get('bbsPass') + '"/>（英数３文字以上）')
						)
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.val('削除する')
						.width(120)
						.height(32)
						.click(function(){
							var form = document.getElementById('edit_area_' + bid).getElementsByTagName('form')[0];
							var ret = me.cont.check(form);
							
							if (ret[1].length > 0){
								alert(ret[1]);
								return false;
							} else {
								if ( ! confirm('この内容を削除してもよろしいですか？' + "\n"
									+ "\n"
									+ '【OK】ボタンを押すと、通信を行います。'
								)){
									return false;
								}
								me.cont.send('/ajax/bbs/conter.a'
									, param = ret[0] + '&bbsId=' + bid + '&act=delete'
									, function(text){
										if (text.substr(0,2) == 'ok'){
											jq.hide(500, function(){
												jq.html('').attr('mode', 0);
											});
											document.getElementById('conter').cnote.value = '';
											setTimeout(function(){
												alert('削除が完了しました。');
												jQuery('#bbs' + bid).html('<span class="c" style="margin-left:10px;">削除</span>');
												jQuery('#res' + bid)
												.html('<span style="color: darkgreen;">削除しました。</span>')
												.next().html('')
												;
												aulta.event.scroll('bbs' + bid);
											}, 1000);
										} else {
											alert(text);
										}
									}
									, 100, 50
									, 'edit_area_' + bid
									, 'edit_area_' + bid
								);
							}
							return false;
						})
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.attr('value', '閉じる')
						.width(120)
						.height(32)
						.css('margin-left', '15px')
						.click(function(){
							jq.hide(500, function(){
								jq.html('').attr('mode', 0);
							});
						})
					)
				)
				.show(500);
				jq.attr('mode', mode);
			};
		}
		/*
		 *3	vandal
		 */
		, vandal : function(mode, bid, jq){
			return function(){
				jq
				.html('')
				.append(
					jQuery(document.createElement('form'))
					.append(
						jQuery(document.createElement('div'))
						.html('↑↑↑ この投稿を<span style="color:red;margin:5px;">管理者に報告</span>します。')
						.css('color', 'green')
					)
					.append(
						jQuery(document.createElement('dl'))
						.addClass('cont_user_info')
						.addClass('cbox')
						.append(
							jQuery(document.createElement('dt')).html('名前')
						)
						.append(
							jQuery(document.createElement('dd')).html(me.ses.get('bbsName'))
						)
						.append(
							jQuery(document.createElement('dt')).html('パスワード')
						)
						.append(
							jQuery(document.createElement('dd')).html(aulta.string.toPassChar(me.ses.get('bbsPass')))
						)
						.append('<input type="hidden" name="cun" value="' + me.ses.get('bbsName') + '" />')
						.append('<input type="hidden" name="cup" value="' + me.ses.get('bbsPass') + '" />')
					)
					.append(
						jQuery(document.createElement('ul'))
						.html('<li>●みんなにとって不愉快な文章ですか？</li>'
								+ '<li>●宣伝や広告を目的とした文章ですか？</li>'
						)
						.css('color', 'red')
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.val('報告する')
						.width(120)
						.height(32)
						.click(function(){
							var form = document.getElementById('edit_area_' + bid).getElementsByTagName('form')[0];
							var ret = me.cont.check(form);
							
							if (ret[1].length > 0){
								alert(ret[1]);
								return false;
							} else {
								if ( ! confirm('この内容を管理者に報告してもよろしいですか？' + "\n"
									+ "\n"
									+ '【OK】ボタンを押すと、通信を行います。'
								)){
									return false;
								}
								me.cont.send('/ajax/bbs/conter.a'
									, param = ret[0] + '&bbsId=' + bid + '&act=vandal'
									, function(text){
										if (text.substr(0,2) == 'ok'){
											jq.hide(500, function(){
												jq.html('').attr('mode', 0);
											});
											document.getElementById('conter').cnote.value = '';
											setTimeout(function(){
												alert('報告が完了しました。');
												jQuery(document.getElementById('res' + bid).parentNode).addClass('a1');
												//jQuery('#bbs' + bid).html('<span class="c" style="margin-left:10px;">削除</span>');
												//jQuery('#res' + bid)
												//.html('<span style="color: darkgreen;">削除しました。</span>')
												//.next().html('')
												//;
												aulta.event.scroll('bbs' + bid);
											}, 1000);
										} else {
											alert(text);
										}
									}
									, 100, 50
									, 'edit_area_' + bid
									, 'edit_area_' + bid
								);
							}
							return false;
						})
					)
					.append(
						jQuery(document.createElement('input'))
						.attr('type', 'button')
						.attr('value', '閉じる')
						.width(120)
						.height(32)
						.css('margin-left', '15px')
						.click(function(){
							jq.hide(500, function(){
								jq.html('').attr('mode', 0);
							});
						})
					)
				)
				.show(500)
				.attr('mode', mode);
			};
		}
		/*
		 *3
		 */
	}
	/*
	 *2	cont
	 */
	, cont : {
		/*
		 *3	check
		 */
		check : function(form){
			var param = ''
				, errorMessage = ''
				, fcun = form.cun
				, fcup = form.cup
				, fcus = form.cus
				, fcnote = form.cnote
				, fcook = form.cook
				;
			fcun.value = aulta.string.replaceText(fcun.value, 0);
			fcup.value = aulta.string.replaceText(fcup.value, 0);
			if (fcnote){
				fcnote.value = aulta.string.replaceText(fcnote.value, 0);
				fcnote.value = aulta.string.replaceDependenceChar(fcnote.value, 0);
			}
			var cun = (fcun ? fcun.value : '') + ''
				, cup = (fcup ? fcup.value : '') + ''
				, cus = (fcus ? fcus.value : '') + ''
				, cnote = (fcnote ? fcnote.value : '') + ''
				, cook = (fcook ? fcook.value : '') + ''
				, csort = ''
				, lastNo = jQuery('.view_list:eq(1) dt:last span:first').html() + "";
				;
				
			jQuery('#conter input[name="csort"]')
			.each(function(){
				if (this.checked) csort = this.value + '';
			});

			if ( ! aulta.string.ereg(cun, '^.{1,10}$')){
				errorMessage += '●名前は、1～10文字で入力してください。' + "\n\t" + '現在:' + cun.length + '文字' + "\n";
			}
			if ( ! aulta.string.ereg(cup, '^[0-9a-zA-Z]{3,100}$')){
				errorMessage += '●パスワードは、英数字で、3文字以上入力してください。' + "\n\t" + '現在:' + cup.length + '文字' + "\n";
			}
			if (fcus){
				if ( ! aulta.string.ereg(cus, '^[01]{1}$')){
					errorMessage += '●性別を選択してください。' + "\n";
				}
			}
			if (fcnote){
				if ( ! aulta.string.ereg(cnote.replace(/\n/g, ' '), '^.{3,3000}$')){
					errorMessage += '●投稿内容は、3～3000文字で入力してください。' + "\n\t" + '現在:' + cnote.length + '文字' + "\n";
				}
			}
			if (cook != '0') cook = '1';
			
			param = '&cun=' + aulta.string.urlencode(cun)
								+ '&cup=' + aulta.string.urlencode(cup)
								+ '&contentId=' + me.val.location.contentId()
								+ '&topicsId=' + me.val.location.topicsId()
								+ '&ajax=ajax';
								
			if (fcus){
				param += '&cus=' + cus;
			}
			if (fcnote){
				param += '&cnote=' + aulta.string.urlencode(cnote);
			}
			if (form.cook){
				if (lastNo == "null") lastNo = 0;
				param += '&cook=' + cook
								+ '&csort=' + csort
								+ '&lastNo=' + lastNo;
			}
			//alert(param);
			return new Array(param, errorMessage);
		}
		/*
		 *3	send
		 */
		, send : function(url, param, callback, loadingX, loadingY, targetId, toId){
			setTimeout(function(){
				aulta.ajax.request(function(ret){
					hideLoadingCover();
					var text = aulta.ajax.analyze(ret);
					if (text == false){
					} else {
						callback(text);
					}
				}, url, param);
			}, 2000);
			if (toId.length > 0) aulta.event.scroll(toId, -80);
			
			var jq = jQuery('#' + targetId);
			var pos = aulta.pos.getAbsolute(targetId);
			showLoadingCover(
				pos[0]
				, pos[1]
				, jq.width()
				, jq.height()
				, loadingX, loadingY
			);
		}
	}
	/*
	 *2	userInfo
	 */
	, userInfo : {
		/*
		 *3	createLink
		 */
		createLink : function(){
			jQuery('.view_list dt[link_user_info!="on"]')
			.attr('link_user_info', 'on')
			.append(
				jQuery(document.createElement('span'))
				.html('【投稿者情報】')
				.css('color', 'blue')
				.css('font-size', '10px')
				.css('font-weight', 'normal')
				.css('margin-left', '10px')
				.css('cursor', 'pointer')
			);
			jQuery('.view_list dt span:last-child')
			.hover(
				function(){jQuery(this).css('text-decoration', 'underline').css('color', 'red')}
				, function(){jQuery(this).css('text-decoration', 'none').css('color', 'blue')}
			)
			.click(function(){
				me.userInfo.open(this);
			})
			;
		}
		/*
		 *3	open
		 */
		, open : function(obj){
			var a = obj.parentNode.getElementsByTagName('a');
			if (a.length == 0){
				obj.innerHTML = '';
				return false;
			}
			a = a[0];
			var href = a.href;
			var buf = href.split('/');
			var no = buf[buf.length - 1];
			no = no.replace('info', '').replace('.html', '');
			var nm = a.innerHTML;
			nm = nm.split('<')[0];
			if (aulta.subwindow.create('userinfo' + no)){
				aulta.subwindow.setTitle(nm + ' さんの投稿情報');
				aulta.subwindow.setHtml('<img src="/img/loading.gif" />');
				var func = function(ret){
					var text = aulta.ajax.analyze(ret);
					if (text == false){
					} else {
					
						aulta.subwindow.setHtml(text);
						
						jQuery('.user_info_data h2')
						.each(function(){
							aulta.create.cornerCircle(this, 'white', 0, 0);
						})
						;
						jQuery('.user_info .frameHead')
						.each(function(){
							aulta.create.cornerCircle(this, 'white', 1, 0);
						})
						;
						jQuery('.user_info .frame dd:last-child')
						.css('margin-bottom', '0px')
						.css('padding-bottom', '0px')
						.css('border', '0')
						;
						jQuery('.cont_place')
						.tableHeadFix({height:180})
						.headTable()		//ヘッダtable
						.bodyTable()		//ボディtable
						.wrapObject()		//包括div
							.css('margin', 'auto')
						;
					}
				}
				aulta.ajax.request(func, '/ajax/user/info' + no + '.a', '&ajax=ajax');
			}
			var jw = jQuery(window)
				, x = 50
				, y = aulta.pos.top() + 80
				, w = jw.width()
				//, h = jw.height() - 160
				, h = 500
				;
			if (w > 750){
				x = (w - 750) / 2
				w = 750;
			}
			aulta.subwindow.move(x, y);
			aulta.subwindow.resize(w, h);
		}
	}
};



/*
 *2	ses
 */
window.me.ses = new function(){
	var _values = {
		bbsName : ''
		, bbsPass : ''
		, bbsSex : -1
		, bbsCook : ''
		, bbsAuth : 0
	};
	/*
	 *3	load
	 */
	this.load = function(callback){
		aulta.ajax.request(function(ret){
			var text = aulta.ajax.analyze(ret);
			if (text == false){
			} else {
				var arr = '';
				eval('arr = ' + text);
				if (typeof(arr) == 'object'){
					_values = arr;
				}
			}
			callback();
		}, '/ajax/load.a', '&ajax=ajax');
	};
	/*
	 *3	save
	 */
	this.save = function(callback){
		aulta.ajax.request(function(ret){
			var text = aulta.ajax.analyze(ret);
			callback((text == 'ok'));
		}, '/ajax/save.a', '&ajax=ajax&data=' + JSON.stringify(_values));
	};
	/*
	 *3	get
	 */
	this.get = function(key){
		return _values[key];
	};
	/*
	 *3	set
	 */
	this.set = function(key, value){
		_values[key] = value;
	};
	/****/
};

/*
 *3	load
 *
window.me.ses.load = function(callback){
	aulta.ajax.request(function(ret){
		var text = aulta.ajax.analyze(ret);
		if (text == false){
		} else {
			var arr = '';
			eval('arr = ' + text);
			if (typeof(arr) == 'object'){
				this._values = arr;
			}
		}
		callback();
	}, '/ajax/load.a', '&ajax=ajax');
};
/*
 *3	save
 *
window.me.ses.save = function(callback){
	aulta.ajax.request(function(ret){
		var text = aulta.ajax.analyze(ret);
		callback((text == 'ok'));
	}, '/ajax/save.a', '&ajax=ajax&data=' + JSON.stringify(this._values));
};
/*
 *3	get
 *
window.me.ses.get = function(key){
	return this._values[key];
};
/*
 *3	set
 *
window.me.ses.set = function(key, value){
	this._values[key] = value;
};

/*
 *1	window.onetime
 */
window.onetime = {
	/*
	 *2	loading
	 */
	loading : {
		/*
		 *3	thisDelete
		 */
		thisDelete : function(){
			var p = onetime.loading;
			if (aulta.utility.propertyLength(p) == 1){
				delete p.thisDelete;
				delete onetime.loading;
			}
		}
		/*
		 *3	headerTitle
		 */
		, headerTitle : function(){
			jQuery('#headerTitle')
			.wrapInner(
				jQuery(document.createElement('div'))
				.css('padding-top', '10px')
				.width(166)
			)
			.append(
				jQuery(document.createElement('div'))
				.css('position', 'absolute')
				.css('backgroundImage', 'url(/img/title1.gif)')
				.css('backgroundRepeat', 'no-repeat')
				.css('backgroundPosition', '0px 0px')
				.css('left', '-26px')
				.css('top', '0px')
				.width(26)
				.height(57)
			).append(
				jQuery(document.createElement('div'))
				.css('position', 'absolute')
				.css('backgroundImage', 'url(/img/title1.gif)')
				.css('backgroundRepeat', 'no-repeat')
				.css('backgroundPosition', '-26px 0px')
				.css('right', '-26px')
				.css('top', '0px')
				.width(26)
				.height(57)
			)
			;
			if (document.getElementById('error')){
				initHeaderTitle = null;
				return;
			}
			
			me.ses.load(
				function(){
					var form = document.getElementById('headerForm');
					if (form){
						form.bbsname.value = me.ses.get('bbsName');
						form.bbspass.value = me.ses.get('bbsPass');
						form.bbssex.value = me.ses.get('bbsSex');
					//} else {
					//	setTimeout(arguments.callee, 200);
					}
					form = document.getElementById('conter');
					if (form){
						form.cun.value = me.ses.get('bbsName');
						form.cup.value = me.ses.get('bbsPass');
						form.cus.value = me.ses.get('bbsSex');
						form.cook.value = me.ses.get('bbsCook');
					}
				}
			);
			
			var bbsName = ''
				, bbsPass = ''
				, bbsSex = -1
				, html
					= '<div style="position:absolute;left:8px;top:8px;">'
						+ '名前 : <input type="text" name="bbsname" value="' + bbsName + '" style="width:100px;" />'
					+ '</div>'
					+ '<div style="position:absolute;left:8px;bottom:8px;">'
						+ 'パス : <input type="password" name="bbspass" value="' + bbsPass + '" style="width:100px;" />'
					+ '</div>'
					+ '<div style="position:absolute;left:156px;top:8px;">'
						+ '<select name="bbssex">'
							+ '<option value="-1"' + (bbsSex == '' ? ' selected="selected"' : '') + '>性別選択</option>'
							+ '<option value="0"' + ((bbsSex != '' && bbsSex == 0) ? ' selected="selected"' : '') + '>男性</option>'
							+ '<option value="1"' + (bbsSex == 1 ? ' selected="selected"' : '') + '>女性</option>'
						+ '</select>'
					+ '</div>'
			;
			var btn = document.createElement('input')
				, sbtn = btn.style;
			btn.type = 'button';
			btn.value = '設定を保存する';
			sbtn.position = 'absolute';
			sbtn.left = '156px';
			sbtn.bottom = '8px';
			sbtn.width = '100px';
			btn.onclick = function(){
				var altData = aulta.data
					, form = document.getElementById('headerForm');
				form.bbsname.value = aulta.string.trim(form.bbsname.value);
				form.bbspass.value = aulta.string.trim(form.bbspass.value);
				var nm = form.bbsname.value
					, pw = form.bbspass.value
					, sx = form.bbssex.value
					, flg = true
					;
				if (pw.length == 0){
					if (!confirm('パスワードが設定されていません。' + "\n\n" + 'このまま保存をしてもよろしいですか？')){
						flg = false;
					}
				}
				if (flg){
					me.ses.set('bbsName', nm);
					me.ses.set('bbsPass', pw);
					me.ses.set('bbsSex', sx);
					me.ses.save(function(ret){
						if (ret){
							form = document.getElementById('conter');
							if (form){
								form.cun.value = me.ses.get('bbsName');
								form.cup.value = me.ses.get('bbsPass');
								form.cus.value = me.ses.get('bbsSex');
								form.cook.value = me.ses.get('bbsCook');
							}
							alert('設定を保存しました。' + "\n\n"
								+ 'パスワードは忘れないようにしてください。' + "\n"
								+ '掲示板投稿欄も変更されていますのでご注意ください。');
						} else {
							alert('サーバ側で保存エラーが発生しました。' + "\n\n" + '内容を見直して、再度ボタンを押してください。');
						}
					});
					
				}
			};
			//
			var div = document.createElement('div')
				sdiv = div.style;
			div.id = 'header_form_exp';
			div.innerHTML = '<div style="padding:8px;">'
				+ '<p>ここは、利用者さんのパソコンごとに保存している内容です。</p>'
				+ '<p>これらの情報を<span>削除したい時</span>は、項目の内容を空白にして「設定を保存する」を押してください。（掲示板投稿欄の名前なども削除します）</p>'
				+ '<p>友達・学校・漫画喫茶など<span>他人のパソコン</span>で利用した後は、ここで設定情報を削除することをオススメします。</p>'
				+ '<p>【名前】【パスワード】【性別】は、掲示板に投稿するときに使用します。</p>'
				+ '<p>【フォント名】【文字サイズ】を変更すると、画面内の文字の形や大きさが変わります。'
				+ '※利用するパソコンに「フォント」がインストールされていない場合は、デフォルトのフォントが使用されます。</p>'
			+ '</div>';
			document.getElementById('headerContent').appendChild(div);
			//
			jQuery('#headerContent')
			.append(
				jQuery(document.createElement('form'))
				.attr('id', 'headerForm')
				.html(html)
				.append(btn)
				.hover(
					function(){
						jQuery('#header_form_exp').show(500);
					}
					, function(){
						jQuery('#header_form_exp').hide(500);
					}
				)
			);
			aulta.create.cornerCircle('headerForm', jQuery('#header').css('background-color'), 0, 0);
			
			delete onetime.loading.headerTitle;
			onetime.loading.thisDelete();
		}
		/*
		 *3	eraceTabText
		 */
		, eraceTabText : function(){
			jQuery('#tabSelect a').html('　');
			delete onetime.loading.eraceTabText;
			onetime.loading.thisDelete();
		}
		/*
		 *3	main	#mainロード直後
		 */
		, main : {
			/*
			 *4	run
			 */
			run : function(){
				aulta.create.boxFont('headerForm', 'main', -8, 8);
				aulta.create.boxFontSize('headerForm', 'main', -8, -8);
				var div = document.createElement('div');
				div.innerHTML = '文字サイズ : ';
				aulta.create.box('headerForm', div, -54, -10);
				
				if (document.getElementById('index')){
					onetime.loading.main.index();
				} else if (document.getElementById('bbs_topics')){
					onetime.loading.main.bbs_topics();
					
				} else if (document.getElementById('bbs_view')){
					onetime.loading.main.bbs_view();
					
				} else if (document.getElementById('bbs_viewall')){
					onetime.loading.main.bbs_viewall();
					
				} else if (document.getElementById('user_info')){
					onetime.loading.main.user_info();
					
				} else if (document.getElementById('category')){
					onetime.loading.main.category();
				}
				
				delete onetime.loading.main.index;
				delete onetime.loading.main.bbs_topics;
				delete onetime.loading.main.bbs_view;
				delete onetime.loading.main.bbs_viewall;
				delete onetime.loading.main.user_info;
				delete onetime.loading.main.category;
				delete onetime.loading.main.run;
				delete onetime.loading.main;
				onetime.loading.thisDelete();
			}
			/*
			 *4 index
			 */
			, index : function(){
				
			}
			/*
			 *4 bbs_topics
			 */
			, bbs_topics : function(){
				
				var contentNo = jQuery('#create_topics_contentno').val();
				if (contentNo.length > 0){
					var topicsList = document.getElementById('topicsList')
						, loc = document.location.href;
						
					loc = (loc.substr(loc.length - 1) == '/')
					if (loc && (topicsList.getElementsByTagName('dt').length < 10)){
						jQuery(topicsList)
						.append(
							jQuery(document.createElement('dt'))
							.html('新しいトピックスを作成してみませんか？')
							.css('color', 'green')
							.css('padding-left', '15px')
						)
						.append(
							jQuery(document.createElement('dd'))
							.append(
								jQuery(document.createElement('div'))
								.html(
									'このゲームはまだまだトピックスが少ない状況です。<br />'
									+ 'あなたがこのゲームに興味があり、このゲームを持っている人との交流を望んでいるなら、下記のリンクからトピックスを作成してみませんか？'
								)
								.css('text-align', 'left')
								.css('margin-bottom', '20px')
							)
							.append(
								jQuery(document.createElement('div'))
								.append(
									jQuery(document.createElement('img'))
									.attr('src', '/img/btn/a2.gif')
									.attr('alt', '新しいトピックスを作成する')
									.attr('width', '229')
									.attr('height', '23')
									.css('cursor', 'pointer')
									.click(function(){
										jQuery('#create_topics img').click();
									})
								)
								.css('text-align', 'center')
							)
						);
					}
					
					jQuery('#create_topics')
					.css('text-align', 'right')
					.append(
						jQuery(document.createElement('img'))
						.attr('src', '/img/btn/a2.gif')
						.attr('alt', '新しいトピックスを作成する')
						.attr('width', '229')
						.attr('height', '23')
						.css('cursor', 'pointer')
						.click(function(){
							if (aulta.subwindow.create('createtopics')){
								aulta.subwindow.setTitle('新しいトピックスを作成する');
								aulta.subwindow.setHtml('<img src="/img/loading.gif" />');
								
								aulta.subwindow.setHtmlElm(
									jQuery(document.createElement('form'))
									.attr('id', 'createtopics_form')
									.submit(function(){
										return false;
									})
									.append(
										jQuery(document.createElement('p'))
										.attr('id', 'createtopics_explanation')
										.html('<h2>トピックスを作成する前に・・・</h2>'
											+ '<ul>'
												+ '<li>トピックス作成の前に、検索を行いましたか？</li>'
												+ '<li>既に別の人が同じようなトピックスを作っている場合は、そちらに投稿してください。</li>'
												+ '<li>攻略情報の質問の場合、トピックスを作成して聞くよりも、掲示板検索で既にある回答を探したほうが早く問題解決できる場合が多くあります。</li>'
												+ '<li>過去のトピックスに回答がある場合、新しく質問をしても、「検索して」という回答しか貰えないこともあります。</li>'
												+ '<li>似たようなトピックスが作られた場合、ロックや削除をすることもあります。</li>'
											+ '</ul>'
										)
										.append(
											jQuery(document.createElement('input'))
											.attr('type', 'button')
											.attr('value', '承諾してトピックスの作成を続ける')
											.click(function(){
												var f = document.getElementById('createtopics_form')
												f.bbsname.value = me.ses.get('bbsName');
												f.bbspass.value = me.ses.get('bbsPass');
												f.bbssex.value = me.ses.get('bbsSex');
												jQuery('#createtopics_explanation')
												.hide(500, function(){
													jQuery('#createtopics_inputs').show(500)
												})
											})
										)
										.append(
											jQuery(document.createElement('input'))
											.attr('type', 'button')
											.attr('value', 'キャンセル')
											.click(function(){
												aulta.subwindow.selectTargetWindow('createtopics');
												aulta.subwindow.close();
											})
										)
									)
									.append(
										jQuery(document.createElement('div'))
										.attr('id', 'createtopics_inputs')
										.css('display', 'none')
										.append(
											jQuery(document.createElement('h3'))
											.html('投稿者情報を入力してください。')
										)
										.append(
											jQuery(document.createElement('table'))
											.html(''
												+ '<tr>'
													+ '<td>名前</td>'
													+ '<td><input type="text" name="bbsname" value="" /></td>'
												+ '</tr>'
												+ '<tr>'
													+ '<td>パスワード</td>'
													+ '<td><input type="password" name="bbspass" value="" /></td>'
												+ '</tr>'
												+ '<tr>'
													+ '<td>性別</td>'
													+ '<td><select name="bbssex"><option value="-1">選択</option><option value="0">男性</option><option value="1">女性</option></select></td>'
												+ '</tr>'
											)
										)
										.append(
											jQuery(document.createElement('h3'))
											.html('トピックスを作成する場所を選択してください。')
										)
										.append(
											jQuery(document.createElement('ul'))
											.append(
												jQuery(document.createElement('li'))
												.append(
													jQuery(document.createElement('label'))
													.html('<input type="radio" name="ctopitype" value="3" />雑談や会話など')
												)
											)
											.append(
												jQuery(document.createElement('li'))
												.append(
													jQuery(document.createElement('label'))
													.html('<input type="radio" name="ctopitype" value="2" />質問・攻略法・裏技（雑談禁止）')
												)
											)
											.append(
												jQuery(document.createElement('li'))
												.append(
													jQuery(document.createElement('label'))
													.html('<input type="radio" name="ctopitype" value="0" />ネット・通信（wi-fiなど）')
												)
											)
										)
										.append(
											jQuery(document.createElement('h3'))
											.html('トピックスのタイトルを入力してください。')
										)
										.append(
											jQuery(document.createElement('p'))
											.html(''
												+ 'トピックス名だけで内容が分かるように、<br />'
												+ '具体的で簡潔なトピックス名をつけてください。'
												+ '<input type="text" name="ctitle" value="" />'
											)
										)
										.append(
											jQuery(document.createElement('h3'))
											.html('内容を入力してください。')
										)
										.append(
											jQuery(document.createElement('p'))
											.html(''
												+ '本文は、50文字以上必須です。<br />'
												+ 'トピックスの使い方・目的・ルールなども書いてください。<br />'
												+ '続きもののトピックスの場合は、前回のトピックスのURLを書いてください'
												+ '<textarea name="cnote"></textarea>'
											)
										)
										.append(
											jQuery(document.createElement('h3'))
											.html('入力した内容を再度確認してください。')
											
										)
										.append(
											jQuery(document.createElement('p'))
											.append(
												jQuery(document.createElement('input'))
												.attr('type', 'button')
												.attr('value', '上記の内容で作成する')
											)
											.click(function(){
												
												var form = document.getElementById('createtopics_form')
													, errorMessage = ''
													;
												
												form.bbsname.value = aulta.string.replaceText(form.bbsname.value, 0);
												form.bbspass.value = aulta.string.replaceText(form.bbspass.value, 0);
												form.ctitle.value = aulta.string.replaceText(form.ctitle.value, 0);
												form.ctitle.value = aulta.string.replaceDependenceChar(form.ctitle.value, 0);
												form.cnote.value = aulta.string.replaceText(form.cnote.value, 0);
												form.cnote.value = aulta.string.replaceDependenceChar(form.cnote.value, 0);
												
												var bbsname = form.bbsname.value + ''
													, bbspass = form.bbspass.value + ''
													, bbssex = form.bbssex.value + ''
													, ctopitype = -1
													, ctitle = form.ctitle.value + ''
													, cnote = form.cnote.value + ''
													;
												jQuery('#createtopics_form input[name="ctopitype"]')
												.each(function(){
													if (this.checked) ctopitype = this.value;
												})
												ctopitype += '';
												
												if ( ! aulta.string.ereg(bbsname, '^.{1,10}$')){
													errorMessage += '名前は、1～10文字で入力してください。' + "\n" + '現在:' + bbsname.length + '文字' + "\n";
												}
												if ( ! aulta.string.ereg(bbspass, '^[0-9a-zA-Z]{3,100}$')){
													errorMessage += 'パスワードは、英数字で、3文字以上入力してください。' + "\n" + '現在:' + bbspass.length + '文字' + "\n";
												}
												if ( ! aulta.string.ereg(bbssex, '^[01]{1}$')){
													errorMessage += '性別を選択してください。' + "\n";
												}
												if ( ! aulta.string.ereg(ctopitype, '^[023]{1}$')){
													errorMessage += 'トピックスの種類を選択してください。' + "\n";
												}
												if ( ! aulta.string.ereg(ctitle, '^.{4,30}$')){
													errorMessage += 'トピックスのタイトルを、4～30文字で入力してください。' + "\n" + '現在:' + ctitle.length + '文字' + "\n";
												}
												if ( ! aulta.string.ereg(cnote.replace(/\n/g, ' '), '^.{50,3000}$')){
													errorMessage += '投稿内容は、50～3000文字で入力してください。' + "\n" + '現在:' + cnote.length + '文字' + "\n";
												}
												
												if (errorMessage.length > 0){
													alert(errorMessage);
													return false;
												} else {
													if ( ! confirm('この内容でトピックスを新規作成してもよろしいですか？' + "\n"
														+ '【OK】ボタンを押すと、作成を行います。' + "\n"
														+ "\n"
														+ '※入力内容に不安がある方はキャンセルを押して、再確認をしてください。'
													)){
														return false;
													}
													var url = '/ajax/bbs/createTopics.a'
														, param = '&cun=' + aulta.string.urlencode(bbsname)
															+ '&cup=' + aulta.string.urlencode(bbspass)
															+ '&cus=' + bbssex
															+ '&cook=0'
															+ '&ctopitype=' + ctopitype
															+ '&ctitle=' + aulta.string.urlencode(ctitle)
															+ '&cnote=' + aulta.string.urlencode(cnote)
															+ '&contentId=' + me.val.location.contentId()
															+ '&ajax=ajax'
															;
													var func = function(ret){
														var text = aulta.ajax.analyze(ret);
														if (text == false){
														} else {
															if (text.substr(0,3) == 'ok_'){
																eval(text.substr(3));
															} else {
																alert(text);
															}
														}
													}
													, send = function(){aulta.ajax.request(func, url, param);};
													setTimeout(send, 1000);
												}
												return false;
											})
										)
									)
								);
								jQuery('#createtopics_form input[name="ctopitype"]')
								.click(function(){
									jQuery('#createtopics_form input[name="ctopitype"]').parent().css('color', 'black');
									jQuery(this).parent().css('color', 'red');
								});
							}
							var jw = jQuery(window)
								, x = (jw.width() - 550) / 2
								, y = aulta.pos.top() + 120
								;
							aulta.subwindow.move(x, y);
							aulta.subwindow.resize(550, 400);
							
						})
					);
				} else {
					jQuery('#create_topics')
					.css('text-align', 'right')
					.append(
						jQuery(document.createElement('div'))
						.html('新しいトピックスの作成は制限しています。')
						.css('color', 'green')
					);
				}
				jQuery('#amazon_all_review img')
				.mouseover(function(){
					this.src = this.src.replace('a.gif', 'b.gif');
				})
				.mouseout(function(){
					this.src = this.src.replace('b.gif', 'a.gif');
				});
			}
			/*
			 *4 bbs_view
			 */
			, bbs_view : function(){
				
				aulta.create.cornerCircle('topi_title', 'white', 0, 0);

				///	サブウィンドウ	トピックス内検索
				onetime.init.createLinkTopicsSearchSubWindow();
				
				///	サブウィンドウ 投稿者情報
				me.userInfo.createLink();
				
				///	修正・削除・報告
				me.bbs.createEditLink();
				
				
				///	返信フォーム
				jQuery('#conter input[type="submit"]')
				.val('投稿する')
				.width(120)
				.height(32)
				;
				
				
				jQuery('#conter')
				.submit(function(){
					var ret = me.cont.check(document.getElementById('conter'));
					if (ret[1].length > 0){
						alert(ret[1]);
						return false;
					} else if ( ! confirm('この内容で投稿してもよろしいですか？' + "\n"
							+ "\n"
							+ '【OK】ボタンを押すと、通信を行います。' + "\n"
							+ "\n"
							+ '※①やⅢのような一部の文字は、似たような文字に置き換わります。' + "\n"
							+ '※入力内容に不安がある方はキャンセルを押して、再確認をしてください。' + "\n"
						)){
						return false;
					} else {
						me.cont.send('/ajax/bbs/conter.a'
							, ret[0] + '&act=res'
							, function(text){
								if (text.substr(0,3) == 'ok_'){
									jQuery('#conter_form_open_close').click();
									document.getElementById('conter').cnote.value = '';
									setTimeout(function(){
										alert('投稿が完了しました。' + "\n" + "\n" + '続けて、新しい投稿を取得します。');
										me.bbs.setLatest(text.substr(3));
									}, 1000);
								} else {
									alert(text);
								}
							}
							, 100, 130
							, 'conter'
							, 'conter'
						);
					}
					return false;
				})
				.wrapInner(
					jQuery(document.createElement('div'))
					.attr('id', 'conter_form')
					.css('padding-top', '15px')
					.hide()
				)
				.prepend(
					jQuery(document.createElement('div'))
					.append(
						jQuery(document.createElement('img'))
						.attr('id', 'conter_form_open_close')
						.attr('src', '/img/btn/c1a.gif')
						.attr('alt', '返信フォームを開く')
						.attr('width', '162')
						.attr('height', '23')
						.css('cursor', 'pointer')
						//jQuery(document.createElement('input'))
						//.attr('id', 'conter_form_open_close')
						//.attr('type', 'button')
						//.attr('value', '返信フォームを開く')
						.toggle(
							function(){
								jQuery('#conter_form').show(1000);
								this.src = '/img/btn/c1b.gif';
								//this.value = '返信フォームを閉じる';
								//this.value = '返信フォームを閉じる';
							}
							,
							function(){
								jQuery('#conter_form').hide(1000);
								this.src = '/img/btn/c1a.gif';
								//this.value = '返信フォームを開く';
							}
						)
					)
					.append(
						jQuery(document.createElement('img'))
						//.attr('id', 'conter_form_open_close')
						.attr('src', '/img/btn/c2.gif')
						.attr('alt', '最新の投稿をチェックする')
						.attr('width', '132')
						.attr('height', '23')
						.css('cursor', 'pointer')
						.css('margin-left', '12px')
						//jQuery(document.createElement('input'))
						//.attr('id', 'conter_form_open_close')
						//.attr('type', 'button')
						//.attr('value', '最新の投稿をチェックする')
						//.css('margin-left', '12px')
						.click(function(){
							me.cont.send('/ajax/bbs/latest.a'
								, '&contentId=' + me.val.location.contentId()
									+ '&topicsId=' + me.val.location.topicsId()
									+ '&lastNo=' + jQuery('.view_list:eq(1) dt:last span:first').html()
									+ '&ajax=ajax'
								, function(text){
									if (text == 'ok'){
										//	新着なし
									} else if (text.substr(0, 3) == 'ok_'){
										me.bbs.setLatest(text.substr(3));
									} else {
										alert(text);
									}
								}
								, 160, -60
							, 'conter'
							, ''
							);
						})
					)
					.append(
						jQuery(document.createElement('a'))
						.css('margin-left', '12px')
						.attr('href', '#wrapper')
						.html('<img src="/img/btn/c3.gif" alt="このページの一番上へ" width="132" height="23" />')
					)
				)
				;
				jQuery('#conter_form')
				.append(
					jQuery('<input type="button" value="プレビュー" />')
					.width(120)
					.height(32)
					.css('margin-left', '10px')
					.toggle(
						function(){
							jQuery('#conter_form textarea').change();
							jQuery('#conter_form_preview').show(100);
						}
						, function(){jQuery('#conter_form_preview').hide(100);}
					)
				)
				.append(
					jQuery(document.createElement('dl'))
					.attr('id', 'conter_form_preview')
					.addClass('view_list')
					.css('margin-top', '15px')
					.hide()
					.append(
						jQuery(document.createElement('dt'))
						.html('<span class="a">プレビュー</span>')
					)
					.append(
						jQuery(document.createElement('dd'))
						.html('')
					)
				)
				;
				jQuery('#conter_form textarea')
				.change(function(){
					var html = jQuery(this).val();
					html = aulta.string.toZenKana(html);
					html = aulta.string.replaceDependenceChar(html);
					html = aulta.string.replaceText(html, 1);
					jQuery('#conter_form_preview dd').html(html);
				});
				
			}
			/*
			 *4 bbs_viewall
			 */
			, bbs_viewall : function(){
				jQuery('#container').css('overflow', 'hidden');
				aulta.create.cornerCircle('topi_title', 'white', 0, 0);
				onetime.init.createLinkTopicsSearchSubWindow();
				me.userInfo.createLink();
				me.bbs.createEditLink();
				
			}
			/*
			 *4 user_info
			 */
			, user_info : function(){
				//	fixedテーブル
				jQuery(function($j){
					$j('.cont_place')
					.tableHeadFix({height:180})
					.headTable()		//ヘッダtable
					.bodyTable()		//ボディtable
					.wrapObject()		//包括div
						.css('margin', 'auto')
					;
				});
				
				jQuery('#main h2')
				.each(function(){
					aulta.create.cornerCircle(this, 'white', 0, 0);
				});
				jQuery('#main h3')
				.each(function(){
					aulta.create.cornerCircle(this, 'white', 4, 0);
				});
			}
			/*
			 *4 category
			 */
			, category : function(){
				
			}
			
		}
	}
		
	/*
	 *2	ready	jQuery.ready()
	 */
	, ready : {
		/*
		 *3	thisDelete
		 */
		thisDelete : function(){
			var p = onetime.ready;
			if (aulta.utility.propertyLength(p) == 1){
				delete p.thisDelete;
				delete onetime.ready;
			}
		}
		/*
		 *3	createBanner	右上バナーエリア
		 */
		, createBanner : function(){
			if (!document.getElementById('banners')) return;
			jQuery('#banners')
			.attr('no', '0')
			.attr('max', document.getElementById('banners').getElementsByTagName('li').length)
			.append(
				jQuery(document.createElement('li'))
				.css('position', 'absolute')
				.css('display', 'block')
				.css('left', '0px')
				.css('top', '0px')
				.css('width', '40px')
				.css('height', '76px')
				.append(
					jQuery(document.createElement('img'))
					.attr('src', '/img/bnboxleft.gif')
					.css('display', 'block')
				)
				.click(function(){
					var jqBanners = jQuery('#banners')
						, old = no = jqBanners.attr('no')
						, max = jqBanners.attr('max')
						;
					if (no < 1) no = max;
					no--;
					jqBanners.attr('no', no);
					var bannerList = document.getElementById('banners').getElementsByTagName('li');
					jQuery(bannerList[no])
					.css('left', '274px')
					.css('display', 'block')
					.css('z-index', '1')
					.animate({left : '40px'}, 1000)
					;
					jQuery(bannerList[old])
					.css('display', 'block')
					.css('z-index', '0')
					.animate({left : '-194px'}, 1000)
					;
				})
			)
			.append(
				jQuery(document.createElement('li'))
				.css('position', 'absolute')
				.css('display', 'block')
				.css('left', '274px')
				.css('top', '0px')
				.css('width', '40px')
				.css('height', '76px')
				.append(
					jQuery(document.createElement('img'))
					.attr('src', '/img/bnboxright.gif')
					.css('display', 'block')
				)
				.click(function(){
					var jqBanners = jQuery('#banners')
						, old = no = jqBanners.attr('no')
						, max = jqBanners.attr('max')
						;
					no++;
					if (no >= max) no = 0;
					jqBanners.attr('no', no);
					var bannerList = document.getElementById('banners').getElementsByTagName('li');
					jQuery(bannerList[no])
					.css('left', '-194px')
					.css('display', 'block')
					.css('z-index', '1')
					.animate({left : '40px'}, 1000)
					;
					jQuery(bannerList[old])
					.css('display', 'block')
					.css('z-index', '0')
					.animate({left : '274px'}, 1000)
					;
				})
			);
			
			setTimeout(function(){
				jQuery('#banners li:last').click();
				setTimeout(arguments.callee, 10000);
			}, 10000);
			/*
			(function(){
				jQuery('#banners li:last').click();
				setTimeout(arguments.callee, 10000);
			})();
			*/
			delete onetime.ready.createBanner;
			onetime.ready.thisDelete();
		}
		/*
		 *3	oldBrowser	IE6以下のブラウザ
		 */
		, oldBrowser : function(){
			if (
				jQuery.browser['msie']
				&& (jQuery.browser['version'] - 0 < 7)
				&& document.getElementById('menu')
			){
				jQuery('#menu')
				.prepend(
					jQuery(document.createElement('div'))
					.append(
						jQuery(document.createElement('h3'))
						.addClass('frameHead')
						.html('最先端のブラウザを入手')
					)
					.append(
						jQuery(document.createElement('div'))
						.addClass('frame')
						.html('あなたは古代のブラウザをお使いのようですね。<br />インターネットを快適に楽しくするために、【最先端の】ブラウザを【無料で】手に入れよう。')
						.append(
							jQuery(document.createElement('ul'))
							.addClass('tree')
							.html(
								'<li><a href="http://mozilla.jp/firefox/" target="_blank">Firefox</a></li>'
								+ '<li><a href="http://www.google.co.jp/chrome/" target="_blank">Google Chrome</a></li>'
								+ '<li><a href="http://www.apple.com/jp/safari/" target="_blank">Apple Safari</a></li>'
								+ '<li><a href="http://www.opera.com/download/" target="_blank">Opera</a></li>'
							)
						)
					)
				);
				jQuery('#menu h3.frameHead')
				.each(function(){
					aulta.create.cornerCircle(this, 'white', 1, 0);
				});
			}
			delete onetime.ready.oldBrowser;
			onetime.ready.thisDelete();
		}
	}
	
	/*
	 *2	init	jQuery.ready()
	 */
	, init : {
		/*
		 *3	thisDelete
		 */
		thisDelete : function(){
			var p = onetime.init;
			if (aulta.utility.propertyLength(p) == 1){
				delete p.thisDelete;
				delete onetime.init;
			}
		}
		/*
		 *3	createLinkTopicsSearchSubWindow	トピックス内検索
		 */
		, createLinkTopicsSearchSubWindow : function(){
		
			if (document.getElementById('bbs_viewall')){
				jQuery('#topi_search')
				.html('')
				.append(
					jQuery(document.createElement('a'))
					.attr('href', './t' + me.val.location.topicsId() + 'b1viw.html')
					.html('<img src="/img/btn/b4.gif" width="200" height="23" alt="通常の表示形式に戻る" />')
					.css('margin-right', '20px')
				);
			} else {
				var loglinkurl = (document.getElementById('log_link') ? jQuery('#log_link').attr('href') : '');
				jQuery('#topi_search')
				.html('')
				.append(
					jQuery('<img src="/img/btn/b5.gif" width="96" height="23" alt="下の方へ" />')
					.click(function(){
						var arr = new Array(), i = 0;
						jQuery('#main .view_list:eq(1) dt')
						.each(function(){
							arr[i++] = jQuery(this).attr('id');
						});
						var cnt = arr.length;
						if (cnt > 4){
							aulta.event.scroll(arr[cnt - 5]);
						} else if (cnt > 0){
							aulta.event.scroll(arr[0]);
						}
					})
					.css('margin-right', '20px')
					.css('cursor', 'pointer')
				);
				if (loglinkurl.length > 0){
					jQuery('#topi_search')
					.append(
						jQuery(document.createElement('a'))
						//.attr('href', './all' + me.val.location.topicsId() + 'view.html')
						.attr('href', loglinkurl)
						.html('<img src="/img/btn/b3.gif" width="200" height="23" alt="このトピックスを一気に読む" />')
						.css('margin-right', '20px')
					);
				}
			}
			jQuery('#topi_search')
			.append(
				jQuery(document.createElement('img'))
				.attr('src', '/img/btn/b2.gif')
				.attr('alt', 'トピックス内検索')
				.attr('width', '126')
				.attr('height', '23')
				.css('cursor', 'pointer')
				.click(function(){
					if (aulta.subwindow.create('topisearch')){
						aulta.subwindow.setTitle('トピックス内検索');
						aulta.subwindow.setHtml('<img src="/img/loading.gif" />');
						
						aulta.subwindow.setHtmlElm(
							jQuery(document.createElement('div'))
							.append(
								jQuery(document.createElement('ul'))
								.append(jQuery(document.createElement('li')).html('今いるトピックスの中だけを検索します。'))
								.append(jQuery(document.createElement('li')).html('該当する件数が多い場合は、先頭から50件まで表示します。'))
								.append(jQuery(document.createElement('li')).html('検索ワードを「スペース」で区切って複数ワード検索ができます。'))
								.append(jQuery(document.createElement('li')).html('「and」は全て含む、「or」はどれか１つを含む、投稿が対象になります。'))
								.css('padding', '3px')
								.css('margin-bottom', '10px')
								.css('background-color', '#FAEBD7')
							)
							.append(
								jQuery(document.createElement('form'))
								.submit(function(){
									var key = aulta.string.toZenKana(jQuery('#topi_search_key').val());
									jQuery('#topi_search_key').val(key);
									var url = '/ajax/bbs/topisearch'
										+ jQuery('#topi_search_contentId').val()
										+ '_'
										+ jQuery('#topi_search_topi_id').val()
										+ '.a'
									, param = '&key=' + key
										+ '&m=' + jQuery('#topi_search_condition').val()
										+ '&ajax=ajax'
										;
										
									var func = function(ret){
										var text = aulta.ajax.analyze(ret);
										if (text == false){
										} else {
											jQuery('#topi_search_result').html(text);
											jQuery('#topi_search_result_url')
											.val(
												'http://' + document.domain + '/c' + jQuery('#topi_search_contentId').val() + 'game/'
												+ 'search' + jQuery('#topi_search_topi_id').val() + '.a'
												+ '?key=' + aulta.string.urlencode(key)
												+ '&m=' + jQuery('#topi_search_condition').val()
											);
										}
									}
									, send = function(){
										aulta.ajax.request(func, url, param);
									};
									jQuery('#topi_search_result').html('<img src="/img/loading.gif" />');
									jQuery('#topi_search_result_url').val('');
									setTimeout(send, 1000);
									return false;
								})
								.append(
									jQuery(document.createElement('input'))
									.attr('type', 'hidden').attr('id', 'topi_search_contentId').attr('value', me.val.location.contentId())
								)
								.append(
									jQuery(document.createElement('input'))
									.attr('type', 'hidden').attr('id', 'topi_search_topi_id').attr('value', me.val.location.topicsId())
								)
								.append(
									jQuery(document.createElement('span'))
									.html('検索ワード')
								)
								.append(
									jQuery(document.createElement('input'))
									.attr('type', 'text').attr('id', 'topi_search_key').attr('value', '')
								)
								.append(
									jQuery(document.createElement('select'))
									.attr('id', 'topi_search_condition')
									.append(
										jQuery(document.createElement('option'))
										.attr('value', '1')
										.html('and')
									)
									.append(
										jQuery(document.createElement('option'))
										.attr('value', '2')
										.html('or')
									)
								)
								.append(
									jQuery(document.createElement('input'))
									.attr('type', 'submit').attr('value', 'トピックス内検索')
								)
								.append(
									jQuery(document.createElement('div'))
									.css('padding-top', '10px')
									.append(
										jQuery(document.createElement('div'))
										.html('現在の検索結果のURL（掲示板への貼り付けなどに）')
										.css('font-weight', 'bold')
										.css('color', 'green')
									)
									.append(
										jQuery(document.createElement('input'))
										.attr('type', 'text')
										.attr('id', 'topi_search_result_url')
										.attr('readonly', 'readonly')
										.css('display', 'block')
										.css('width', '90%')
										.css('background-color', '#f0f0f0')
										.focus(function(){this.select();})
									)
								)
								.css('margin-bottom', '15px')
							)
							.append(
								jQuery(document.createElement('div'))
								.attr('id', 'topi_search_result')
								.html('')
							)
						);
					}
					var jw = jQuery(window)
						, x = 50
						, y = aulta.pos.top() + 120
						, w = jw.width()
						, h = jw.height() - 240
						;
					if (w > 530){
						x = (w - 530) / 2
						w = 530;
					}
					aulta.subwindow.move(x, y);
					aulta.subwindow.resize(w, h);
				})
			);
			delete onetime.init.createLinkTopicsSearchSubWindow;
			onetime.init.thisDelete();
		}
	}
};





/*
 *1	jQuery.ready
 */
jQuery(document).ready(function(){
	
	///	別ウィンドウで開くリンク
	aulta.init.setTargetOutsideLink(['jump.php'], ['ecx.images-amazon.com', '.aulta.net']);

	/*
	jQuery('#maptab area.a0')
	.hover(
		function(){jQuery('#main #tabmenu').css('background-position', '0px 0px');}
		, function(){jQuery('#main #tabmenu').css('background-position', '485px 0px');}
	);
	jQuery('#maptab area.a1')
	.hover(
		function(){jQuery('#main #tabmenu').css('background-position', '-485px 0px');}
		, function(){jQuery('#main #tabmenu').css('background-position', '485px 0px');}
	);
	jQuery('#maptab area.a2')
	.hover(
		function(){jQuery('#main #tabmenu').css('background-position', '-970px 0px');}
		, function(){jQuery('#main #tabmenu').css('background-position', '485px 0px');}
	);
	jQuery('#maptab area.a3')
	.hover(
		function(){jQuery('#main #tabmenu').css('background-position', '-1455px 0px');}
		, function(){jQuery('#main #tabmenu').css('background-position', '485px 0px');}
	);
	jQuery('#maptab area.a4')
	.hover(
		function(){jQuery('#main #tabmenu').css('background-position', '-1940px 0px');}
		, function(){jQuery('#main #tabmenu').css('background-position', '485px 0px');}
	);
	*/


	if (document.getElementById('index')){
		/*****************/
		///	ローディングバーを非表示で生成
		jQuery('body')
		.append(
			jQuery(document.createElement('div'))
			.attr('id', 'hover_thm_image')
			.css('position', 'absolute')
			.append(
				jQuery(document.createElement('img'))
			)
		);
		
		aulta.create.cornerCircle('mobile', 'white', 0, 0);
		
		(function(){
			var oj = document.getElementById('main');
			if (oj){
				var h2 = oj.getElementsByTagName('h2')
				for (var i = 0, j = h2.length; i < j; i++){
					aulta.create.cornerCircle(h2[i], 'white', 0, 0);
				}
			}
		})();
		
		jQuery('.latest_list tr:even')
		.addClass('line');
		
	}
	
	
	///	frameHeadの角丸
	jQuery('.frameHead')
	.css('display', 'block')
	.append(
		jQuery(document.createElement('img'))
		.attr('src', '/img/cc_lt.gif')
		.css('position', 'absolute')
		.css('display', 'block')
		.css('left', '0')
		.css('top', '0')
	)
	.append(
		jQuery(document.createElement('img'))
		.attr('src', '/img/cc_rt.gif')
		.css('position', 'absolute')
		.css('display', 'block')
		.css('right', '0')
		.css('top', '0')
	)
	;
	
	if (me.ses.get('UserNo') > 2){
		jQuery('#sub')
		.prepend(
			jQuery(document.createElement('div'))
			.append(
				jQuery('<input type="button" value="あなたの投稿履歴" />')
				.css('width', '330px')
				.css('padding', '10px 0px')
				.css('margin-bottom', '20px')
				.css('font-size', '24px')
				.click(function(){
					var no = me.ses.get('UserNo');
					if (aulta.subwindow.create('userinfo' + no)){
						aulta.subwindow.setTitle('あなたの投稿情報');
						aulta.subwindow.setHtml('<img src="/img/loading.gif" />');
						var func = function(ret){
							var text = aulta.ajax.analyze(ret);
							if (text == false){
							} else {
								aulta.subwindow.setHtml(text);
								
								jQuery('.user_info_data h2')
								.each(function(){
									aulta.create.cornerCircle(this, 'white', 0, 0);
								})
								;
								jQuery('.user_info .frameHead')
								.each(function(){
									aulta.create.cornerCircle(this, 'white', 1, 0);
								})
								;
								jQuery('.user_info .frame dd:last-child')
								.css('margin-bottom', '0px')
								.css('padding-bottom', '0px')
								.css('border', '0')
								;
								jQuery('.cont_place')
								.tableHeadFix({height:180})
								.headTable()		//ヘッダtable
								.bodyTable()		//ボディtable
								.wrapObject()		//包括div
									.css('margin', 'auto')
								;
							}
						}
						aulta.ajax.request(func, '/ajax/user/info' + no + '.a', '&ajax=ajax');
					}
					var jw = jQuery(window)
						, x = 50
						, y = aulta.pos.top() + 80
						, w = jw.width()
						//, h = jw.height() - 160
						, h = 500
						;
					if (w > 750){
						x = (w - 750) / 2
						w = 750;
					}
					aulta.subwindow.move(x, y);
					aulta.subwindow.resize(w, h);
				})
			)
		);
	}
	
	///	frameBorder li:last-child を外す
	jQuery('.frameBorder li:last-child')
	.css('margin-bottom', '0px')
	.css('padding-bottom', '0px')
	.css('border', '0');

	/*****************/
	///	ローディングバーを非表示で生成
	jQuery('body')
	.append(
		jQuery(document.createElement('div'))
		.attr('id', 'conter_form_loading')
		.append(
			jQuery(document.createElement('div'))
		)
		.append(
			jQuery(document.createElement('img'))
			.attr('src', '/img/loading.gif')
		)
	)
	
	/*****************/
	///	#content_image のprettyPhoto
	if (document.getElementById('content_image')){
		jQuery('#content_image a')
		.prettyPhoto({
			animationSpeed: 'normal', // fast/slow/normal
			padding: 40, // padding for each side of the picture
			opacity: 0.35, // Value betwee 0 and 1
			showTitle: true, // true/false
			allowresize: true, // true/false
			counter_separator_label: '/' // The separator for the gallery counter 1 "of" 2
		})
		;
	}
	
	///	#amazon_images のprettyPhoto
	if (document.getElementById('amazon_images')){
		jQuery('#amazon_images a')
		.prettyPhoto({
			animationSpeed: 'normal', // fast/slow/normal
			padding: 40, // padding for each side of the picture
			opacity: 0.35, // Value betwee 0 and 1
			showTitle: true, // true/false
			allowresize: true, // true/false
			counter_separator_label: '/' // The separator for the gallery counter 1 "of" 2
		})
		;
	}
	
	//	最新トピックス
	jQuery('#sub ul.latest li, #latest2 ul li')
	.append(
		jQuery(document.createElement('div'))
		.addClass('latest_topics_button')
		.append(
			jQuery(document.createElement('input'))
			.attr('type', 'button')
			.attr('value', 'トピを見る!')
		)
	)
	.hover(
		function(){
			if (this.className != 'google'){
				jQuery(this).find('div.latest_topics_button').show();
			}
		},
		function(){
			jQuery(this).find('div.latest_topics_button').hide();
		}
	);
	jQuery('.latest_topics_button input')
	.click(function(){
		var a = jQuery(this).parent().parent().find('a')
			, title = a.text()
			, url = a.attr('href')
			, id = 'latest_' + url.replace(/\//g, '_').replace(/:/g, '_').replace(/\./g, '_')
			, param = '&ajax=ajax'
				+ '&url=' + url
			, pos = aulta.pos.getAbsolute(this)
			;
		if (aulta.subwindow.create(id)){
			aulta.subwindow.setTitle(title);
			aulta.subwindow.setHtml('<img src="/img/loading.gif" />');
			var func = function(ret){
				var text = aulta.ajax.analyze(ret);
				if (text == false){
				} else if (text.substr(0,3) == 'ok_'){
					aulta.subwindow.setHtml('<div class="latest_topics_data">' + text.substr(3) + '</div>');
				}
			}
			aulta.ajax.request(func, '/ajax/bbs/latestTopics.a', param);
		}
		var jw = jQuery(window)
			, x = pos[0] - 600
			, y = aulta.pos.top() + 150
			, w = 500
			, h = 400
			;
		if (x < 20) x = 20;
		aulta.subwindow.move(x, y);
		aulta.subwindow.resize(w, h);
		aulta.subwindow.foreground();
	});
	
	///	右上バナーエリア
	onetime.ready.createBanner();
	
	///	古いブラウザ
	onetime.ready.oldBrowser();
	
	///	#アンカータグ スムーズスクロール
	jQuery('a[href*="#wrapper"]')
	.click(function(){
		aulta.event.scroll(0);
		return false;
	});
	
	
	
});



function createFooterAmazon(jsAmazonItems, isSearch){
	var jqAmazonList = jQuery(document.createElement('ul'));
	jqAmazonList
	.attr('id', 'amazonRanking')
	.addClass('frame')
	.addClass('cbox');
	for(var i in jsAmazonItems){
		var val = jsAmazonItems[i]
			, s = (isSearch ? '<br /><a href="/gameSearch.a?key=' + val['Asin'] + '" title="game' + i + '">&gt;&gt; ゲームファンの中で探す</a>' : '')
			;
		jqAmazonList
		.append(
			jQuery(document.createElement('li'))
			.append(
				jQuery(document.createElement('a'))
				.attr('rel', 'nofollow')
				.attr('href', val['DetailPageURL'])
				.append(
					jQuery(document.createElement('img'))
					.attr('src', val['MediumImage'])
					.attr('alt', 'amazon' + i)
					.attr('width', val['ImgWidth'])
					.attr('height', val['ImgHeight'])
				)
				.append(
					document.createTextNode(
						val['ContentTitle']
					)
				)
			)
			.append(s)
		);
	}
	jQuery('#fotter_amazon')
	.html('')
	.append(
		jQuery(document.createElement('h3'))
		.addClass('frameHead')
		.html('売れてます')
	)
	.append(jqAmazonList)
	;
}


function createBookmarks(){
	var html = ''
		, lhref = encodeURIComponent(location.href)
		, ltitle = encodeURIComponent(document.title)
		, arr = {
			yahoo : {
				title : 'Yahoo!ブックマーク',
				url : 'http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?ei=UTF-8&amp;u=' + lhref+ '&amp;t=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/yahoo.gif'
				}
			},
			google : {
				title : 'Googleブックマーク',
				url : 'http://www.google.com/bookmarks/mark?op=add&amp;bkmk=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/google.gif'
				}
			},
			hatena : {
				title : 'はてなブックマーク',
				url : 'http://b.hatena.ne.jp/add?mode=confirm&amp;url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/hatena.gif'
				}
			},
			livedoor : {
				title : 'livedoorClip',
				url : 'http://clip.livedoor.com/redirect?link=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/livedoor.gif'
				}
			},
			delicious : {
				title : 'del.icio.us',
				url : 'http://del.icio.us/post?url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/delicious.gif'
				}
			},
			newsing : {
				title : 'newsing',
				url : 'http://newsing.jp/nbutton?url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/newsing.gif'
				}
			},
			fc2 : {
				title : 'FC2',
				url : 'http://bookmark.fc2.com/user/post?url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/fc2.gif'
				}
			},
			technorati : {
				title : 'Technorati',
				url : 'http://www.technorati.com/faves?add=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/technorati.gif'
				}
			},
			nifty : {
				title : 'ニフティクリップ',
				url : 'http://clip.nifty.com/create?url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/nifty.gif'
				}
			},
			iza : {
				title : 'iza',
				url : 'http://www.iza.ne.jp/bookmark/add/regist/back/' + location.href,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/iza.gif'
				}
			},
			choix : {
				title : 'Choix',
				url : 'http://www.choix.jp/submit?bookurl=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/choix.gif'
				}
			},
			flog : {
				title : 'Flog',
				url : 'http://www.flog.jp/post.php?url_uri=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/flog.gif'
				}
			},
			buzzurl : {
				title : 'Buzzurl',
				url : 'http://buzzurl.jp/config/add/confirm?url=' + lhref+ '&amp;title=' + ltitle,
				img : {
					src : 'http://aulta.jp/api/bookmark/img/buzzurl.gif'
				}
			}
		};
	html += '<p style="text-align:right;">';
	for (var i in arr){
		var oj = arr[i];
		html += '<a href="' + oj.url + '" style="font-size:12px; text-decoration:none;margin-left:8px;" title="' + oj.title + '">'
			+ '<img src="' + oj.img.src + '" alt="' + oj.title + '" width="16" height="16" style="vertical-align: middle; border: none;" />'
			+ '</a>';
	}
	html += '</p>';
	jQuery('#topi_search')
	.after(html);
}

/*******/

