function ToggleBlock(SetID){
	$("#"+SetID).slideToggle("slow");
}


function ToggleInline(SetID){
	$(".error").remove();
	if($("#"+SetID).css("display") === 'inline'){
		$("#"+SetID).css("display" , "none");
	}else{
		$("#"+SetID).css("display" , "inline");
	}
}

//
function Scroll(SetID){
	$.scrollTo("#"+SetID, 'slow');
}
//画像の拡大縮小
function ImageExpansion(SetID){
	if($("#"+SetID).css("display") !== "none"){
		$("#"+SetID).fadeOut("slow");
	}else{
		$("#"+SetID).fadeIn("slow");
	}
}

/****メンバーページ******/

///制限変更
function SaveLimitChange(qNo){
	$("#Limit"+qNo).slideToggle("slow");
	$("#ChangeLimit"+qNo).slideToggle("slow");
}

//////投票コード
function FormPaste(url,HomeUrl){
    var formWindow = HomeUrl+"member/paste.php?url="+url;
    var opnW = window.open(formWindow,"投票フォームコード","scrollbars=yes,width=780,height=600");
	opnW.focus();
}


/*投票フォーム　コード*/
//設定開く
function SetOpen(SetID){
	$("#"+SetID).slideToggle("slow");
}


function calc16(n16){
n16="0"+parseInt(n16,10).toString(16).toUpperCase();
n16=n16.substr(n16.length-2,2)
return n16;
}

//色変更
function ChangColor(SetID,Col){
	var Mcolor = SetID+"M";
	var SetColor = "#"+Col
	document.getElementById(Mcolor).style.background = SetColor;
	document.getElementById(SetID).value = Col;
}

///////　退会確認　////////
function DounanoWithDraw(){

	if(document.withdrawForm.password.value){
		if(confirm("本当に退会してもよろしいですか？")){ return true }{ return false }
	}else{
		alert('退会される場合はパスワードを入力し\n退会をクリックして下さい');
		return false;
	
	}
}

//投票者データグラフOPEN
function VoteGraph(){
	if($(".VoteBarGraph").css("display") !== "none"){
		$(".VoteBarGraph").fadeOut("slow");
		$(".VDs1").fadeIn("slow");
		$(".VDs2").fadeOut("slow");
		$(".VDc").text('グラフ表示');
	}else{
		$(".VoteBarGraph").fadeIn("slow");
		$(".VDs1").fadeOut("slow");
		$(".VDs2").fadeIn("slow");
		$(".VDc").text('グラフ隠す');
	}
}


///コメントオープン
function CommentOpen(){
	if($("#ComBlock").css("display") !== 'none'){
		$("#coc").text('表示');
	}else{
		$("#coc").text('隠す');
	}
	$("#ComBlock").slideToggle("slow");
	$.scrollTo("#ComBlock", 'slow');
}

function ToComment(){
	$("#coc").text('隠す');
	$("#ComBlock").slideDown("slow");
	$.scrollTo("#ComBlock", 'slow');
}

///コメント削除チェック
function CdelCheck(name){
	if(confirm(name+"さんからの\nコメントを削除しますか？")){ return true }{ return false }
}


//////選択項目修正
function OpenSelectAmend(qNo,sNo){
	$(".error").remove();
	var Sid = "s"+qNo+"s"+sNo;
	var NowText = $("#"+Sid).text();
	var AmendInpId = "amd"+qNo+"s"+sNo;
	if($("#"+Sid).css("display") === 'inline'){
		$(".selAm").css("display","none");
		$(".nsSp").css("display","inline");
		$("#"+Sid).css("display","none");
		var AIhtml = '<span class="selAm" id="SP'+AmendInpId  +'">';
		AIhtml += '<input type="text" class="selectAmend" id="'+AmendInpId  +'" value="'+NowText+'" />';
		AIhtml += '<input type="button" value="修正" onclick="SelectAmendUpdate('+qNo+','+sNo+')" />';
		AIhtml += '</span>';

		$("#"+Sid).after(AIhtml);
	}else{
		$("#"+Sid).css("display","inline");
		$("#SP"+AmendInpId).remove();
	
	}
}

///選択項目追加チェック
function CheckAddSel(qNo , TextId){
	var AddText = $("#"+TextId).val();

	if(!AddText){
		alert('追加する選択項目を入力してください');
		return false;
	}else{
		if(confirm("質問"+qNo+"選択項目に\n-----------\n\n"+AddText+"\n\n-----------\nを追加しますか？")){
		}else{ return false }
	}
}

////タイトル変更
function OpenPurportAmend(){
	
	if($("#AmendPurport").css("display") === "none"){
		$("#AmendPurport").slideDown("slow");
		$("#purport").slideUp("slow");
	}else{
		$("#AmendPurport").slideUp("slow");
		$("#purport").slideDown("slow");
	}

}

////質問文変更
function OpenQitemAmend(qNo){
	
	if($("#AmendQitem"+qNo).css("display") === "none"){
		$("#AmendQitem"+qNo).slideDown("slow");
		$("#QI"+qNo).slideUp("slow");
	}else{
		$("#AmendQitem"+qNo).slideUp("slow");
		$("#QI"+qNo).slideDown("slow");
	}

}


/**********************************
アンケート作成
***********************************/
///

function QHelp(SetID){
	var display =$("#"+SetID).css("display");
	$(".HideHelp").slideUp("normal");
	if(display !== 'block'){
		$("#"+SetID).slideDown("slow");
	}
}

function togetherToggle(SetID){
	$("#"+SetID).slideToggle("slow");
}

///
function AddColor(SetID){
	$("#"+SetID).css("background-color","rgb(255,240,240)")
}

//////途中データ削除
function MqDelete(){
   if(confirm("作成中のデータを削除してよろしいですか？")){ 
    return true
   }else{
    return false
   }
}



///元画面にデータがあればそれを表示
function inportSelectData(qNo){
	$(".slideUpHelp").slideUp("normal");
	$("#TBpack"+qNo).slideToggle("slow");
	var SelData = "";
	for(var i = 1; i<=20; i++){
		var GetData = document.getElementById("qNo"+qNo+"sel"+i).value;
		if(document.getElementById("UpqNo"+qNo+"sel"+i)){
			var GetFile = document.getElementById("UpqNo"+qNo+"sel"+i).value;
		}else{
			var GetFile = "";
		}
		
		if((GetData)||(GetFile)){
			SelData += GetData + "\n";
		}
	}
	if(SelData){
		document.getElementById("together"+qNo).value = SelData;
	}
}



////　　一括入力　　//////////////
function UpTogether(qNo){
	var together = document.getElementById("together"+qNo).value;
	var togetherArray = together.split("\n");
	var error = '';
	if(together){
		var si = 0;
		for(i=0; i<togetherArray.length; i++){
				si = si+1;
			if(togetherArray[i]){
				document.getElementById("qNo"+qNo+"sel"+si).value = togetherArray[i];
				$("#LIqNo"+qNo+"sel"+si).slideDown();
				if(togetherArray[i].length > 30){
					var print_i = i+1;
					error += "選択項目「"+togetherArray[i]+"」は"+togetherArray[i].length+"文字あります\n30文字以内にして下さい\n";
				}
			}
		}
		if(!error){
			$("#TBpack"+qNo).slideUp("slow");
		}else{
			alert(error);
		}
	}else{
		if(confirm("入力内容が確認出来ません\nこの画面を閉じてもよろしいですか？")){
			$("#TBpack"+qNo).slideUp("slow");
		}
	}
}


//選択肢の追加
function Sadd(qNo){
	for(var i = 1; i<=20; i++){
		var trDis = document.getElementById("LIqNo"+qNo+"sel"+i).style.display;
		if(trDis === "none"){
			$("#LIqNo"+qNo+"sel"+i).slideDown("slow");
			break;
		}
	}
}


//////画像ＵＰ画面
function ImgUpWin(Url,qNo,sNo){
    var ImageWindow = Url+"?qNo="+qNo+"&sNo="+sNo;
    var opnW = window.open(ImageWindow,"画像ＵＰ","width=400,height=230");
    opnW.focus();
}

//画像データを親元へ
function LoadFile(){
	var qNo = document.loadForm.qNo.value;
	var sNo = document.loadForm.sNo.value;
	var upfile = document.loadForm.upfile.value;
	var file_name = document.loadForm.file_name.value;
	var width = document.loadForm.width.value;
	var height = document.loadForm.height.value;
	
	var LoadData = file_name+'&&'+width+'&&'+height;
	if(sNo){
		var sNoData = 'sel'+sNo;
	}else{
		var sNoData = '';
	}
	
	var ULhtml = '<input type="hidden" id="UpqNo' + qNo + sNoData + '" value="' + LoadData + '" />(画像';
	ULhtml += '<span class="Bfile">'+upfile+'</span>';
	ULhtml += '<a href="javascript:DeleteImg(\''+"saveImg"+qNo+sNoData+'\')">×</a>)';
	
	window.opener.$("#saveImg"+ qNo + sNoData).html(ULhtml);
	window.close();
}

//画像削除
function DeleteImg(SetId){
	if(confirm("この画像を削除してもよろしいですか？")){ 
		$("#"+SetId).empty();
	}
}

//質問順移動確認
function QTCheck(qNo){
	var conf = "";
	for(var i = 1; i <= 5;  i++){
		if((document.getElementById("QBlock"+i).style.display !== "none") 
		&&(document.getElementById("InpQ"+i).style.display !== "none")){
			conf += "質問"+i+"が作成中です\n保存されてないデータは失われます\n"
		}
	}
	
	if(confirm("質問"+qNo+"の質問順を一つ下げます\n"+conf+"よろしいですか？\n"))
	{return true }{ return false }
}

//質問削除確認
function QDCheck(qNo){
	if(confirm("質問"+qNo+"を削除します\n削除した質問は復元できません\nよろしいですか？"))
	{return true }{ return false }
}


/////オリジナルＯＰＥＮ
function openOrgWin(vNo,Type){
	$(".VdS"+vNo).slideUp("slow");
	if(document.getElementById("original"+vNo).checked === true){
		if(!$("#OVDselect"+vNo).text()){
			$("#OVB"+vNo).slideDown("slow");
		}
		$("#VdSoriginal"+vNo).slideDown("slow");
	}else{
		$("#OVB"+vNo).slideUp("slow");
		$("#VdS"+Type+vNo).slideDown("slow");
	}
}

///最後の確認
function QuestionMakeFinalcheck(){
	if(confirm("確定してアンケートを開始します\nよろしいですか？"))
	{return true }{ return false }
}

//最終内容チェック
function FinalCheckFromTop(){
	$.scrollTo("#FCheckI",{speed:1000});

}

/*****************************
回答ページ
*****************************/
////新回答にチェック
function InpCheck(qNo){
	document.getElementsByName("QUESTION"+qNo+"[]").checked = false;
	document.getElementById("new"+qNo).checked = true;
}

////新回答にチェックOFF
function ncOff(qNo){
	if(document.getElementById("new"+qNo)){
		document.getElementById("new"+qNo).checked = false;
	}
}




///////　回答があっているか確認　////////
function AnswerCheck(){
	var question_total = document.answerFrom.question_total.value;//質問総数
	var error = "";
	var NewAns = "";
	for (var qNo = 1; qNo <= question_total; qNo++){
	
		var ansType = document.getElementById("ansType"+qNo).value;//回答の種類
		var sure = document.getElementById("sure"+qNo).value;//回答の必須・任意
		
		
		//回答を取得
		var ans = new Array();
		for (var i= 0; i < document.answerFrom.length; i++){
			if ((document.answerFrom.elements[i].name=='QUESTION'+qNo+'[]')  && (document.answerFrom.elements[i].checked)){
				ans.push(document.answerFrom.elements[i].value);
				
				 if(document.answerFrom.elements[i].value === "new"){
				 	NewAns =  "ON";
				 }else{
				 	NewAns =  "";
				 }
			}
		}
		
		if(sure === "s"){
			error += (!ans[0]) ? "質問"+qNo+"は必須回答です\n" : "";
		}
		
		if(!error){
			if(ansType === "P"){
				var num = document.getElementById("num"+qNo).value;//複数時回答数
				var mm = num.split("-");
				if(ans.length > 0){
					error += (ans.length < mm[0]) ? "質問"+qNo+"の回答が指定数に届きません\n" : "";
					error += (ans.length > mm[1]) ? "質問"+qNo+"の回答が指定数より多く選択されています\n" : "";
				}
			}
			
			if(NewAns == "ON"){
				var newAnsValue = $("#newAns"+qNo).val();
				if(!newAnsValue){
					error += "質問"+qNo+"　新しい回答を選んだ場合は回答をご入力下さい\n" ;
				}
			}
			
		}
	
	}
	
	////ここから投票者データの確認
	for(var vi = 1; vi<=3; vi++){
		if(document.getElementById("V"+vi)){
			var s_vote = document.getElementById("V"+vi).selectedIndex;
			var vote =  document.getElementById("V"+vi).options[s_vote].value;
			var vname = document.getElementById("vname"+vi).value;
			error += (vote < 1) ? vname+"が選択されてません\n" : "";
		}
	}

	//エラーがあったら
	if(error){
		alert(error);
		return false;
	}
}


/********************
メンバーぺージ
*********************/
function LogOutCheck(){

   if(confirm("ログアウトしてもよろしいですか？")){ return true }{ return false }
	
}

///　アンケートの削除確認　///
function QDeleteCheck(purport){

   if(confirm("このアンケートを削除します\n確認しよろしければパスワードを入力して削除して下さい？")){ return true }{ return false }

}

///締切訂正
function DLsel(qNo){
	var sSelDL = document.getElementById("SelDL"+qNo).selectedIndex;
	var SelDL = document.getElementById("SelDL"+qNo).options[sSelDL].value;
	
	if(SelDL === 'T'){
		$("#DLN"+qNo).slideUp("slow");
		$("#DLT"+qNo).slideDown("slow");
	}else if(SelDL === 'N'){
		$("#DLT"+qNo).slideUp("slow");
		$("#DLN"+qNo).slideDown("slow");
	}

}


function FOR_MANUAL(No){
      href = "../manual/#manual"+No;

window.open(href,"カテゴリ一覧","scrollbars=1,width=780,height=500");

}


function LIST(){

window.open("../manual/category.html","カテゴリ一覧","scrollbars=1,width=450,height=400");
}





