/*=====================================================================*/
/* タイトル ：                                                         */
/* Program  ： 株式会社ゴビ                                            */
/*                Copyright (C) 2009 GOV Co.,Ltd. All Rights Reserved. */
/*=====================================================================*/
function emailcheck(str)
{
    if(str.match(/^\S+@\S+\.\S+$/)){
        return 0;
    }else{
        return 1;
    }
}

function trashGomi(s)
{
	s=unescape(escape(s).split("%00")[0]);
	return s;
}
function getByte(str)
{
	if (str=="" || !str || str==null) return 0;
	str=trashGomi(str);
	var strS=str.replace(/[^0-9a-zｱ-ﾝ\!\"\#\$\%\&\'\(\)\-\=\^\~\\\|\@\`\[\{\;\+\:\*\]\}\,\<\.\>\/\?\_\r\n]/ig,"##");
	return strS.length;
}
function count_char()
{
	with( document.frmCheck )
	{
		txtByte.value=getByte(txaInfo.value);
	}
}
function count_charM()
{
	with( document.frmCheck )
	{
		txtByteM.value=getByte(txaInfoM.value);
	}
}
function ckDate(datestr) 
{
     // 正規表現による書式チェック
     if(!datestr.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)){
         return false;
     }
     var vYear = datestr.substr(0, 4) - 0;
     var vMonth = datestr.substr(5, 2) - 1; // Javascriptは、0-11で表現
     var vDay;
     if( isNaN(vMonth) == true )
     {
     	vMonth = datestr.substr(5, 1) - 1;
     	vDay = datestr.substr(7, 2) - 0;
     }
     else
     {
     	vDay = datestr.substr(8, 2) - 0;
     }

     // 月,日の妥当性チェック
     if(vMonth >= 0 && vMonth <= 11 && vDay >= 1 && vDay <= 31){
         var vDt = new Date(vYear, vMonth, vDay);
         if(isNaN(vDt)){
             return false;
         }else if(vDt.getFullYear() == vYear && vDt.getMonth() == vMonth && vDt.getDate() == vDay){
             return true;
         }else{
             return false;
         }
     }else{
         return false;
     }
}

function get_today()
{
	today = new Date();
	y = today.getFullYear();
	m = today.getMonth()+1;
	d = today.getDate();
	str = y + "/" + m + "/" + d;
	return str;
}

function ckDateNow(datestr)
{
	now = Date.parse(get_today());
	comp = Date.parse(datestr);
	if( comp - now > 0 )
	{
		return 1;
	}
	if( comp - now < 0 )
	{
		return -1;
	}
	return 0;
}

function ckDateComp(date_1,date_2)
{
	comp_1 = Date.parse(date_1);
	comp_2 = Date.parse(date_2);
	
	if( comp_1 - comp_2 > 0 )
	{
		return 1;
	}
	if( comp_1 - comp_2 < 0 )
	{
		return -1;
	}
	return 0;
}

function ckMax(str)
{
	if(!str.match(/^[0-9]+$/)){
		return false;
	}
	return true;
}


/***** 処理用スクリプト *****/
function TO_den_toko(no)
{
	with( document.frm )
	{
		no_komoku.value = no;
		action = "den_toko.php";
		submit();
	}
}
function CL_den_toko()
{
	with( document.frm )
	{
		jikko.value = 1;
		action = "den_toko.php";
		submit();
	}
}
function BACKTO_den_toko(img)
{
	with( document.frm )
	{
		if(img)
		{
			alert("写真は再度アップロードしてください。\n" );
		}
		action = 'den_toko.php';
		submit();
	}
}
function TO_den_kiji_list(no,page)
{
	with( document.frm )
	{
		no_komoku.value = no;
		action = 'den_kiji_list.php?page=' + page;
		submit();
	}
}
function TO_den_kiji(no,page)
{
	with( document.frm )
	{
		no_kiji.value = no;
		if( page < 0 )
		{
			action = 'den_kiji.php';
		}
		else
		{
			action = 'den_kiji.php?page=' + page;
		}
		submit();
	}
}
function TO_den_toko_upload_kari()
{
	with( document.frm )
	{
		action = "den_toko_upload_kari.php";
		submit();
	}
}
function TO_den_toko_upload_hon(img)
{
	with( document.frm )
	{
		if( confirm("本当にこの内容で送信しますか？") )
		{
			action = "den_toko_upload_hon.php";
			submit();
		}
		else
		{
			if(img)
			{
				alert("写真は再度アップロードしてください。\n" );
			}
			action = "den_toko.php";
		}
	}
}
function TO_oya_kiji_list(no,page)
{
	with( document.frm )
	{
		no_komoku.value = no;
		action = 'oya_kiji_list.php?page=' + page;
		submit();
	}
}
function TO_oya_kiji(no,page)
{
	with( document.frm )
	{
		no_kiji.value = no;
		if( page < 0 )
		{
			action = 'oya_kiji.php';
		}
		else
		{
			action = 'oya_kiji.php?page=' + page;
		}
		submit();
	}
}
function TO_bar_kensaku(no)
{
	with( document.frm )
	{
		if( no > 0 )
		{
			no_kiji.value = no;
		}
		else
		{
			jikko.value = 1;
		}
		action = "bar_kensaku.php";
		submit();
	}
}

function POPUP_bar_kiji(no)
{
        var str = new String();

        with( document.frm )
        {
                str = "bar_kiji.php?no=" + no;
                window.open(str, '_blank', 'width=800,height=600,scrollbars=1,resizable=yes');
        }
}

function TO_bar_kiji(num)
{
        with( document.frm )
        {
		no.value = num;
		action = 'bar_kiji.php';
		submit();

        }
}

function POPUP_googlemap_kakunin(n,e,nm)
{
        var str = new String();

        with( document.frm )
        {
                str = "map_kakunin.php?e=" + e + "&n=" + n + "&nm=" + nm;
                window.open(str, '_blank', 'width=800,height=600');
        }
}

