/* ================================================================================
* Title: Jquery Function
*
* Copyright (c) 2009 Astra The Studio Inc.
* http://www.studio.co.jp/
* Date: Feb.13, 2009
* @author: Chihiro Mori
* @version: 1.0.3
*
* jQuery 1.5.2
*
* 確認済ブラウザ: [Mac] FireFox3.0, Safari3.1.2 [Win] IE6.0, 7.0
* Macで作業するときの注意：バックスラッシュ\を入力するときはoptionを押しながらエンマーク
================================================================================ */
/* 目次
selfLink():
対象：ページ内の全てのHEEF属性を持ったAタグ（#のみ、hoge.html#hoge、は除外）
・自ページリンクにcurrentクラスを付与し、href属性を削除
・ページ内リンクのスムーススクロール
※スラッシュ（/）とファイル名を省略したアクセスの場合は、/index.htmlを補完して評価

menuRollover():
対象： ul#cNav img, div#detailMenuList img 
透明効果を使ったIMGタグのマウスオーバー
※imgの親のAタグがcurrentだったら完全透明となり、背景が透過。

pulldown():
イベントの設定：ul#cNav li.pulldown, li#detailMenuListSub
イベントの対象：上記に含まれるDIVタグ

headerScroll():
positionにfixを指定した要素も、横スクロールに対応できるようにする。
IDに#headerWrapを指定した、DIV等のブロック要素のみ評価。

*/

(function($)
{


				//$=jQuery.noConflict()
	$(function()
	{
					$.ASconf.exetend();
					//$.ASconf.applicationAdd();
					$.ASconf.selfLink();
					$.ASconf.lastChild();// add by kamiya
					$.ASconf.menuRollover();
					$.ASconf.btnRollover();
					$.ASconf.menuRollover2();
					$.ASconf.pulldown();
					$.ASconf.roomListZebra();
					//$.ASconf.headerScroll();
					//$.ASconf.searchMenu();
					$.ASconf.accordion();
					$.ASconf.parseJSON();
					$.ASconf.eventSearch();
					$.ASconf.swapImages();
					//$.ASconf.swapImages2();
					//$.ASconf.searchPopUp();
					$.ASconf.selfScroll();//タイミングが早いFireFoxでだめ。ヘッダー分ずれる。ってかwindow.loadでないとダメかも…
					
					$.ASconf.minifix();//微調整用
					
					$.ASconf.initLightBox();
					$.ASconf.calendar();
					//$.ASconf.creatEvcalUrl();
					$.ASconf.initJqueryPopupWindow();
					$.ASconf.fontChangeByOS();
					$.ASconf.fixManualLayout();
					$.ASconf.fixPriceLayout();
					//$.ASconf.initTopModalWindow();
					$.ASconf.homeFix();
					$.ASconf.initEasySlider();

	});
	$.ASconf =
	{
	//---------------------------------------------------------------------
		exetend:function(){
			$.fn.extend({
				 //.log()をつけてチェーン途中でもログ出力
				 log: function() {
					  console.log($(this));
					  return this;
				 },
				 //画像の本来の大きさ取得
				 getImgSize:function(){
					  var image = $(this).get()[0];                        
					  var run, mem, w, h, key = "actual";
					  if('naturalWidth' in image){//for Firefox Webkit
								return {height:image.naturalHeight, width:image.naturalWidth}
					  }
					  if('src' in image){//for IE
						   if (image[key] && image[key].src === image.src) {return  image[key];}
								if (document.uniqueID) { // for IE
									 run = image.runtimeStyle;//runtimeStyleを保存
									 mem = {w:run.width,h:run.height};//幅と高さを保存
									 run.width = "auto";//runtimeStyleを一旦autoに上書き→runtimeStyleは!importantよりも最優先される
									 run.height = "auto";
									 w = image.width;//改めてwidthとかを取る
									 h = image.height;
									 run.width = mem.w;//元に戻してあげる
									 run.height = mem.h;
								} else {// for Opera and Other
									 mem = {w: image.width, h: image.height}; //幅と高さを保存
									 $(this)
										  .removeAttr("width")
										  .removeAttr("height")
										  .css({width:"",  height:""});//attrとかcss上の幅と高さを削除
									 w = image.width;//改めてwidthとかを取る
									 h = image.height;
									 image.width  = mem.w;//かわいそうなので、元に戻してあげる
									 image.height = mem.h;
								}
								return image[key] = {width: w, height: h, src: image.src};//imageにwidthとheightを入れる。
					  }
					  return {height:image.height,width:image.width}//幅と高さを返す
							   
				 },
				 //ブラウザーごとに分岐
				 browserIf:function(obj){
					  //http://w3g.jp/blog/tools/jquery_browser_sniffingを参照
					  if(!$.support.checkOn && $.support.checkClone){
						   var _browser = "webkit";
					  }else if($.support.checkOn && $.support.htmlSerialize && window.globalStorage){
						   var _browser = "firefox";
					  }else if($.support.checkOn && $.support.htmlSerialize && !window.globalStorage){
						   var _browser = "opera";
					  }else if(!$.support.noCloneEvent && $.support.opacity){
						   var _browser = "ie9";
					  }else if(!$.support.opacity){
						   if(!$.support.style){
								if (typeof document.documentElement.style.maxHeight != "undefined") {
								  var _browser = "ie7";
								} else {
								  var _browser = "ie6";
								}
						   }else{
							 var _browser = "ie8";
						   }
					  }else{
						   var _browser = "unknown";
					  }
					  //ブラウザの種類を元に関数を実行
					  if(obj !== undefined){//objが無いときは実行しない
						   if($.isFunction(eval('obj.'+_browser))){//該当のブラウザ用の関数が設定されてないときは実行しない
								obj[_browser](this);//引数にthis
						   }
						   if($.isFunction(obj.elseBrowser)){//elseBrowserが設定されてないときは実行しない。
								obj.elseBrowser(this);//引数にthis
						   }
					  }
					  return this;
				 },
				 //ブラウザーごとのクラスを付与
				 addBrowserClass:function(){
					  //http://w3g.jp/blog/tools/jquery_browser_sniffingを参照
					  if(!$.support.checkOn && $.support.checkClone){
						  var _browser = "webkit";
					  }else if($.support.checkOn && $.support.noCloneEvent && window.globalStorage){
						 var _browser = "firefox";
					  }else if($.support.checkOn && $.support.noCloneEvent && !window.globalStorage){
						  var _browser = "opera";
					  }else if(!$.support.noCloneEvent && $.support.opacity){
						  var _browser = "ie9";
					  }else if(!$.support.opacity){
						   if(!$.support.style){
								if (typeof document.documentElement.style.maxHeight != "undefined") {
								  var _browser = "ie7";
								} else {
								  var _browser = "ie6";
								}
						   }else{
							  var _browser = "ie8";
						   }
					  }else{
						   var _browser = "unknown";
					  }
					  $(this).addClass(_browser)
					  return this;
				 }
			});
		}
		,
		//-----------------------------------------------------------------
		selfLink: function ()
		{
			var selfLinkClass = 'current';
			$.ASconf.theUrl = location.href.replace(location.hash, '').replace(/(\/|\#)$/, '/index.html');
			
			$('a[href]').each(function()
			{
				var i = document.createElement('span');
				i.innerHTML = '<a href="' + $(this).attr('href') + '" />';
				var absolutePath = i.firstChild.href;
				if(absolutePath == $.ASconf.theUrl){
					$(this).addClass(selfLinkClass).removeAttr('href');
				}
			});
		}
		,
		//-----------------------------------------------------------------
		selfScroll: function()
		{//^は初めの文字が#だった場合。*にするとhoge.html#hogeもマッチだけど、ページ内とページ外の判定無し
			//headerfixはヘッダーが固定の場合のヘッダーの高さ
			var headerfix = 0;
			var locationHash = location.hash;
			$('a[href*=#]').click(function()
			{

				var hash = this.hash;

			var thisURL = location.href;
			var locationHref = thisURL.replace(hash, '');
				if(!hash || hash == "#")
					return false;
					
				if(this.href.replace(hash, '') == $.ASconf.theUrl || hash == '#pagetop')
				{	
					$($.browser.safari ? 'body' : 'html')
					.animate({scrollTop: $(hash).offset().top - headerfix}, 500);
					return false;
				}
			});
			
			if(locationHash)
			{//別ページへ移動するときもスムースに！
				var isMSIE = /*@cc_on!@*/0;
				 if(isMSIE) {
				 //IEの場合はちょっと待ってからスクロール
				 setTimeout(function(){scrollTo(0,0);$('html').animate({scrollTop: $(locationHash).offset().top - headerfix}, 500);},50);
				 } else {
					scrollTo(0, 0);
					$($.browser.safari ? 'body' : 'html')
					.animate({scrollTop: $(locationHash).offset().top - headerfix}, 500);
				 }
			}
		}
		,
		
		//-----------------------------------------------------------------
		searchPopUp: function()
		{
			$('body.searchList #tab li.col3, body.comparison #tab li.col3').hover(
				function(){
					$(this)
					.find("div.popUp").show().end()
					.css("cursor","pointer");
				},
				function(){
					$(this).find("div.popUp").hide()
					.end().css("cursor","auto");
				}
			);
		}
		,
		//-------------------------------------------------------------------
		menuRollover: function()
		{
			var parentClass = 'current';
			
			$('#headerContact2 a img, ul#cNav a img, div#headerWrap ul.cNavSub a img, div#detailMenuList a img').each(function()
			{
				var $this = $(this);
				if($this.parent().attr('class') != parentClass)
				{
					$this.hover(function(){
					$this.stop().fadeTo('fast', 0.6);}
					,function(){
					$this.fadeTo('fast', 1);});
				}else {
					if($this.attr('src').lastIndexOf('_on.gif')==-1)
					$(this).stop().fadeTo(0, 0.6);
				}
			});
		}
		,
		//-------------------------------------------------------------------
		menuRollover2: function()
		{//サイトトップの「イベントサポート」と「メルマガ会員募集」
			var parentClass = 'current';
			
			$('#subNav li a img').each(function()
			{
				if($(this).parent().attr('class') != parentClass)
				{
					$(this).hover(function(){
					$(this).stop().fadeTo('fast', 0);}
					,function(){
					$(this).fadeTo('fast', 1);});
				}else {
					$(this).stop().fadeTo(0, 0);
				}
			});
		}
		,
		//-----------------------------------------------------------------
		pulldown: function()
		{
			$('li#detailMenuListSub').each(function()
			{
				//一旦非表示にする
				$(this).find('div').hide().end().hover(function(){
					$(this).find('a#pullBtn').stop(true, true).fadeTo('fast', 0);
					$(this).find('div').stop(true, true).slideDown('fast');
				},function() {
					$(this).find('a#pullBtn').stop(true, true).fadeTo('fast', 1);
					$(this).find('div').stop(true, true).slideUp('fast');
				});
				
				//各施設一覧ヘッダーのリンクをクリックしたら隠す
//				var target = $(this).find('div');
//				$(this).find('td a').click(function(){
//					$(target).stop(true, true).slideUp('fast');});
//					
			});
		}
		,
		//-----------------------------------------------------------------
		roomListZebra: function()
		{
			$('ul.roomList').each(function()
			{
				$(this).find('li.roomWrap').each(function(n)
				{
					if(n % 2 == 0)
					{
						$(this).css('width','309px');
					}
				});
			});
		}
		,
		//-----------------------------------------------------------------
		btnRollover: function()
		{
			var parentClass = 'current';
			//$('img.btn,div#main img.btn,div#main table.btns img, div#main div.imgsWrap p.layout, div#index table dt img, #result th.photo img,div#main a[href][href!=#] > img').each(function()
			$('img.btn, div#main table.btns img, div#main div.imgsWrap p.layout, div#index table dt img, #result th.photo img, ul#aNav li a img, #section dt a img').each(function()
			{
				if($(this).parent().attr('class') == parentClass){
					$(this).fadeTo(0, 0.3);
				} else{
					$(this).hover(function(){
						$(this).stop().fadeTo('fast', 0.5);
					}
					,function(){
						$(this).stop().fadeTo('fast', 1);
					});
				}
			});
		}
		,
		//-----------------------------------------------------------------
//		headerScroll: function()
//		{
///*			var target = $('div#headerWrap');
//			
//			function winScroll(e)
//			{
//				var scrollLeft = $(document).scrollLeft();
//				target.stop().css('left', -scrollLeft);
//			}
//			winScroll();
//			$(window).bind('scroll', winScroll);
//			$(window).bind('resize', winScroll);*/
//		}
//		,
		//-----------------------------------------------------------------
//		searchMenu: function()
//		{
//			$('body:not(.accessMap) div#searchMenu').each(function()
//			{
//				var target = $(this);
//				var offsetTop = target.offset().top;
//				var defaultOffset = offsetTop;
//				var targetHeight = target.attr('offsetHeight');
//				var footerOffset = $('div#footerWrap').offset().top;
//				var maxScroll = footerOffset - (targetHeight + defaultOffset);				
//				
//				function menuScroll(e)
//				{
//					var scrollTop = $(document).scrollTop();
//					if(scrollTop - defaultOffset < maxScroll)
//					{
//						if(offsetTop < scrollTop)
//						{
//							var offset = (scrollTop - defaultOffset);
//							$(target).stop().animate({top:offset+'px'},{ duration:350, queue: false });
//						}
//						else
//							$(target).stop().animate({top:0},{ duration:350, queue: false });
//					}
//					else
//						$(target).stop().animate({top:maxScroll},{ duration:350, queue: false });
//				}
//				$(window).bind('scroll', menuScroll);
//				$(window).bind('resize', menuScroll);
//				menuScroll();
//				
//				//ソート条件を変更したらページ上部へ戻る
//				function formChange(e)
//				{
//					$($.browser.safari ? 'body' : 'html')
//					.animate({scrollTop: 0}, 300, 'easeInExpo');
//					if($(this).is('a'))
//						return false;
//				}
//				$(this).find('label:not(.select), div#tab a, div#sort a').bind('click', formChange);
//				$(this).find('select').bind('change', formChange);
//				
//				//個別ページのプルダウン
//				//pulldown() へ移動↑
//				
//			});
//		}
//		,
		//-------------------------------------------------------------------
		accordion: function()
		{
			$('div#detail div.option h3').each(function()
			{
				var textNode = $(this).next('div').show();
				$(this).click(function (){
					if ($(textNode).is(':hidden'))
						$(textNode).slideDown();
					else
						$(textNode).slideUp('fast');
				});
			}).hover(function(){$(this).stop().fadeTo('fast', 0.7);},
			function(){$(this).stop().fadeTo('fast', 1);});
		}
		,
		//-------------------------------------------------------------------
		lastChild: function()
		{
			$('body.manual #listIndex tr:last-child > td:last-child').each(function(){
				if($(this).children().length === 0){
					$(this).addClass("lastTd");
				}
			})
		}
		,
		//-------------------------------------------------------------------
		parseJSON: function()
		{
			//if(fas) 201201 mori 修正 変数が無いページのエラー回避
			if(window['fas'] != null)
			{
				var cnt = 0;
				for(i in fas)
				{
					cnt ++;
					
					$('#mapImg div').append('<p><img src="shr/img/visitor/img_area' + cnt + '.jpg" /></p>');
					$('#areaFas').append('<div><h5><img src="shr/img/visitor/ttl_area' + cnt + '.gif" /></h5><ul></ul></div>');
					
					var imgArea = $('#areaMap #mapImg div p');
					$(imgArea).stop().fadeTo(0, 0);
					
					var listArea = $('#areaMap #areaFas div');
					$(listArea).stop().fadeTo(0, 0);
					
					var num = fas[i].length;
					for(j = 0; j < num; j++)
					{
						$('#areaMap #areaFas div').eq(cnt-1).find('ul').append('<li><a href="' + links[i][j] + '">' + fas[i][j] + '</a></li>');
					}
				}
				$('#mapBaseImg area').each(function(n){
					$(this).click(function()
					{
						$(imgArea).each(function(i){
							if(n != i){
								$(this).stop().fadeTo('fast', 0);
							}else {
								$(this).stop().fadeTo('fast', 1);
							};
						});
						$(listArea).each(function(i){
							if(n != i){
								$(this).stop().fadeTo('fast', 0);
								$(this).css('z-index','1');
							}else {
								$(this).stop().fadeTo('fast', 1, function(){
									$('#areaMap #areaFas').css('background', 'none');
								});
								$(this).css('z-index','2');
							};
						});
						$('#baseImg').stop().fadeTo('fast', 0);
					});
				});
			}else {
				//
			}
		}
		,
		//-------------------------------------------------------------------
		eventSearch: function()
		{
			var catBox = $('body.event.top div#section div.catlistbox');
			var resultBox = $('body.event.top div#section div.fa_purpose');
			
			$(catBox).each(function(n)
			{
				$(this).hide();
				if(n == 0){
					$(this).show();
				}
			});
			var btns = $('body.event.top #categoryBtn').find('li');
			btns.each(function(n)
			{
				$(this).css('cursor', 'pointer');
				$(this).click(function()
				{
					btns.each(function()
					{//カレント判定
						$(this).fadeTo(0, 1).removeClass('on');
					});
					$(this).fadeTo(0, 0).addClass('on');
					$(catBox).each(function(m)
					{
						$(this).hide();
						if(n == m){
							$(this).show();
						}
					});
					$(resultBox).each(function(m)
					{
						$(this).show();
					});
				});
				$(this).find('img').hover(function(){
					$(this).stop().fadeTo('fast', 0.3);
				}
				,function(){
					if(!($(this).hasClass('on')))
					{
					$(this).stop().fadeTo('fast', 1);
					}
				});
			});
			$('body.event.top #exselect li.btn').each(function(n)
			{
				$(this).css('cursor', 'pointer');
				$(this).click(function()
				{
					$(resultBox).each(function(m)
					{
						$(this).hide();
					});
					var rNum = $(this).attr('id').split('result');
					$('div#fa_purpose' + rNum[1]).show();
				});
				$(this).hover(function(){
					$(this).stop().fadeTo('fast', 0.5);
				}
				,function(){
					$(this).stop().fadeTo('fast', 1);
				});
			});
		}
		,
		//-------------------------------------------------------------------
		swapImages: function()
		{
			//$('#result div.photos').each(function()
			$('div.photos').each(function()
			{
				var target = $(this).find('p.big img');
				var originalSrc = target.attr('src');

				$(this).find('p.small img').hover(function()
				{
					var rolloverSrc = $(this).attr('src').replace('_s.jpg', '.jpg');
					$(this).stop().css('cursor','pointer').fadeTo('fast', 0.5);
					$(target).attr('src', rolloverSrc);
				}
				,function(){
					$(this).stop().fadeTo('fast', 1);})
				.each(function(){//プリロード
        	$("<img>").attr('src', $(this).attr('src').replace('_s.jpg', '.jpg'))});
			});
		}
		,
		//-------------------------------------------------------------------
		initEasySlider: function()
		{
			var dom = $("#pickupList");
			if(dom.get(0))
			{
				dom.easySlider(
				{
					auto: true,
					pause: 3000,
					continuous: true 
				});
			}
		}
		,
		//-------------------------------------------------------------------
//		swapImages2: function()
//		{
//			$('div#detail div.photos, div.result_box div.photos').each(function()
//			{
//				var target = $(this).find('p.big img');
//				var originalSrc = target.attr('src');
//				
////				$(this).mouseout(function(event)
////				{
////					//$(target).stop().fadeTo(0, 0.5, function(){$(target).fadeTo('fast', 1);}).attr('src', originalSrc);
////					$(target).attr('src', originalSrc);
////				});
////console.log('call');
//				$(this).find('p.small img').hover(function()
//				{
//					var rolloverSrc = $(this).attr('src').replace('_s.jpg', '.jpg');
//					$(this).stop().css('cursor','pointer').fadeTo('fast', 0.5);
//					$(target).attr('src', rolloverSrc);
//				}
//				,function(){
//					$(this).stop().fadeTo('fast', 1);})
//				.each(function(){//プリロード
//        	$("<img>").attr('src', $(this).attr('src').replace('_s.jpg', '.jpg'))});
//			});
//		}
//		,
		//-------------------------------------------------------------------
		minifix: function()
		{
			$('ul#cNav li.pulldown a[href*=#]').click(function(){return false;}).css("cursor","default").find('img').unbind();
			//closeMenu('fa25',[2,3]);
			closeMenu('fa26',[2,3,6]);
			//closeMenu('fa28',[3]);
			//closeMenu('fa27',[3]);
			manualPDF('fa26');
			manualPDF('fa25');
			manualPDF('fa28');
			//manualPDF('fa24');
			
			
			function closeMenu(fa,tmenu){
				try{
				if($('body').hasClass(fa)){
					var menulist = ['never','price/index.html','utilities.html','equip.html','access.html','manual.html','download.html','application.html']
					var dml = $('body.'+ fa + ' #detailMenuList> ul > li');
					for(i = 0;i <= closeMenu.length;i++){
						var selector = 'a[href*="'+ menulist[tmenu[i]] +'"]';
						dml.find(selector).removeAttr('href').css({pointer:'default',display:'inline-block',background:'#FFFFFF'}).find('img').fadeTo(0,0.7).unbind();
					}
				} else {
					return false;
				}
				}catch(e){	
					console.log(e);
				}
			}
			
			function manualPDF(fa){
				try{
				if($('body').hasClass(fa)){
					var faNum = fa.replace(/fa/,"")
				$('body.'+ fa +' #detailMenuList > ul > li a[href$="manual.html"]').attr({href:'/pdf/'+ faNum +'_manual.pdf',target:'_blank'})
				} else {
					return false;
				}
				}catch(e){
					console.log(e);
				}
			}
			
			$('body').addBrowserClass();//ブラウザごとのクラスを追加
		/*	var content = $('<span class="red">2011年6月13日（月）申込分より会場使用料金が新しくなりました。</span><br /><br />')
			$('body.page.searchDetails')
				.not('.fa25, .fa26, .fa16, .fa27')
					.find('div#detail > div.section > div.option > div.optionText > p')
						.prepend(content)
			$('body.page.searchDetails.fa16')
				.find('div#detail > div.section > h2:not(#a16_03)')
					.parent()
						.find('div.option > div.optionText > p')
							.prepend(content)*/
			
			
			/*
			$('body.page.searchDetails')
				.each(function(){
					if($(this).hasClass('fa16')){
						console.log('not hallB')
						var $target = $(this)
							.find('div#detail > div.section > div.option > div.optionText > p')
							.not(':eq(2)')
					}else 	if(!$(this).hasClass('.fa25')||!$(this).hasClass('.fa26')){
						console.log('not fa25 fa26')
						var $target = $(this)
							.find('div#detail > div.section > div.option > div.optionText > p')
					}
					
					$target
						.prepend('<span class="red">2011年6月13日（月）申込分より会場使用料金が新しくなります。</span><br /><br />')
				
				})*/
			
/*			var now = new Date();
			var tgt = new Date(2011,0,5,9);
			if(now <= tgt){
			$('#header').append('<div style="position:absolute;width:147px;height:49px;top:42px;left:490px"><a href="http://www.bellesalle.co.jp/backnumber/top/2010/12_883.html"><img src="http://www.bellesalle.co.jp/shr/img/header_banner.gif" alt="年末年始の営業時間のご案内" width="147" height="49" class="bnr" /></a></div>').find('img.bnr').hover(function(){$(this).stop().fadeTo('fast', 0.7);},function(){$(this).stop().fadeTo('fast', 1);});
			}*/
			
/*			if($('body').hasClass('fa27') && $('body').hasClass('searchDetails')){
				$('#detail > div.section > div.imgsWrap a[href$=pdf]')
					.click(function(){return false;})
				
			}*/
			
			
			
		},
		initLightBox:function()
		{
			$(function($){
					
				if($("body").hasClass("cases")){   
					$('#photoContents a.lb').lightBox({
						imageLoading: '/shr/img/lb/lightbox-ico-loading.gif',
						imageBtnClose: '/shr/img/lb/lightbox-btn-close.gif',
						imageBtnPrev: '/shr/img/lb/lightbox-btn-prev.gif',
						imageBtnNext: '/shr/img/lb/lightbox-btn-next.gif',
						txtImage:'',
						txtOf:'of'
					});
				}
			});
		},
		calendar:function()
		{
			if($('body').hasClass('evcal')){
					$('ul#eventList > li').each(function(){
						var cnt = $(this)
						var headerCnt = $(this).find('div.eventHeader');
						var bodyCnt = $(this).find('div.eventBodyWrap');
						var speed = 500;
						bodyCnt.hide();
						headerCnt.click(function(){
							if(cnt.hasClass('open')){
									headerCnt.find('div.opclIcon').removeClass('open');	
									bodyCnt.slideUp(speed);
									cnt.removeClass('open');
							} else {
									headerCnt.find('.opclIcon').addClass('open');	
									bodyCnt.slideDown(speed);
									cnt.addClass('open');
							}
						});
					});
					$('div#calendar div.calCnt table td').each(function(){
						if($(this).html() == "" || $(this).html() == "&nbsp;"){
							$(this).addClass('empty');
						}
					});
					$('div#placeSearch > ul > li[class!=noselect] > a[href=#]').each(function(){
							$(this).addClass('nolink').removeAttr('href');
					});
						
						//imgBoxの高さを画像にあわせる？
						$('ul#eventList > li div.eventBody > div.imgBox').each(function(){
							
							var imgBox = $(this);
							var img = $(this).find('img');
							$('<img>').attr('src',img.attr('src')).load(function(){
								var size = realImgSize($(this).get(0));
								imgBox.height(size.height);
							});
							/* LICENSE: MIT
							 * AUTHOR: uupaa.js@gmail.com
							 */
							function realImgSize(image) {
							  var run, mem, w, h, key = "actual";
							
							  // for Firefox, Safari, Google Chrome
							  if ("naturalWidth" in image) {
								return { width:  image.naturalWidth,
										 height: image.naturalHeight };
							  }
							
							  if ("src" in image) { // HTMLImageElement
								if (image[key] && image[key].src === image.src) {
								  return image[key];
								}
								if (document.uniqueID) { // for IE
								 /* run = image.runtimeStyle;
								  mem = { w: run.width, h: run.height }; // keep runtimeStyle
								  run.width  = "auto"; // override
								  run.height = "auto";
								  w = image.width;
								  h = image.height;
								  run.width  = mem.w; // restore
								  run.height = mem.h;*/
								} else { // for Opera and Other
							/*
								  function fn() {
									w = image.width;
									h = image.height;
								  }
								  mem = { w: image.width, h: image.height }; // keep current style
								  image.removeAttribute("width");
								  image.addEventListener("DOMAttrModified", fn, false);
								  image.removeAttribute("height");
								  // call fn
								  image.removeEventListener("DOMAttrModified", fn, false);
								  image.width  = mem.w; // restore
								  image.height = mem.h;
							 */
								  mem = { w: image.width, h: image.height }; // keep current style
								  image.removeAttribute("width");
								  image.removeAttribute("height");
								  w = image.width;
								  h = image.height;
								  image.width  = mem.w; // restore
								  image.height = mem.h;
								}
								return image[key] = { width: w, height: h, src: image.src }; // bond
							  }
							  // HTMLCanvasElement
							  return { width: image.width, height: image.height };
							}
					
					
					function browserCheckFnc(){
							 if(!$$.support.checkOn && $$.support.checkClone){
								  return "WEBKIT";
							 }else if($$.support.checkOn && $$.support.htmlSerialize && window.globalStorage){
								  return "FIREFOX";
							 }else if($$.support.checkOn && $$.support.htmlSerialize && !window.globalStorage){
								  return "OPERA";
							 }else if(!$$.support.htmlSerialize && $$.support.scriptEval){
								  return "IE9";
							 }else if(!$$.support.opacity){
								 if(!$$.support.style){
									 if (typeof document.documentElement.style.maxHeight != "undefined") {
										  return "IE7";
									 } else {
										  return "IE6";
									 }
								 }else{
										  return "IE8";
								 }
							 }else{
								  return "UNKNOWN";
							 }
						}
						
					
					});
				}
		},
		creatEvcalUrl:function()
		{
			var now = new Date();
			var year = now.getFullYear();
			var month = now.getMonth() + 1;
			var month = (month < 10)?"0" + month:month;
			var day = now.getDate();
			var day = (day < 10)?"0" + day:day;
			var url = {
				protocol:document.location.protocol + "//",
				domain:document.location.hostname,
				evCalPath:"/event/index.php?",
				fa:"f=&",
				y:"y=" + year + "&",
				m:"m=" + month + "&",
				d:"d=" + day + "&",
				c:"c="
			}
			var urlArr = [
						  url.protocol,
						  url.domain,
						  url.evCalPath,
						  url.fa,
						  url.y,
						  url.m,
						  url.d,
						  url.c
						  ];
			var urlStr = urlArr.join("");
			$('#main a#evCalLink').attr('href',urlStr);
		},
		initJqueryPopupWindow:function()
		{
			$(function()
			{
				if($('body').hasClass('owakare')){
  					$("div.page1 a.popupwindow").popupwindow();
				}
			});
		},
		applicationAdd:function(){
			if($('body').hasClass('application')){
				var imgPath = '/shr/img/icon_pdfdl.gif';
				var cnt = $('<tr><th>緊急対応用<br />変更・解約 申出書</th><td class="centerBox">お申込内容の変更・解約の際にご利用下さい<span style="font-weight:700">（緊急対応用）</span></td><td><a href="/pdf/cancel2.pdf" target="_blank"><img src="' + imgPath +'" width="110" height="36" alt="PDFファイル" /></a></td></tr>');
				$('table.ttlBox + table').append(cnt);
			}
		},
		fontChangeByOS:function(){
			//console.log(navigator.userAgent,navigator.userAgent.match(/[Mm]ac/))
			if(navigator.userAgent.match(/[Mm]ac/)){
				$('body')
					.addClass('mac')
					//.attr('style',"font:11px/1 'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'ＭＳ Ｐゴシック',sans-serif;letter-spacing:-1px;");
			}
		},
		fixManualLayout:function(){
			if($('body').hasClass('manual')){
				$('ol#manualList')
					.find('li > ol.lowerList1 > li:has(ol:first-child.lowerList2) > ol')
						.browserIf({
							ie6:function(obj){
								$(obj)
									.each(function(){
										$(this)
											.parent()
												.css({
													 position:'relative',
													 left:-15
													 })
											.end()
											.css('margin-top','-1.1em')
											.css('padding-left','45px')
									})
							},
							ie7:function(obj){
								$(obj)
									.each(function(){
										$(this)
											.parent()
												.css({
													 position:'relative',
													 left:-15
													 })
											.end()
											.css('margin-top','-1.2em')
											.css('padding-left','45px')
									})
							},
							ie8:function(obj){
								$(obj)
									.each(function(){
										$(this)
											.parent()
												.css('position','relative')
											.end()
											.css({
												 marginTop:'-1.5em',
												 paddingLeft:'25px'
												 })
									})
							}
						})
					.end()
					.find('li > table').each(function(){
						$(this)
							.find('tr:last')
								.addClass('last')
							.end()
							.find('tr:first')
								.addClass('first')
									.find('th:not(:first)')
										.addClass('notFirst')
									.end()
									.find('th:last')
										.addClass('last')
					})
						
				
					
			}
		},
		fixPriceLayout:function(){
			
			if($('body').hasClass('ie7') || $('body').hasClass('ie6')){
				
				var faFlag =  true;//($('body').hasClass('fa01') && $('body').hasClass('fa02'))?true:(!$('body').hasClass('fa01'))?false:true;
				
				if(faFlag){
				if($('body').hasClass('searchDetails')){
					$('#detail')
						.find('table.topCont2')
							.find('tr')
								.each(function(){
									var cells = $(this).find('td');
									var flag = cells.eq(0).attr('rowspan') === 2?true:false;
									if(flag){
										cells
											.eq(11)
												.css('border-right','3px solid #c5c5c5');
										cells
											.eq(13)
												.css('border-right','3px solid #c5c5c5');
									}else{
										cells
											.eq(7)
												.css('border-right','3px solid #c5c5c5');
										cells
											.eq(9)
												.css('border-right','3px solid #c5c5c5');
									}
									
									
								})
					$('div.section table.type3')
						.each(function(){
							$(this)
								.find('tbody > tr')
									.each(function(){
										
								$(this).find('td:eq(2)')
									.css('border-right','3px solid #c5c5c5')
								.end()
								.find('td:eq(4)')
									.css('border-right','3px solid #c5c5c5')
										
									})
						})
					
				}
				}
			}
		},
		initTopModalWindow:function(){
			
			
			
			if($('body').hasClass('home')){
				
				var cfg = {
					closeBtn:{
						h:19,
						w:19,
						topOffset:-9,
						leftOffset:-9
					},
					mainBanner:{
						h:349,
						w:546
					}
				};
				
			
				var cookieName = 'topModalWindow';
				var cookieValTrue = 'true';
				
				if(!checkCookie()){
					writeCookie();
				
				
					var contents = $('<div id="modalWindow"><a href="/bs_nishi8project/premiumseminar/"><img src="/shr/img/top_modal_banner.jpg" alt="プレミアムセミナー＆内覧会のお知らせ" width="546" height="349" /></a></div>');
					contents.css({
						position:'absolute',
						zIndex:10000,
						width: cfg.mainBanner.w + (cfg.closeBtn.w + cfg.closeBtn.leftOffset),
						height:cfg.mainBanner.h + (cfg.closeBtn.h + cfg.closeBtn.topOffset)
					})
					.find('img').css({
						marginTop:8
					})
					
					var closeBtn = $('<div id="#closeBtn"><img src="/shr/img/top_modal_close.gif" width="'+ cfg.closeBtn.w +'" height="'+ cfg.closeBtn.w +'" alt="閉じる" /></div>');
					closeBtn
					.hover(function(){
						$(this).find('img')
							.stop(true,false)
							.fadeTo('fast',0.5)
					},function(){
						$(this).find('img')
							.stop(true,false)
							.fadeTo('fast',1)
					
					})
					.css({
						position:'relative',
						width:cfg.closeBtn.w,
						height:cfg.closeBtn.h,
						left:cfg.mainBanner.w + cfg.closeBtn.leftOffset,
						top:-cfg.mainBanner.h + cfg.closeBtn.topOffset,
						cursor:'pointer'
					})
					contents.append(closeBtn);
					
					fixPosition();
					
					$(window)
						.resize(function(){
							fixPosition();
						})
						.scroll(function(){
							fixPosition();
						})
					
					$(function(){
						contents
							.fadeTo(0,0)
							.appendTo('body')
							.fadeTo(500,1)
						closeBtn
							.click(function(){
								closeModalWindow()
							})
						$('body').click(function(){
							closeModalWindow();
							
						})
					})
				}
			}
			function closeModalWindow(){
						contents.fadeTo(500,0,function(){
							$(this).remove();
						})			
				}
				
				
			function fixPosition(){
				var winSize = {h:$(window).height(),w:$(window).width()}
				var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
				contents.css({
					top: (winSize.h - contents.height()) / 2 + scrollTop,
					left:(winSize.w - contents.width()) / 2
				})
			}
			
			function checkCookie(){
				var val_arr = document.cookie.split(';');
				var val = false;
				for(var i = 0;i < val_arr.length;i++){
					if(val_arr[i].indexOf(cookieName) != -1 && val_arr[i].indexOf(cookieValTrue) != -1){
						val = true;
					}
				}
				return val;
			}
			
			
			function writeCookie(){
				var exp = new Date();
				var str = cookieName + '=' + cookieValTrue + ';';
				document.cookie = str;				
			}
		
			
		},
		homeFix:function(){
			//if(!$('body').hasClass('home')) return false;
			$('#index > table td > dl > dd >h3').filter(function(){
				if($(this).find('a').text().indexOf('ベルサール新宿セントラルパーク') != -1){
					return this
				}
			}).css('font-size','11px')
			
			$('body.page.searchList table td dl dd h3').filter(function(){
				if($(this).find('a').text().indexOf('ベルサール新宿グランドコンファレンスセンター') != -1){
					return this
				}
				
			}).css({
				fontSize:'11px',
				lineHeight:'1.3',
				paddingTop:'4px'
			})
		}
	//-----------------------------------------------------------------
	//-----------------------------------------------------------------
	};
//---------------------------------------------------------------------
})(jQuery);


//jQuery.event.add(window,"load",$.ASconf.selfLinkAndSmoothScrollInit);
//consoleのエラー避け
if (!window.console) {
  (function() {
      var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
        "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
      window.console = {};
      for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
  })();
}

