function jumpToFlightInfo(url) {
	location.href=url
}
function jumpToWindow(url,w,h) {
	window.open(url,'newwindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=' + w + ',height=' + h);
}



/*==============================================
	Onload function Module
==============================================*/
$(function(){
	//$('#topmain').append(topmain);
	var topmain_tag = document.getElementById("topmain");
	topmain_tag.innerHTML = topmain;
	var topleft_tag = document.getElementById("topleft");
	topleft_tag.innerHTML = topleft;
	tabStart();
	
	/*
	//運航情報の文字変更
	var myStr;
	var ieCheck = jQuery.support.noCloneEvent;
	
	if(ieCheck){
		$(".flashtext").remove();
	}else{
		$(".csvtext").remove();
	}
	//alert("test");
	//*/
	
	var ifIE6 = false;
	if(!jQuery.support.opacity){
    if(!jQuery.support.style){
        if (typeof document.documentElement.style.maxHeight == "undefined") {
			ifIE6 = true;
        }
    }
}
	
	$(".csvtext").remove();
	$("#sideform").css("top","233px");
	$(".topbnr").css("top","609px");
	if(ifIE6 == false){
		$("#side_member_blk").css("top","988px");
	}else{
		$("#side_member_blk").css("top","970px");
	}

	
	
	
	
	
	//重要なお知らせの表示／非表示
	//*
	/*
	$.ajax({
		type: "GET",
		url: "http://www.info.fujidreamairlines.com/important/data/logs.csv",
		dataType: "text",
		success: function(str){
			var lng = str.length;
			if(lng > 0){
				$("#top_info").css("display","block");
				myStr = str.slice(str.indexOf(",")+1,str.length-2);
				if(ieCheck) {
					$("#top_info dd a").html(myStr);
				}
				
				//絶対位置のフォームの位置修正
				$("#sideform").css("top","233px");
				$(".topbnr").css("top","609px");
				$("#side_member_blk").css("top","982px")
			}else{
				$("#top_info").css("display","none");
			}
		},
		beforeSend: function(xhr){
			xhr.overrideMimeType("text/html;charset=Shift_JIS");
		}
	});
	//*/
	
	/*
	$.ajax( {
		url: "http://www.info.fujidreamairlines.com/important/logs.xml",
		type: 'GET',
		success:function(data) {
			
			$(data).find("itext").each(function() {
				alert($(this).text());
				//var $book = $(this);
				//$dl.append($("<dt/>").append($book.attr("name")));
				$(this).find("price").each(function() {
					var $price = $(this);
					$dl.append($("<dd/>").append($price));
				});
			});
			//$dl.appendTo("#result");
		}
		
	});
	//*/
	
	/* iPad対応CSS */
	iPadLoadStyle("http://www.info.fujidreamairlines.com/common/css/ipad.css");
	
	flashLoader();
});


function flashLoader() {
	var flashvars = {};
	var params = {
	  menu: "false",
	  wmode : "transparent",
	  allowscriptaccess: "always"
	};
	var attributes = {};
	swfobject.embedSWF("http://www.info.fujidreamairlines.com/common/swf/main.swf", "mapflash", "231", "345", "9.0.0", "http://www.info.fujidreamairlines.com/index_rn/swf/expressinstall.swf", flashvars, params, attributes);
}

/* iPad用振り分け関数 */
function iPadLoadStyle(){
  window.iPad = /iPad/.test(navigator.userAgent);
  if(iPad){
    var args = arguments,
    d = document,
    head = d.getElementsByTagName('head'),
    linktag = function(h,m){
      var tag = d.createElement("link");
      tag.href = h;
      tag.media = m;
      tag.type = "text/css";
      tag.rel = "stylesheet";
      return tag;
    };
    //common
    if(args[0]) head.item(0).appendChild(linktag(args[0],"only screen and (max-device-width: 1024px)"));
    //landscape
    if(args[1]) head.item(0).appendChild(linktag(args[1],"all and (orientation:landscape)"));
    //portrait
    if(args[2]) head.item(0).appendChild(linktag(args[2],"all and (orientation:portrait)"));
  }
};



/* rollover Module -----------------*/

/* マウスダウン付きのロールオーバー -----------------*/
SimpleLib.bind( "init_button", function(){  
    $(function(){  
        $(".btn-roll").button( { over:true, down:true, selected:true, fade:false } );  
        $(".btn-roll").click( function(){  
            $(this).button("down" );  

        });  
    });  
}, true );  


/* 透過を利用したロールオーバー -----------------*/
$(function() {
	var opacity_image=new Object();
	$('.roll img, input:image').not("[src*='_on.']").each(function(i){
//		var i=$(this).attr('class');
		if (!($(this).hasClass('no_rollover') || $(this).hasClass('map_area_js'))) {
//		if(i!='no_rollover' || i!='map_area_js'){
			$(this).hover(function(){
				$(this).css({cursor:'pointer',opacity:'0.90'});
			},function(){
				$(this).css({cursor:'default',opacity:'1'});
			});
		}
	});


/* fontsize Module -----------------*/
$('.mojisize li').hover(function(){
		$(this).css({cursor:'pointer'});
	},function(){
		$(this).css({cursor:'default'});
});


/* mainimage fade Module -----------------*/
	$('head').append('<style type="text/css">#headmain img{display:none;}</style>');
	$(function(){
    $('#headmain img').fadeIn(2000);	
	});

});


/* image_carousel Module -----------------*/
$(function(){
$("#foo2").carouFredSel({
    curcular: false,
    infinite: false,
		duration: 5500,
    auto :  true,
    prev : {   
        button  : "#foo2_prev",
        key     : "left"
    },
    next : {
        button  : "#foo2_next",
        key     : "right"
    },
    pagination  : "#foo2_pag"
});
});


/* smoothScroll -------------------*/
var smoothScroll = {};
smoothScroll.scrolling = false;
smoothScroll.start = function(targetId,easing,callbackFunc) {
	smoothScroll.scrolling = true;
	var $element = $('#'+targetId)[0];
	var easing = easing || 0.14;
	var interval = 30;
	var st = $(document).scrollTop();
	var sl = $(document).scrollLeft();
	var ww = $(window).width();
	var wh = $(window).height();
	var dw = $(document).width();
	var dh = $(document).height();
	var tX = 0; var tY = 0;
	var myTimer, moveX, moveY;
	while($element) {
	   tX += $element.offsetLeft;
	   tY += $element.offsetTop;
	   $element = $element.offsetParent;
	}
	if (dw > (tX + ww)) {
		var toX = tX - sl;
	} else {
		var toX = dw - sl - ww;
	}
	if (dh > (tY + wh)) {
		var toY = tY - st;
	} else {
		var toY = dh - st - wh;
	}
	function windowScroll() {	
		if (0 > toX) {
			moveX = Math.floor(toX*easing);
		} else {
			moveX = Math.ceil(toX*easing);
		}		
		if (0 > toY) {
			moveY = Math.floor(toY*easing);
		} else {
			moveY = Math.ceil(toY*easing);
		}		
		sl += moveX;
		st += moveY;
		window.scrollTo(sl, st);
		toX -= moveX;
		toY -= moveY;
		myTimer = setTimeout(windowScroll,interval);
		if (moveX == 0 && moveY == 0) {
			smoothScroll.scrolling = false;
			clearTimeout(myTimer);
			if ($.isFunction(callbackFunc)) { callbackFunc; }
		}
	}
	windowScroll();	
};
smoothScroll.setup = function() {
	var
		allLinks = document.links,
		lnk = "",
		targetId;
	for(var i = 0 ; i < allLinks.length; i++) {
		lnk = allLinks[i];
		if ((lnk.href && lnk.href.indexOf('#') != -1) && ((lnk.pathname == location.pathname) || ('/'+lnk.pathname == location.pathname)) && $(lnk).hasClass("scroll")) {
			lnk.onclick = function() {
				if (smoothScroll.scrolling) { return; }
				targetId = this.hash.replace(/#/g,"");
				if (document.getElementById(targetId)) {
					smoothScroll.start(targetId);
					return false;
				}
			};
		}
	}
};
$(document).ready(smoothScroll.setup);
