// alert(''); document.write(''); Form.serialize();
document.write(
	  '<script type="text/javascript" src="/allis/prototype.js"></script>'
	+ '<script type="text/javascript" src="/flash/playerJs/"></script>'
);
var ajaxErrorFlg = false;
// ◆◆◆ shareDelete ◆◆◆ //
//function shareDelete(URI, param, locationURI){
//	var inputValue = window.prompt('削除する為にはログインIDの再入力が必要です\nログインIDを入力して下さい', '');
//	if( inputValue === null ){
//		return;
//	}
//	ajaxRequest(URI, param + '&pw=' + encodeURIComponent(inputValue), '', locationURI, '', '削除しました');
//	return;
//}
function shareDeleteConfirm(URI, param, locationURI, alertFlg, alertStr){
	shareAlertConfirm('削除してもよろしいですか？', URI, param, '', locationURI, alertFlg, alertStr);
	return;
}
function shareAlertConfirm(alertStrThis, URI, param, id, locationURI, alertFlg, alertStr, func, funcParam){
	if( !confirm(alertStrThis) ){
		return;
	}
	ajaxRequest(URI, param, id, locationURI, alertFlg, alertStr, func, funcParam);
	return;
}

// ◆◆◆ ajaxShare ◆◆◆ //
function ajaxRequest(uri, param, id, uriRe, reStrAlertFlg, alertStr, func, funcParam){
	this.ajaxErrorFlg = false;
	new Ajax.Request(
		uri
		,{
			method      : 'post'
			,parameters : 'ajax=1&' + param
			,onComplete : function(re){ ajaxRequest_end(re, id, uriRe, reStrAlertFlg, alertStr, func, funcParam); }
			,onFailure  : ajaxRequest_error
		}
	);
	return;
}
function ajaxRequest_error(num){
	num = parseInt(num);
	if( !num ){
		num = 'connectError';
	}
	alert('通信に失敗しました(' + num + ')');
	this.ajaxErrorFlg = true;
	return;
}
function ajaxRequest_end(re, id, uriRe, reStrAlertFlg, alertStr, func, funcParam){
	if( this.ajaxErrorFlg === true ){
		return;
	}
	var val = re.responseText;
	if( !val ){
		return ajaxRequest_error(2);
	}
	if( val === 'false' ){
		return ajaxRequest_error(3);
	}
	if( id ){
		$(id).innerHTML = val;
	}
	if( reStrAlertFlg ){
		if( val !== 'true' ){
			alert(val);
			return;
		}
	}
	if( alertStr ){
		if( val !== 'true' ){
			alert(val);
		}else{
			alert(alertStr);
		}
	}
	if( uriRe ){
		location.href = uriRe;
	}
	if( func ){
		func(funcParam);
	}
	return;
}
// ◆◆◆ onload ◆◆◆ //
window.onload = function (){
	getBlocksList();
	getMembersList();
	flashPlayerDisplay();
	filesCommentGet(new Array());
	groupsShowGetNormalMembers();
	return;
}
// ◆◆◆ getBlocks ◆◆◆ //
function setDisplay(obj){
	obj.style.display = 'block';
	return;
}
function getBlocksList(flg, id, start){
	var ajaxAreaId = 'blocksList';
	var obj        = $(ajaxAreaId);
	flg   = flg   ? flg   : '';
	id    = id    ? id    : '';
	start = start ? start : '';
	if( obj === null ){
		return;
	}
	if( !flg ){
		var htmlArray = obj.innerHTML.split(',');
		flg = htmlArray[0];
		id  = htmlArray[1];
		if( flg === 'add' ){
			blocksListForm();
		}
	}
	return ajaxRequest(
		'/blocks/get/'
		,'id_blocks_current=' + encodeURIComponent(id) + '&flg=' + flg + '&start=' + start
		,ajaxAreaId
		, '', '', '', setDisplay, obj
	);
}
function blocksListForm(flg, id, start){
	var ajaxAreaId = 'blocksListForm';
	var obj        = $(ajaxAreaId);
	var objInput   = $('blocksListFormInput');
	var idList;
	flg   = flg   ? flg   : '';
	id    = id    ? id    : '';
	start = start ? start : '';
	
	if( obj === null ){
		return;
	}
	if( !flg ){
		idList = obj.innerHTML;
	}else{
		if( objInput !== null ){
			idList = objInput.value;
		}
	}
	return ajaxRequest(
		'/blocks/getNameList/'
		,'flg='              + encodeURIComponent(flg)
		+ '&id_blocks='      + encodeURIComponent(id)
		+ '&id_blocks_list=' + encodeURIComponent(idList) + '&start=' + start
		,ajaxAreaId
		, '', '', '', setDisplay, obj
	);
}
// ◆◆◆ getMembers ◆◆◆ //
function getMembersList(start, keyword, flg){
	var ajaxAreaId = 'membersList';
	var obj        = $(ajaxAreaId);
	var objInput   = $('memberListKeyword');
	flg     = flg     ? flg     : '';
	start   = start   ? start   : '';
	keyword = keyword ? keyword : '';
	if( obj === null ){
		return;
	}
	if( start === '' && flg === '' ){
		var htmlArray = obj.innerHTML.split(',');
		start   = htmlArray[0];
		keyword = htmlArray[1];
		membersListForm();
	}else{
		if( objInput !== null ){
			keyword = encodeURIComponent(objInput.value);
		}
	}
	return ajaxRequest(
		'/members/get/'
		,'start=' + encodeURIComponent(start) + '&keyword=' + keyword
		,ajaxAreaId
		, '', '', '', setDisplay, obj
	);
}

function membersListForm(flg, id, param){
	var ajaxAreaId = 'membersListForm';
	var obj        = $(ajaxAreaId);
	var objInput   = $('membersListFormInput');
	var objInputAd = $('membersListFormAdInput');
	var idList;
	var idListAd;
	flg   = flg   ? flg   : '';
	id    = id    ? id    : '';
	param = param ? param : '';
	if( obj === null ){
		return;
	}
	if( !flg ){
		var htmlArray = obj.innerHTML.split(',');
		idList   = htmlArray[0];
		idListAd = htmlArray[1];
	}else{
		if( objInput !== null ){
			idList = encodeURIComponent(objInput.value);
		}
		if( objInputAd !== null ){
			idListAd = encodeURIComponent(objInputAd.value);
		}
	}
	return ajaxRequest(
		'/members/getNameList/'
		,'flg='                     + encodeURIComponent(flg)
		+ '&id_members='            + encodeURIComponent(id)
		+ '&id_members_list='       + idList
		+ '&id_members_list_admin=' + idListAd + '&' + param
		,ajaxAreaId
		, '', '', '', setDisplay, obj
	);
}
// ◆◆◆ groupsShowGetNormalMembers ◆◆◆ //
function groupsShowGetNormalMembers(id, start){
	var ajaxAreaId = 'groupsShowGetNormalMembers';
	var obj        = $(ajaxAreaId);
	id    = id    ? id    : '';
	start = start ? start : '';
	if( obj === null ){
		return;
	}
	if( !id ){
		id = obj.innerHTML.split(',');
	}
	return ajaxRequest(
		'/groups/groupsShowGetNormalMembers/'
		,'start=' + encodeURIComponent(start) + '&id_groups=' + id
		,ajaxAreaId
		, '', '', '', setDisplay, obj
	);
}

// ◆◆◆ headerSearch ◆◆◆ //
function headerSearch(){
	var obj = $('headerSearch');
	if( obj.header_keyword_type.value === 'files' ){
		obj.action = '/groups/filesSearch/';
	}else{
		obj.action = '/groups/groupsSearch/';
	}
	obj.submit();
	return;
}
// ◆◆◆ groupsFilesShow ◆◆◆ //
// ◆◆ flashPlayer //
function flashPlayerDisplay(){
	var areaId = 'flashPlayers';
	var obj    = $(areaId);
	if( obj === null ){
		return;
	}
	var id_files = obj.innerHTML;
	uriPlayer = '/flash/player.swf' + '?VideoId=' + id_files + '&autoplay=true';
	uriList   = '/flash/list.swf'   + '?VideoId=' + id_files;
	obj.innerHTML =
		'<div class="flashPlayerDisplayPlayer">'
			+'<object'
			+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+' width="450" height="404"'
			+' type="application/x-shockwave-flash"'
			+' codetype="application/x-shockwave-flash"'
			+' id="flashPlayer1">'
			+'<param name="quality" value="best" />'
			+'<param name="movie" value="' + uriPlayer + '" />'
			+'<param name="allowFullScreen" value="true" />'
			+'<param name="allowScriptAccess" value="always" />'
			+'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"'
			+' allowScriptAccess="always" id="flashPlayer2"'
			+' src="' + uriPlayer + '" allowFullScreen="true" width="450" height="404">'
			+'</embed>'
			+'</object>'
		+'</div>'

		+'<div class="flashPlayerDisplayList">'
			+'<object'
			+' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
			+' width="296" height="431"'
			+' type="application/x-shockwave-flash"'
			+' codetype="application/x-shockwave-flash"'
			+' id="flashList1">'
			+'<param name="quality" value="best" />'
			+'<param name="allowScriptAccess" value="always" />'
			+'<param name="movie" value="' + uriList + '" />'
			+'<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"'
			+' allowScriptAccess="always" id="flashList2"'
			+' src="' + uriList + '" width="296" height="431">'
			+'</embed>'
			+'</object>'
		+'</div>'
	;
	return;
}
// ◆◆投票 //
function filesVote(id_groups, id_files){
	areaId = 'vote';
	ajaxRequest(
		'/groups/filesVote/'
		,'id_groups='      + encodeURIComponent(id_groups)
			+ '&id_files=' + encodeURIComponent(id_files)
		,areaId
	);
	$('voteLink').innerHTML = '';
	return;
}
// ◆◆コメント //
function filesCommentGet(dataArray){
	areaId = 'comment';
	var obj = $(areaId);
	if( obj === null ){
		return;
	}
	if( !dataArray.length ){
		var idArray = obj.innerHTML.split(',');
		var id_groups = idArray[0];
		var id_files  = idArray[1];
	}else{
		var id_groups = dataArray[0];
		var id_files  = dataArray[1];
	}
	return ajaxRequest(
		'/groups/filesCommentGet/'
		,'id_groups='      + encodeURIComponent(id_groups)
			+ '&id_files=' + encodeURIComponent(id_files)
			+ '&start='    + encodeURIComponent(dataArray[2])
		,areaId
	);
}
function filesCommentAdd(id_groups, id_files, msg, uid){
	ajaxRequest(
		'/groups/filesCommentAdd/'
		,'id_groups='      + encodeURIComponent(id_groups)
			+ '&id_files=' + encodeURIComponent(id_files)
			+ '&msg='      + encodeURIComponent(msg)
			+ '&uid='      + encodeURIComponent(uid)
		,'' ,'' , true, '', filesCommentGet, new Array(id_groups, id_files, 0)
	);
	return;
}
function filesCommentDel(id_groups, id_files, id_files_comment){
	if( !confirm('削除してもよろしいですか？') ){
		return;
	}
	return ajaxRequest(
		'/groups/filesCommentDelete/'
		,'id_groups='              + encodeURIComponent(id_groups)
			+ '&id_files='         + encodeURIComponent(id_files)
			+ '&id_files_comment=' + encodeURIComponent(id_files_comment)
		,'' ,'' , true, '', filesCommentGet, new Array(id_groups, id_files, 0)
	);
}
// ◆◆FLASH //
var editFlag = false;
function flashGetObj(type){
	if( navigator.appName.indexOf("Microsoft") != -1 ){
		if( type == 'play' ){
			return $('flashPlayer1');
		}
		return $('flashList1');
	}else{
		if( type == 'play' ){
			return $('flashPlayer2');
		}
		return $('flashList2');
	}
}
// left -> right
function send_data_fromA(ary,node){
	obj = flashGetObj('list');
	obj.receive_data_forB( ary, node );
}
// right delete date -> left
function delete_id_fromB(id){
	obj = flashGetObj('play');
	obj.delete_id_forA( id );
}
function auto_scroll_fromA(id){
	obj = flashGetObj('list');
	obj.auto_scroll_forB(id);
}
// edit right disable
function edit_start_fromA(){
	editFlag = true;
	obj = flashGetObj('list');
	obj.edit_start_forB();
}
// edit end right enable
function edit_end_fromA(){
	editFlag = false;
	obj = flashGetObj('list');
	obj.edit_end_forB();
}
// login
function login_data_fromA( id , name ){
	obj = flashGetObj('list');
	obj.login_data_forB(id,name);
}
// video seek
function seek_video_fromB(second){
	obj = flashGetObj('play');
	obj.seek_video_forA(second);
}
// 
function get_URL_fromB(){
	obj = flashGetObj('list');
	obj.get_URL_forB(obj.location.href);
}
// 
function start_newpage( page_type ){
	obj = flashGetObj('list');
	obj.ini_page(page_type);
}
// return default
function end_newpage(){
	obj = flashGetObj('list');
	obj.close_page();
}
function send_auction_img_url( path, num ){
	obj = flashGetObj('play');
	obj.auction_img_url(path, num);
}
function forward_auction_data(path){
	obj = flashGetObj('play');
	obj.get_ad(path);
}
function show_all(){
	obj = flashGetObj('list');
	objlist.show_all_tabs();
}
function chk_ad(ad_flag){
	obj = flashGetObj('list');
	obj.check_ad(ad_flag);
}

