﻿/*                                                             */
/*         豊橋観光コンベンション協会    WEBシステム           */
/*                                                             */
/*                    一般利用者用ページ                       */
/*                 Javascript関数定義 [共通]                   */
/*                                                             */
/*         2010 (c) e-pokke Inc.  All rights reserved.         */
/*                                                             */



// ----- 送信・変更時の確認 -----
var change_flag = 0;
var send_flag = 0;

function check_submit() {
  if ( send_flag == 1 ) {
    alert('ただいま送信中です。\n「OK」ボタンをクリックしてお待ちください。');
    return false;
  }

  send_flag = 1;

  return true;
}

// ----- サイト内検索時のチェック -----
function check_submit_search() {
  if ( document.search_form.Sword.value == '' ) {
    alert('検索するキーワードを入力してください。');
    document.search_form.Sword.focus();
    return false;
  }
  return true;
}

// ----- 観光情報検索時の全選択・解除 -----
function select_all(obj) {
  if ( obj ) {
    if ( obj.length ) {
      for ( i=0; i<obj.length; i++ ) {
        obj[i].checked = true;
      }
    }
    else {
      obj.checked = true;
    }
  }
}

function unselect_all(obj) {
  if ( obj ) {
    if ( obj.length ) {
      for ( i=0; i<obj.length; i++ ) {
        obj[i].checked = false;
      }
    }
    else {
      obj.checked = false;
    }
  }
}

// ----- 祭・イベントカレンダーの表示 -----
function view_calendar(ym) {
  new Ajax.Updater(
    'event_calendar' ,
    '/toyohashi/search/event_calendar.cgi' ,
    { method     : 'post' ,
      parameters : 'ym=' + ym,
      onFailure  : function() {
        $( 'event_calendar' ).innerHTML = '<div class="error_msg_title">通信エラーが発生しました。</div>';
      }
    }
  );
}

// ----- 祭・イベントPICKUPの表示 -----
function view_pickup() {
  new Ajax.Updater(
    'event_pickup' ,
    '/toyohashi/search/event_pickup.cgi' ,
    { method     : 'post' ,
      parameters : '',
      onFailure  : function() {
        $( 'event_pickup' ).innerHTML = '<div class="error_msg_title">通信エラーが発生しました。</div>';
      }
    }
  );
}

// ----- 足跡の表示 -----
function view_footprint(ct,acode) {
  new Ajax.Updater(
    'foot_print' ,
    '/toyohashi/search/get_footprint.cgi' ,
    { method     : 'post' ,
      parameters : 'ct=' + ct + '&acode=' + acode ,
      onFailure  : function() {
        $( 'foot_print' ).innerHTML = '<div class="error_msg_title">通信エラーが発生しました。</div>';
      }
    }
  );
}

// ----- アクセスログ記録 -----
function access () {
  var now = new Date();
  document.write("<img src='/toyohashi/search/access_log.cgi?url=" + document.URL + "&t=" + now.getTime() + "' width='1' height='1' border='0' />");
}





// ----- オブジェクトの取得 -----
function get_object(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  }
  else if (document.all) {
    return document.all(id);
  }
  return null;
}

// ----- クッキーの読み込み -----
function getCookie(key){
  tmp = document.cookie+";";
  tmp1 = tmp.indexOf(key, 0);
  if( tmp1 != -1 ){
    tmp = tmp.substring( tmp1, tmp.length );
    start = tmp.indexOf("=", 0 ) + 1;
    end = tmp.indexOf( ";", start );
    return( unescape( tmp.substring( start, end )));
  }
  return("");
}


// ----- 別ウィンドウの表示 -----
function openwin(url,width,height,target) {
  if (url != '') {
//    var tg = ( target == '' ) ? '_blank' : target;
    var x = parseInt( window.screen.width/2-width/2 );
    var y = parseInt( window.screen.height/2-height/2 );
    window.open(url,target,"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+x+",top="+y+",screenX="+x+",screenY="+y);
  }
}

// ----- エリアの表示・非表示(display) -----
function view_display(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.display='block';
    }
  }
}

function hidden_display(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.display='none';
    }
  }
}

// ----- 指定エリアの表示・非表示(display) -----
function change_display(id) {
  obj = get_object(id);
  if ( obj ) {
    if ( obj.style.display == 'none' || obj.style.display == '' ) {
      obj.style.display = 'block';
    }
    else {
      obj.style.display = 'none';
    }
  }
}

// ----- エリアの表示・非表示(visibility) -----
function view_visibility(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.visibility='visible';
    }
  }
}

function hidden_visibility(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.visibility='hidden';
    }
  }
}

// ----- 指定エリアの表示・非表示(visibility) -----
function change_visibility(id) {
  obj = get_object(id);
  if ( obj ) {
    if ( obj.style.visibility == 'hidden' || obj.style.visibility == '' ) {
      obj.style.visibility = 'visible';
    }
    else {
      obj.style.visibility = 'hidden';
    }
  }
}
// ---------- End of File ----------

