<!--

var topFlashCookie = false;

var minH = 600;
var minW = 980;

var isSmartPhone = false;
var isPageDomLoaded = false;


/*DOM操作*/
if ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0) {
	isSmartPhone = true;
}

if( !isSmartPhone ){
	//PCからみたときは背景画像けしておく
	$('head').append('<style type="text/css">#flashNavigation{visibility:hidden;}#footerFlash{visibility:hidden;}#topmaparea img{display:none;}</style>');
}

//ダミーリンク消しておく
$('head').append('<style type="text/css">a#flashgofancyonlineshop{display:none;}</style>');


/*クッキー*/
$.cookie=function(name,value) {
	if(typeof value!='undefined') {
		document.cookie=[name,'=',encodeURIComponent(value)].join('');
	}else{
		var cookieValue=null;
		if (document.cookie&&document.cookie!='') {
			var cookies=document.cookie.split(';');
			for (var i=0;i< cookies.length;i++) {
				var cookie=$.trim(cookies[i]);
				if (cookie.substring(0,name.length+1)==(name+'=')) {
					cookieValue=decodeURIComponent(cookie.substring(name.length+1));
					break;
				}
			}
		}
		return cookieValue;
	}
};

if($.cookie('openningFlag')){
	topFlashCookie=true;
	$.cookie('openningFlag',1);
}else{
	topFlashCookie=false;
	$.cookie('openningFlag',0);
}



/*トップフラッシュ*/
function writeTopFlash( flashPath, xmlPath ){
	
	var flashvars = {
		configpath:xmlPath,
		cookie:topFlashCookie
	};
	
	var params = {
		scale:'noScale',
		menu:'false',
		quality:'high',
		allowfullscreen :'true',
		wmode:'transparent',
		allowScriptAccess:'always'
	};
	
	var attributes = {
		id: 'external_flashTop_swf',
		name:'external_flashTop_swf'
	};
	
	swfobject.embedSWF(flashPath, "flashTop_contents", "100%", "100%", "10", "", flashvars, params, attributes);

}




/*ナビフラッシュ*/
function writeGNavi( flashPath ){
	
	var category = getFlashCategory();
	
	var flashvars = {
		targscene:category
	};
	
	var params = {
		scale:'noScale',
		menu:'false',
		quality:'high',
		allowfullscreen :'true',
		wmode:'transparent',
		allowScriptAccess:'always'
	};
	
	var attributes = {
		id: 'external_flashNavigation_swf',
		name:'external_flashNavigation_swf'
	};
	
	swfobject.embedSWF(flashPath, "flashNavigation_contents", "100%", "307", "10", "", flashvars, params, attributes);

}


/*店舗検索フラッシュ*/
function writeStoreLocator( flashPath, xmlPath ){

	var flashvars = {
		configpath:xmlPath
	};
	
	var params = {
		scale:'noScale',
		menu:'false',
		quality:'high',
		allowfullscreen :'true',
		wmode:'transparent',
		allowScriptAccess:'always'
	};
	
	var attributes = {
		id: 'external_flashStore_swf',
		name:'external_flashStore_swf'
	};
	
	swfobject.embedSWF(flashPath, "topmaparea", "864", "432", "10", "", flashvars, params, attributes);

}


/*LEGENDOFKALDIフラッシュ*/
function writeLegendFlash( flashPath ){

	var flashvars = {
	};
	
	var params = {
		scale:'noScale',
		menu:'false',
		quality:'high',
		allowfullscreen :'true',
		wmode:'transparent',
		allowScriptAccess:'always'
	};
	
	var attributes = {
		id: 'external_flashLegend_swf',
		name:'external_flashLegend_swf'
	};
	
	swfobject.embedSWF(flashPath, "flashLegend_contents", "166", "74", "10", "", flashvars, params, attributes);

}


/*フッターフラッシュ*/
function writeFooterFlash( flashPath ){

	var flashvars = {
	};
	
	var params = {
		scale:'noScale',
		menu:'false',
		quality:'high',
		allowfullscreen :'true',
		wmode:'transparent',
		allowScriptAccess:'always'
	};
	
	var attributes = {
		id: 'external_flashFooter_swf',
		name:'external_flashFooter_swf'
	};
	
	swfobject.embedSWF(flashPath, "flashFooter_contents", "100%", "62", "10", "", flashvars, params, attributes);

}

function getFlashCategory(){
	
	var myurl = document.URL;
	
	if( myurl.indexOf( "hr" ) > -1 ){
		return 9;
	}else if( myurl.indexOf( "stores" ) > -1 ){
		return 0;
	}else if( myurl.indexOf( "cafe" ) > -1 ){
		return 3;
	}else if( myurl.indexOf( "news" ) > -1 ){
		return 1;
	}else if( myurl.indexOf( "coffee" ) > -1 ){
		return 2;
	//}else if( myurl.indexOf( "cafe" ) > -1 ){
	//	return 3;
	}else if( myurl.indexOf( "corporate" ) > -1 ){
		return 4;
	}else if( myurl.indexOf( "related" ) > -1 ){
		return 5;
	}else if( myurl.indexOf( "sitemap" ) > -1 ){
		return 6;
	}else if( myurl.indexOf( "ask" ) > -1 ){
		return 7;
	}else if( myurl.indexOf( "deve" ) > -1 ){
		return 8;
	}else{
		return 0;
	}
	
}



/*DOM読み込み終了時*/
$(function(){
	setFlashSize();
	
	initializeNavigation();
	
	//オンリサイズ
	$(window).resize(function(){
		setFlashSize();
	});
	
	writeOnlineShopDummyLink();
	
	isPageDomLoaded = true;
});

function writeOnlineShopDummyLink(){
	$("body").append('<a href="/onlineshop.html" id="flashgofancyonlineshop">オンラインショップ</a>');
}

/*ページ読み込み終了時*/
jQuery.event.add(window, "load", function(){
	setFlashSize();
	
	//トップページ
	if( $("body#top") ){
		$("header").css( "visibility", "visible" );
		$("footer").css( "visibility", "visible" );
		
		if( $("#flashTop_contents") ){
			$("#flashTop_contents").css( "backgroundColor", "#000" );
		}
		if( $("#contents") ){
			$("#contents").css( "backgroundColor", "#000" );
		}
		
	}
	
});

/*ライトボックス呼び出し*/
function getOnlineShopPage(){
	if( isPageDomLoaded ){
		$("a#flashgofancyonlineshop").fancybox().trigger('click');
	}
}

/*ページトップ*/
function getPageTop(){
	if( isPageDomLoaded ){
		scrollToTop();
	}
}

function scrollToTop(){
	$('html,body').animate({ scrollTop: $("#top").offset().top }, 'slow','swing');
	return false;
}


function initializeNavigation(){
	if( !isSmartPhone ){
		if( $("#flashNavigation") ){
			//PCからみたときは背景画像けしておく
			$("#flashNavigation").css( "background", "none" );
			$("#flashNavigation").css( "visibility", "visible" );
		}
		if( $("#footerFlash") ){
			//PCからみたときは背景画像けしておく
			$("#footerFlash").css( "background", "none" );
			$("#footerFlash").css( "visibility", "visible" );
		}
	}
}

function setFlashSize(){
	
	var topflashContainer = $("#flashTop_contents");
	var navflashContainer = $("#flashNavigation_contents");
	var footerflashContainer = $("#flashFooter_contents");
	
	var topflash = $("#external_flashTop_swf");
	var navflash = $("#external_flashNavigation_swf");
	var footerflash = $("#external_flashFooter_swf");

	var winHeight = $(window).height();
	var winWidth = $(window).width();
	var targH;
	var targW;
	
	if( winWidth < minW ){
		targW = minW;
	}else{
		targW = "100%";
	}
	
	if( winHeight < minH ){
		targH = minH - 109;
	}else{
		targH = winHeight - 109;
	}
	
	if(topflashContainer){
		topflashContainer.css( "width", targW );
		topflashContainer.css( "height", targH );
	}
	
	if(navflashContainer){
		navflashContainer.css( "width", targW );
	}
	
	if(footerflashContainer){
		footerflashContainer.css( "width", targW );
	}
	
	if(topflash){
		topflash.css( "width", targW );
		topflash.css( "height", targH );
	}
	
	if(navflash){
		navflash.css( "width", targW );
	}
	
	if(footerflash){
		footerflash.css( "width", targW );
	}

}





//-->
