$(function() {
					 
	if ($(".galleryTabs")) {
		/*
		if ($.browser && $.browser.msie && $.browser.version <= 7) {
			$('.galleryTabs').tabs('.gallery > div', {
				event: 'mouseover',										 
				effect: 'fade',
				fadeInSpeed: 0, 
				fadeOutSpeed: 0, 
				rotate: true
			}).slideshow({autoplay: true, interval: 3000});
			$('.gallery div').css("display","block");
		}
		else {
			$('.galleryTabs').tabs('.gallery > div', {
				event: 'mouseover',										 
				effect: 'fade',
				fadeInSpeed: 1000, 
				fadeOutSpeed: 1000, 
				rotate: true
			}).slideshow({autoplay: true, interval: 3000});
		}
		*/
		$('.galleryTabs').tabs('.gallery > div', {
			event: 'mouseover',										 
			effect: 'fade',
			fadeInSpeed: 1000, 
			fadeOutSpeed: 1000, 
			rotate: true
		}).slideshow({autoplay: true, interval: 3000});
	}
	
	if ($('a[class$="external"]')) {
		$('a[class$="external"]').click(function(){
				this.target="_blank";
		});
	}
	
	if ($('a[rel$="external"]')) {
		$('a[rel$="external"]').click(function(){
				this.target="_blank";
		});
	}

	if ($("#blogArchivesLink")) {
		$("#blogArchivesLink").tooltip({ effect: 'fade', relative: true, position:'bottom, left', offset:[0, 105]});
	}
	
	if ($("#blogCategoriesLink")) {
		$("#blogCategoriesLink").tooltip({ effect: 'fade', relative: true, position:'bottom, left', offset:[0, 110]});
		$("#blogCategoriesLink").overlay();
	}
	
	if ($("#topicsCategoriesLink")) {
		$("#topicsCategoriesLink").tooltip({ effect: 'fade', relative: true, position:'bottom, left', offset:[0, 120]});
		$("#topicsCategoriesLink").overlay();
	}
	
	if ($("#EntryNextPrevTopics").length) {
		offsetY = -115;
		offsetX = -93;
		offsetY_IE = -5;
		offsetX_IE = 25;
		position = 'top, center';
		position_IE = 'top, center';
	}
	else if ($("#EntryNextPrevSnap").length) {
		offsetY = -150;
		offsetX = -74;
		offsetY_IE = -5;
		offsetX_IE = 25;
		position = 'top, right';
		position_IE = 'top, center';
	}
	else {
		offsetY = 0;
		offsetX = 0;
		offsetY_IE = 0;
		offsetX_IE = 0;
		position = 'top, center';
		position_IE = 'top, center';
	}
	
	if ($("#EntryNextImg")) {
		if ($.browser.msie && $.browser.version < 7) {
			$("#EntryNextImg").tooltip({ effect: 'fade', relative: true, position:position_IE, offset:[offsetY_IE, offsetX_IE]});
			$("#EntryNextImg").overlay();
		}
		else {
			$("#EntryNextImg").tooltip({ effect: 'fade', relative: true, position:position, offset:[offsetY, offsetX]});
			$("#EntryNextImg").overlay();
		}
	}
	
	if ($("#EntryPrevImg")) {
		if ($.browser.msie && $.browser.version < 7) {
			$("#EntryPrevImg").tooltip({ effect: 'fade', relative: true, position:position_IE, offset:[offsetY_IE, offsetX_IE]});
			$("#EntryPrevImg").overlay();
		}
		else {
			$("#EntryPrevImg").tooltip({ effect: 'fade', relative: true, position:position, offset:[offsetY, offsetX]});
			$("#EntryPrevImg").overlay();
		}
	}
	
	if ($("#seasonList")) {
		if ($.browser.msie && $.browser.version < 7) {
			$("#seasonList").tooltip({ effect: 'fade', relative: true, position:'bottom, center', offset:[-20, 0]});
			$("#seasonList").overlay();
		}
		else {
			$("#seasonList").tooltip({ effect: 'fade', relative: true, position:'bottom, center', offset:[-20, -20]});
			$("#seasonList").overlay();
		}
	}

	if ($("#pageTopImg")) {
		$('#pageTopImg').click(function () {
			$('html,body').animate({ scrollTop: 0 }, 1000, 'quart');
			return false;
		});
	}
	
	if ($.browser && $.browser.msie && $.browser.version <= 6) {
		$('#pageTop').exFixed();
	}

});
	
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};  

$(document).ready(function(){
	
	if ($("label")) {
		$("label").inFieldLabels();
	}

});
	
$(window).bind('resize', function() {
	if ($('.gallery div')) {
		$('.gallery div').css("display","block");
	}
	SetResize();
});

$(window).bind('resize.contents', function() {
	SetResizeSnapPhoto();
});

$(window).bind('load', function() {
	SetResizeSnapPhoto();
});

function SetResize(){
	var thumbsWidth = ($('#contents').width() - 20) / 3;
	ResizeImage('#header', 815, 0, 665, 0);
	ResizeImage('.gallery', 795, 427, 635, 328, 20);
	ResizeImage('#contents', 815, 0, 635, 0);
	ResizeTopicsSub('#footerLeft', 815, 650, $('#header').width() - 15);

	if ($('#news')&&$('#snap')&&$('#blog')&&$('#topics')) {
		resizeThumbNews('#news', 445, 380, 142, 80, 8);
		resizeThumbSnap('#snap', 294, 242, 14);
		resizeThumbTopics('#topics', $('#header').width() - 20, 460, 142, 80, 8);
		resizeThumbBlog('#blog', $('#header').width() - 20, 460, 142, 80, 8);
	}

	ResizeImage('#blogHeaderLeft', 525, 0, 475, 0);
	ResizeImage('#blogProfile dd', 320, 0, 270, 0, -10);
	ResizeImage('#blogProfile', $('#blogProfile dd').width() + 180, 0, $('#blogProfile dd').width() + 180, 0, 25);
	ResizeThumbList('.blogger', 156, 4);
	ResizeThumbList('.topics', 208, 3);
	ResizeThumbList('.snap', 156, 4);
	ResizeThumbList('.feature', 208, 3);
	ResizeThumbList('.sevendays', 156, 4);
	ResizeTopicsSub('.entryBodyTopics', 545, 420, $('#header').width() - 240);
	SetResizeSnapPhoto();
	//ResizeImage('#interview_top_img img', $('#header').width(), 0, $('#header').width(), 0);
	//ResizeImage('#special_top_img img', $('#header').width(), 0, $('#header').width(), 0);
	ResizeImage('#magazine_top_img img', 397, 0, 250, 0);
	ResizeImage('.magazine_img img', 172, 0, 120, 0);
	ResizeImage('.about_top_right img', 287, 0, 220, 0);

	SetResizeFeaturePhoto('#left_cnt_inbox02', 458, 300);
	
	displayBackBody('.interview');
	ResizeImage('.interview_back', $('#contents').width() - 44, 177, $('#contents').width() - 44, 177);
	ResizeImage('.interview_back_right', $('#contents').width() - 286, 0, $('#contents').width() - 286, 0);
	
	displayBackBody('.special');
	ResizeImage('.special_back', $('#contents').width() - 44, 177, $('#contents').width() - 44, 177);
	ResizeImage('.special_back_right', $('#contents').width() - 286, 0, $('#contents').width() - 286, 0);

	Resize7days('#entryBodySevendays', 460, 330);

/*
	if((!navigator.userAgent.match(/iPhone/i)) && !(navigator.userAgent.match(/iPod/i)) && !(navigator.userAgent.match(/iPad/i))) {
		if ($("#contentsDescription")) {
			result = $("#contentsDescription").html();
			if (result != null) {
				if ($.browser.msie) {
				}
				else {
					$("#contentsDescription").html(result.replace(/\r?\n/g, "<br />"));
				}
			}
		}
	}
*/
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		if ($("#contentsDescription")) {
			result = $("#contentsDescription").html();
			$("#contentsDescription").hide();
			if (result != null) {
				$("#contentsDescription").html(result.replace(/<\/?[^>]+>/gi, ""));
			}
			$("#contentsDescription").show();
		}
	}

}

function Resize7days(name, max_width, min_width){
	if ($(name)) {
		var new_width = $('#contents').width() - 320;
		
		if( new_width > max_width){
			new_width = max_width;
		}
		else if(new_width < min_width) {
			new_width = min_width;
		}
		if ($.browser.msie && $.browser.version <= 6) {
			new_width = new_width - 15;
		}
		
		$(name).height('auto').width(new_width);
		$("#imgMain img").width(new_width);
		
		new_height = $("#imgMain img").height() + 140;
		new_top = $("#imgMain img").height() + 36;
		new_left = ($("#imgMain img").width() - 320) / 2;
		$("#imgMainWrap").height(new_height);
		$("#pager").css('top', new_top);
		$("#pager").css('left', new_left);
	}
}

function displayBackBody(name) {
	var contentWidth = $("body").width();
	var displayBodyLong = "";
	var displayBodyMiddle = "";
	var displayBodyShort = "";
	
	if (contentWidth <= 1200){
		displayBodyLong = "none";
		displayBodyMiddle = "none";
		displayBodyShort = "block";
	} else if (contentWidth > 1200 && contentWidth <= 1400){
		displayBodyLong = "none";
		displayBodyMiddle = "block";
		displayBodyShort = "none";
	} else {
		displayBodyLong = "block";
		displayBodyMiddle = "none";
		displayBodyShort = "none";
	}
	
	$(name + "_backnum_body_long").css("display",displayBodyLong);
	$(name + "_backnum_body_middle").css("display",displayBodyMiddle);
	$(name + "_backnum_body_short").css("display",displayBodyShort);

}

function ResizeThumbList(name, img_width, division){
	if ($(name)) {
		$(name).each(function(){
				var new_padding = Math.floor(($('#contents').width() - (img_width * division) - 20) / (division - 1));
				
				$('#' + name.replace(".","") + 'List').css('padding-left', 10);
				if( new_padding <= 0 ){
					$(this).css('padding-right', 2);
					if ($.browser.msie && $.browser.version <= 6) {
						$('#' + name.replace(".","") + 'List').css('padding-left', 3);
					}
				}
				else {
					$(this).css('padding-right', new_padding);
				}
				$(name + "Right").css('padding-right', 0);
		});
	}												
}

function SetResizeFeaturePhoto(name, max_width, min_width){
	if ($(name)) {
		$(name).each(function(){
				var new_width = $('#contents').width() - 320;
				
				if( new_width > max_width){
					new_width = max_width;
				}
				else if(new_width < min_width) {
					new_width = min_width;
				}
				
				$(this).height('auto').width(new_width);
		});
	}												
}

function resizeThumbNews(name, width1, height1, width2, height2, border) {
	var contentWidth = $("body").width();
	var ratio = 0;
	var linkWidth = 0;
	var linkHeight = 0;
	var imgWidth = 0;
	var childWidth = 0;
	var childHeight = 0;
	var parentWidth = 0;
	var parentHeight = 0;
	var displayBody = "";
	var displayBodyShort = "";
	var padding = 0;
	
	if (contentWidth <= 1000){
		if ($.browser.msie && $.browser.version <= 6) {
			ratio = 0.85;
		}
		else {
			ratio = 0.8;
		}
		displayBody = "none"
		displayBodyShort = "block"
	} else if (contentWidth > 1000 && contentWidth <= 1250){
		ratio = 0.85;
		displayBody = "none"
		displayBodyShort = "block"
	} else {
		ratio = 1;
		displayBody = "block"
		displayBodyShort = "none"
	}
	if ($.browser.msie && $.browser.version <= 6) {
		border = 0;
		padding = 10;
	}
	imgWidth = Math.floor(width2*ratio);
	linkWidth = Math.floor(width2*ratio)-border;
	linkHeight = Math.floor(height2*ratio)-border;
	childWidth = Math.floor(width2*ratio);
	childHeight = Math.floor(height2*ratio);
	parentWidth = Math.floor(width1*ratio)+padding;
	parentHeight = Math.floor(height1*ratio);
	
	$(name+" .itemsImg a img").css("width",imgWidth);
	$(name+" .itemsImg a").css("width",linkWidth);
	$(name+" .itemsImg a").css("height",linkHeight);
	$(name+" .itemsImg").css("width",childWidth);
	$(name+" .itemsImg").css("height",childHeight);
	$(name+" .itemsEntryTitle").css("width",parentWidth-childWidth-20);
	$(name+" .itemsBody").css("width",parentWidth-childWidth-20);
	$(name+" .blackDotLine").css("width",parentWidth-childWidth-40);
	$(name+" .items").css("width",parentWidth);
	$(name+" .items").css("height",childHeight+15);
	$(name+" .thumbsWrap").css("width",parentWidth);
	$(name+" .thumbsWrap").css("height",parentHeight);
	$(name).css("width",parentWidth);
	$(name).css("height",parentHeight);
	$(name+" .itemsBody").css("display",displayBody);
	$(name+" .bodyShort").css("display",displayBodyShort);

}

function resizeThumbSnap(name, width, height, border) {
	var contentWidth = $("body").width();
	var ratio = 0;
	var linkWidth = 0;
	var linkHeight = 0;
	var imgWidth = 0;
	var childWidth = 0;
	var childHeight = 0;
	var parentWidth = 0;
	var parentHeight = 0;
	var lineWidth = 0;
	var lineLeft = 73;
	
	if (contentWidth <= 1150){
		ratio = 0.8;
	} else if (contentWidth > 1150 && contentWidth <= 1350){
		ratio = 0.85;
	} else {
		ratio = 1;
	}
	if ($.browser.msie && $.browser.version <= 6) {
		border = 0;
		width -= 20;
		lineLeft += 6;
		padding = 10;
	}
	linkWidth = Math.floor(width*ratio)-border;
	linkHeight = Math.floor(height*ratio)-border;
	imgWidth = Math.floor(width*ratio);
	childWidth = Math.floor(width*ratio);
	childHeight = Math.floor(height*ratio);
	parentWidth = Math.floor(width*ratio);
	lineWidth = Math.floor(width*ratio)-lineLeft;

	$(name+" .itemsWrap a img").css("width",imgWidth);
	$(name+" .itemsWrap a").css("width",linkWidth);
	$(name+" .itemsWrap a").css("height",linkHeight);
	$(name+" .itemsWrap").css("width",childWidth);
	$(name+" .itemsWrap").css("height",childHeight);
	$(name+" .thumbsWrap").css("width",childWidth);
	$(name+" .thumbsWrap").css("height",childHeight);
	$(name+" .naviLineTop").css("width",lineWidth);
	$(name+" .naviLineBottom").css("width",childWidth);
	$(name).css("width",parentWidth);

}

function resizeThumbTopics(name, width1, height1, width2, height2, border) {
	var contentWidth = $("body").width();
	var ratio = 0;
	var baseRatio = 0;
	var linkWidth = 0;
	var linkHeight = 0;
	var imgWidth = 0;
	var childWidth = 0;
	var childHeight = 0;
	var firstChildLinkWidth = 0;
	var firstChildLinkHeight = 0;
	var firstChildWidth = 0;
	var firstChildHeight = 0;
	var parentWidth = 0;
	var parentHeight = 0;
	var displayBody = "";
	var displayBodyShort = "";
	var displayTitle = "";
	var displayTitleShort = "";
	var padding = 0;
	
	if (contentWidth <= 1200){
		if ($.browser.msie && $.browser.version <= 6) {
			ratio = 0.8;
		}
		else {
			ratio = 0.8;
		}
		baseRatio = 0.85;
		displayBody = "none"
		displayBodyShort = "block"
		displayTitle = "none";
		displayTitleShort = "block";
	} else if (contentWidth > 1200 && contentWidth <= 1400){
		ratio = 0.83;
		baseRatio = 0.9;
		displayBody = "none"
		displayBodyShort = "block"
		displayTitle = "none";
		displayTitleShort = "block";
	} else {
		ratio = 1;
		baseRatio = 1;
		displayBody = "block"
		displayBodyShort = "none"
		displayTitle = "block";
		displayTitleShort = "none";
	}
	if ($.browser.msie && $.browser.version <= 6) {
		border = 0;
		padding = 20;
	}
	linkWidth = Math.floor(width2*ratio)-border;
	linkHeight = Math.floor(height2*ratio)-border;
	childWidth = Math.floor(width2*ratio);
	childHeight = Math.floor(height2*ratio);
	firstChildLinkWidth = Math.floor((width2+110)*ratio)-border;
	firstChildLinkHeight = Math.floor((height2+62)*ratio)-border;
	firstChildWidth = Math.floor((width2+110)*ratio);
	firstChildHeight = Math.floor((height2+62)*ratio)+40;
	parentWidth = Math.floor(width1+padding);
	parentHeight = Math.floor(height1*baseRatio);
	//imgWidth = Math.floor(parentWidth/3)-100;
	imgWidth = Math.floor(width2*ratio);
	
	$(name+" .itemsImg a img").css("width",imgWidth);
	$(name+" .itemsImg a").css("width",linkWidth);
	$(name+" .itemsImg a").css("height",linkHeight);
	$(name+" .itemsImg").css("width",childWidth);
	$(name+" .itemsImg").css("height",childHeight);
	$(name+" .itemsTitle").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .itemsBody").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .blackDotLine").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .items").css("width",Math.floor(parentWidth/3));
	$(name+" .items").css("height",firstChildHeight+15);
	$(name+" #itemsFirst .itemsImg a img").css("width",firstChildWidth);
	$(name+" #itemsFirst .itemsImg a").css("width",firstChildLinkWidth);
	$(name+" #itemsFirst .itemsImg a").css("height",firstChildLinkHeight);
	$(name+" #itemsFirst .itemsImg").css("width",firstChildWidth);
	$(name+" #itemsFirst .itemsImg").css("height",firstChildHeight-40);
	$(name+" #itemsFirst .itemsTitle").css("width",parentWidth-firstChildWidth-10);
	$(name+" #itemsFirst .itemsBody").css("width",parentWidth-firstChildWidth-10);
	$(name+" #itemsFirst .blackDotLine").css("width",parentWidth-firstChildWidth-10);
	$(name+" #itemsFirst").css("width",parentWidth);
	$(name+" #itemsFirst").css("height",firstChildHeight);
	$(name+" .thumbsWrap").css("width",parentWidth);
	$(name+" .thumbsWrap").css("height",(firstChildHeight*2)+100);
	$(name+" .itemsWrap").css("width",parentWidth);
	$(name+" .itemsWrap").css("height",parentHeight);
	$(name).css("width",parentWidth);
	$(name).css("height",parentHeight);
	$(name+" .itemsTitle").css("display",displayTitle);
	$(name+" .titleShort").css("display",displayTitleShort);
	$(name+" .itemsBody").css("display",displayBody);
	$(name+" .bodyShort").css("display",displayBodyShort);

}

function resizeThumbBlog(name, width1, height1, width2, height2, border) {
	var contentWidth = $("body").width();
	var ratio = 0;
	var baseRatio = 0;
	var linkWidth = 0;
	var linkHeight = 0;
	var imgWidth = 0;
	var childWidth = 0;
	var childHeight = 0;
	var parentWidth = 0;
	var parentHeight = 0;
	var displayBody = "";
	var displayBodyShort = "";
	var displayTitle = "";
	var displayTitleShort = "";
	var padding = 0;
	
	if (contentWidth <= 1200){
		if ($.browser.msie && $.browser.version <= 6) {
			ratio = 0.8;
		}
		else {
			ratio = 0.8;
		}
		baseRatio = 0.85;
		displayBody = "none"
		displayBodyShort = "block"
		displayTitle = "none";
		displayTitleShort = "block";
	} else if (contentWidth > 1200 && contentWidth <= 1400){
		ratio = 0.83;
		baseRatio = 0.9;
		displayBody = "none"
		displayBodyShort = "block"
		displayTitle = "none";
		displayTitleShort = "block";
	} else {
		ratio = 1;
		baseRatio = 1;
		displayBody = "block"
		displayBodyShort = "none"
		displayTitle = "block";
		displayTitleShort = "none";
	}
	if ($.browser.msie && $.browser.version <= 6) {
		border = 0;
		padding = 20;
	}
	linkWidth = Math.floor(width2*ratio)-border;
	linkHeight = Math.floor(height2*ratio)-border;
	childWidth = Math.floor(width2*ratio);
	childHeight = Math.floor(height2*ratio);
	parentWidth = Math.floor(width1+padding);
	parentHeight = Math.floor(height1*baseRatio);
	//imgWidth = Math.floor(parentWidth/3)-100;
	imgWidth = Math.floor(width2*ratio);
	
	$(name+" .itemsImg a img").css("width",imgWidth);
	$(name+" .itemsImg a").css("width",linkWidth);
	$(name+" .itemsImg a").css("height",linkHeight);
	$(name+" .itemsImg").css("width",childWidth);
	$(name+" .itemsImg").css("height",childHeight);
	$(name+" .itemsTitle").css("width",Math.floor(parentWidth/3)-childWidth-20);
	$(name+" .itemsEntryTitle").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .itemsBody").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .blackDotLine").css("width",Math.floor(parentWidth/3)-10);
	$(name+" .items").css("width",Math.floor(parentWidth/3));
	$(name+" .items").css("height",Math.floor((parentHeight-100)/2));
	$(name+" .thumbsWrap").css("width",parentWidth);
	$(name+" .thumbsWrap").css("height",parentHeight);
	$(name+" .itemsWrap").css("width",parentWidth);
	$(name+" .itemsWrap").css("height",parentHeight);
	$(name).css("width",parentWidth);
	$(name).css("height",parentHeight);
	$(name+" .itemsEntryTitle").css("display",displayTitle);
	$(name+" .titleShort").css("display",displayTitleShort);
	$(name+" .itemsBody").css("display",displayBody);
	$(name+" .bodyShort").css("display",displayBodyShort);

}

function SetResizeSnapPhoto(){
	ResizeImageSnap('#snap_l_photo', 485, 295);
}

function ResizeTopicsSub(name, max_width, min_width, new_width){
	if ($(name)) {
		$(name).each(function(){			
				if( new_width > max_width){
					new_width = max_width;
				}
				else if(new_width < min_width) {
					new_width = min_width;
				}
				
				$(this).width(new_width);
		});
	}												
}

function ResizeImageSnap(name, max_width, min_width){
	if ($(name)) {
		$(name).each(function(){
				var new_width = $('#contents').width() - 330;
				var new_padding = 0;
				
				if( new_width > max_width){
					new_width = max_width;
				}
				else if(new_width < min_width) {
					new_width = min_width;
				}
				
				$(this).height('auto').width(new_width);
				
				if( $('#snap_right').height() <= $('#snap_l_photo').height() + 6){
					new_padding = ($('#snap_l_photo').height() + 6) - $('#snap_right').height();
				}
				
				$('#snap_right').css('padding-bottom', new_padding + 5);
		});
	}												
}

function ResizeThumb(name, img_width, division){
	if ($(name)) {
		$(name).each(function(){
				var new_padding = Math.floor(($('#contents').width() - (img_width * division)) / (division  * 2));
				
				$(this).css('padding-left', new_padding);
				$(this).css('padding-right', new_padding);
		});
	}												
}

function ResizeThumbSnapList(name, img_width, division){
	if ($(name)) {
		$(name).each(function(){
				var new_padding = Math.floor(($('#contents').width() - (img_width * division) - 20) / (division - 1));
				
				$('#snapList').css('padding-left', 10);
				if( new_padding <= 0 ){
					$(this).css('padding-right', 2);
					if ($.browser.msie && $.browser.version <= 6) {
						$('#snapList').css('padding-left', 3);
					}
				}
				else {
					$(this).css('padding-right', new_padding);
				}
				$(".snapRight").css('padding-right', 0);
		});
	}												
}

function ResizeImage(name, max_width, max_height, min_width, min_height, length_ie){
	if ($(name)) {
		$(name).each(function(){
				var scaleW = getWindowWidth()/1400;
				var scaleH = getWindowHeight()/2000;
				var new_width = 0;
				var new_height = 0;
				
				if( scaleW >= scaleH ){
					new_width = Math.floor(max_width * scaleW);
					new_height = Math.floor(max_height * scaleW);
				}
				else {
					new_width = Math.floor(max_width * scaleH);
					new_height = Math.floor(max_height * scaleH);
				}
				
				if( new_width > max_width || new_height > max_height){
					new_width = max_width;
					new_height = max_height;
				}
				else if(new_width < min_width || new_height < min_height) {
					new_width = min_width;
					new_height = min_height;
				}
		
				if (length_ie && $.browser.msie && $.browser.version <= 6) {
					new_width = new_width + length_ie;
					new_height = new_height + length_ie;
				}
				
				if( max_height == 0 && min_height == 0 ){
					$(this).height('auto').width(new_width);
				}
				else {
					$(this).height(new_height).width(new_width);
				}
		});
	}												
}

function getWindowWidth(){
  if(window.innerWidth) return window.innerWidth; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientWidth){ // 以下 IE
   return document.documentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
   return document.body.clientWidth;
  }
  return 0;
}

function getWindowHeight(){
  if(window.innerHeight) return window.innerHeight; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientHeight){ // 以下 IE
   return document.documentElement.clientHeight;
  }
  else if(document.body && document.body.clientHeight){
   return document.body.clientHeight;
  }
  return 0;
}

function SetTracking(_url, _folder, _target){
  if (_target == 0) {
	  location.href=_url;
  }
  else {
	  var otherWin = window.open(_url);
		if (!$.browser.msie) {
			otherWin.focus();
		}
  }
  pageTracker._trackPageview(_folder);
}

function OpenMaxWindow(_url, _folder){
  maxWin = window.open(_url,'milk','toolbar=no,menubar=no,location=no,status=no,scrollbars=no,resizable=yes');
  maxWin.moveTo(0,0);
  maxWin.resizeTo(screen.availWidth,screen.availHeight);
  maxWin.focus();
  pageTracker._trackPageview(_folder);
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";
			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";
			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }
  document.write(str);
}
function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    
    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//検索用

var jquery_loader         = '/common/img/search_preloader.gif';
var json_search_data      = '/search_data.txt';
var json_search_keyword   = '';
var json_search_is_loaded = false;
var json_search_entries;
 
function json_search()
{
    json_search_keyword = $('input#searchTxt').val();
 
    $('#searchResult').html('')
                        .css('height', '100px')
                        .css('background', 'transparent url(' + jquery_loader + ') no-repeat center center');
 
    $('#contents').css('display', 'none');
 
    if (json_search_is_loaded)
    {
        json_search_archive();
    }
    else
    {
        $.ajax({url: json_search_data, type: 'GET', dataType: 'xml', timeout: 1500,
            error: function() {
                $('#searchResult').css('height', 'auto')
                                    .css('background-image', 'none')
                                    .html('エラーです。ページのリロードをして再度検索をしてください。');
            },
            complete: function(xml) {
                var data_string = xml.responseText;
 
                data_string = data_string.replace(new RegExp('<.*?>', "i"), '');
                json_search_entries = eval(data_string);
 
                json_search_archive();
 
                json_search_is_loaded = true;
            }
        });
    }
}
 
function json_search_archive()
{
    var result_data = new Array();
 
    json_search_keyword = json_search_keyword.replace(/([\/\\\.\*\+\?\|\(\)\[\]\{\}\$\^])/g, "\\$1");
    json_search_keyword = json_search_keyword.replace(/( +|　+)/, ' ');
    json_search_keyword = json_search_keyword.replace(/( |　)$/, '');
 
    var keywords = json_search_keyword.split(/ |　/);
    var key = new Array();

    for (var i = 0;i < keywords.length;i++)
    {
        key[key.length] = new RegExp(keywords[i], "i");
    }
 
    for (var i = 0;i < json_search_entries.length - 1;i++)
    {
        var is_match = true;
 
        for (var j = 0;j < key.length;j++)
        {
            var res_body = key[j].exec( json_search_entries[i].body );
            var res_title = key[j].exec( json_search_entries[i].title );
 
            if (!res_body && !res_title)
            {
                is_match = false;
            }
        }
 
        if (is_match)
        {
            result_data[result_data.length] = json_search_entries[i];
        }
    }
 
    var result_html = '';
 
    if (result_data.length == 0)
    {
        result_html = 'の検索結果：0件</p><p class="searchResultClose"><a class="imgbutton" href="javascript:void(0)" onclick="clear_block(\'#searchResult\')">検索結果を閉じる</a>';
    }
    else
    {
        result_html = json_search_result_html(result_data, keywords);
    }
		result_html = '<p id="searchResultTitle">『' + json_search_keyword + '』' + result_html + '</p>';
		result_html_h = '<div id="searchResultHeader">';
		result_html_h += '<ul id="searchResultTopicPath">';
		result_html_h += '<li><a href="/">Home </a></li>';
		result_html_h += '<li>&gt; Search</li>';
		result_html_h += '</ul>';
		result_html_h += '<h2 class="CaslonBold">Search</h2>';
		result_html_h += '</div>';
		result_html_h += '<div id="searchResultInner">';
		result_html = result_html_h + result_html + '</div>';
 
    $('#searchResult').css('height', 'auto')
                        .css('background-image', 'none')
                        .html(result_html);
}
 
function json_search_result_html(result_data, keywords)
{
    var html = 'の検索結果：' + result_data.length + '件</p><div class="searchResultList"><ul>';
 
    for (var i= 0;i < result_data.length;i++)
    {
        html += '<li class="blackDotLine"><p><span class="searchResultCategory">' + result_data[i].category + '</span><a href="' + result_data[i].link + '?search_word=' + json_search_keyword + '" target="_blank">' + result_data[i].title + '</a><span class="searchResultDate">' + result_data[i].date + '</span></p></li>';
    }
 
    html += '</ul></div><p class="searchResultClose"><a class="imgbutton" href="javascript:void(0)" onclick="clear_block(\'#searchResult\')">検索結果を閉じる</a>';
 
    return html;
}
 
function clear_block(blockid)
{
    $(blockid).html('');
    $('#contents').css('display', 'inherit');
}

jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++){
		jQuery("<img>").attr("src", arguments[i]);
	}
};
$.preloadImages("/img/top_magazine.jpg","/img/top_interview.jpg","/img/top_special.jpg","/img/top_gallery.jpg","/common/img/mag_cover_milk_fra.jpg","/common/img/mag_cover_milk_jpn.jpg","/img/banner_special.jpg","/img/banner_interview.jpg","/common/php/get_images.php?url=http://milkjapon.com/feature/banner/banner_feature.jpg");