$(document).ready(function(){

	

	

	

	

	/***************************************

	 * object clone

	 ***************************************/

	$.cloneObject = function(source,isDeep) {

		if(isDeep){

			return $.extend(true,{},source);

		}

		return $.extend({},source);

	}	

	 

	/***************************************

	 * calusel slider

	 ***************************************/

	//var carouselInit = function(){

	var $stars = $('#carousel ul')

	var starsInnerDef = $('#carousel ul').html()

	var thumbWidth = 105 //$('#carousel ul li:first').outerWidth()

	var thumbDefX = 26 //$('.carousel_next a').outerWidth()

	var thumbPerPage = 9

	var thumbCnt = 0

	var thumbNow = 1

	var getPageNow = function /*get*/(){return Math.ceil(thumbNow/thumbPerPage)}

	var getPageMax = function /*get*/(){return Math.ceil(thumbCnt/thumbPerPage)}

	var getPageWidth = function /*get*/(){return thumbWidth*thumbPerPage}

	var caluselMotionFlg = false

	var eOpt = {

					duration: 452, easing: "easeInOutCubic",

					complete: function(){}

				}

	

	//// set stageWidth //////////////////////

	var fixWidth = function (){

		var tmpw = $('#carousel').width();

		$('#carousel ul li').each(function(i,elem){

			thumbCnt++

			if(i>=thumbPerPage)tmpw += thumbWidth;

		});

		$stars.css('width',tmpw)

	}

	

	fixWidth()

	$('.carousel_next a').attr('href','javascript:void(0);')

	$('.carousel_previous a').attr('href','javascript:void(0);')

	

	var thumbMin = 1

	var thumbMax = thumbCnt

	var thumbCntDef = thumbCnt

	

	//// Duplicate list data ///////////////////////////////

	$stars.append(starsInnerDef)

	fixWidth()

	

	//// <carousel thumbs label> position FIX ///////////////////////////

	$('.carousel_label').each(function(i,elem){

		$(elem).css('margin-left',-1*(15+($(elem).width())/2)+"px")

	});

	

	$('#carouselList > li > a').hover(function(e){

		$(e.target).find('.carousel_label').css({'zIndex':'3'});

	},function(e){

		$('#carouselList > li > a').find('.carousel_label').css({'zIndex':'2'});

	})

	

	//// fade ////

	if(!$.browser.msie){

		$('#carouselList li').each(function(i,elem){

			var $elm = $(elem)

			$elm.fadeInFlg = false;

			$elm.fadeOutFlg = false;

			$elm.find('.carousel_thumb_overlay').bind('mouseover',function(e){

				$elm.find('.carousel_label').css('opacity',0).animate({opacity:1},{duration:225,easing:"linear"});

			});

			$elm.find('.carousel_thumb_overlay').bind('mouseout',function(e){

				$elm.find('.carousel_label').css('display','block').animate({opacity:0},{duration:300,easing:"linear"});

			});

		})

	}

	

	//// SLIDE FUNCTION ///////////////////////////////

	var everyMotionCompleteFnc = function(){

		//console.log('thumbNow:'+thumbNow)

		//console.log('pageNow:'+getPageNow())

	}

	var slide1 = function(e,delta){

		//alert(e+","+delta)

		

		//if(typeof(delta) == "undefined") delta =0

		

		//NO SCROLL!

        if (e.preventDefault) {

                e.preventDefault();

        }

        e.returnValue = false;

        

		if(caluselMotionFlg)return;

		

		//>>

		if(delta<0 && thumbNow > thumbMax){

			//aftr++

			thumbNow -= thumbCntDef

			$stars.css({"left":$stars.position().left+thumbCntDef*thumbWidth})

			fixWidth()

			//$('#carouselList li:eq('+thumbNow-1+')').css

			//$('#carouselList li:eq()')

		}

		//<<

		if(delta>0 && thumbNow<=thumbMin){

			//before++

			thumbNow += thumbCntDef//thumbCntDef

			$stars.css({"left":$stars.position().left-thumbCntDef*thumbWidth})

			fixWidth()

		}

		

		

		var eop = $.cloneObject(eOpt);

		

		eop.complete = function(){thumbNow-=delta; caluselMotionFlg = false; everyMotionCompleteFnc()}

		$stars.animate(

			{left:$stars.position().left + delta*thumbWidth},eop)

		

		caluselMotionFlg = true;

		

	}

	

	//// NEXT ///////////////////////////////

	$('.carousel_next').bind('click',function(e){

		slide1(e,-1)

	})

	//// PREVIOUS ///////////////////////////////

	$('.carousel_previous').bind('click',function(e){

		slide1(e,1)

	})

	//// MOUSE SCROLL ///////////////////////////////	

	$('#carousel').bind('mousewheel',slide1)

	 

	 

	 //carouselInit();

	 

	

	/**

	 * set Homepage

	 ***************/

//	$('#set_browser_home').attr('href',document.location);//'javascript:void(0);');

//	document.body.style.behavior = 'url( #default#homepage )';

//	$('#set_browser_home').click(function(){document.body.setHomePage(document.location);})

	

	

	

	

	///// searchForm

	//$('#searchform').swapSelectForm()

	//$('#searchform').bind($.swapSelectForm.evt_selectComplete,function(){alert('aaa')})

	

	

	

	

	

	/************************************************************************

	* Flash pluginCheck And Image Splash

	************************************************************************/

	function slideSwitch(_mode){ //_mode/*:Number*/) {

		var _mode = 5

		var ss = $('#slideshow')

		,strWidth = ss.css('width')

		,strHeight = ss.css('height')

		,$active = $('#slideshow a.active')

		;

		if ( $active.length == 0 ) $active = $('#slideshow a:last');

		

		var mode = _mode ? _mode : Math.ceil(Math.random()*4);//4 //1 + Math.ceil(Math.random()*3); //1 nuki.

		

		/**/

		 //// need to whiteIn ////

		if(ss.find('.slideOverlay').length===0){

			$overlay = $('<div class="slideOverlay" />');

			$overlay.appendTo(ss)

			$overlay.css({width:strWidth,height:strHeight,opacity: 0.0});

		}else{

			$overlay = ss.find('.slideOverlay');

		}

		

		var $next =  $active.next().next().length ? $active.next() : $('#slideshow a:first');

		

		$active.addClass('last-active');

	

		$active.css({left: 0,top:0});

		$next.css({left: 0,top:0});

		

		switch(mode){

			/*case 1:

			//// [MODE] slideIn(axis:Horizontal[<]) ////

				var nx = Number(strWidth.match(/px/i) ? strWidth.substr(0,strWidth.indexOf("px")) : strWidth);

				$active.animate({left:-nx}

					,1600, "easeOutExpo");

				$next.css({left: nx})

					.addClass('active')

					.animate({left: 0}, 1600, "easeOutExpo", function() {

						$active.removeClass('active last-active');

					});

				$overlay.css({opacity: .92})

					.animate({opacity: 0.0}, 1000, "easeInQuad", function() {

					});

			break;

			case 2:

			//// [MODE] slideIn(axis:Horizontal[>]) ////

				var nx = Number(strWidth.match(/px/i) ? strWidth.substr(0,strWidth.indexOf("px")) : strWidth);

				$active.animate({left:nx}

					,1600, "easeOutExpo");

				$next.css({left: -nx})

					.addClass('active')

					.animate({left: 0}, 1600, "easeOutExpo", function() {

						$active.removeClass('active last-active');

					});

				$overlay.css({opacity: .92})

					.animate({opacity: 0.0}, 1000, "easeInQuad", function() {

					});

			break;

			case 3:

			//// [MODE] slideIn(axis:Vertical[downer]) ////

				var ny = Number(strHeight.match(/px/i) ? strHeight.substr(0,strHeight.indexOf("px")) : strHeight);

				$active.animate({top:35} //ny/7}

					,1500, "linear");

				$next.css({top: -30//1*ny/7.5

					, opacity: 0})

					.addClass('active')

					.animate({top: 0, opacity: 1}, 1500, "easeOutExpo", function() {

						$active.removeClass('active last-active');

					});

				$overlay.css({opacity: .92})

					.animate({opacity: 0.0}, 1000, "easeInQuad", function() {

					});

			break;

			case 4:

			//// [MODE] slideIn(axis:Vertical[upper]) ////

				var ny = Number(strHeight.match(/px/i) ? strHeight.substr(0,strHeight.indexOf("px")) : strHeight);

				$active.animate({top:-35}//ny/7

								,1500, "linear");

				$next.css({top: 30//1*ny/7.5

						  , opacity: 0})

					.addClass('active')

					.animate({top: 0, opacity: 1}, 1500, "easeOutExpo", function() {

						$active.removeClass('active last-active');

					});

				$overlay.css({opacity: .92})

					.animate({opacity: 0.0}, 1000, "easeInQuad", function() {

					});

			

			break;*/

			default:

			//// [MODE] alphaIn ////

				$next.css({opacity: 0.0})

					.addClass('active')

					.animate({opacity: 1.0}, 1670, "linear", function() {

						$active.removeClass('active last-active');

					});

			//// [MODE] whiteIn ////

				/*$overlay.css({opacity: 1.0})

					.animate({opacity: 0.0}, 1000, "linear", function() {

					});

				$next.css({opacity: 1.0}).addClass('active');

				$active.removeClass('active last-active');*/

		}

		

	}

	

	if(chkFlaVer() == 0){

		//alert("NO FLASH!")

		//var hero = $("#hero_module")

		//var imgLnks = []

		//var $slideShow = $('<div id="slideshow" />').append(

		//	imgLnks[0] = '<a href="http://www.disney.co.jp/toystory/" title="" class="active nth-child1"><span class="title">トイ・ストーリー  3</span><span class="description">ウッディは、少年アンディの子供部屋で暮らすカウボーイ人形。</span></a>',

		//	imgLnks[1] = '<a href="#" title="" class="nth-child2"><span class="title">タイトルタイトルタイトルタイトルタイトル</span><span class="description">ディスクリプションディスクリプションディスクリプションディスクリプション</span></a>',

		//	imgLnks[2] = '<a href="#" title="" class="nth-child3"><span class="title">タイトルタイトルタイトルタイトルタイトル</span><span class="description">ディスクリプションディスクリプションディスクリプションディスクリプション</span></a>',

		//	imgLnks[3] = '<a href="#" title="" class="nth-child4"><span class="title">タイトルタイトルタイトルタイトルタイトル</span><span class="description">ディスクリプションディスクリプションディスクリプションディスクリプション</span></a>'

		//)

		//hero.append($slideShow)

		var $slideShow = $('#slideshow')

		$slideShow.css("display","block");

	

		//switching contentHeaderImage

		setInterval( slideSwitch, 5000 );

	}else{

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	//embeds movie player.

	var flashvars = {

		confPath: "../../content/player/playlist_xml_feed_hp_100907.xml"	//path from swf.

	}

	,params = {

		play: "true",

		loop: "false",

		menu: "false",

		quality: "best",

		scale: "noscale",

		salign: "lt",

		wmode: "transparent",

		base: "res710/images/module/player/"

	}

	,attributes = { };

	swfobject.embedSWF("res710/images/module/player/preloader_v3.swf", "hero_module", "990px", "342px", "10", "res710/images/module/common/expressInstall.swf", flashvars, params, attributes);

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	}

	

});

//var slideSwitch
