
function check_duplication_id(){
	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	var elm = document.getElementById('hn');
	var check_id = rtrim(ltrim(elm.value));

	if(check_id==""){
		elm.value="";
		elm.style.backgroundColor = '#FF3333';
	}else{
		elm.style.backgroundColor = '#FFFFFF';
		sendRequest(checkID,"&check_id="+check_id+"&time="+timestamp+rand+"",'POST',G_URL_DUP,true,false);
	}

}

function check_duplication_id_not_mine(){

	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	var elm = document.getElementById('hn');
	var check_id = elm.value;

	if(check_id==""){
		elm.style.backgroundColor = '#FF3333';
	}else{
		elm.style.backgroundColor = '#FFFFFF';
		sendRequest(checkID,"&check_id="+check_id+"&fl=not_mine&time="+timestamp+rand+"",'POST',G_URL_DUP,true,false);
	}

}



//response
function checkID ( req ) {
	var text = req.responseText;
	if(text=="0"){
		alert('ご利用可能です！');
	}else{
		alert('このHNはご利用できません');
	}
}



function search_zip(id_name){
	var searchZipVal =  document.getElementById(id_name).value;

	if(searchZipVal!=""){
		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();
		document.getElementById(id_name).style.backgroundColor = '#FFFFFF';
		sendRequest(resultZip,"&zip="+searchZipVal+"&time=_"+timestamp+rand+"",'POST',ZIP_SEARCH_,true,false);
	}else{
		document.getElementById(id_name).focus();
		document.getElementById(id_name).style.backgroundColor = '#FF3333';
	}
}



//response
function resultZip ( req ) {
	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}

	if(text!=""){
		var tmp = text.split("&");
		var tmp_val_Array = new Array();
		var tmp_id_Array = new Array();

		for(i = 0; i < tmp.length; i++){
			var tmp2 = tmp[i].split('=');
			for (ii = 0; ii < tmp2.length;ii++){
				if(ii%2){
					tmp_val_Array[i] = tmp2[ii];
				}else{
					tmp_id_Array[i] = tmp2[ii];
				}
			}
		}

		for(iii=0;iii<tmp_val_Array.length;iii++){
			var pos = tmp_id_Array[iii];
			var elm = document.getElementById(pos);
			elm.value=tmp_val_Array[iii];
		}

	}else{
	}

}


function add_Fav_bbs(bbs_id){

	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	sendRequest(Res_add_Fav_bbs,"&bbs_id="+bbs_id+"&time=_"+timestamp+rand+"",'POST',BBS_AD_FAV,true,false);


}

function Res_add_Fav_bbs ( req ) {
	var text = req.responseText;

	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}

	if(text=="1"){
		alert('お気に入りに登録いたしました');

	}else{
		alert('既にお気に入りに登録されています');
	}
}


function show_reading_history_and_fav(flg,id){

	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	var Myrand=Math.floor(Math.random()*10000);

	var tmpImgtag = "<br><center><img src='/shared/images/indicator.gif'>&nbsp;&nbsp;<font style='font-size:9px;'>データ取得中</font></center>";
	document.getElementById('rhf').innerHTML = decodeURIComponent(tmpImgtag);

	sendRequest(Show_RHF_req,"&times="+Myrand+"&user_id="+id+"&flg="+flg+"&time=_"+timestamp+rand,'POST',SHOW_RHF,true,false);

}

function Show_RHF_req(req){


	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}



	document.getElementById('rhf').innerHTML = decodeURIComponent(text);
}

function all_delete_fav(id){


	if(confirm('全てのお気に入りを削除しますか？')){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();
		var Myrand=Math.floor(Math.random()*10000);


		var tmpImgtag = "<br><center><img src='/shared/images/indicator.gif'>&nbsp;&nbsp;<font style='font-size:9px;'>データ削除中</font></center>";
		document.getElementById('rhf').innerHTML = decodeURIComponent(tmpImgtag);

		sendRequest(common_Func_2,"&time=_"+Myrand+"&tmp="+timestamp+rand,'POST',DEL_FAV_ALL,true,false);

	}

}

function all_delete_rh(id){


	if(confirm('全ての閲覧履歴を削除しますか？')){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();
		var Myrand=Math.floor(Math.random()*10000);


		var tmpImgtag = "<br><center><img src='/shared/images/indicator.gif'>&nbsp;&nbsp;<font style='font-size:9px;'>データ削除中</font></center>";
		document.getElementById('rhf').innerHTML = decodeURIComponent(tmpImgtag);

		sendRequest(common_Func_1,"&time=_"+Myrand+"&tmp="+timestamp+rand,'POST',DEL_RH,true,false);

	}

}

function common_Func_1(req){
	var text = req.responseText;
	show_reading_history_and_fav('1',text);
}
function common_Func_2(req){
	var text = req.responseText;
	show_reading_history_and_fav('2',text);
}


function bbs_delete_fav(fav_id,id){

	if(confirm('お気に入りを削除しますか？')){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();

		var Myrand=Math.floor(Math.random()*10000);

		var tmpImgtag = "<br><center><img src='/shared/images/indicator.gif'>&nbsp;&nbsp;<font style='font-size:9px;'>データ削除中</font></center>";
		document.getElementById('rhf').innerHTML = decodeURIComponent(tmpImgtag);
		sendRequest(common_Func_2,"&bbs_fav_id="+fav_id+"&time=_"+Myrand+"&tmp="+timestamp+rand,'POST',DEL_FAV,true,false);

	}

}


function display_Res_Body(){

	var elm = document.getElementById('hidden_flg');

	var loopC  = document.getElementById('loopC').value;

	var loop = parseInt(loopC);


	if(elm.value=="1"){
		for(var i=1;i<=loop;i++){
			var pos = "res_body_"+i;
			document.getElementById(pos).style.display="none";
		}

		document.getElementById('hid_bt').value="レス 詳細表示";
		elm.value="0";
	}else{
		for(var i=1;i<=loop;i++){
			var pos = "res_body_"+i;
			document.getElementById(pos).style.display="block";
		}

		document.getElementById('hid_bt').value="レス 簡易表示";
		elm.value="1";
	}

}



function move_area(){
	var elm = document.getElementById('rearank');
	if(elm.value==""){
//		alert('地域を選択してください');
		elm.focus();
		elm.select();
	}else{
		var h = AREA_RANK + elm.value + ".html";
		document.location.href=h;
	}
}


function move_cat(){
	var elm = document.getElementById('catrank');
	if(elm.value==""){
//		alert('ジャンルを選択してください');
		elm.focus();
		elm.select();
	}else{
		var h  = CAT_RANK + elm.value + ".html";
		document.location.href=h;
	}
}



function erase_date(){

	var elm = document.getElementById('selDate');
	elm.value="";

}


function show_pg_calender(id,min_date,max_date){

	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	sendRequest(disp_Cal,"&id="+id+"&min_date="+min_date+"&max_date="+max_date+"&time="+timestamp+rand+"",'POST',PG_SUB_CAL,true,false);

}

function disp_Cal(req){

	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}

	document.getElementById('cal').innerHTML = decodeURIComponent(text);

}




function back_cal_month(id,min_date,max_date,preview){
	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	sendRequest(disp_Cal,"&id="+id+"&min_date="+min_date+"&max_date="+max_date+"&preview="+preview+"&time="+timestamp+rand+"",'POST',PG_SUB_CAL,true,false);

}


function next_cal_month(id,min_date,max_date,preview){
	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();
	sendRequest(disp_Cal,"&id="+id+"&min_date="+min_date+"&max_date="+max_date+"&preview="+preview+"&time="+timestamp+rand+"",'POST',PG_SUB_CAL,true,false);
}

function set_selDate(selDate){
	document.getElementById('selDate').innerHTML = selDate;
	document.getElementById('selDate_hidden').value = selDate;
}



function select_Area(obj){

	var elm = document.getElementById('pref');

	var text = obj.options[obj.selectedIndex].text;

	if(elm.value!="0"){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();

		var tmpImgtag = "<br><img src='/shared/images/indicator.gif' style='margin-left:20px;'>&nbsp;&nbsp;<font style='font-size:9px;'>"+text+"&nbsp;エリア取得中</font>";
		document.getElementById('areaList').innerHTML = decodeURIComponent(tmpImgtag);

		sendRequest(disp_Index_Select,"&pref_cd="+elm.value+"&time="+timestamp+rand+"",'POST',INDEX_SELECT_AREA,true,false);

	}

}

function selected_Area(area_id){

	var elm = document.getElementById('pref');


	if(elm.value!="0" && area_id!="0" & area_id!=""){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();

		sendRequest(disp_Index_Select,"&pref_cd="+elm.value+"&area_id="+area_id+"&time="+timestamp+rand+"",'POST',INDEX_SELECT_AREA,true,false);

	}

}





function disp_Index_Select(req){

	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}


	document.getElementById('areaList').innerHTML = decodeURIComponent(text);

}


function ltrim(argValue){

    return String(argValue).replace(/^[ 　]*/gim, "");

}

function rtrim(argValue){

    return String(argValue).replace(/[ 　]*$/gim, "");

}


function check_Valid_reissue(){

	var hn =  document.getElementById('hn');
	var mail_addr =  document.getElementById('mail_addr');

	if(rtrim(ltrim(hn.value))==""){
		hn.value="";
		hn.style.backgroundColor = '#FF3333';
	}
	if(rtrim(ltrim(mail_addr.value))==""){
		mail_addr.value="";
		mail_addr.style.backgroundColor = '#FF3333';
	}

	if(rtrim(ltrim(mail_addr.value))!="" && rtrim(ltrim(hn.value))!=""){

		document.reissueF.submit();

	}

}


//	お問い合わせへのリンク遷移(ポップアップ)

function pop_up_inquiry(fl,program_id){

	var rand = Math.random();

	if(fl.match("pg")){
		Inquiry_Window = window.open(G_URL_NONE_SSL+"program/inquiry.php?program_id="+program_id+"&elf=1"+rand+"","Inquiry_Window","width=884,height=700,scrollbars=yes");
		Inquiry_Window.focus();
	}else{

		Inquiry_Window = window.open(G_URL_NONE_SSL+"program/inquiry.php?office_id="+program_id+"&elf=2"+rand+"","Inquiry_Window","width=884,height=700,scrollbars=yes");
		Inquiry_Window.focus();

	}

}


function ReloadParent() {
    // 親窓のチェック
    if (! window.opener || window.opener.closed) {
        return;
    }

    // 親窓リロード
    window.opener.location.reload(true);

	var url = G_URL+"program/inquiry.php?"+location.search.substr(1);

	location.href(url);
}



function mv_dust(){
	var elm =  document.getElementById('mail_id');
	if(confirm('メッセージを削除しますか？\r\n\r\n削除すると送受信BOXに戻すことはできません')){
		document.dustF.submit();
	}
}


//	都市情報へのリンク遷移(ポップアップ)
function town_info(fl,page){

	if(fl=="area"){
		Info_Window = window.open(G_URL_NONE_SSL+"program/town_info/area/"+page+"/","Info_Window","width=884,height=700,scrollbars=yes");
		Info_Window.focus();
	}else{
		Info_Window = window.open(G_URL_NONE_SSL+"program/town_info/pref/"+page+"/","Info_Window","width=884,height=700,scrollbars=yes");
		Info_Window.focus();
	}

}


function search_Holiday(day){
	var elm = document.getElementById('pref_top');
	var url = G_URL_NONE_SSL + "program/search.php?selDate="+escape(day)+"&fl=1&pref_code="+elm.value;

	if(elm.value=="1" || elm.value=="47"){

		url += "&area_id=0";

	}

	document.location.href=url;
}


function show_blog_calender(id){

	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();

	sendRequest(disp_Cal,"&office_id="+id+"&time="+timestamp+rand+"",'POST',BLOG_SUB_CAL,true,false);

}


function back_Blog_cal_month(id,preview){
	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();
	sendRequest(disp_Cal,"&office_id="+id+"&preview="+preview+"&time="+timestamp+rand+"",'POST',BLOG_SUB_CAL,true,false);
}


function next_Blog_cal_month(id,preview){
	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();
	sendRequest(disp_Cal,"&office_id="+id+"&preview="+preview+"&time="+timestamp+rand+"",'POST',BLOG_SUB_CAL,true,false);
}


function del_blog_entry(){

	var cnt=0;

	for(var i=0;i<document.myFORM.length;i++){
		//チェックボックスであれば
		if(document.myFORM[i].type=="checkbox"){
			if(document.myFORM[i].checked){
				cnt++;
			}
		}
	}

	if(cnt>=1){
		if(confirm('選択されている記事を削除しますか？')){
			document.myFORM.submit();
		}
	}else{
		alert('削除する記事を選択してください');
	}

}


function subst_List(year){

	if(year==""){
		var Y = document.getElementById('subst_year').value;
	}else{
		var Y = year;
	}


	var date = new Date();
	var timestamp = date.getTime();
	var rand = Math.random();
	sendRequest(disp_List,"&year="+Y+"&time="+timestamp+rand+"",'POST',MEMBER_SUBST_LIST,true,false);

}

function disp_List(req){

	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}

	document.getElementById('subst_list').innerHTML = decodeURIComponent(text);

}


function show_maps(id){
	GMAPS_Window = window.open(G_URL_NONE_SSL+"program/show_map.php?program_id="+id+"","GMAPS_Window","width=450,height=500,scrollbars=yes");
	GMAPS_Window.focus();
}


function reason_toggle(flg){
	document.getElementById('disp_reason').style.display = flg;
}

function re_addision_Valid(){

	var elm1 = document.getElementById('re_login_id');
	var elm2 = document.getElementById('re_passwd');
	var elm3 = document.getElementById('hn');
	var elm4 = document.getElementById('mail_addr');

	if(	elm1.value=="" ||	elm2.value=="" ||	elm3.value=="" ||	elm4.value=="" ){

		if(elm1.value==""){	elm1.style.backgroundColor = '#FF3333';	}
		if(elm2.value==""){	elm2.style.backgroundColor = '#FF3333';	}
		if(elm3.value==""){	elm3.style.backgroundColor = '#FF3333';	}
		if(elm4.value==""){	elm4.style.backgroundColor = '#FF3333';	}

	}else{
		document.re_ad_f.submit();
	}
}


function select_Show(area_id){

	var elm		= document.getElementById('pref_code');
	var elm2	= document.getElementById('disp_area');

	if(elm.value=="1" || elm.value=="47"){

		var date = new Date();
		var timestamp = date.getTime();
		var rand = Math.random();

		sendRequest(disp_Select_Val,"&pref_cd="+elm.value+"&area_id="+area_id+"&time="+timestamp+rand+"",'POST',SEARCH_SELECT_AREA,true,false);

		elm2.style.display="block";

	}else{

		elm2.style.display="none";
	}


}

function disp_Select_Val(req){
	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}
	document.getElementById('select_area').innerHTML = decodeURIComponent(text);
}


function DelSend_BoxMail(){

	var cnt=0;

	for(var i=0;i<document.SF.length;i++){
		//チェックボックスであれば
		if(document.SF[i].type=="checkbox"){
			if(document.SF[i].checked){
				cnt++;
			}
		}
	}

	if(cnt>=1){
		if(confirm('選択されている送信メールを削除しますか？')){
			document.SF.submit();
		}
	}else{
		alert('削除する送信メールを選択してください');
	}


}



function DelDust_BinMail(){

	var cnt=0;

	for(var i=0;i<document.DF.length;i++){
		//チェックボックスであれば
		if(document.DF[i].type=="checkbox"){
			if(document.DF[i].checked){
				cnt++;
			}
		}
	}

	if(cnt>=1){
		if(confirm('選択されているメールを削除しますか？\r\nごみ箱から削除しますた、復元はできません。')){
			document.DF.submit();
		}
	}else{
		alert('削除するメールを選択してください');
	}


}

function PrintPage_Show(id){


	GMAP_Window = window.open(G_URL_NONE_SSL+"program/show_map.php?program_id="+id+"&elf=1","GMAP_Window","width=650,height=700,scrollbars=yes");
	GMAP_Window.focus();

//	window.print();
}


//--------------------------------------------------------------------------

