/*
$(function() {
	$("#q").Watermark("サイト内検索");
});

$(document).ready(function() {
	$('#q').formtips({ 
		class_name: 'boxSearch' //テキスト用のclass
	});
});
*/

function User_VoiceTG(id,str){
	alert(id + "---" + str);
}

//FileUL
$(function() {
	$('#ulBt').click(function() {
		//ボタン無効化
		document.getElementById('ulBt').disabled =true;
		//くるくる
		$('#indi').html("<img src='/common/images/mini_loading.gif'>");
		$('#fields').upload('./bg_file_ul.php', function(res) {
			//レスポンスがあったらくるくる消す
			$('#indi').html("");
			if(res.match('1000')){
				alert('ファイルを選択してください');
			}else if(res.match('1001')){
				alert('CSVファイルを選択してください');
			}else if(res.match(/^foe/)){
				alert("ファイルオープンエラー"+res);
			}else if(res.match(/^DataError/)){
				$('#response').html(res);
				alert("データ形式が不正です");
			}else if(res.match('9999')){
				alert('システムエラー');
			}else{
				$('#response').html(res);
			}
			//ボタン活性化
			document.getElementById('ulBt').disabled =false;
		}, 'html');
	});
});



function NoneExecUL(){
	$(function() {
		//ボタン無効化
		document.getElementById('ulBt').disabled =true;
		document.getElementById('goBt').disabled =true;
		document.getElementById('noBt').disabled =true;
		//くるくる
		$('#indi_no').html("<img src='/common/images/mini_loading.gif'>");
		$('#ul2db').upload('./bg_file_unlink.php', function(res) {
			//ボタン活性化
			document.getElementById('ulBt').disabled =false;
			//くるくる解除
			$('#indi_no').html("");
			document.fff.reset();
			$('input.clearf').val('');
			//
			$('#ul_confirm').html('データ登録せずに処理を終えました');
		}, 'html');
	});
}

function ExecUL(){

	$(function() {
		//ボタン無効化
		document.getElementById('ulBt').disabled =true;
		document.getElementById('goBt').disabled =true;
		document.getElementById('noBt').disabled =true;
		//くるくる
		$('#indi_ok').html("<img src='/common/images/mini_loading.gif'>");
		$('#ul2db').upload('./bg_file_2_db.php', function(res) {
			//ボタン活性化
			document.getElementById('ulBt').disabled =false;
			//くるくる解除
			$('#indi_ok').html("");
			document.fff.reset();
			$('input.clearf').val('');
			//
			$('#ul_confirm').html(res);

		}, 'html');
	});
}

function AllCheck(flg){
	var tmp = document.getElementById(flg).checked;

	if(flg=="feature"){
		for (i = 1; i <= 15; i++) {
			document.getElementById("cd_"+flg+i).checked = tmp;
		}
	}else if(flg=="function"){
		for (i = 1; i <=14 ; i++) {
			document.getElementById("cd_"+flg+i).checked = tmp;
		}
	}else{
		for (i = 1; i <=4 ; i++) {
			document.getElementById("cd_"+flg+i).checked = tmp;
		}
	}
}

function AllTG(flg,pos){
	var tmp = document.getElementById("cd_"+flg+pos).checked;
	if(tmp){
		var tmp2 = true;
		if(flg=="feature"){
			for (i = 1; i <= 10; i++) {
				if(document.getElementById("cd_"+flg+i).checked){
				}else{
					var tmp2 = false;
				}
			}
		}else if(flg=="function"){
			for (i = 1; i <=9 ; i++) {
				if(document.getElementById("cd_"+flg+i).checked){
				}else{
					var tmp2 = false;
				}
			}
		}else{
			for (i = 1; i <=4 ; i++) {
				if(document.getElementById("cd_"+flg+i).checked){
				}else{
					var tmp2 = false;
				}
			}
		}
		document.getElementById(flg).checked = tmp2;
	}else{
		document.getElementById(flg).checked = tmp;
	}
}


function DispTG(pos,f){
	var ff = "#search_tweet_"+f;
	var fm = "#btDetail_"+f;
	if(document.getElementById(pos).style.display=="none"){
		document.getElementById("search_tweet_"+f).style.display = "block";
		if($(ff).html()==""){
			$(ff).html("<img src='/common/images/mini_loading.gif'>");
			$.post("./getSearch.php", {"q" :$(ff).attr('title') , "id":f}, function(data){
					$(ff).html(data);
					},"html"
				);
			//TP
			var tf = "#tp_"+f;
//			$(tf).html("<img src='/common/images/mini_loading.gif'>");
//			$(tf).fadeOut("slow");
			$.post("./getSearchTP.php", {"q" :$(tf).attr('title') ,"url" :$(tf).attr('url') , "id":f}, function(data){
					$(tf).fadeIn("normal");
					$(tf).html(data);
					},"html"
				);
		}

		//OPEN!
		document.getElementById(pos).style.display = "block";
		$(fm).removeClass("btDetail").addClass("btClose");
	}else{
		document.getElementById("search_tweet_"+f).style.display = "block";
		document.getElementById(pos).style.display = "none";
		$(fm).removeClass("btClose").addClass("btDetail");
	}
}

function user_Voice(f){
	var ff = "#search_tweet_"+f;
	var fff = "#more_pos_"+f;
	$(ff).html("<img src='/common/images/mini_loading.gif'>");
	$.post("./getSearch.php", {"q" :$(ff).attr('title'), "id":f}, function(data){
			$(ff).html(data);
			},"html"
		);
	$(fff).val('1');
}

function Read_More(f){
	var fff = "#more_pos_"+f;
	//今の値のid
	var n = "next_page_"+f+"_"+$(fff).val();

	var ind = "#more_indi_"+f;
	if($(ind).html()==""){

		if(document.getElementById(n)!=null){
			$(ind).html("<img src='/common/images/mini_loading.gif'>");
			//次の表示場所
			var d = "more_disp_"+f+"_"+($(fff).val()*1+1);
			$.post("./getSearchMore.php", {"n":document.getElementById(n).value, "id":f}, function(data){
					document.getElementById(d).innerHTML=data;
					$(ind).html("");
					},"html"
				);
			//次用に追加する
			$(fff).val($(fff).val()*1+1);
		}else{
			alert('ユーザーの声が存在しません');
		}
	}else{
		alert('処理中です　お待ちください。');
	}
}


