
/*--------------------------------------------------------------------------
				JavaScript File for Party & Party OpenPNE
						jQueryと併せて使用すること
							Kazuma Sekiguchi
							Version 0.20 20090829
--------------------------------------------------------------------------*/

/*-------------コミュニティトピック投稿フォーム生成-----------------------*/

/*初期状態*/
function showAddTopicForm(title , body , recipeUnit , recipeIngredient , recipeQuantity ,recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText , albumData , albumExplain){
	var optionValue = jQuery("select#topic_type").val();
	switch(eval(optionValue)){
		case 1:
			showBasicTopicForm(title , body);
		break;
		case 2:
			showClassTopicForm(title , body);
		break;
		case 3:
			showRecipeTopicForm(title , body , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText);
		break;
		case 4:
			showAlbumTopicForm(title , body , albumData , albumExplain);
	}
}

/*トピック編集時に使用*/
function showUsedTopicForm(title , body , topic_type , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText , albumData , albumExplain){
	if(eval(topic_type) == ''){
		return false;
	}
	else{
		switch(eval(topic_type)){
		case 1:
		showBasicTopicForm(title , body);
		break;
		case 2:
			showClassTopicForm(title , body);
		break;
		case 3:
			showRecipeTopicForm(title , body , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText);
		break;
		case 4:
			showAlbumTopicForm(title , body , albumData , albumExplain);
	}
}
}
/*トピック編集時画像処理付きに使用*/
function showUsedTopicFormWithImages(title , body , image_file1 , image_file2 , image_file3 , topic_type , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeStepImages , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText , albumData , albumExplain){
	if(eval(topic_type) == ''){
		return false;
	}
	else{
		switch(eval(topic_type)){
		case 1:
		showBasicTopicForm(title , body);
		break;
		case 2:
			showClassTopicForm(title , body);
		break;
		case 3:
			showRecipeTopicFormWithImages(title , body , image_file1 , image_file2 , image_file3 , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText , recipeStepImages);
		break;
		case 4:
			showAlbumTopicForm(title , body , albumData , albumExplain);
	}
}
}


/*各フォーム項目を出力*/
function showBasicTopicForm(title , body){
	jQuery("div#topic_form").html('<table><tbody><tr><th width="150">タイトル<small>(必須)</small></th><td><input type="text" class="input_text" name="title" value="'+title+'" size="50" /></td></tr><tr><th width="150">本文<small>(必須)</small></th><td><textarea name="body" rows="10" cols="40">'+body+'</textarea></td></tr><tr><th width="150">写真1</th><td><input type="file" class="input_file" name="image_filename1" size="40" /></td></tr><tr><th width="150">写真2</th><td><input type="file" class="input_file" name="image_filename2" size="40" /></td></tr><tr><th width="150">写真3</th><td><input type="file" class="input_file" name="image_filename3" size="40" /></td></tr></tbody></table>');
}
/*教室情報項目を出力*/
function showClassTopicForm(title , body){
	jQuery("div#topic_form").html('<table><tbody><tr><th width="150">タイトル<small>(必須)</small></th><td><input type="text" class="input_text" name="title" value="'+title+'" size="50" /></td></tr><tr><th width="150">本文<small>(必須)</small></th><td><textarea name="body" rows="10" cols="40">'+body+'</textarea></td></tr><tr><th width="150">写真1</th><td><input type="file" class="input_file" name="image_filename1" size="40" /></td></tr><tr><th width="150">写真2</th><td><input type="file" class="input_file" name="image_filename2" size="40" /></td></tr><tr><th width="150">写真3</th><td><input type="file" class="input_file" name="image_filename3" size="40" /></td></tr></tbody></table>');
}
/*レシピ登録項目を出力*/
function showRecipeTopicForm(title , body , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText){
	
	var recipeCategory = recipeCategory;
	
	if(recipeIngredient == ""){
		var recipeIngredient_arr = 0;
	}
	else if(recipeIngredient.indexOf("_" , 0) < 0){
		var recipeIngredient_flg = 1;
	}
	else{
		var recipeIngredient_arr = new Array;
		recipeIngredient_arr = recipeIngredient.split("_");
	}
	if(recipeQuantity == ""){
		var recipeQuantity_arr = 0;
	}
	else if(recipeQuantity.indexOf("_" , 0) < 0){
		var recipeQuantity_flg = 1;
	}
	else{
		var recipeQuantity_arr = new Array;
		recipeQuantity_arr = recipeQuantity.split("_");
	}
	if(recipeStep == ""){
		var recipeStep_arr = 0;
	}
	else if(recipeStep.indexOf("_" , 0) < 0){
		var recipeStep_flg = 1;
	}
	else{
		var recipeStep_arr = new Array;
		recipeStep_arr = recipeStep.split("_");
	}
	if(recipeCategoryFromDB.length){
		var recipeCategory_arr = new Array;
		recipeCategory_arr = recipeCategoryFromDB.split("_");
		recipeCategory_arr.unshift("");
		recipeCategory_arr.unshift("");
		recipeCategory_arr.unshift("");//配列の先頭に項目を３つ追加（新規追加とパーティ料理を飛ばすため）
		var recipeCategory_Flg = 1;
	}
	else{
		var recipeCategory_Flg = 0;
	}
	var output = '<table><tbody><tr><th width="150">レシピ名<small>(必須)</small></th><td colspan="3"><input type="text" class="input_text" name="title" value="'+title+'" size="50" /></td></tr>';
	output = output + '<tr><th width="150">レシピの概要<small>(必須)</small></th><td colspan="3"><textarea name="body" rows="10" cols="40">'+body.replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr><tr><th width="150">写真1<small>（完成写真など）</small></th><td colspan="3"><input type="file" class="input_file" name="image_filename1" size="40" /></td></tr><tr><th width="150">写真2<small>（完成写真など）</small></th><td colspan="3"><input type="file" class="input_file" name="image_filename2" size="40" /></td></tr><tr><th width="150">写真3<small>（完成写真など）</small></th><td colspan="3"><input type="file" class="input_file" name="image_filename3" size="40" /></td></tr><tr><th width="150">分量の単位<small>(半角数字、必須)</small></th><td colspan="3"><input type="text" class="input_text" name="recipeUnit" value="'+recipeUnit+'" size="10" />人分</td></tr>';
	
	if(recipeIngredient_flg == 1){
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="'+recipeIngredient+'" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="'+recipeQuantity+'" /></td></tr>';
	}
	else if(recipeIngredient_arr != 0){
		for(i = 0; i < recipeIngredient_arr.length; i++){
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="'+recipeIngredient_arr[i]+'" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="'+recipeQuantity_arr[i]+'" /></td></tr>';
			}
	}
	else{
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="" /></td></tr>';
	}
	output = output + '<tr><th width="150">材料の項目追加</th><td colspan="3"><a id="recipeAddButton">追加</a></td>';
	
	if(recipeCategory_Flg == 0){
		var tmp = 2;
	}
	else{
		var tmp = recipeCategory_arr.length - 1;
	}
	
	output = output + '<tr><th width="150">カテゴリー</th><td colspan="3">';
	for(i = 1; i <= tmp; i++){
		if(i == 1){
			if(i == recipeCategory){
				var output_tmp = '<label><input type="radio" name="recipeCategory" value="1" checked="checked" />その他（新規作成）</label><input type="text" name="recipeCategoryFreeText" class="input_text" value="'+recipeCategoryFreeText+'" />';
			}
			else{
				var output_tmp = '<label><input type="radio" name="recipeCategory" value="1" />その他（新規作成）</label><input type="text" name="recipeCategoryFreeText" class="input_text" value="" />';
			}
		}
		else if(i == 2){
			if(i == recipeCategory){
				output = output + '<label><input type="radio" name="recipeCategory" value="2" checked="checked" />パーティー料理</label>';
			}
			else{
				output = output + '<label><input type="radio" name="recipeCategory" value="2" />パーティー料理</label>';
			}
		}
		else if(i == recipeCategory){
			output = output + '<label><input type="radio" name="recipeCategory" value="'+i+'" checked="checked" />'+recipeCategory_arr[i]+'</label>';
		}
		else if(recipeCategory_Flg != 0){
			output = output + '<label><input type="radio" name="recipeCategory" value="'+i+'" />'+recipeCategory_arr[i]+'</label>';
		}
	}
	output = output + output_tmp + '</td></tr>';
	if(recipeStep_flg == 1){
		output = output + '<tr><th width="150">手順'+i+'の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40">'+recipeStep.replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3"><input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
		}
	else if(recipeStep_arr != 0){
		for(i = 0; i < recipeStep_arr.length; i++){
			j = i + 1;
		output = output + '<tr><th width="150">手順'+j+'の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40">'+recipeStep_arr[i].replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3"><input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
		}
	}
	else{
		output = output + '<tr><th width="150">手順1の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40"></textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3"><input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
	}
	output = output + '<tr><th width="150">手順の追加</th><td colspan="3"><a id="recipeStepAddButton">追加</a></td>';
	output = output + '</tbody></table>';
	jQuery("div#topic_form").html(output);
	jQuery("a#recipeAddButton").click(function(){
		addRecipeTopicForm();
	});
	jQuery("a#recipeStepAddButton").click(function(){
		addRecipeStepForm();
	});
}

/*レシピ登録項目編集時に使用（画像処理付き）*/
function showRecipeTopicFormWithImages(title , body , image_file1 , image_file2 , image_file3 , recipeUnit , recipeIngredient , recipeQuantity , recipeStep , recipeCategory , recipeCategoryFromDB , recipeCategoryFreeText , recipeStepImages){
	var recipeCategory = recipeCategory;
	
	if(recipeIngredient == ""){
		var recipeIngredient_arr = 0;
	}
	else if(recipeIngredient.indexOf("_" , 0) < 0){
		var recipeIngredient_flg = 1;
	}
	else{
		var recipeIngredient_arr = new Array;
		recipeIngredient_arr = recipeIngredient.split("_");
	}
	if(recipeQuantity == ""){
		var recipeQuantity_arr = 0;
	}
	else if(recipeQuantity.indexOf("_" , 0) < 0){
		var recipeQuantity_flg = 1;
	}
	else{
		var recipeQuantity_arr = new Array;
		recipeQuantity_arr = recipeQuantity.split("_");
	}
	if(recipeStep == ""){
		var recipeStep_arr = 0;
	}
	else if(recipeStep.indexOf("_" , 0) < 0){
		var recipeStep_flg = 1;
	}
	else{
		var recipeStep_arr = new Array;
		recipeStep_arr = recipeStep.split("_");
	}
	if(image_file1.length < 1){
		image_file1 = 0;
	}
	if(image_file2.length < 1){
		image_file2 = 0;
	}
	if(image_file3.length < 1){
		image_file3 = 0;
	}
	if(recipeStepImages == ""){
		var recipeStepImages_arr = 0;
	}
	else if(recipeStepImages.indexOf("++" , 0) < 0){
		var recipeStepImages_flg = 1;
	}
	else{
		var recipeStepImages_arr = new Array;
		recipeStepImages_arr = recipeStepImages.split("++");
	}
	if(recipeCategoryFromDB.length){
		var recipeCategory_arr = new Array;
		recipeCategory_arr = recipeCategoryFromDB.split("_");
		recipeCategory_arr.unshift("");
		recipeCategory_arr.unshift("");
		recipeCategory_arr.unshift("");//配列の先頭に項目を３つ追加（新規追加とパーティ料理を飛ばすため）
		var recipeCategory_Flg = 1;
	}
	else{
		var recipeCategory_Flg = 0;
	}
	
	var output = '<table><tbody><tr><th width="150">レシピ名<small>(必須)</small></th><td colspan="3"><input type="text" class="input_text" name="title" value="'+title+'" size="50" /></td></tr>';
	output = output + '<tr><th width="150">レシピの概要<small>(必須)</small></th><td colspan="3"><textarea name="body" rows="10" cols="40">'+body.replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr><tr><th width="150">写真1<small>（完成写真など）</small></th><td colspan="3">';
	if(image_file1 != 0){
		output = output + '<img src="../img.php?filename='+image_file1+'&w=60&h=60&m=pc" id="image_file1_img" />';
		output = output + '<a onclick="delImage(\'image_file1\')" id="image_file1_a">画像を削除</a><br />';
		output = output + '<input type="hidden" name="original_image_file1" value="'+image_file1+'" id="image_file1" />';
		output = output + '<small id="image_file1_explain">画像を変更する場合は、新しく画像を指定してください</small><br />';
	}
	output = output + '<input type="file" class="input_file" name="image_filename1" size="40" /></td></tr><tr><th width="150">写真2<small>（完成写真など）</small></th><td colspan="3">';
	if(image_file2 != 0){
		output = output + '<img src="../img.php?filename='+image_file2+'&w=60&h=60&m=pc" id="image_file2_img" />';
		output = output + '<a onclick="delImage(\'image_file2\')" id="image_file2_a">画像を削除</a><br />';
		output = output + '<input type="hidden" name="original_image_file2" value="'+image_file2+'" id="image_file2" />';
		output = output + '<small id="image_file2_explain">画像を変更する場合は、新しく画像を指定してください</small><br />';
	}
	output = output + '<input type="file" class="input_file" name="image_filename2" size="40" /></td></tr><tr><th width="150">写真3<small>（完成写真など）</small></th><td colspan="3">';
	if(image_file3 != 0){
		output = output + '<img src="../img.php?filename='+image_file3+'&w=60&h=60&m=pc" id="image_file3_img" />';
		output = output + '<a onclick="delImage(\'image_file3\')" id="image_file3_a">画像を削除</a><br />';
		output = output + '<input type="hidden" name="original_image_file3" value="'+image_file3+'" id="image_file3" />';
		output = output + '<small id="image_file3_explain">画像を変更する場合は、新しく画像を指定してください</small><br />';
	}
	output = output + '<input type="file" class="input_file" name="image_filename3" size="40" /></td></tr><tr><th width="150">分量の単位<small>(半角数字、必須)</small></th><td colspan="3"><input type="text" class="input_text" name="recipeUnit" value="'+recipeUnit+'" size="10" />人分</td></tr>';
	
	if(recipeIngredient_flg == 1){
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="'+recipeIngredient+'" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="'+recipeQuantity+'" /></td></tr>';
	}
	else if(recipeIngredient_arr != 0){
		for(i = 0; i < recipeIngredient_arr.length; i++){
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="'+recipeIngredient_arr[i]+'" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="'+recipeQuantity_arr[i]+'" /></td></tr>';
			}
	}
	else{
		output = output + '<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="" /></td></tr>';
	}
	output = output + '<tr><th width="150">材料の項目追加</th><td colspan="3"><a id="recipeAddButton">追加</a></td>';
	
	
	if(recipeCategory_Flg == 0){
		var tmp = 2;
	}
	else{
		var tmp = recipeCategory_arr.length - 1;
	}
	output = output + '<tr><th width="150">カテゴリー</th><td colspan="3">';
	for(i = 1; i <= tmp; i++){
		if(i == 1){
			var output_tmp = '<label><input type="radio" name="recipeCategory" value="1" />その他（新規作成）</label><input type="text" name="recipeCategoryFreeText" class="input_text" value="" />';
		}
		else if(i == 2){
			if(i == recipeCategory){
				output = output + '<label><input type="radio" name="recipeCategory" value="2" checked="checked" />パーティー料理</label>';
			}
			else{
				output = output + '<label><input type="radio" name="recipeCategory" value="2" />パーティー料理</label>';
			}
		}
		else if(i == recipeCategory){
			output = output + '<label><input type="radio" name="recipeCategory" value="'+i+'" checked="checked" />'+recipeCategory_arr[i]+'</label>';
		}
		else if(recipeCategory_Flg != 0){
			output = output + '<label><input type="radio" name="recipeCategory" value="'+i+'" />'+recipeCategory_arr[i]+'</label>';
		}
	}
	output = output + output_tmp + '</td></tr>';
	if(recipeStep_flg == 1){
		output = output + '<tr><th width="150">手順'+i+'の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40">'+recipeStep.replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3">';
		
		/*手順画像変更用*/
		if(recipeStepImages_arr != 0){
			output = output + '<img src="../img.php?filename='+recipeStepImages+'&w=60&h=60&m=pc" id="image_step_img" />';
			output = output + '<a onclick="delImage(\'image_step\')" id="image_step_a">画像を削除</a><br />';
			output = output + '<input type="hidden" name="original_image_step[]" value="'+recipeStepImages+'" id="image_step" />';
			output = output + '<small id="image_step_explain">画像を変更する場合は、新しく画像を指定してください</small><br />';
		}
		
		output = output + '<input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
		}
	else if(recipeStep_arr != 0){
		for(i = 0; i < recipeStep_arr.length; i++){
			j = i + 1;
		output = output + '<tr><th width="150">手順'+j+'の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40">'+recipeStep_arr[i].replace(/&lt;br&gt;/g , "\n")+'</textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3">';
		/*手順画像変更用*/
		if(recipeStepImages_arr[i] != ""){
			output = output + '<img src="../img.php?filename='+recipeStepImages_arr[i]+'&w=60&h=60&m=pc" id="image_step_'+i+'_img" />';
			output = output + '<a onclick="delImage(\'image_step_'+i+'\')" id="image_step_'+i+'_a">画像を削除</a><br />';
			output = output + '<input type="hidden" name="original_image_step[]" value="'+recipeStepImages_arr[i]+'" id="image_step_'+i+'" />';
			output = output + '<small id="image_step_'+i+'_explain">画像を変更する場合は、新しく画像を指定してください</small><br />';
		}
		
		output = output + '<input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
		}
	}
	else{
		output = output + '<tr><th width="150">手順1の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40"></textarea></td></tr>';
		output = output + '<tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3"><input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>';
	}
	output = output + '<tr><th width="150">手順の追加</th><td colspan="3"><a id="recipeStepAddButton">追加</a></td>';
	output = output + '</tbody></table>';
	jQuery("div#topic_form").html(output);
	jQuery("a#recipeAddButton").click(function(){
		addRecipeTopicForm();
	});
	jQuery("a#recipeStepAddButton").click(function(){
		addRecipeStepForm();
	});
}

/*画像削除*/
function delImage(imageName){
	jQuery("div#topic_form input#"+imageName+"").val("");
	jQuery("div#topic_form #"+imageName+"_img").remove();
	jQuery("div#topic_form #"+imageName+"_explain").remove();
	jQuery("div#topic_form #"+imageName+"_a").remove();
}

/*レシピ材料、分量追加時に呼び出される*/
function addRecipeTopicForm(){
	jQuery("div#topic_form tr.recipe:last").after('<tr class="recipe"><th width="150">材料</th><td><input type="text" class="input_text" name="recipeIngredient[]" value="" /></td><td>分量</td><td><input type="text" class="input_text" name="recipeQuantity[]" value="" /></td></tr>');
}

/*手順、手順追加時に呼び出される*/
function addRecipeStepForm(){
	var count = jQuery("tr.recipestep").length + 1;
	jQuery("div#topic_form tr.recipestep:last").after('<tr><th width="150">手順'+count+'の説明</th><td colspan="3"><textarea name="recipeStep[]" rows="10" cols="40"></textarea></td></tr><tr class="recipestep"><th width="150">手順説明用写真</th><td colspan="3"><input type="file" class="input_file" name="step_image[]" size="40" /></td></tr>');
}

/*アルバム登録項目を出力*/
function showAlbumTopicForm(title , body , albumData , albumExplain){
	if(albumData == ""){
		var albumData_arr = 0;
	}
	else if(albumData.indexOf("++" , 0) < 0){
		var albumData_flg = 1;
		var albumDataCount = 1;
	}
	else{
		var albumData_arr = new Array;
		albumData_arr = albumData.split("++");
		var albumDataCount = albumData_arr.length;
	}
	if(albumExplain == ""){
		var albumExplain_arr = 0;
	}
	else if(albumExplain.indexOf("__" , 0) < 0){
		var albumExplain_flg = 1;
		var albumExplainCount = 1;
	}
	else{
		var albumExplain_arr = new Array;
		albumExplain_arr = albumExplain.split("__");
		var albumExplainCount = albumExplain_arr.length;
	}
	
	var outputForm = '<table><tbody><tr><th width="150">タイトル<small>(必須)</small></th><td><input type="text" class="input_text" name="title" value="'+title+'" size="50" /></td></tr><tr><th width="150">アルバムの説明<small>(必須)</small></th><td><textarea name="body" rows="10" cols="40">'+body+'</textarea></td></tr>';
	for(i = 0; i < 20; i++){
		t = i + 1;
		if((albumData_flg == 1) && (i == 0)){
			outputForm = outputForm + '<tr><th width="150">写真'+(t)+'</th><td colspan="3">';
			outputForm = outputForm + '<img src="../img.php?filename='+albumData+'&w=60&h=60&m=pc" id="image_filename'+t+'_img" />';
			outputForm = outputForm + '<a onclick="delAlbumImage(\'image_filename'+t+'\')" id="image_filename'+t+'_a">画像を削除</a><br />';
			outputForm = outputForm + '<small id="image_filename'+t+'_explain">既に写真は登録済みです。変更される場合のみ登録してください</small>';
			outputForm = outputForm + '<input type="file" class="input_file" name="image_filename'+t+'" size="40" /><input type="hidden" name="original_image_filename'+t+'" value="'+albumData+'" id="image_filename'+t+'" />';
			outputForm = outputForm + '</td></tr><tr><th width="150">写真の説明</th><td  colspan="3"><input type="text" class="input_text" name="albumExplain'+t+'" value="'+albumExplain+'" /></td></tr>';
		}
		else if((albumData_arr != 0) && (albumDataCount > i)){
			outputForm = outputForm + '<tr><th width="150">写真'+(t)+'</th><td colspan="3">';
			outputForm = outputForm + '<img src="../img.php?filename='+albumData_arr[i]+'&w=60&h=60&m=pc" id="image_filename'+t+'_img" />';
			outputForm = outputForm + '<a onclick="delAlbumImage(\'image_filename'+t+'\')" id="image_filename'+t+'_a">画像を削除</a><br />';
			outputForm = outputForm + '<small id="image_filename'+t+'_explain">既に写真は登録済みです。変更される場合のみ登録してください</small>';
			outputForm = outputForm + '<input type="file" class="input_file" name="image_filename'+t+'" size="40" /><input type="hidden" name="original_image_filename'+t+'" value="'+albumData_arr[i]+'" id="image_filename'+t+'" />';
			if(albumExplain_arr != 0){
				if(albumExplain_arr[i].length > 0){
					outputForm = outputForm + '</td></tr><tr><th width="150">写真の説明</th><td  colspan="3"><input type="text" class="input_text" name="albumExplain'+t+'" value="'+albumExplain_arr[i]+'" /></td></tr>';
				}
			}
			else{
				outputForm = outputForm + '</td></tr><tr><th width="150">写真の説明</th><td  colspan="3"><input type="text" class="input_text" name="albumExplain'+t+'" /></td></tr>';
			}
		}
		else{
			outputForm = outputForm + '<tr><th width="150">画像'+(t)+'</th><td colspan="3"><input type="file" class="input_file" name="image_filename'+t+'" size="40" /></td></tr><tr><th width="150">画像の説明</th><td  colspan="3"><input type="text" class="input_text" name="albumExplain'+t+'" /></td></tr>';
		}
	}
	outputForm = outputForm + '</tbody></table>';
	jQuery("div#topic_form").html(outputForm);
}
/*画像削除*/
function delAlbumImage(imageName){
	jQuery("div#topic_form input#"+imageName+"").val("");
	jQuery("div#topic_form #"+imageName+"_img").remove();
	jQuery("div#topic_form #"+imageName+"_a").remove();
	jQuery("div#topic_form #"+imageName+"_explain").remove();
}

/*イベント登録時にイベント情報を共通する先生登録用プルダウン*/
function common_event_info_pulldown(friend_commu){
	var count = jQuery("tr.common_event").length + 1;
	output = '<tr class="common_event"><th width="150">イベントを共有するマイスター（'+count+'人目）</th><td>';
	output = output + jQuery("td.common_event:last").html();
	output = output + '</td></tr>';
	if(count == 2){
		jQuery("div#common_event").html(output);
	}
	else{
		jQuery("div#common_event tr.common_event:last").after(output);
	}
}

/*コメント部分偶数行に背景色を付ける*/
function commentBackColor(){
	jQuery("div.listContents dl:even").css("backgroundColor" , "#FFF0E3");
}

/*ヘルプ部分の表示（初期状態)*/
function initHelpContents(){
	jQuery("div#helpContents dd").hide();
}

/*ヘルプ部分クリックで展開*/
function clickExtendHelpContents(){
	jQuery("div#helpContents dt").click(function (){
		jQuery(this).next().toggle();
	});
}
/*ヘルプページ内スクロール*/
function inPageScroll(){
  jQuery("a[href='#']").easingScroll(
  {
  	duration: 2000
  });
}
