$(document).ready(function(){

/* ----------------------------------------------------
	■表組み整形
---------------------------------------------------- */
var tbl = $("div.entryBox table.tableBox");
var tbl2 = $("div.entryBox table.type2");
var tbl3 = $("div.entryBox table.type3");
var tbl4 = $("div.entryBox table.type4");
var tbl5 = $("div.entryBox table.type5");

$("td.td1",tbl2).addClass("th1");
$("td.td1",tbl4).addClass("th1");
$("td.td1",tbl5).addClass("th1");
$("tr.tr1 td",tbl3).addClass("th2");
$("tr.tr1 td",tbl4).addClass("th2");
$("tr.tr1 td",tbl5).addClass("th2");


/* ----------------------------------------------------
	■タイトル無し
---------------------------------------------------- */
var notitprev = $("div.hiddenTitle").prev("div.entryBox");
notitprev.addClass("hiddenTitlePrev");


/* ----------------------------------------------------
	■画像レイアウト
---------------------------------------------------- */
// L2・R2
$(".entryBox img.imgL2, .entryBox img.imgR2").val(function(){
	var eb = $(this).parents(".entryBox").find(".body");
	var ew = eb.width(); // 記事幅を取得
	var iw = $(this).outerWidth(); // 画像幅を取得
	var w = ew - iw - 15;
	eb.find(".text").css("width", w); // テキスト幅を設定
	eb.find(".img").css("width", iw); // 画像幅を設定
});

// L2・R2（ボックス・カラム）
$(".type9set .entryBox img.imgL2, .type9set .entryBox img.imgR2, .type14set .entryBox img.imgL2, .type14set .entryBox img.imgR2").val(function(){
	var eb = $(this).parents(".entryBox");
	var ew = eb.width(); // 記事幅を取得
	var iw = $(this).outerWidth(); // 画像幅を取得
	var w = ew - iw - 15;
	eb.find(".text").css("width", w); // テキスト幅を設定
	eb.find(".img").css("width", iw); // 画像幅を設定
});

// L2・R2 （表組み）
$("table.entryTable img.imgL2, table.entryTable img.imgR2").val(function(){
	var eb = $(this).parents("td");
	var ew = eb.width(); // 記事幅を取得
	var iw = $(this).outerWidth(); // 画像幅を取得
	var w = ew - iw - 15;
	eb.find(".text").css("width", w); // テキスト幅を設定
	eb.find(".img").css("width", iw); // 画像幅を設定
});

// L（ボックス・カラム）
$(".entryBox > p.imgL img.imgL").val(function(){
	var eb = $(this).parents(".entryBox");
	var iw = $(this).outerWidth(); // 画像幅を取得
	$(this).parent(".imgL").css("width", iw + 15);
	eb.find(".title .inner").css("margin-left", iw + 15);
});

// R（ボックス・カラム）
$(".entryBox > p.imgR img.imgR").val(function(){
	var eb = $(this).parents(".entryBox");
	var iw = $(this).outerWidth(); // 画像幅を取得
	$(this).parent(".imgR").css("width", iw + 10);
});


/* ----------------------------------------------------
	■記事の高さ揃え
---------------------------------------------------- */
$('.type21 ul.imgList li').tile(2);		// 画像ギャラリー 2列
$('.type12 ul.imgList li').tile(3);		// 画像ギャラリー 3列
$('.type7 ul.imgList li').tile(4);		// 画像ギャラリー 4列
$('.type13 ul.imgList li').tile(5);		// 画像ギャラリー 5列
$('.type10 .entryBox').tile(2);			// ボックス 2列
$('.type11 .entryBox').tile(3);			// ボックス 3列
$('.type15 .entryBox').tile(2);			// カラム 2列
$('.type16 .entryBox').tile(3);			// カラム 3列


/* ----------------------------------------------------
	■記事のタイル表示
---------------------------------------------------- */
$('.type17 .entries, .type18 .entries, .type19 .entries, .type20 .entries').masonry();			// ボックスB 2列


/* ----------------------------------------------------
	■記事レイアウト（フロー）
---------------------------------------------------- */
$(".type2 .entries .entryBox").prepend('<div class="icon">↓</div>');


/* ----------------------------------------------------
	■記事レイアウト（Q&A）
---------------------------------------------------- */
var eb = $(".type3 .entries .entryBox");
$('.title', eb).prepend('<div class="iconQ">Q</div>');
$('.body', eb).prepend('<div class="iconA">A</div>');


/* ----------------------------------------------------
	■記事レイアウト（リンク集）
---------------------------------------------------- */
$(".type4 .entries .entryBox .title").prepend('<div class="icon">→</div>');


/* ----------------------------------------------------
	■スクロール
---------------------------------------------------- */
jQuery.easing.quart = function(x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};  

$('#pagetop').click(
	function() {
		$('html,body').animate({ scrollTop: 0 }, 700, 'quart');
		return false;
	}
);


/* ----------------------------------------------------
	■サイトマップ
---------------------------------------------------- */
var siteul = $("#main ul.sitemapList");
$('li:first-child',siteul).addClass('begin');						// ホーム
$('li',siteul).addClass('root');									// ルート
$('li.sub',siteul).removeClass('root');								// 子からrootを外す
$('li.sub',siteul).prev('li').addClass('parent');					// 親
$('li.sub',siteul).removeClass('parent');							// 子
$('li.sub',siteul).addClass('subRoot2');							// 一番下の子
$('li.root',siteul).prevAll('li.subRoot2').removeClass('subRoot2');// 一番下じゃない子からsubRoot2を外す
$('li.root',siteul).prev('li.sub').addClass('subEnd');				// 子を閉じる
$('li.sub:last-child',siteul).addClass('subEnd2');					// 一番下の子を閉じる
$('li.subRoot2',siteul).prev('li.parent').addClass('end2');			// 子がある最後の親を閉じる
$('li.root:last-child',siteul).addClass('end');						// 最後の親を閉じる


/* ----------------------------------------------------
	■グローバルナビ
---------------------------------------------------- */
var navi = $("ul#navi");
$("li:first-child",navi).addClass("begin");
$("li:last-child",navi).addClass("end");


/* ----------------------------------------------------
	■サイドナビ
---------------------------------------------------- */
var naviS = $("ul#naviS");
$("li:first-child",naviS).addClass("first-child");
$("li:last-child",naviS).addClass("last-child");
$("li.sub:last-child",naviS).addClass("sub-last-child");
$('li.sub',naviS).next('li.parent').addClass('parent2');
var val = $('li.sub a.on',naviS).parent('li');
var val = val.prevAll('li.parent:eq(0)').addClass('on');
$('a',val).addClass('on');


/* ----------------------------------------------------
	■フッターナビ 折り返し
---------------------------------------------------- */
var naviF = $("ul#naviF");
$("li.begin",naviF).before("<br>");
$("br:first-child",naviF).remove("br");


/* End */
});

