/*
	基本のJS
	作成日：080211
	更新日：080211
*/

/* ちらつき回避 */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

/* クローズボタン */
function closeWin(){
	window.close();
}

/* ポップアップ */
function popup(win_url,win_width,win_height) {
	var win_date = "location=yes,menubar=no,status=yes,scrollbars=yes,resizable=yes," + win_width + "," + win_height;
	WinOpen = window.open(win_url,'popup',win_date);
	WinOpen.focus();
}

/* ポップアップ2 TVS英語で使用 */
function winopen(url,name,features) {
	window.open(url,name,features);
}

/* 予約モジュール */
$(function(){
	$("li#tabJapan a").bind("click", function(){
																		$("form#formJapan").css("display","block");	
																		$("form#formOverSea").css("display","none");
																		$("li#tabJapan a img").attr("src","/common/images/reservation-tab-01-on.gif");
																		$("li#tabOverSea a img").attr("src","/common/images/reservation-tab-02.gif");
																		return false;
																						});
	$("li#tabOverSea a").bind("click", function(){
																		$("form#formJapan").css("display","none");
																		$("form#formOverSea").css("display","block");
																		$("li#tabJapan a img").attr("src","/common/images/reservation-tab-01.gif");
																		$("li#tabOverSea a img").attr("src","/common/images/reservation-tab-02-on.gif");
																		return false;
																						});
	$("form#formOverSea").css("display","none");
});

$(function(){
	// 見出しの前にロケータがある場合
	$("div#mainContents div.locator h2:first-child").addClass("siblingA");//margin-top: 10px;
	$("div#mainContents div.locator h3:first-child").addClass("firstChild");//margin-top: 10px;
	$("div#mainContents div.locator h4:first-child").addClass("firstChild");//margin-top: 10px;
	$("div#mainContents div.locator + h2").addClass("siblingA");//margin-top: 10px;
	$("div#mainContents div.locator + h3").addClass("siblingA");//margin-top: 10px;
	$("div#mainContents div.locator + h4").addClass("siblingA");//margin-top: 10px;

	// 見出し要素の後ろにカラムがある場合
	$("div#mainContents h2 + div.locator h3:first-child").addClass("siblingB");//margin-top: 0;

	// 見出しが連続する場合
	$("div#mainContents h2 + h3").addClass("siblingB");//margin-top: 0;
	$("div#mainContents h3 + h4").addClass("siblingB");//margin-top: 0;

	// lastChild
	$("div#platform p:last-child").addClass("lastChild");
	$("div#platform ul:last-child").addClass("lastChild");
	$("div#platform ol:last-child").addClass("lastChild");
	$("div#platform li:last-child").addClass("lastChild");
	$("div#platform dl:last-child").addClass("lastChild");
	$("div#platform dt:last-child").addClass("lastChild");
	$("div#platform dd:last-child").addClass("lastChild");
	$("div.inner > :last-child").addClass("directLastChild");

	$("div#mainContents p.symbol + ul").addClass("symbol");

	// Scroll
	//$('a[@href*="#"]').click(function() {
	//	if(this.href != location.href) {
	//		var id = this.href.substring(this.href.indexOf('#'),this.href.length);
	//		$(id).ScrollTo(300, 'easeout');
	//		return false;
	//	}
	//});


	//別窓ウインドウ
	$('[@href^="http"]').not('[@href*="'+document.domain+'"]').click(function(){
		window.open(this.href, "_blank");
		return false;
	}).each(function() {
		$(this.parentNode).addClass('external');
	});

	$('#localNavi [@href^="http"]').not('[@href*="'+document.domain+'"]').click(function(){
		window.open(this.href, "_blank");
		return false;
	}).each(function() {
		$(this.parentNode).addClass('external');
	});
	
	//別窓アイコン
	$('span.external').not('[@class*="noIcon"]').children('a').each(function(){
			$(this).append('<img src="/common/images/cnt-icon-win.gif" width="14" height="12" />');
			$(this).hover(function(){
					$(this).children().attr('src','/common/images/cnt-icon-win-on.gif');
					},function(){
					$(this).children().attr('src','/common/images/cnt-icon-win.gif');
			});
	});

	//別窓アイコン
	$('span.anchorText').not('[@class*="noIcon"]').children('a').each(function(){
			$(this).before('<img src="/common/images/mark-link2.gif" width="4" height="18" />');
	});

	//PDF
	$('a[@href$=".pdf"]').click(function(){
		window.open(this.href, "_blank");
		return false;	
	}).each(function() {
		$(this.parentNode).addClass('pdf');
	});	

	urlEn = location.href.indexOf("/en/");
	if (urlEn == -1){
		//$('[@href^="http"]').attr("title","別ウィンドウが開きます");
		$('a[@href$=".pdf"]').attr("title","別ウィンドウが開きます");
		var winIcon = '<img src="/common/images/icon-win.gif" alt="別ウインドウ" class="icon">';
	} else {
		$('[@href^="http"]').attr("title","Another window opens.");
		$('a[@href$=".pdf"]').attr("title","Another window opens.");
		var winIcon = '<img src="/common/images/icon-win.gif" alt="Another window" class="icon">';
	}
	//$('div#mainContents a[@href^="http://"]').after(winIcon);
	//$('div#mainContents a[@href^="javascript:winopen"]').after(winIcon);
	//$('a[img] + img.icon').remove();
	
	//奇数、偶数を自動追加
	$('ul').each(function(){
		$(this).find('li:odd').addClass('even');
		$(this).find('li:even').addClass('odd');
	});
	$('table').each(function(){
		$(this).find('tr:odd').addClass('even');
		$(this).find('tr:even').addClass('odd');
	});
	
	//画像へ直リンクするとthickboxで表示(thickbox.js利用)
	//tb_init('a[@href$=".jpg"], a[@href$=".gif"], a[@href$=".png"]');

	//ローカルナビのカレント表示

	//デザイン
	//$("h1").corner("5px top");  
	//$("h2").corner("5px");
	
	//簡単カレント表示
	//$('div#localNav a[@href]').each(function(){
	//	if (this.href == location.href) {
	//		$(this.parentNode).addClass('current');
	//	}
	//});
	
});

// Licenced as Public Domain (http://creativecommons.org/licenses/publicdomain/)
// $Id: jquery_auto.js 426 2006-05-06 19:54:39Z Michał $


// Initialization

$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

$(document).ready($.auto.init);


// Auto-hidden elements

$.auto.hide = {
	init: function() {
		$('.Hide').hide();
	}
};


// Mouse hover

$.auto.hover = {

	init: function() {
		$('img.hover')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
		$('input.hover')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},

	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1-over$2");
	},

	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1-over$2");
		this.src = this.src.replace(/^(.+)-over-over(\.[a-z]+)$/, "$1-over$2");
	},

	exit: function() {
		this.src = this.src.replace(/^(.+)-over(\.[a-z]+)$/, "$1$2");
	}
};


// 予約モジュール

function suite()
{
	newwindow = window.open('url','suite');
}

// クイック検索

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

