
//クッキー保存
function setCookie(name ,value)
{
	
	// クッキーに保存する文字列
	var str = "";
	//クッキー名
	str = name + "=";
	
	str += value;
	// クッキーに保存
	document.cookie = str + ";path=/";

}

//保存されているクッキーから、指定したクッキー名の値を取得
function getCookie(c_name){

  var st="";
  var ed="";
  if (document.cookie.length>0){
    st=document.cookie.indexOf(c_name + "=");
    if (st!=-1){ 
      st=st+c_name.length+1;
      ed=document.cookie.indexOf(";",st);
      if (ed==-1) ed=document.cookie.length;
      return unescape(document.cookie.substring(st,ed));
    } 
  }
  return "";
}

// クッキーの削除
function deleteCookie(cname) {
  cName = cname + "="; // 削除するクッキー名
  dTime = new Date();
  dTime.setYear(dTime.getYear() - 1);
  document.cookie = cName + ";path=/;expires=" + dTime.toGMTString();
}


// window close 汎用
function window_close(){
    window.opener = window;
    var win = window.open(location.href,"_self");
    win.close();
}

function changeAll(id) {
	var checked;
	$A($(id).getElementsByTagName('input')).each(function(input) {
	if(input.name == 'checkbox_all') { checked = input.checked; }
	if (input.type == "checkbox" && input.checked != checked) { input.checked = checked; }
	});
}
function isCheckedCheckbox(id) {
	var count = 0;
	$A($(id).getElementsByTagName('input')).each(function(input) {
	if (input.type == "checkbox" && input.checked) { count++; }
	});
	return count > 0;
}
function checkAllSubmit(id, msg)
{
	if(!isCheckedCheckbox(id)) {
		alert('チェックボックスをチェックしてから実行してください'); return false;
	}
	if(msg == null || msg == "")
			msg = 'チェックしたデータを更新しますが、よいですか？';
		return confirm(msg);
	return true;
}

function goSubmit(checkflg)
{
	var frm = document.actForm;
	frm.checkflg.value=checkflg;
	frm.submit();
}

// 入力文字のカウントを返す
function ShowLength( obj ,return_display_id) {
    document.getElementById( return_display_id ).innerHTML = obj.value.length ;
    //textObj = document.createTextNode( obj.value.length );
    //document.getElementById( return_display_id ).replaceChild(textObj);
}

// 表示･非表示切替
function display_toggle(id, myself, $open_img, $close_img)
{
    doc = document.getElementById( id );
    display = doc.style.display;
    
    if (doc.style.display == "none") {
    // OPEN
        doc.style.display = "block";
        if(myself.value) myself.value = $close_img ;
        if(myself.src) myself.src = $close_img ;
    
    } else {
    // CLOSE
        doc.style.display = "none";
        if(myself.value) myself.value = $open_img ;
        if(myself.src) myself.src = $open_img ;
    }
}

// 
function no_login_alert()
{
    alert("こちらの機能はログイン後にご利用になれます");
}

// addBookmark
function addBookmark(title,url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    } else if( document.all ) {
        window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
        return true;
    }
}

// jquery post
function send_post($url, $data, $callback_success, $callback_error, $async, $dataType)
{
	if (!$async)	$async = false ;
	if (!$dataType)	$dataType = "html";
	jQuery.ajax({
		type: "POST",
		async: $async,
		url: $url,
		data: $data,
		dataType: $dataType,
		success: $callback_success,
	    error:$callback_error
	});
}

