// script

//gnavi お気に入りの読み込み
var favoriteListObj;

if( !favoriteListObj )
{
document.write( '<script language="JavaScript" src="http://www.tokyodisneyresort.co.jp/js/FavoriteList.js" charset="utf-8"></script> ');
}


//gnavi お気に入りのボタン表示設定
var getpathlnk = new Object();
$(document).ready(function(){
getpathlnk = window.location.pathname;
if( getpathlnk.match("/dream/") || getpathlnk.match("/special/") || getpathlnk.match("/enjoy/") || getpathlnk.match("/magic/") || getpathlnk.match("/online/") ) {
	$("#header .siteNavi .NvFlistbtn").hide();
}
else {
$("#header .NvFlistbtn").css("width","154px");
$("#header .NvFlistbtn a").css("width","154px");
}
});

		


/* window name
window.name = "tdrhome";
window.focus();
*/

// tdr logo
function TdrAnimation(){
simg=new Array(8);
simg[0]="/swf/snavi/anime_A";
simg[1]="/swf/snavi/anime_B";
simg[2]="/swf/snavi/anime_D";
simg[3]="/swf/snavi/anime_E";
simg[4]="/swf/snavi/anime_G";
simg[5]="/swf/snavi/anime_J";
simg[6]="/swf/snavi/anime_K";
simg[7]="/swf/snavi/anime_L";
Myimg=Math.floor(8*Math.random());
document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.c...' width='248' height='114'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='"+simg[Myimg]+".swf' /><param name='quality' value='high' /><param name='wmode' value='transparent'><param name='LOOP' value='false'><embed src='"+simg[Myimg]+".swf' quality='high' wmode='transparent' width='248' height='114' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' loop='false' /></embed></object>");
}



// pngFix
/*
$(document).ready(function(){ 
		$(document).pngFix(); 
}); 
*/

// サイト内検索
    function checkForm() {
        var txt = document.getElementById("q").value;
		if(document.seachForm.q.value == "このサイト内で検索"){
		return false;
		} 
		else if(document.seachForm.q.value == ""){
		return false;
		} else {
		return true;
		}
    }
		



//ナビ開閉
$(document).ready(function(){
	$('#GrovalNavi li ul').hide();
$("#GrovalNavi li").hover(function(){
		$(this).find('ul:first').show("slow");
		},function(){
		$(this).find('ul:first').hide("slow");
		});
});

//サービスナビ開閉
$(document).ready(
function(){
	$("#srv_gnavi li ul").hide();
    $("#srv_gnavi li").hover(
    	function(){
            $("ul:not(:animated)",this).slideDown("normal")
        },
        function(){
            $("ul",this).slideUp("normal");
    });
});

//位置取得

function getWinYOffset()
{
	if(window.scrollY)
		return window.scrollY; // Mozilla
	if(window.pageYOffset)
		return window.pageYOffset; // Opera, NN4

	// 以下 IE
	if(document.documentElement && document.documentElement.scrollTop)
	{
		//Strict Mode
		return document.documentElement.scrollTop;
	}
	else
	if(document.body && document.body.scrollTop)
	{
		//Quirks Mode
		return document.body.scrollTop;
	}
	return 0;
}



// PopupImg
$(document).ready(function(){
	$("body").append("<div id='glayLayer'></div><div id='PopLayer'></div>");

	// ShowImg  クリック拡大表示
	$(".ShowImg").css("cursor","pointer").click(
		function(){
		$("#glayLayer").show().css("height",$("#container").height()+"px");
		$("#PopLayer").show();
		$("#PopLayer").append("<DIV id='PupupImg'><img src='"+ this.name +"' alt='' /><center><p class='Btn-Close ShowImg-Close TxtImg'>Close</p></center></DIV>");
		$("#PupupImg").show();

		$("#PopLayer").css("top", (getWinYOffset() + 130) + "px").css("position","absolute");

		/* Closeボタン */
		$("#PupupImg").find(".ShowImg-Close").click(
			function(){
				$("#PupupImg").remove();
				$("#glayLayer").hide();
				$("#PopLayer").hide();
		});

    });	
		/* Closeボタン以外で閉じる */
	$("#glayLayer").click(
		function(){
			$("#PupupImg").remove();
			$("#glayLayer").hide();
			$("#PopLayer").hide();
	});


	// ThumbPopImg　オンマウス拡大表示
	$(".ThumbPopImg").css("cursor","pointer").hover(
		function(){
			$(this).append("<div id='PopLayer'><DIV id='PupupImg'><img src='"+ this.name +"' alt='' /></DIV></div>");
			if( $.browser.msie && $.browser.version < 8 )
			{
				$("#PopLayer").css( { top : (getWinYOffset()-550) + "px", left : "-50px", position : "absolute" } );
			}
			$("#PopLayer").show();
			$("#PupupImg").fadeIn("");

		},
		function(){
			$("#PupupImg").remove();
			$("#PopLayer").remove();
	});



	// PopMovie  動画表示
	$(".PopMovie").css("cursor","pointer").click(
		function(){
			$("#glayLayer").show().css("height",$("#container").height()+"px");

			$("#PopLayer").css( { top : (getWinYOffset() + 130) + "px", position : "absolute" } );
			$("#PopLayer").html(
				"<div id='PupupImg'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.c...' width='480' height='400' id='overlayFlash' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='"+ this.name +"' /><param name='quality' value='high' /><param name='salign' value='lt' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#ffffff' /><embed src='"+ this.name +"' quality='high' salign='lt' bgcolor='#ffffff' width='480' height='400' name='overlayFlash' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://get.adobe.com/flashplayer/' /></object><center><a href='javascript:;' class='PopMovie-Close'><p class='Btn-Close TxtImg'>Close</p></a></center></div>").show();

			/* Closeボタン */
			$( "#PupupImg" ).find(".PopMovie-Close").click(
				function(){
						$("#PupupImg").remove();
						$("#glayLayer").hide();
						$("#PopLayer").hide();
			});
	});
});


//Win 表示・非表示

function ShowWin(showid) 
{
	$("#glayLayer").show().css( "height", $("#container").height() + "px" );
	$("#PopLayer").show().append( "<DIV id='PupupImg'>"+ $( "#" + showid ).html() + "</DIV>" );
	$("#PupupImg").show();

	$("#PopLayer").css( { top : (getWinYOffset() + 130) + "px", position : "absolute" } ).addClass(showid);

	/* Closeボタン */
	if( $.browser.msie && $.browser.version == '6.0' )
	{
		$("#PupupImg").find(".Btn-Close").css( "visibility", "visible" );
		$("#PupupImg").find(".Btn-Close img").css( "visibility", "visible" );
	}
	
	$("#PupupImg").find(".Btn-Close").click(
		function()
		{
			$("#PupupImg").remove();
			$("#glayLayer").hide();
			$("#PopLayer").removeClass(showid).hide();
	});

	/* Closeボタン以外で閉じる */
	$("#glayLayer").click(
		function()
		{
			$("#PupupImg").remove();
			$("#glayLayer").hide();
			$("#PopLayer").removeClass(showid).hide();
	});
}

// Thumb
$(document).ready(function(){
	$(".NvPage .ThumbPop, .NvFun .ThumbPop").hover(function(){
		$("#ThumbPopArea").append("<DIV id='Thumb-Txt'><img src='"+ this.name +"' alt='' /></DIV>");
		$("#Thumb-Txt")
			.show("fast")
		$(this).find(".thumb-Txt").show();	
	},function(){
	$("#Thumb-Txt").remove();
		$(this).find(".thumb-Txt").hide();	
	});
	$("#sideNavi-B .ThumbPop").hover(function(){
		$("#sideNavi-B").append("<DIV id='Thumb-Txt'><img src='"+ this.name +"' alt='' /></DIV>");
		$("#Thumb-Txt")
			.show("fast")
		$(this).find(".thumb-Txt").show();	
	},function(){
	$("#Thumb-Txt").remove();
		$(this).find(".thumb-Txt").hide();	
	});
});



// BenriMap Popup
$(document).ready(function(){
		$("#GdCheck .BenriGdTable th .BenriMap").hide();	
	$("#GdCheck .BenriGdTable th").hover(function(){
		$(this).find(".BenriMap").show();	
	},function(){
		$(this).find(".BenriMap").hide();	
	});
});


//検索条件表示・非表示
function showhide(id) {

/*	$("body").append("<div id='glayLayer'></div>"); */

  if(document.getElementById){
     if(document.getElementById(id).style.visibility == "visible"){
        document.getElementById(id).style.visibility = "hidden";
/*			$("#glayLayer").remove();*/
    	}else{
/*			$("#glayLayer").show()
				.css("height",$("#container").height()+"px");*/
        document.getElementById(id).style.visibility = "visible";
        document.getElementById(id).style.zIndex = "5000";
    	}
/*	$("#glayLayer").click(function(){
		document.getElementById(id).style.visibility = "hidden";
		$("#glayLayer").remove();
	});*/
   }
}






// 高さをコンテンツにあわせる
footerFixFunction = function (){
};

divy = 80;

// 高さをコンテンツにあわせる
fixHeightFunction = function ()
{
	$("#contents,#sideNavi,#sideNavi-In").height( "auto" );

	var mainH = $("#main").height();
	var conH = $("#contents").height();
	var snH = $("#sideNavi").height();

	var snLogoH = $("#sideNavi .NvLogo").height();
	var snTodayH = $("#sideNavi .NvToday").height();
	var snPageH = $("#sideNavi .NvPage").height();
	var snOtherH = $("#sideNavi .NvOther").height()+5;
	var snFListH = $("#sideNavi .NvFlist").height();
	

	if ( (conH+divy) > snH )
	{
		$("#sideNavi").height(conH+divy);

		var innerHeight;

		if( $("#sideNavi .NvFlist").length > 0 )
		{
			if( $.browser.msie )
				innerHeight = conH - snLogoH - snTodayH - snPageH - snOtherH - snFListH + 65;
			else
				innerHeight = conH - snLogoH - snTodayH - snPageH - snOtherH - snFListH + 60;
		}
		else
		{
			if( $("#sideNavi .NvPage").length > 0 )
				innerHeight = conH - snLogoH - snTodayH - snPageH - snOtherH - 47;
			else
			{
				var snNowH = $("#sideNavi .NvNow").height();
				innerHeight = conH - snNowH - 100;
			}
		}
		$("#sideNavi-In").height( innerHeight );
	}
	else
	{
		var contentHeight;
		if( $.browser.msie && $.browser.version == '6.0' )
			contentHeight = snH + 90;
		else
			contentHeight = snH - divy;
		
		$("#contents").height( contentHeight );
	}
    footerFixFunction();
};

GetHeight = function ( id, name )
{
    var app = navigator.appName.charAt(0);
    if(navigator.userAgent.indexOf('Safari') != -1)
    {
        $( "#" + id ).height( parent.frames[name].document.body.scrollHeight + 0 );
    }
    else if (app == "N")
    {
        $( "#" + id ).height( parent.frames[name].document.height + 0 );
    }
    else
    {
       $( "#" + id ).height( parent.frames[name].document.body.scrollHeight + 0 );
    }
	fixHeightFunction();
};

if( location.hostname != "search.tokyodisneyresort.co.jp" )
{
	var domain = "http://" + location.hostname;
	var alink = location.href;
	alink = alink.split( domain ).join( "" );
	if( !( alink == "/" || alink == "/index.php" || alink == "/index.html" ) )
		$(fixHeightFunction);
}

//stripe-table
$(document).ready(function(){
  // 偶数行にのみクラスを指定
  $('table.stripe-table tr:nth-child(2n+1)').addClass('even-row');
});
		




//Open Window
$(document).ready(function(){
	/* OpenWin */
  $('.OpenWin').click(function(){
		if($.browser.msie && $.browser.version<8){
			window.open(this.href,'home');return false;
		} else {
			window.open(this.href,'home').focus();return false;
		}
  });
	/* tdr750 */
  $('.OpenWin750').click(function(){
		if($.browser.msie && $.browser.version<8){
			window.open(this.href,'home');return false;
		} else {
			window.open(this.href,'home').focus();return false;
		}
  });
	/* online */
  $('.OpenWinOnline').click(function(){
		if($.browser.msie && $.browser.version<8){
			window.open(this.href,'online');return false;
		} else {
			window.open(this.href,'online').focus();return false;
		}
  });
});

// スマートフォン判別
function is_mobile () {
  var useragents = [
    'iPhone',         // Apple iPhone
    'iPod',           // Apple iPod touch
    'iPad',           // Apple iPad
    'Android',        // 1.5+ Android
    'dream',          // Pre 1.5 Android
    'CUPCAKE',        // 1.5+ Android
    'blackberry9500', // Storm
    'blackberry9530', // Storm
    'blackberry9520', // Storm v2
    'blackberry9550', // Storm v2
    'blackberry9800', // Torch
    'webOS',          // Palm Pre Experimental
    'incognito',      // Other iPhone browser
    'webmate'         // Other iPhone browser
  ];
  var pattern = new RegExp(useragents.join('|'), 'i');
  return pattern.test(navigator.userAgent);
}

// POPUP 
	function wpop(popupURL,wNAME,wSIZE){
		var name = navigator.appName;
		if (is_mobile()) {
		var popup = window.open(popupURL,'_blank');
		}
		else if (name == "Microsoft Internet Explorer"){
		// open the popup window Internet Explorer
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars=no,resizable=no');
		}
		else {
		// open the popup window Netscape
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=yes,menubar=no,scrollbars=no,resizable=no');
		}
	}

	function wpop2(popupURL,wNAME,wSIZE){
		var name = navigator.appName;
		if (is_mobile()) {
		var popup = window.open(popupURL,'_blank');
		}
		else if (name == "Microsoft Internet Explorer"){
		// open the popup window Internet Explorer
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars=yes,resizable=no');
		}
		else {
		// open the popup window Netscape
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=yes,menubar=no,scrollbars=yes,resizable=no');
		}
	}
	function wpop3(popupURL,wNAME,wSIZE){
		var name = navigator.appName;
		if (is_mobile()) {
		var popup = window.open(popupURL,'_blank');
		}
		else if (name == "Microsoft Internet Explorer"){
		// open the popup window Internet Explorer
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars=yes,resizable=yes');
		}
		else {
		// open the popup window Netscape
		var popup = window.open(popupURL,wNAME,wSIZE+',toolbar=no,location=0,directories=0,status=yes,menubar=no,scrollbars=yes,resizable=yes');
		}
	}
	function vm(url){
		window.open(url,'vm','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=980,height=720');
		}
// TOT 
function winopen(){
window.open("http://www.tot1899.com","tot","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes")
}




//* リンク時のきりかえ
var anlnk = "";
function ank()
{
	anlnk = location.hash;
	
	if(anlnk == "#GdCheck") 
	{	//benrigoods
		showhide('GdCheck');
		location.replace(anlnk);
	}
	else if(anlnk == "#SubMap") 
	{//rest
		showhide('SubMap');
		location.replace(anlnk);
	}
	else
	{
	}
}
$(ank);	

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

