// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// 多重送信防止用カウンター
var postCount = 0;
// ポップアップwindowオブジェクト
var win = null;

// 多重送信防止関数
function multiPostProtect() {
  if(postCount == 0) {
    postCount++;
    return true;
  }
  return false;
}

// リンク送信関数
function linkForPost(name) {
  if (multiPostProtect()) {
    var form = document.forms[0];
    var element = document.createElement('input');
    element.setAttribute('type', 'hidden');
    element.setAttribute('name', 'buttons[' + name +']');
    form.appendChild(element);
    form.submit();
  }
  return false;
}

// ポップアップオープン制御関数
function openRequestedPopup(url, name, width, height) {
  if (win == null || win.closed) {
    win = window.open(url, name, "width = " + width + ", height = " + height + ", menubar = no, toolbar = no, location = no, status = no, scrollbars = no");
  }
  else {
    win.blur();
    win.focus();
  }
}
