$(function(){
	// ---------------------------
	//	for IE6 - ie6_common.js
	// ---------------------------
	if($.browser.msie && $.browser.version == 6){
		ie6_common();
	}

	// ---------------------------
	//	add external class
	// ---------------------------
	$("div#main a[target='_blank']:not(:has(img)):not(a.noicon):not([href*='.pdf'])")
		.wrap('<span class="external"></span>')
		.append('<img src="/assets/images/icon/external.gif" />');

	$("p#indexTextMain a[target='_blank']:not(:has(img)):not(a.noicon):not([href*='.pdf'])")
		.wrap('<span class="external"></span>')
		.append('<img src="/assets/images/icon/external.gif" />');
	
	// ---------------------------
	//	add pdf file class
	// ---------------------------
	$("a[href*='.pdf']:not(:has(img)):not(a.noicon)").wrap('<span class="pdfFile"></span>');
	$("span.pdfFile").append('<img src="/assets/images/icon/pdf.gif" alt="PDFファイル" />');

	// ---------------------------
	//	add border link image
	// ---------------------------
	$("img[src*='_thumb.gif']").addClass('cover');
	$("img[src*='_thumb.jpg']").addClass('cover');

	// ---------------------------
	//	print
	// ---------------------------
	$("div[class*='headingLevel'] ul.inline li a img[src*='_print_off.gif']").click(function(){
		print();
	});

	$("div#container").after('<br class="printFix" />');

	// ---------------------------
	//	stripe pattern
	// ---------------------------
	$('div#main .stripePattern > :nth-child(odd)').addClass("stripePattern-odd");
	$('div#main .stripePattern > :nth-child(even)').addClass("stripePattern-even");

	// ---------------------------
	//	height
	// ---------------------------
	$(window).load(function(){
		colHeight();
		TextResizeDetector.TARGET_ELEMENT_ID = 'container'; 
		TextResizeDetector.addEventListener(colHeight);
	});

});


// ------------------------------------------------------
//	colHeight
// ------------------------------------------------------
function colHeight() {
	setColHeight($("div.layout2col"), "div.box div.boxText");
	setColHeight($("div.layout3col"), "div.box div.boxText");
	setColHeight($("div.layout4col"), "div.box div.boxText");

	setColHeight($("div.tabMenu"), "ul.inline li a");

}

// ------------------------------------------------------
//	setColHeight
// ------------------------------------------------------
function setColHeight(parent, target) {
	$(parent).each(function(){
		var newHeight = 0;
		$(target, this).each(function(){
			$(this).attr("style", "height:auto;");	//リサイズ時用にリセット
			var targetHeight = $(this).height();
			if(newHeight < targetHeight){
				newHeight = targetHeight;
			}
		});
		$(target, this).each(function(){
			$(this).attr("style", "height:" + newHeight + "px;");
		});
	});
}


