﻿//                                                        //
//          moving-s.com Javascript関数定義               //
//                        [共通]                          //
//                                                        //
//     Copyright 2008 e-pokke Inc. All rights reserved.   //
//                                                        //


// ----- 送信・変更時の確認 -----

var send_flag = 0;

function check_submit() {
  if ( send_flag == 1 ) {
    alert('ただいま送信中です。\n「OK」ボタンをクリックしてお待ちください。');
    return false;
  }

  send_flag = 1;

  return true;
}


// ----- オブジェクトの取得 -----
function get_object(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  }
  else if (document.all) {
    return document.all(id);
  }
  return null;
}

// ----- 背景色の変更 -----
function change_bgcolor(obj,bgcolor){
  if(obj) {
    if (obj.style) obj.style.backgroundColor = bgcolor;
  }
}

// ----- クッキーの読み込み -----
function get_cookie(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=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+x+",top="+y+",screenX="+x+",screenY="+y);
  }
}

// ----- 指定エリアの表示・非表示(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';
    }
  }
}

// ----- エリアの表示・非表示(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';
    }
  }
}

// ----- エリアの表示・非表示(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';
    }
  }
}

// ----- ミニカレンダーの表示 -----
function view_mini_calendar(ym) {
  new Ajax.Updater(
    'cal-mini' ,
    '/mitumori/mini_calendar.cgi' ,
    { method     : 'post' ,
      parameters : 'Mode=view&ym=' + ym ,
      onFailure  : function() {
        $( 'cal-mini' ).innerHTML = '通信エラーが発生しました。';
      }
    }
  );
}

// ----- ボタン画像のロールオーバー -----
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// 2010/5/10 Y.Miyawaki START

// twitterでつぶやくためにタイトルを短くする
function GetTitleToTwitt() {
  url = window.location;

  window_title = document.title;

  window_title = window_title.replace(/:引越しのムービングエス！/, '');
  window_title = window_title.replace(/:営業ブログ/, '');

}

// パラメータを設定してtwitterのページを開く
function TwittAboutThis(){
  GetTitleToTwitt();
  var twitturl ='http://twitter.com/home?status='+encodeURIComponent(window_title + ' ' + url);
  window.open(twitturl,'_blank');
}

// 2010/5/10 Y.Miyawaki END

// ---------- End of File ----------

