// windowサイズを取得して
//縦の高さ 横の幅を設定する関数
//参考ページ http://www.sasaraan.net/program/js/jswndstate.html
//参考ページ http://nanto.asablo.jp/blog/2005/10/29/123294

var Width, Height;                   // 画面サイズ
var ua = navigator.userAgent;       // ユーザーエージェント
var nHit = ua.indexOf("MSIE");     // 合致した部分の先頭文字の添え字
var bIE = (nHit >=  0);                 // IE かどうか
var work_status; //営業日か否か
var finish_working_limit //現在から営業終了となるまでの秒数
var sec = 0; //秒数
var main_area_id = 'main_area'; //メインエリアid
var menu_area_id = 'menu_zone'; //メニューエリアid
var main_area_min_width = 600; //メインエリアの幅
var menu_area_width = 300; //メニューエリアの幅

function change_footer_layout() {
     var nWidth, nHeight,menu_style,main_area_width,border_width,main_style,main_inner_style,main_height,main_inner_height,main_width;// サイズ
     var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");  // バージョンが 6 かどうか
     var bStd = (document.compatMode && document.compatMode=="CSS1Compat");
                                                                           // 標準モードかどうか

     if (bIE) {
          if (bVer6 && bStd) {
               nWidth = document.documentElement.clientWidth;
               nHeight = document.documentElement.clientHeight;
          } else {
               nWidth = document.body.clientWidth;
               nHeight = document.body.clientHeight;
          }
     } else {
          nWidth = window.innerWidth;
          nHeight = window.innerHeight;
     }

     //Height値がない(最初)またはHeight値はあるがnHeightと値が異なる場合
     //または Width値がない(最初)またはWidth値はあるがnWidthと値が異なる場合
     if (!Height || nHeight != Height || !Width || nWidth != Width){

          Height = nHeight;
          Width = nWidth;
		  border_width = Width - main_area_min_width;
			menu_style = $(menu_area_id).style;
			main_style = $(main_area_id).style;

		  //横幅がメインアリア＋メニューエリアより大きければ メニューエリアを表示してメインエリアにmarginを設定
		  if(border_width >= menu_area_width){
		    main_area_width = Width - menu_area_width;
			menu_style.display = 'block';
			main_style.right = menu_area_width + 'px';
			main_style.width = main_area_width + 'px';
			$('view_menu').style.display = 'none';
			$('tel_announce').style.display = 'block';
		  }else{
			menu_style.display = 'none';
			main_style.right = '0';
			main_style.width = Width + 'px';
			$('view_menu').style.display = 'block';
			$('tel_announce').style.display = 'none';
		  }

     }
     


}



//営業時間か否かで 問い合わせの表示を変更する関数
function view_toiawase(){
	Width = document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth;
	Height = document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight;

     //営業中である場合
     if(work_status){
    	//秒数をカウント
        sec++;
        //秒数が営業リミットをオーバーしてれば work_statusを0に
        if(sec > finish_working_limit){work_status = 0;}
        //表示変更関数
        change_hidden_class('tel_announce',1);
     }else{
		change_hidden_class('tel_announce',0);
	 }
}

