// JavaScript Document

$(document).ready(function(){

	//link scroll
/*    $('a[href^=#]').click(function(){
        var targetID;
        targetID = $( $(this).attr('href') );
        if (targetID.length == 0) {
            return;
        }
				if ($(this).parents("#HaruNav")) {
        $('html, body').animate({scrollTop: targetID.offset().top-100}, "slow");
				} else {
        $('html, body').animate({scrollTop: targetID.offset().top}, "slow");
				}
        return false;
    });*/

		$("a[href^=#]").click(function(){
		var Hash = $(this.hash);
		var HashOffset = $(Hash).offset().top;
			if ($(this).parents("#HaruNav")) {
			$("html,body").animate({ scrollTop: HashOffset-100 }, 1000);
			} else {
			$("html,body").animate({ scrollTop: HashOffset }, 1000);
			}
			return false;
		});
		
	//floating nav
	var HaruNavY = $("#HaruNav").offset().top;

    $(window).scroll(
    	function() {
    		
    		var top = 0;
    		
    		top = $(window).scrollTop();
    		
            if (top > HaruNavY) {
               $("#shell").css({'position': 'fixed', 'top': '0px'});
								if($.browser.msie && $.browser.version<7){
										$("#HaruNav").css({'position': 'absolute'}).get(0).style.setExpression("top","$(window).scrollTop()-$('#HaruTitle').offset().top")
								}
            } else {
           	   $("#shell").css({'position': 'relative'});
								if($.browser.msie && $.browser.version<7){
										$("#HaruNav").css({'position': 'relative'}).get(0).style.setExpression("top","0")
								}
            } 
        return false;
            
    	}
   	); 
	
	//Clip
	if(jQuery.browser.msie){
	 $("span#copy-desc").css("cursor","pointer").click(function(){
			window.clipboardData.setData("text","学生限定　春のキャンパスデーパスポート\nhttp://www.tokyodisneyresort.co.jp/tdr/event/harucam2012/index.html");
				if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
				} else {
				alert("クリップボードにコピーしました。");
				}
					return null;
	 });
	}else{
	
		 $("span#copy-desc").zclip({
				path:"js/ZeroClipboard.swf",
				copy:"学生限定　春のキャンパスデーパスポート\nhttp://www.tokyodisneyresort.co.jp/tdr/event/harucam2012/index.html"
		 });
	}


// floating
	$("a.FloatWin").css("cursor","pointer").live("click",	function(){
			var layH = $("#PopLayer").height()/2+"px";
			var layW = $("#PopLayer").width()/2+"px";
			var target;
			target = $(this).attr('href');
			$("#glayLayer").show().css( "height", $("#container").height() + "px" );
			$("#PopLayer").show().css( { left:"50%", marginLeft:"-"+layW, top : ($(document).scrollTop()+100)+'px', position : "absolute" } ).append( "<DIV id='PupupArea'></DIV>" );
//				if($.browser.msie && $.browser.version<7){
//						$("#PopLayer").css( {  top : ($(document).scrollTop()+100)+'px',position : "absolute" } );
//					$(window).scroll(function(){
//						$("#PopLayer").get(0).style.setExpression("top","($(document).scrollTop()+150)+'px'")
//					})
//				}
			$("#PupupArea").load(target);
			return false;
	});

	//* Closeボタン */
	$("#PupupArea .close").live("click",	function()
		{
			$("#PopLayer").hide();
			$("#PupupArea").remove();
			$("#glayLayer").hide();
	});

	//* Closeボタン以外で閉じる */
	$("#glayLayer").click(
		function()
		{
			$("#PopLayer").hide();
			$("#PupupArea").remove();
			$("#glayLayer").hide();

	});
});
