(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz;})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret;};})(name,prop[name]):prop[name];}
function Class(){if(!initializing&&this.init)
this.init.apply(this,arguments);}
Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class;};})();
//<-- Class Initialize.20110331

var
bindClick,
$playlist, 
void0='javascript:void(0);',
gClasses = {},
hmc = {},
spAgent={},
escapeHTML = function(str) {
  return str.replace(/[&"<>]/g, function(c) {
    return {
      "&": "&amp;",
      '"': "&quot;",
      "<": "&lt;",
      ">": "&gt;"
    }[c];
  });
}


//smartphone USER AGENT
spAgent.iPhone = navigator.userAgent.match(/iPhone/i);
spAgent.iPad = navigator.userAgent.match(/iPad/i);
bindClick = (spAgent.iPhone || spAgent.iPad) ? 'touchend':'click';

//4 chk on PC browsers.
bindClick = 'click';

//test - ALL UA is iphone
//spAgent.iPhone = true;


/////// ShareBtns ////////

(function($){
		  
	var 

	//// Properties ////////////////////////////
	methods,
	elem, //this
	targs,
	conf,
	def,
	trackFncs = new Array(),
	trackCpFnc = function(){}, // < public metod
	trackCodes = ['mail','twitter','mixi','fb','ybook','ameba','goo','hatena'],
	
	//// DOM ////////////////////////////
	$close,
	$inner,
	$hmc, //target category player
	$fbMetaTags,
	fd = false,
	
	//Methods
	toString,
	
	//// Shortcuts ////////////////////////////
	void0 = 'javascript:void(0);',
	
	//Events
	//$('selector').bind(evt_**,function(){}); //append evt
	//$.event.trigger(evt_**); //dispatch evt
	evt_="evt_"
	
	;
	////DefaultParamatorz ////////////////////////////
	def = {
		id:0,
		name:"relTabWindow"
	};
	
	//// Constractor ////////////////////////////
	$.fn.relTabWindow = function (options, custom_callback) {
		
		if (this.length) {
			this.each(function () {
				var data = $(this).data(toString()) ? $.extend({},
					$(this).data(toString()), options) : $.extend({}, def, options);
				$(this).data(toString(), data).addClass(toString()+"_element");
			});
		} else {
			$(this).data(toString(), $.extend({}, def, options));
		}
		
		elem = this;
		conf = $(elem).data(toString());
		targs[conf.id] = elem
		
		$close = $('<a class="hmcClose" href="javascript:void(0);">×</a>')
		$inner = $('<div></div>')
		
		
		switch(conf.id){///write Inners
			case 1:
				$inner.append('<div class="embUrl cfx">'
+'<input id="hmcEmbInput" name="hmcEmbInput" readonly="readonly" value="" />'
+''
+'<object width="60" height="18" id="embCopybtn">'
+'	<param name="movie" value="../res710/images/module/player-category/copyclip.swf?inputId=hmcEmbInput" />'
+'	<param name="allowScriptAccess" value="true" />'
+'	<param name="wmode" value="transparent" />'
+'	<embed src="../res710/images/module/player-category/copyclip.swf?inputId=hmcEmbInput" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" width="60" height="18"></embed>'
+'</object>'
+'</div>')
				//$inner.find('.embCopybtn').click(function(e){setClipboard($(this).parent().find('input').attr('value'))})
			break;
			case 2:
				$inner.append('<ul id="hmcShaBtns" class="shaBtns">'
+'	<li class="nth-child1"><a href="">メール</a></li>' // type="custom" onclick="cto.tracklink(this)" は下にて。
+'	<li class="nth-child2"><a href="">Twitter</a></li>'
+'	<li class="nth-child3"><a href="">mixi</a></li>'
+'	<li class="nth-child4"><a href="">facebook</a></li>'
+'	<li class="nth-child5"><a href="">Yahoo!ブックマーク</a></li>'
+'	<li class="nth-child6"><a href="">Ameba</a></li>'
+'	<li class="nth-child7"><a href="">gooブログ</a></li>'
+'	<li class="nth-child8"><a href="">はてなブックマーク</a></li>'
+'</ul>'
+'<p class="shaCautiontxt">各ソーシャルメディアサイトは、13歳以上の方がご利用になれます。ここから先のページは、Disney.jpサイト外のページです。リンク先のウェブサイトのご利用にあたっては、各ウェブサイトのご利用条件、個人情報保護方針等をご確認ください。リンクをクリックするとリンク先へ移動します。</p>')
				
			break;
		}
		
		$hmc = $('#hero_module_category')
		$hmc.css('-moz-outline','none')	//hide Focus-Rect-Border(dotted) on FireFox.
		//$('body').prepend(elem.append($close).css('z-index',1500 + conf.id))
		
		elem.append($close).css('z-index',1500 + conf.id)
		
		/* iPadのみ配置がずれるため、elemの親を変更。this.open内177行目辺りも変更が必要です。
		if(spAgent.iPad){
			$hmc.after(elem)
		}else{*/
			//elements insert to body except iphone/ipad
			$('body').prepend(elem)
		//}
		
		elem.append($inner);
		
		//events
		$close.bind("click",this,close)
		
		return this;
	};
	
	//// make static Elements at once. ////////////////////////////
	var init = function () {
		// jQuery object generator to save a bit of space
		function $div(n) {
			return $('<div id="' + toString() + '_' + n + '"/>');
		}
		
		targs = []

	},
	
	toString = function(){
		return 'relTabWindow';
	},
	
	open = function(i,title,videoId,relatedVideo,offsetTop){
		/*console.log('open - '+i+':')
		console.log(targs[i])
		console.log(title)
		console.log(videoId)
		console.log(relatedVideo)*/
		
		var strDD = "ディズニー動画"
		,strDDurl = "http://video.disney.co.jp"
		,$item
		;
		
		$playlist.find('playlist > item').each(function(i,elm){
			if($(elm).find('share > movieId').text() == videoId){
				$item = $(elm);
			}
		});
		//$.log(videoId);
		//$.log($item)
		
		var trackingPrefix = $playlist.find('config > tracking > version').text() + '_' + $playlist.find('config > tracking > category').text() + '_'
		,placementCode = $item.find('trackingSub > placementcode').text()
		;
		
		//$.log(trackingPrefix+placementCode)
		
		//$hmc = $('#hero_module_category');
		
		if(!offsetTop)offsetTop = 375;
		
		/*
		if(spAgent.iPad){
			targs[i].css({
				'display':'block',
				//'top':'358px'
				'left':'2px',
				'top':'350px'
			})
			
		}else{*/
			targs[i].css({
				'display':'block',
				'top':String($hmc.offset().top+offsetTop)+'px',
				'left':String($hmc.offset().left)+'px'
			})
		//}
		
		if (!fd) {
			$(window).resize(function(){
				if (typeof($hmc) != "object") 
					return;
				for (var n in targs) {
					targs[n].css({
						'top': String($hmc.offset().top + offsetTop) + 'px',
						'left': String($hmc.offset().left) + 'px'
					})
				}
			});
			fd = true
		}
		switch(i){
			
			case 1:
				/*var embedVideoPath = "http://video.disney.co.jp/*******.swf?vid="+videoId;
				
				$('#hmcEmbInput').attr('value','<object width="480" height="385"><param name="movie" value="'+embedVideoPath+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+embedVideoPath+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>')*/
				var embedsrc = 'http://video.disney.co.jp/share/html/'+videoId+'.js';
				$('#hmcEmbInput').attr('value','<script type="text/javascript" src="'+embedsrc+'"></script>');
				
				var $dmy = $('<a href="'+embedsrc+'" type="custom" name="'+trackingPrefix+placementCode+'-embedcode" target=""></a>');
				
				//if(typeof trackCpFnc == 'function')
				//$('#embCopybtn').unbind('click',this.trackCpFnc)
				
				//[fla]ExternalInterface.call [js]hmc.$w1.relTabWindow.trackCpFnc() @ copyBrn.swf on click event.
				methods.trackCpFnc = $.scope(this,function(){
					
					//tracking from flash
					//$hmc.get(0).hmcCallAccessTrack(embedsrc,'embedcode',false);
					
					//tracking from js
					//alert("Q")
					cto.tracklink($dmy.get(0));
					$.log('send Tracking-data : name = '+$dmy.get(0).name)
					
				});
				
				//$('#embCopybtn').bind('click',this.trackCpFnc)
				//$('#embCopybtn').parent().bind('click', function(){$.log(hmc.$w1.relTabWindow.trackCpFnc); hmc.$w1.relTabWindow.trackCpFnc();})
				
				//if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)){
				if(spAgent.iPhone || spAgent.iPad){
					//unset readonly, Focus to input area.
					$('#hmcEmbInput')
						.width(455)
						.attr('readonly','')
						.focus().get(0).select()
						;
				}
				
				break;
			
			case 2:
				var	strTitle = encodeURIComponent(title+' - '+strDD),
					strVPath = "http://video.disney.co.jp/"+videoId+".html",//relatedVideo
					mixiChKey = '24c934d83bff6793071aa6115d2927dff53d3f9d';
				var lnks = [
					//MailTo
					/****** *Must have "ecl.js"! ******/
					//**----------------------------vvv modified next 2 line a+ 100928 vvv------------------------------------**/
					//'mailto:?subject='+ EscapeSJIS(strTitle) +'&body='+EscapeSJIS('この動画おすすめ！\n'+title+'\n'+strVPath+'\n\n'+strDD+'\n'+strDDurl),
					'mailto:?subject='+ EscapeSJIS(title+' - '+strDD) +'&body='+EscapeSJIS('この動画おすすめ！\n'+title+'\n'+strVPath+'\n\n'+strDD+' Disney Video\n'+strDDurl),
					//Twitter
					'http://twitter.com/home?status='+strTitle+' | '+strVPath,
					//mixi
					/////'http://mixi.jp/add_diary.pl?diary_title='+strTitle+'&diary_body='+strVPath,
					////http://mixi.jp/share.pl?u=http://video.disney.co.jp/forDisney/shareTemplate/sample_ogp.html&k=24c934d83bff6793071aa6115d2927dff53d3f9d
					'http://mixi.jp/share.pl?u='+strVPath+'&k='+mixiChKey,
					//Facebook
					////http://www.facebook.com/sharer.php?u=http://video.disney.co.jp/forDisney/shareTemplate/sample_ogp.html&t=アリス・インワンダーランド
					'http://www.facebook.com/sharer.php?u='+strVPath+'&t='+strTitle,
					//Yahoo
					'http://bookmarks.yahoo.co.jp/action/bookmark?t='+strTitle+'&u='+strVPath,
					//Ameba
					'http://blog.ameba.jp/ucs/entry/srventryinsertinput.do?entry_title=&entry_text='+encodeURIComponent('この動画おすすめ！\n\n<a href="'+strVPath+'" target="_blank">'+title+'</a>\n\n\n<a href="'+strDDurl+'" target="_blank">'+strDD+'</a>')+'&editor_flg=1',
					//Goo
					/////'http://blog.goo.ne.jp/admin/newentry/?fid=bookmarklet&title='+strTitle+'&burl='+strVPath,
					'http://blog.goo.ne.jp/portal_login/blogparts/?&key='+videoId+'&title='+strTitle+'&type=disneym',
					//Hatena
					///// 'http://b.hatena.ne.jp/add?mode=confirm&title='+strTitle+'&url='+strVPath
					'http://b.hatena.ne.jp/entry/add/'+strVPath
				]
				
				//other text encode for iphone.
				//if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)){
				if(spAgent.iPhone || spAgent.iPad){
					lnks[0] = 'mailto:?subject='+ encodeURIComponent(title+' - '+strDD) +'&body='+encodeURIComponent('この動画おすすめ！\n'+title+'\n'+strVPath+'\n\n'+strDD+' Disney Video\n'+strDDurl);
				}
				
				
				//// append | swap MetaTags 4 Facebook!
				/*if(typeof $fbMetaTags != "undefined") $fbMetaTags.remove();
				$fbMetaTags = $('<meta property="og:title" content="'+title+' - '+strDD+'"/>'
					+'<meta property="og:type" content="movie"/>'
					+'<meta property="og:url" content="'+strVPath+'"/>'
					+'<meta property="og:image" content="'+strVPath+'thumb***.jpg"/>'
					+'<meta property="og:description" content="'+'"/>')
				$('head').append($fbMetaTags);
				*/
				
				var names = [
					trackingPrefix+placementCode+'-mail',
					trackingPrefix+placementCode+'-twitter',
					trackingPrefix+placementCode+'-mixi',
					trackingPrefix+placementCode+'-fb',
					trackingPrefix+placementCode+'-ybook',
					trackingPrefix+placementCode+'-ameba',
					trackingPrefix+placementCode+'-goo',
					trackingPrefix+placementCode+'-hatena'
				]
				
				//write & trackEvents
				$('#hmcShaBtns').find("li > a").each(function(idx,t){
					if(trackFncs.length && typeof trackFncs[idx]=='function') $(t).unbind('click',trackFncs[idx]);
					
					trackFncs[idx] = $.scope(this,function(){
						//alert(trackCodes[idx]+'\n'+lnks[idx]);
						
						////********** tracking from flash **********////
						//$hmc.get(0).hmcCallAccessTrack(lnks[idx],trackCodes[idx],false);
						
						////********** tracking from js **********////
						cto.tracklink(t);
						$.log('send Tracking-data : name = '+t.name)
						
					});
					//$(t).attr('href',lnks[idx]).attr('target','_blank')
					$(t).attr('href',lnks[idx])
						.attr('target','_blank')
						.attr('type','custom')
						.attr('name',names[idx])
						.bind('click',trackFncs[idx])
					;
				});
				
				break;
		}
	},
	close = function(i){
		//console.log('close - '+i+':')
		if(typeof(i) != "number"){
			if($(this).parent().get(0).id.search(/[0-9]+$/g) != -1){
			i = parseInt($(this).parent().get(0).id.match(/[0-9]+$/g));
			}else{ console.log('not found tabwindow-ID. when close the tabwindow.');return; }
		}
		
		//$(this).parent()
		targs[i].css('display','none')
		$hmc = $('#hero_module_category')
		
		//call flash method.
		try{$hmc.get(0).hmcCloseAllRelTabs();}catch(e){};
		try{$('#hm_btn_share_bg').width(0);$('#hm_btn_embeds_bg').width(0);}catch(e){};
	};
	
		
	//// Create Public Methods ////////////////////////////
	methods = $.fn.relTabWindow;
	methods.toString = toString;
	methods.init = init;
	methods.close = close;
	methods.open = open;
	methods.conf = conf;
	methods.trackCpFnc = trackCpFnc;
	
	//// Initialize when the DOM has loaded ////////////////////////////
	$(function () {
		init();
	});

}(jQuery));








$j(document).ready(function($){
	
	
	
	
	/***************************************
	 * scope
	 ***************************************/
	$.scope = function(target,func){ return function() { func.apply(target,arguments);}};
	$.log = function(t){try{console.log(t);}catch(e){}};
	
	/***************************************
	 * object clone
	 ***************************************/
	$.cloneObject = function(source,isDeep) {
		if(isDeep){
			return $.extend(true,{},source);
		}
		return $.extend({},source);
	}

	/// arg.fnc variables.
	var vView,vControl,plist;
	
	
	/***************************************
	 * Class::VideoView
	 ***************************************/
	gClasses.VideoView = Class.extend({
		carouselId :'',
		$stars : null,
		thumbWidth : 0,
		thumbDefX : 0,
		thumbPerPage : 6,
		thumbCnt : 0,
		thumbNow : 0,
		getPageNow : function /*get*/(){return Math.floor(this.thumbNow/this.thumbPerPage)},
		getPageMax : function /*get*/(){return Math.ceil(this.thumbCnt/this.thumbPerPage)},
		getPageWidth : function /*get*/(){return this.thumbWidth*this.thumbPerPage},
		tmpw : 0,
		caluselMotionFlg : false,
		
		eOpt : {
			'duration':660,
			'easing':'easeOutCubic',
			'complete':function(){}
		},
		
		everyMotionCompleteFnc : function(){
			this.caluselMotionFlg = false;
		},
		
		//// set stageWidth //////////////////////
		fixWidth : function (){
			var tmpw = $('#'+this.carouselId).width();
			$('#'+this.carouselId + ' ul li').each($.scope(this,function(i,elem){
				this.thumbCnt++
				if(i>=this.thumbPerPage)tmpw += this.thumbWidth;
			}));
			this.$stars.css('width',tmpw)
		},
		
		gotoIndex : function(idx){
			if(this.caluselMotionFlg)return;
			var eop = $.cloneObject(this.eOpt);
			eop.duration = 390;
			
			eop.complete = $.scope(this,function(){
				this.thumbNow=idx;
				this.caluselMotionFlg = false;
				this.everyMotionCompleteFnc()
			});
			this.$stars.animate(
				{left:-idx*this.thumbWidth},eop
			);
				
			this.caluselMotionFlg = true;
		},
		gotoPage : function(pageNext){
			if(this.caluselMotionFlg)return;
			
			var nPage = this.getPageNow();
			var surplus = this.thumbNow - nPage*this.thumbPerPage;
			var pageDiff = (surplus != 0 && pageNext - nPage <= 0) ? 0 : pageNext - nPage;
			var eop = $.cloneObject(this.eOpt);
			
			
			//this.thumbNow += pageDiff*this.thumbPerPage;
			this.thumbNow += pageDiff*this.thumbPerPage - surplus;
			
			if(this.thumbNow<0){this.thumbNow = ((this.getPageMax()-1)*this.thumbPerPage)}
			else if(this.thumbNow/this.thumbPerPage>=this.getPageMax()){this.thumbNow = 0};
			
			eop.complete = $.scope(this,function(){this.everyMotionCompleteFnc()});
			var xp = this.thumbDefX - this.getPageWidth()*(this.getPageNow());;
			
			//console.log("現在"+nPage+"ページ(+"+surplus+"thumb)です。"+pageNext+"ページに移動を試みます。\nページ差分："+pageDiff+"\n移動left : "+xp+" nextThumbIndex:"+this.thumbNow)
			
			this.$stars.animate( {"left":xp},eop);
			//pageNext
			this.caluselMotionFlg = true;
		},
		
		/// Events
		
		eNextClick : function(e){this.gotoPage(this.getPageNow()+1); e.preventDefault();},
		ePreviousClick : function(e){this.gotoPage(this.getPageNow()-1); e.preventDefault();},
		eMouseScroll : function(e,delta){
			//alert(e+","+delta)
			
			//NO SCROLL!
			if(e){
				if (e.preventDefault) {
					e.preventDefault();
				}
				e.returnValue = false;
			}
			
			if(this.caluselMotionFlg)return;
			
			//>>
			if((delta<0 && this.thumbNow >= this.thumbCnt-1 ) ||
			//<<
			(delta>0 && this.thumbNow<=0)) return;
			
			delta = delta>0 ? 1:-1;
			
			var eop = $.cloneObject(this.eOpt);
			eop.duration = 200;
			
			eop.complete = $.scope(this,function(){
				this.thumbNow-=delta;
				this.caluselMotionFlg = false;
				this.everyMotionCompleteFnc()
			});
			this.$stars.animate(
				{left:this.$stars.position().left+delta*this.thumbWidth},eop
			);
				
			this.caluselMotionFlg = true;
		},
		
		select : function(id){
			if(this.getPageMax()>1 && ((this.getPageNow()*this.thumbPerPage)-1 > id || (this.getPageNow()-1)*this.thumbPerPage < id) ){
				//スクロール可で選択idがインデックス外であるとき（自動送りのとき）、ページを自動スクロール
				this.gotoPage(Math.floor(id/this.thumbPerPage));
			}
			this.$stars.find('li > a').removeClass('now');
			this.$stars.find('li:eq('+id+') > a').addClass('now');
			//thumbs fit to left.
			//if(this.thumbNow -id != 0)this.gotoIndex(id);
		},
		
		/// Constractor
		init:function(targetId,playlist){
			
			
			var carouselId = 'hm_carousel';
			var carListId = 'hm_carList';
			
			$('#'+targetId).html('<div id="hm_video">'
+'				</div>'
+'				<div id="hm_info_wrapper">'
+'					<div id="hm_info">'
+'						<h4 id="hm_title"></h4>'
+'						<p id="hm_description"></p>'
+'						<ul id="hm_relbtns" class="cfx">'
+'						</ul>'
+'					</div>'
+'					<div id="hm_sharebtns">'
+'						<span id="hm_btn_share_bg"></span>'
+'						<span id="hm_btn_embeds_bg"></span>'
+'						<ul id="hm_sharebtns" class="cfx clearfloat">'
+'							<li class="hm_btn_share"><a href="#">シェアする</a></li>'
+'							<li class="hm_btn_embeds"><a href="#">埋め込みコード</a></li>'
+'							<li class="hm_btn_related"><a href="#">関連動画を見る</a></li>'
+'						</ul>'
+'					</div>'
+'					<div id="'+carouselId+'" class="clearfloat">'
+'						<div id="hm_carousel_previous"><a href="#">&laquo;</a></div>'
+'						<div id="hm_carList_wrapper">'
+'							<ul id="'+carListId+'"></ul>'
+'						</div>'
+'						<div id="hm_carousel_next"><a href="#">&raquo;</a></div>'
+'					</div>'
+'				</div>');
			
			
			//// make thumbs
			playlist.find('item > core > thumbnailImage').each(function(n,o){
				$('#'+carListId).append('<li><a href="'+void0+'"><img src="'+$(o).attr('url')+'" alt="" /></a></li>');
			});
			
			this.carouselId = carouselId;
			this.$stars = $('#'+this.carouselId + ' ul').css('position','absolute');
			this.thumbWidth = $('#'+this.carouselId + ' ul li:first').outerWidth();
			this.thumbDefX = 0;//$('#'+this.carouselId + '_previous a').outerWidth();
			//this.tmpw = $('#'+this.carouselId + '').width()
			this.fixWidth();
			this.enables = this.thumbCnt > this.thumbPerPage;
			
			//サムネイルがはみ出さない場合、スクロールしない
			if(!this.enables){
				$('#'+carouselId + '_previous a').attr('href',void0).addClass('off').bind(bindClick,function(e){return false;});
				$('#'+carouselId + '_next a').attr('href',void0).addClass('off').bind(bindClick,function(e){return false;});
				//console.log('videoのカルーセルをスクロールさせない thumbCnt:'+this.thumbCnt);
				return;
			}
			
			$('#'+carouselId + '_next a').attr('href',void0).bind(bindClick,$.scope(this,this.eNextClick));
			$('#'+carouselId + '_previous a').attr('href',void0).bind(bindClick,$.scope(this,this.ePreviousClick));
			$('#'+carouselId).bind("mousewheel",$.scope(this,this.eMouseScroll));
		}
	});
	
	
	/***************************************
	 * Class::VideoController
	 ***************************************/
	gClasses.VideoController = Class.extend({
		dat : null,
		now : 0,
		carousel : null,
		tracking: {},
		sharebtnEvFnc:[],
		
		
		/// Constractor
		init : function(playlist_xml_parsed_by_jquery, carousel){
			this.dat = playlist_xml_parsed_by_jquery;
			this.carousel = carousel;
			this.reflesh(0);
			this.carousel.$stars.find('li > a').each($.scope(this,function(n,o){
				$(o).bind(bindClick,$.scope(this,function(e){
					e.preventDefault();
					this.reflesh(n);
				}));
			}));
			
		},
		
		///// video周りの表示を更新します。
		reflesh : function(id){
			
			
			//videoインデックスのはみ出し禁止
			if(id>=this.dat.find('item').length || id<0) id = 0;
			//console.log(id)
			
			var item = this.dat.find('item:eq('+id+')')
			,trackingPrefix = this.dat.find('config > tracking > version').text() + '_' + this.dat.find('config > tracking > category').text() + '_'
			,placementCode = item.find('trackingSub > placementcode').text()
			;
			
			this.now = id;
			
			this.carousel.select(id);
			
			//表示の初期化
			$('#hm_video').html('');
			$('#hm_relbtns').html('');
			hmc.$w1.relTabWindow.close(1)
			hmc.$w2.relTabWindow.close(2)
			
			$('#hm_title').text(item.find('copy > displayName').text())
			$('#hm_description').html(item.find('copy > description').text())
				
			item.find('relatedLinks > link').each($.scope(this,function(n,o){
				$('#hm_relbtns').append('<li><a href="'+$(o).attr('url')+'" target="'+$(o).attr('target')+'" name="'+trackingPrefix+placementCode+'-link'+(n+1)+'" type="custom" onclick="cto.tracklink(this)"><span class="btntick"></span><span class="btntext">'+$(o).attr('title')+'</span><span class="btnright"></span></a></li>');
			}));
			
			/// videoタグ
			var visEnabled,visJpOnly, //vdat = item.find('video'),
			vurl = item.find('stream').attr('url'),
			caution = '<div class="caution">この動画はipad/iphoneでご覧頂くことはできません。</div>';
			
			
			visJpOnly = (/\/\/cp96449\.edgefcs\.net\/ondemand\//).test(vurl);
			visEnabled = (/\/\/cp91605\.edgefcs\.net\/ondemand\//).test(vurl);
			vurl = visJpOnly ? null : 'http://progressivevideo.disney.co.jp/' + vurl.substr(vurl.indexOf('/ondemand/')+10);
			
			//$.log('video url : '+vurl+'\nis JP only? : '+visJpOnly);
			
			if(!visEnabled || !vurl){
				//NG
				$('#hm_video').append(caution)
				return false;
			}else{
				//OK
				//$('#hm_video').append('<video poster="'+vdat.attr('poster')+'" src="'+vdat.attr('src')+'" preload="auto" controls="controls"><source src="'+vdat.attr('src')+'" type=\''+vdat.attr('type')+'\' /></video>');
				$('#hm_video').append('<video src="'+vurl+'" preload="auto" controls="controls"><source src="'+vurl+'" /></video>')
			}
			
			
			
			///////////// videoイベント+（トラッキング） /////////////
			
			var $video =$('#hm_video video');
			
			//トラッキング初期設定
			if(!this.tracking.trackPath){
				this.tracking.trackPath = "vid:"
					+ this.dat.find('config > tracking > version').text() + '/'
					+ this.dat.find('config > tracking > category').text() + '/';
				this.tracking.movieId = this.dat.find('config > tracking > movieID').text();
			}
				
			$video.data('firstDetect',true);
			this.tracking.mediaFileName =  vurl.substr(vurl.lastIndexOf("/")+1);
			this.tracking.mediaName =  this.tracking.trackPath + this.tracking.mediaFileName;
			
			$video.bind('ended',$.scope(this,function(e){
				//console.log('movie再生終了！次の動画にインデックスを移動します。 now:'+this.now)
				cto.MediaClose(this.tracking.mediaName);
				this.reflesh(this.now+1);
			})).bind('error',$.scope(this,function(e){
				//再生不能
				$('#hm_video').append(caution);
			}));
			
			$video.bind('durationchange',$.scope(this,function(e){
				if($video.data('firstDetect')==true){
					/// Openは初回のみ。
					//$.log(this.tracking.mediaName+'\n'+e.target.duration+'\n'+this.tracking.movieId)
					cto.MediaOpen(this.tracking.mediaName, e.target.duration, this.tracking.movieId);
					$video.data('firstDetect',false);
				}
				this.tracking.duration = e.target.duration;
				//$.log('-------------------- video.durationchange --------------------');
				//$.log('duration : '+e.target.duration);
				//$.log('currentTime : '+e.target.currentTime);
			}));
			
			$video.bind('play',$.scope(this,function(e){
				$.log('-------------------- video.play --------------------');
				//$.log('currentTime : '+e.target.currentTime);
				//digMediaPlay(mediaName, mediaOffset, contentType, propertyName)
				$video.data('isPlaying',true);
				cto.MediaPlay(this.tracking.mediaName, e.target.currentTime);
			}));
			
			//seeked・seekingイベントはiphoneのsafariでは発生しない。
			$video.bind('seeking',$.scope(this,function(e){
				$.log('-------------------- video.seek... --------------------');
				//$.log('currentTime : '+e.target.currentTime);
			}));
			
			$video.bind('pause',$.scope(this,function(e){
				$.log('-------------------- video.pause --------------------');
				//$.log('currentTime : '+e.target.currentTime);
				//digMediaPlay(mediaName, mediaOffset, contentType);
				$video.data('isPlaying',false);
				cto.MediaStop(this.tracking.mediaName, e.target.currentTime);
			}));
			
			//ページ推移イベントはunbindする
			/* ページ推移のイベントも取れない。
			if(this.tracking.beforeUnloadFnc){
				$(window).unbind('beforeunload',this.tracking.beforeUnloadFnc);
			}
			
			this.tracking.beforeUnloadFnc = $.scope(this, function(e){
				if($video.data('isPlaying')==true){
					cto.MediaStop(this.tracking.mediaName, $video.get(0).currentTime);
				}
				//alert('ページ推移します'+$video.get(0).currentTime)
				cto.MediaClose(this.tracking.mediaName);
			});
			
			$(window).bind('beforeunload',this.tracking.beforeUnloadFnc);
			*/
			
			///////////// シェアボタンイベント /////////////
			
			$('.hm_btn_related a')
			

			if(this.sharebtnEvFnc.length){
				$('.hm_btn_embeds a').unbind(bindClick,this.sharebtnEvFnc[0]);
				$('.hm_btn_share a').unbind(bindClick,this.sharebtnEvFnc[1]);
				$('.hm_btn_related a').unbind(bindClick,this.sharebtnEvFnc[2]);
			}
			
			//movieIdなどが無くてボタンが不要な場合、消す
			if(!item.find('share > movieId').text()){
				$('.hm_btn_embeds').hide()//.css('visibility','hidden')
				$('.hm_btn_share').hide()//.css('visibility','hidden')
			} else {
				$('.hm_btn_embeds').show()//.css('visibility','visible')
				$('.hm_btn_share').show()//.css('visibility','visible')
			}
			if(!item.find('share > relatedVideo').text()){
				$('.hm_btn_related').css('visibility','hidden')
			} else {
				$('.hm_btn_related').css('visibility','visible')
			}
			
			this.sharebtnEvFnc = 
			[
				$.scope(this,function(e){
					//e.preventDefault();
					hmc.$w2.relTabWindow.close(2);
					hmc.$w1.relTabWindow.open(1,
						item.find('copy > displayName').text(),
						item.find('share > movieId').text(),
						item.find('share > relatedVideo').text(),
						$('#hm_carousel').position().top-2
					)
					$('#hm_btn_embeds_bg').width(480);
				}),
				$.scope(this,function(e){
					e.preventDefault();
					hmc.$w1.relTabWindow.close(1);
					hmc.$w2.relTabWindow.open(2,
						item.find('copy > displayName').text(),
						item.find('share > movieId').text(),
						item.find('share > relatedVideo').text(),
						$('#hm_carousel').position().top-2
					)
					$('#hm_btn_share_bg').width(480);
				}),
				$.scope(this,function(e){
					cto.tracklink(e.target);
					//alert(e.target.name);
				})
			]
			
			
			$('.hm_btn_embeds a')
				.attr('href',void0)
				.bind(bindClick,this.sharebtnEvFnc[0]);
				
			$('.hm_btn_share a')
				.attr('href',void0)
				.bind(bindClick,this.sharebtnEvFnc[1]);
			
			$('.hm_btn_related a')
				.attr('href',item.find('share > relatedVideo').text())
				.attr('type','custom')
				.attr('name',trackingPrefix+placementCode+'-relatedvideo')
				.bind('click',this.sharebtnEvFnc[2]);
			
			
			
			return true;
		}
	});
	
	/* VideoEventTest 
	
	$(["loadstart",
	"progress",
	"suspend",
	"load",
	"abort",
	"error",
	"emptied",
	"stalled",
	"play",
	"pause",
	"loadedmetadata",
	"loadeddata",
	"waiting",
	"playing",
	"canplay",
	"canplaythrough",
	"seeking",
	"seeked",
	"timeupdate",
	"ended",
	"ratechange",
	"durationchange",
	"volumechange"]).each(function(n,eventName) {
		$('#hm_video video').get(0).addEventListener(eventName, function() {
			console.log(eventName);
		},true);
	});
	*/
	

	
	
	
	
	
	/***************************************
	 * jQuery.blend
	 * When using fade effects to alpha channel PNG, abort this process on MSIE.
	 
	if(!$.browser.msie){
		$("#global_navi a").blend({speed:350,opacity:1});	
	}else{
		//4 IE
	}
	 ***************************************/
	
	/***************************************
	 * searchBar
	 ***************************************/
	 $.fn.extend({
		 inputFocusTexSwap: function() {
			 var $searchInput = this
			 var searchInputColorDef = $searchInput.css('color')
			 var searchWordsDef = $searchInput.attr('value')
			 
			 $searchInput.bind('focus',function(e){
				var v =$searchInput.attr('value')
				if(v == searchWordsDef ) $searchInput.attr('value',"");
				$searchInput.addClass('focus');
			})
			 $searchInput.bind('blur',function(e){
				var v =$searchInput.attr('value')
				if(v == "") $searchInput.attr('value',searchWordsDef);
				$searchInput.removeClass('focus');
			})
			 return this;
		 }
	 });
	 
	 //set after
	 //$('#search_input').inputFocusTexSwap();
	 
	
	/***************************************
	 * Add DropShadow!
	 ***************************************/
	$(".dropsdw2x2_190, .dropsdw2x2_484, .dropsdw2x2_304").prepend('<span class="after" />');
	
	
	/***************************************
	 *twoColumnList  AND thumbList_MH  - height - Fix , and smallBtn
	 ***************************************/
	var smlBtnPref  = "a.button_more, a.button_buy, a.button_dl, a.button_playnow, a.button_community, a.button_campaign, a.button_official, a.button_itunes, a.button_relation"
	var fixSmlBtnHeight = function($p,mDiff){
		$p.find(smlBtnPref).each(function(i,elm){
			var defmt = $(elm).css('margin-top')
			defmt = parseInt(defmt.replace(/px(;*)|em(;*)|\%(;*)$/,''))
			//alert(mDiff+defmt);
			$(elm).css('margin-top',mDiff+defmt)
		})
	},
	threeColumnHeightFix = function(tPref){
		$(tPref).each(function(i,elm){
			var maxH,$n1,$n2,$n3
			if(i%3 != 0) return;
			//gusu nomi
			$n1 = $(elm)
			$n2 = $(tPref+":eq("+(i+1)+")");
			$n3 = $(tPref+":eq("+(i+2)+")");
			if(!$n2){
				return;
			}else if(!$n3){
				maxH = Math.max($n1.height(),$n2.height())
				fixSmlBtnHeight($n1,maxH-$n1.height())
				fixSmlBtnHeight($n2,maxH-$n2.height())
				//$n1.height(maxH)
				//$n2.height(maxH)
				$n1.css('minHeight',maxH)
				$n2.css('minHeight',maxH)
			}else{
				maxH = Math.max($n3.height(),Math.max($n1.height(),$n2.height()))
				fixSmlBtnHeight($n1, maxH-$n1.height())
				fixSmlBtnHeight($n2, maxH-$n2.height())
				fixSmlBtnHeight($n3, maxH-$n3.height())
				//$n1.height(maxH)
				//$n2.height(maxH)
				//$n3.height(maxH)
				$n1.css('minHeight',maxH)
				$n2.css('minHeight',maxH)
				$n3.css('minHeight',maxH)
			}
		})
	},
	twoColumnHeightFix = function(tPref){
		$(tPref).each(function(i,elm){
			var maxH,$next
			if(i%2 != 0)return;
			//gusu nomi
			$n1 = $(elm)
			$n2 = $(tPref+":eq("+(i+1)+")");
			if(!$n2) return;
			maxH = Math.max($n1.height(),$n2.height())
			fixSmlBtnHeight($n2,maxH-$n2.height())
			fixSmlBtnHeight($n1,maxH-$n1.height())
			//$n1.height(maxH)
			//$n2.height(maxH)
			$n1.css('minHeight',maxH)
			$n2.css('minHeight',maxH+1)
		})
	};
	
	//first-child(s)  only.
	twoColumnHeightFix(".twoColumnList > li")
	//$(".thumbList_LH li").each(function(i,elm){alert($(elm).html())})
	threeColumnHeightFix(".thumbList_LH > li")
	threeColumnHeightFix(".thumbList_MH > li")
	
	
	/***************************************
	 * QR Code enlarge Effect.
	 ***************************************/
	if(typeof($.fn.fancybox)!="undefined"){
	$("a.enlarge").fancybox({
		'hideOnContentClick' : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'onStart'	:function(){$("object").css('visibility','hidden')},
		'onClosed'	:function(){$("object").css('visibility','visible')},
		'padding':20,
		'titleShow'		: false
	});
	}
	
	hmc={
		$w1 : $('<div id="hmctw1" class="hmcWindow"></div>'),
		$w2 : $('<div id="hmctw2" class="hmcWindow"></div>')
	}
	hmc.$w1.relTabWindow({id:1})
	hmc.$w2.relTabWindow({id:2})
	
});


