jQuery(function($){

/*------------------------------------------------------------------------
   最新コンテンツの切E悗
------------------------------------------------------------------------*/
$(document).ready(function() {
if (typeof document.documentElement.style.maxHeight != "undefined") {
  if(navigator.userAgent.indexOf("MSIE") != -1) {
	$('#latestContents a').each(function() {
	  $(this).css({
		'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +
		$(this).attr('src') +
		'", sizingMethod="scale");'
	  });
	});
  }
 }

  $('#visual li').fadeTo(0 , 0).css('display' , 'none');
  $('#visual01').css('display' , 'block').fadeTo(200 , 1);
//マウスオーバーした時の動E
	$('#controller a').mouseover(function () {
	  //ビジュアE
	  var visualid = $(this).attr("rel");
	  $('#visual li:not(visualid)').css("z-index",0).stop().fadeTo(400 , 0).css('display' , 'none');
	  $(visualid).css('display' , 'block').css("z-index",10).stop().fadeTo(400 , 1);

	  //コント充ラー
	  $('#controller a').removeClass('current');
	  $(this).addClass('current');
	  //return false;
	});

});



//充テーショE
visualLength = 3;   //画E凌E
firstInt = 0;       //最初に表示すE菫E
changeSpeed = 5000; //画E鮴擇E悗┐Eさ

randomInt = firstInt + 1;

$(document).ready(function(){
	//マウスオーバーすE反値を置き換えE
	$('#controller01 a').mouseover(function () {
	  randomInt = 1;
	});
	$('#controller02 a').mouseover(function () {
	  randomInt = 2;
	});
	$('#controller03 a').mouseover(function () {
	  randomInt = 3;
	});

	//EE間毎にスクE廛箸鮓討喀个
	var t = setInterval(loadVisual, changeSpeed);
	
	//呼び出さEE好E廛
	function loadVisual(){
	  visualInt = "#visual0" + randomInt;
	  $('#visual li:not(visualid , :animated)').css("z-index",0).stop().fadeTo(400 , 0).hide();
	  $(visualInt).show().css("z-index",10).stop().fadeTo(400 , 1);

	  controllerInt = "#controller0" + randomInt + " a";
	  $('#controller a').removeClass('current');
	  $(controllerInt).addClass('current');

		if(randomInt < visualLength){
			randomInt = parseInt(randomInt) + 1;
		}
		else{
			randomInt = 1;
		}
	}
});


/*------------------------------------------------------------------------
   特集 ページ内E鵐
------------------------------------------------------------------------*/
$(document).ready(function(){
	$('#special .pageIndex li:nth-child(3n+2)').css("margin" , "0 5px");
});

/*------------------------------------------------------------------------
   スムーズスク充E
------------------------------------------------------------------------*/

jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
 
$(document).ready(function(){
	$('a[href*=#]').not('#controller a , #fontController a').click(function() {
		var $target = jQuery(this.hash);
		$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
		if ($target.length) {
			var targetOffset = $target.offset().top;
			jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
			return false;
		}
	});
});


/*------------------------------------------------------------------------
   ポップアップウィンドウ
------------------------------------------------------------------------*/
jQuery.fn.popupwindow = function(p) {

	var profiles = p || {};

	return this.each(function(index){
		var settings, parameters, mysettings, b, a, winObj;
		
		// for overrideing the default settings
		mysettings = (jQuery(this).attr("rel") || "").split(",");

		
		settings = {
			height:700, // sets the height in pixels of the window.
			width:900, // sets the width in pixels of the window.
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:1, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
			onUnload:null // function to call when the window is closed
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists

		if(mysettings.length == 1 && mysettings[0].split(":").length == 1)	{
			a = mysettings[0];
			// see if a profile has been defined
			if(typeof profiles[a] != "undefined") {
				settings = jQuery.extend(settings, profiles[a]);
			}
		}
		else {
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=0; i < mysettings.length; i++) {
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2) {
					settings[b[0]] = b[1];
				}
			}
		}

		// center the window
		if (settings.center == 1) {
			settings.top = (screen.height-(settings.height + 110))/2;
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		jQuery(this).bind("click", function() {
			var name = settings.createnew ? "PopUpWindow" + index : "PopUpWindow";
			winObj = window.open(this.href, name, parameters);
			
			if (settings.onUnload) {
				// Incremental check for window status
				// Attaching directly to window.onunlaod event causes invoke when document within window is reloaded
				// (i.e. an inner refresh)
				unloadInterval = setInterval(function() {
					if (!winObj || winObj.closed) {
						clearInterval(unloadInterval);	
						settings.onUnload.call($(this));
					}
				},500);
			}
			
			winObj.focus();
			
			return false;
		});
	});

};

var profiles = {
	windowA: { width:600 },
	windowB: { width:700 },
	windowC: { width:800 },
	windowD: { width:635 },
	windowE: { width:800 },
};
function unloadcallback() {
	alert("unloaded");
};
$(function() {
	$(".popupwindow").popupwindow(profiles);
});

});


/*------------------------------------------------------------------------
   Session詳細高さを揃えE
------------------------------------------------------------------------*/
function setEqualHeight(columns){
	var tallestcolumn = 0;
	columns.each(
	function(){
		currentHeight = $(this).height();
		if(currentHeight > tallestcolumn){
			tallestcolumn = currentHeight;
		}
	});
	columns.height(tallestcolumn);
}
$(document).ready(function() {
	setEqualHeight($(".lowerLayer .sessionList ul li, #home #latestSpecial li, #top #latestSpecial li, #otherList section"));
}); 


/*------------------------------------------------------------------------
   inline-blockのマージンを取E紛数）
------------------------------------------------------------------------*/
$(function() {
	$("#home #latestSpecial li:odd, #top #latestSpecial li:odd").css("margin-right","0");
});





