/**************************************************************** /
//月ごとにサイト上部アイコンイメージを変更
//****************************************************************/
//function monthImageChange () {
//	datetoday = new Date(); //オブジェクトを作成
//	theMonth = datetoday.getMonth()+1; //月を取得
//	//イメージを挿入
//	var image = '<img src="/common/monthImageChange/ImgMonth' + theMonth + '.jpg" />';
//	$("#randomImage").html(image);
//}
/**************************************************************** /
//月ごとにサイト上部アイコンイメージを変更
//****************************************************************/
function monthImageChange () {
	datetoday = new Date(); //オブジェクトを作成
	theMonth = datetoday.getMonth()+1; //月を取得
	theDay   = datetoday.getDate();    //日を取得
	
	//3月16日〜4月31日まで4月分の画像を表示する。
	if ( (theMonth==3) && (theDay>=16) ) {
		theMonth = 4;
	}
	
	//イメージを挿入
	var image = '<img src="/common/monthImageChange/ImgMonth' + theMonth + '.jpg" />';
	$("#randomImage").html(image);
}


/**************************************************************** 
* 外部JSファイル読み込み関数 @ 利用法 引数に読込ファイルを記述
****************************************************************/ 
function requireJS(uri) {
	document.write('<script type="text/javascript" src="' + uri + '"></script>');
}
/** 外部CSSファイル読み込み関数 @ 利用法 引数に読込ファイルを記述 **/
function requireCSS(uri) {
	document.write('<link rel="stylesheet" type="text/css" href="' + uri + '" />');
}
/**************************************************************** 
* 外部JSファイル読み込み
****************************************************************/ 
/** smoothScroll **/
requireJS ('/common/js/smooth.pack.js');
/** rollover **/
requireJS ('/common/js/rollover.js');
/** spry **/
requireJS ('/common/SpryAssets/SpryValidationTextField.js');
requireCSS('/common/SpryAssets/SpryValidationTextField.css');
requireJS ('/common/SpryAssets/SpryTabbedPanels.js');
requireCSS('/common/SpryAssets/SpryTabbedPanels.css');
/** thickboxAjax **/
//requireJS ('../common/thickbox/jquery.js');
//requireJS ('../common/thickbox/thickbox.js');
//requireCSS('../common/thickbox/thickbox.css');
/** JQUERY.UI **/
requireCSS('/common/jquery-ui-1.7.1/development-bundle/themes/base/ui.all.css');
requireJS ('/common/jquery-ui-1.7.1/development-bundle/ui/ui.core.js');
requireJS ('/common/jquery-ui-1.7.1/development-bundle/ui/ui.draggable.js');
//requireJS ('/common/jquery-ui-1.7.1/development-bundle/ui/ui.resizable.js');
requireJS ('/common/jquery-ui-1.7.1/development-bundle/ui/ui.dialog.js');
requireJS ('/common/jquery-ui-1.7.1/development-bundle/external/bgiframe/jquery.bgiframe.js');






/**************************************************************** 
* Javascript の エラーアラートを非表示にする記述
****************************************************************/ 
function TigilError() {
	return true;
}
window.onerror = TigilError;






/**************************************************************** 
* 機　能： オブジェクトの表示非表示を制御する 1 
*        （表示している場合は非表示、非表示の場合は表示） 
* 引　数： ch 表示/非表示を切り替えるオブジェクト名 
* 戻り値： なし 
* http://www.kanaya440.com/contents/tips/javascript/012.html
****************************************************************/ 
function dispSwitch(ch) { 
    var obj=document.all && document.all(ch) || document.getElementById && document.getElementById(ch); 
    if(obj && obj.style) obj.style.display= 
    "none" == obj.style.display ?"" : "none" 
}





/**************************************************************** 
* jQuery利用関数
****************************************************************/ 


$(document).ready(function($){
	
	/** ページが読み込まれた時に#eventCalenderIframeイベントカレンダーがあるiframe内の高さにiframeの高さを揃える **/
	$('#eventCalenderIframe').load(function(){
		if (typeof $(this).attr('height') != 'undefined') {
			$(this).height(this.contentWindow.document.documentElement.scrollHeight);
		}
	});
	$('#eventCalenderIframe').triggerHandler('load');
	
	//グローバルナビのお買い物ボタンのドロップダウンメニューリンクを非・表示
	$("#gNavi li:first").mouseover(function(){
		$("#shoppingMenu").css("display","block");
	});
	$("#gNavi li:first").mouseout(function(){
		$("#shoppingMenu").css("display","none");
	});
	$("#shoppingMenu").mouseover(function(){
		$("#shoppingMenu").css("display","block");
	});
	$("#shoppingMenu").mouseout(function(){
		$("#shoppingMenu").css("display","none");
	});
	
	

	//店名から探すタブをクリックした場合の処理
	$("#tab01").click(function(){
		$("#tab01").html('<img src="/common/img/tab01_on.jpg" class="dispBlock" />');
		$("#tab02").html('<img src="/common/img/tab02.jpg" class="dispBlock" />');
		$("#tab03").html('<img src="/common/img/tab03.jpg" class="dispBlock" />');
		$("#categoryOpenButton").hide();
		$("#categoryCloseButton").hide();
		$("#mapOpenButton").hide();
		$("#mapCloseButton").hide();
		
		//デフォルトでは店名から探すFlashは非表示だが、オンクリックで非表示させる
		$("#shopName").css("dispaly","block");
	});
	
	//地図から探すタブをクリックした場合の処理
	$("#tab02").click(function(){
		$("#tab01").html('<img src="/common/img/tab01.jpg" class="dispBlock" />');
		$("#tab02").html('<img src="/common/img/tab02_on.jpg" class="dispBlock" />');
		$("#tab03").html('<img src="/common/img/tab03.jpg" class="dispBlock" />');
		$("#categoryOpenButton").hide();
		$("#categoryCloseButton").hide();
		$("#mapOpenButton").hide();
		$("#mapCloseButton").hide();
	});
	
	//クーポンから探すタブをクリックした場合の処理
	$("#tab03").click(function(){
		$("#tab01").html('<img src="/common/img/tab01.jpg" class="dispBlock" />');
		$("#tab02").html('<img src="/common/img/tab02.jpg" class="dispBlock" />');
		$("#tab03").html('<img src="/common/img/tab03_on.jpg" class="dispBlock" />');
		$("#categoryOpenButton").hide();
		$("#categoryCloseButton").hide();
		$("#mapOpenButton").hide();
		$("#mapCloseButton").hide();
	});
	
	
	
	//店舗情報検索エリア内親カテゴリーをチェンジした際に子カテゴリーを対応する<OPTION>群に書き換える
	$("#parentCateId").change(function(){
		var value  = $(this).val(); //親カテゴリー内<option value="">内の値
		var random = Math.floor(Math.random()*99999999+1); //8桁の乱数
		var url    = "/program.shopSearch.categoryOptionGet.php?parentCateId=" + value + "&" + random;
		$("#cateId").load(url);
	});
	
	
	
	//TOPページでクーポン情報一覧ダイアログを表示させる
	$("#newCouponArea .listLink a").click(function(){
	
		$("div[aria-labelledby='ui-dialog-title-newCouponlinkAll']").css("display","block");
		
		var random = Math.floor(Math.random()*99999999+1); //8桁の乱数
		var url = "/program.common.ajaxLoad.php?newCouponlinkAll=" + random;
		$("#newCouponlinkAll").load(url).dialog({
			height: 300,
			width:350
		});
		
		$("div[aria-labelledby='ui-dialog-title-newCouponlinkAll'] div.ui-widget-header").css("backgroundImage","url(/common/img/dialogCouponTitleBg.jpg)");
		
	});
	
	
	
	//TOPページで求人情報一覧ダイアログを表示させる
	$("#JobOfferArea .listLink a").click(function(){
	
		$("div[aria-labelledby='ui-dialog-title-JobOfferlinkAll']").css("display","block");
		
		var random = Math.floor(Math.random()*99999999+1); //8桁の乱数
		var url = "/program.common.ajaxLoad.php?JobOfferlinkAll=" + random;
		$("#JobOfferlinkAll").load(url).dialog({
			height: 300,
			width:350
		});
		
		$("div[aria-labelledby='ui-dialog-title-JobOfferlinkAll'] div.ui-widget-header").css("backgroundImage","url(/common/img/dialogJobOfferTitleBg.jpg)");
	});
	
});
