if (!document.getElementById) location.replace("http://www.disney.go.com/home/html/index.html");
$j = jQuery.noConflict();



/* ------------------------------------------------------------ */
/*                                                              */
/*                         global param                         */
/*                                                              */
/* ------------------------------------------------------------ */

var _hpath     = (location.href.substr(location.href.length-1,1)=='/') ? (location.pathname+'index.html'):location.pathname;
var _hpath_ary = _hpath.substr(1).split('/');
var _dcpp      = '/' + _hpath_ary.slice(0,-1).join('/');
var _html      = _hpath.substring(_hpath.lastIndexOf('/',255)+1,255);
var _ch        = 'dc';
var _hstyle    = 'clouds2';

var _bid=394;


//------------------------------------------------------------
// siteId Detection
//------------------------------------------------------------

var siteId = (typeof siteId == 'undefined') ? 1 : siteId;
if (_hpath_ary[0] == "toondisney") siteId = 2;
if (_hpath_ary[0] == "jetix") siteId = 3;

if (location.search) {
	var sAry=location.search.substr(1).split('&');
	for (var i=0;i<sAry.length;i++) {
		if (sAry[0] == "siteId") siteId = sAry[1];
	}
};





/* ------------------------------------------------------------ */
/*                                                              */
/*                            initial                           */
/*                                                              */
/* ------------------------------------------------------------ */
document.write('<script type="text/javascript" src="/_global/js/axyzsdk.js?ad.axyzconductor.jp,0"><\/script>');
document.write('<script type="text/javascript" src="/_global/js/core/swfobject.js"><\/script>');
document.write('<script type="text/javascript" src="/_global/js/jquery/ifixpng.js"><\/script>');
document.write('<script type="text/javascript" src="/_global/js/jquery/thickbox/thickbox.js"><\/script>');
document.write('<link rel="stylesheet" type="text/css" href="/_global/js/jquery/thickbox/thickbox.css" media="screen" \/>');

jQuery(function($){
	if ($('body').attr('class') != null) _hstyle = $('body').attr('class');
	if ((_hpath_ary[0]=='dc' && _hpath_ary[1]=='program' && _hpath_ary[2]=='playhouse') || ($('body').attr('class') == 'phd')) {
		_ch = 'phd';
		_hstyle = 'phd';
	}
	$('body').addClass(_hstyle);
	if($('body').attr('id') != 'popup'){$.writeHeader();}
	if(_html=='copyright.html'){$('li.copyright').hide();}
	if(_html=='sitemanage.html'){$('li.copyright').hide();}
	if(_html=='wallpaper.html'){$('li.copyright').hide();}
});









/* ------------------------------------------------------------ */
/*                                                              */
/*                       Web Analytics                          */
/*                                                              */
/* ------------------------------------------------------------ */
document.write('<script type="text/javascript" src="http://analytics.disneyinternational.com/analytics/wdigWebAnalytics.js"></script>');

/*
	mediaTrack('open',mediaName,mediaLength,mediaPlayerName);
	mediaTrack('play',mediaName,mediaOffset,contentType);
	mediaTrack('stop',mediaName,mediaOffset,contentType);
	mediaTrack('close',mediaName);
*/
function mediaTrack() {
	var a = mediaTrack.arguments;
	if(a.length) {
		switch (a[0]) {
			case 'open' : cto.MediaOpen(a[1],a[2],a[3]); break;
			case 'play' : cto.MediaPlay(a[1],a[2],a[3]); break;
			case 'stop' : cto.MediaStop(a[1],a[2],a[3]); break;
			case 'close': cto.MediaClose(a[1]); break;
		}
	}
}





/* ------------------------------------------------------------ */
/*                                                              */
/*                           hitBox                             */
/*                                                              */
/* ------------------------------------------------------------ */
function hbchk () {
//	return true;
	if((location.href.indexOf("//disneychannel.jp",0)>-1)||(location.href.indexOf("www.disneychannel.jp",0)>-1)||(location.href.indexOf("dev.disneychannel.jp",0)>-1)) {
		return true;
	} else {
		return false;
	}
}
function writeHitbox(){
	if (hbchk()) {
		document.write('<script type="text/javascript" src="/_global/js/analytics.js"><\/script>');
	}
}

var _mlc = '';	// hitbox 用変数
function dynamic_hbx (p_pn, p_mlc, p_n1, p_n2) {
	if(!hbchk()) return;
	if (p_mlc.length>0) _dcpp = _dcpp+'/'+p_mlc;
	_mlc = _dcpp+';/disneychannel'+_dcpp+';/JP/disneychannel'+_dcpp+';/ASIAPAC/JP/disneychannel'+_dcpp;
	_hbflash (p_pn, _mlc, p_n1, p_n2);
//																alert(p_pn + '\n' + _mlc.split(';').join('\n'));
}




/* ------------------------------------------------------------ */
/*                                                              */
/*                   writeHeader / writeFooter                  */
/*                                                              */
/* ------------------------------------------------------------ */

(function($) {
	$.writeHeader = function() {
		if ($('#header').size()) {
			$('#header').append('<div id="swfHeadHolder"></div>');
			
			var headerxml = 'header_' + _ch + '.xml';
			var height = 151; if (_ch=='phd') height=178;
			
			/* 5th */
/*
			if (_ch=='dc') {
				height = 166;
				headerxml = 'header_dc5th.xml';
			}
*/
			
			/* PHD Top Esc */
			if (_hpath == '/dc/program/playhouse/index.html'||_hpath == '/dc/program/playhouse/index2.html') return;
			
			writeSWF({w:994,h:height,id:'swfHead',swf:'/_global/swf/fii2/base.swf',param:'_conf=/dc/_common/xml/_fii_dc.xml&_cont=/dc/_common/xml/' + headerxml});
		}
	};
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                             writeMsg                         */
/*                                                              */
/* ------------------------------------------------------------ */
(function($) {
	$.writeMsg = function() {
		$('#header').append('<div id="swfMsgHolder"></div>');
		var msgxml = 'alert.xml';
		writeSWF({w:994,h:50,id:'swfMsg',swf:'/_global/swf/fii2/base.swf',param:'_conf=/dc/_common/xml/_fii_dc.xml&_cont=/dc/_common/xml/' + msgxml});
	}
})(jQuery);
function writeMsg() {
	$j.writeMsg();
}





/* ------------------------------------------------------------ */
/*                                                              */
/*                          writeSWF                            */
/*                                                              */
/* ------------------------------------------------------------ */

function writeSWF(p){

	/* --- case of Null --- */
	if (!p.v)      p.v      = 8;
	if (!p.bg)     p.bg     = '#ffffff';
	if (!p.scale)  p.scale  = 'noscale';
	if (!p.salign) p.salign = 'TL';

	var so = new SWFObject(p.swf, p.id, p.w, p.h, p.v, p.bg);

	/* --- add param --- */
	so.addParam('scale',  p.scale);
	so.addParam('salign', p.salign);
	if (p.wmode) {
		so.addParam('wmode', p.wmode);  // Japanese IME & Scroll Wheel
	} else {
		so.addParam('wmode', 'transparent');
	}
	so.addParam('allowFullScreen', 'true');

	/* --- add variable --- */
	if (p.param) { var pAry=p.param.split('&'); for (var i=0;i<pAry.length;i++) {var a=pAry[i].split('='); so.addVariable(a[0],a[1]);} };
	if (location.search) { var sAry=location.search.substr(1).split('&'); for (var i=0;i<sAry.length;i++) {var a=sAry[i].split('='); so.addVariable(a[0],a[1]);} };
	so.addVariable('_hpath', _hpath);
	so.addVariable('_hstyle', _hstyle);

	/* --- marginFix & write --- */
	so.setAttribute('style', ';');
	so.setAttribute('redirectUrl', 'http://home.disney.co.jp/onlinehelp/software#co1?flash=false');
	
	so.write(p.id+'Holder');
}


function setHeight() {
	
}





/* ------------------------------------------------------------ */
/*                                                              */
/*                       jQuery : ready                         */
/*                                                              */
/* ------------------------------------------------------------ */

jQuery(function($){

	// form decoration : [ui(user interface)] enhance -----------------------------------------------------
	$('.ui input:radio').click(function(){
		$('.ui input[name=' + $(this).attr('name') + ']').parent().removeClass('selected');
		$(this).parent().addClass('selected');
	});
	$('.ui .reset').click(function(){
		$('.ui .selected').removeClass('selected');
	});

	// png fix ------------------------------------------------------------
	$.ifixpng('/_global/img/blank.gif'); 
	$('img[@src$=.png]').ifixpng();
	$('#container').ifixpng();
	$('#contentBody').ifixpng();
	$('#contentFoot').ifixpng();
	$('#contentHead').ifixpng();
	$('#contentHead2').ifixpng();
	$('#contentHead3').ifixpng();
	$('#footer').ifixpng();
	$('.nav').ifixpng();
});




/* ------------------------------------------------------------ */
/*                                                              */
/*                          require                             */
/*                                                              */
/* ------------------------------------------------------------ */

//require plugin by Mohd Khairi Lamsah (hairiemx at gmail dot com)
//Feel free to modify it. 

(function($){
	$.plg={
		inited:false,
		list:{},
		css:{},
		fn:[],
		queue:[],
		jsBase:'.',
		cssBase:'.',
		complete:function(){
			$.plg.inited=false;
			$(document).ready(function(){
				while($.plg.fn.length)
					$.plg.fn.shift().apply(document);
			});
		},
		next: function(){
			var plugin=$.plg.queue.shift();
			$.plg.inited=true;
			if(typeof $.plg.list[plugin.name]=='undefined'){
				var src = $.plg.jsBase + '/' + plugin.name + '.js';
				$.plg.list[plugin.name]=false;
				$.get(src, function(data){
				$.plg.list[plugin.name]=true;
				//Evaluate later when dom is ready
				$.plg.fn.push(function(){eval.call(window,data);});
				//Run plugin onload after dom is ready
				if(plugin.onload)$.plg.fn.push(plugin.onload);
				//Proceed to next 
				$.plg.proceed();
				});
			}
			else if ($.plg.list[plugin.name]){
				//If the plugin is already loaded, 
				//push onload to function queue and 
				//proceed to next plugin.
				if(plugin.onload)
					$.plg.fn.push(plugin.onload);
				$.plg.proceed();
			}
			
		},
		proceed:function(){
			if($.plg.queue.length)
				$.plg.next();
			else
				$.plg.complete();
		}
	};
	 
	//Try get jquery-require.js base path
	$("head > script[@src$='common.js']").each(function(){
		var pathArray=this.src.split('/');
		pathArray.pop();
		$.plg.jsBase=pathArray.join('/') || '.';
		$.plg.cssBase=$.plg.jsBase.replace('/js','/styles');
	});
	 
	$.extend({
	requirecss: function(c){
		var cList=c.split(",");
		for(var i=0;i<cList.length;i++){
			var cssFile=cList[i];
			if(typeof $.plg.css[cssFile]=="undefined"){
				var c = document.createElement('link'); 
				c.type = 'text/css';
				c.rel = 'stylesheet';
				c.href = $.plg.cssBase + '/' + cssFile + '.css';
				$('head')[0].appendChild(c);
				$.plg.css[cssFile]=true;
			}
		}
	},
	require: function(plugin){
		var p=plugin.split(',');
		//If no onload function is assigned, assigned load function to null
		var func=arguments.length > 1?arguments[1]:null;
		var pLength=p.length;
		for(var i=0;i<pLength;i++){
				//Push the plugin into queue
			$.plg.queue.push({name: p[i], onload: (i==pLength-1?func:null)}); 
		}
		if(!$.plg.inited){
			$.plg.next();
		}
	}
	});

$.fn.extend({
	requireComplete: function(f) {
		//If plugin loading process complete
		if (!$.plg.inited){
			// Execute the function immediately
			f.apply( document );
		}
		// Otherwise, remember the function for later
		else 
			// Add the function to the wait list
			$.plg.fn.push( f );
		return this;
	}
	});
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                          TDC func                            */
/*                                                              */
/* ------------------------------------------------------------ */

function pop_standard(id, sid){				// POPUP 番組詳細
	var url = '';
	if (!sid || sid == '1') {url='/program/time/standard_program.jsp?id='+id;}
	if (sid == '2') {url='/toondisney/program/time/standard_program.jsp?id='+id;}
	if (sid == '3') {url='/jetix/program/time/standard_program.jsp?id='+id;}

	var win = window.open(url,'popStandard','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=390,height=395');
	win.focus();
}

function pop_download(url){				// POPUP ダウンロード
	var win = window.open(url,'popDownload','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=590,height=620');
	win.focus();
}

function pop_download_exposition(){
	var win = window.open('/dc/download/wallpaper.html','popDownloadExposition','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=500,height=390');
	win.focus();
}


function put_minisitebox (fid, pid) {
	// ---------- TDC2 common ----------
	
	if (pid=='littleeinstein') pid='little_einsteins';
	
	writeSWF({w:405, h:87, id:fid, swf:"/_global/swf/fii2/base.swf",param:"_conf=/dc/_common/xml/_fii_dc.xml&_cont=/dc/_common/xml/onairtime.xml&_ssid="+pid});
	
}





/* ------------------------------------------------------------ */
/*                                                              */
/*                       image switcher                         */
/*            [ filename.ext <-> filename_on.ext ]              */
/*                                                              */
/* ------------------------------------------------------------ */
(function($){
  $.fn.extend({
    imghover: function() {
      return this.each(function() {
        var node = $(this);
        if (!node.is('img')&&!node.is(':image')){
          node.find('img,:image').imghover();
          return;
        }
        node.hover(function() {
          node.addClass('hover');
          if (!node.hasClass('on')) $.fn.imgOn(node);
        },function() {
          node.removeClass('hover');
          if (!node.hasClass('on')) $.fn.imgOff(node);
        });
      });
    },
    imgtoggle: function() {
      return this.each(function() {
        var node = $(this);
        if (!node.is('img')&&!node.is(':image')){
          node.find('img,:image').imgtoggle();
          return;
        }
        node.click(function() {
          if (node.hasClass('on')) {
            $.fn.imgOff(node);
          } else {
            if (!node.hasClass('hover')) $.fn.imgOn(node);
          }
          node.toggleClass('on');
        });
      });
    },
    imgOn: function(node) {
      node.attr('src',node.attr('src').replace(/^(.+)(\.[a-z]+)$/,'$1_on$2'));
    },
    imgOff: function(node) {
      node.attr('src',node.attr('src').replace(/^(.+)_on(\.[a-z]+)$/,'$1$2'));
    }
  });
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                      jQuery initialize                       */
/*                                                              */
/* ------------------------------------------------------------ */

try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}  // ie6 background-image reload issue

$j(function($){

	// img hover : toggle -------------------------------------------
	$('.imghover').imghover();
	$('.imgtoggle').imgtoggle();

});





/* ------------------------------------------------------------ */
/*                                                              */
/*                       image switcher                         */
/*            [ filename.ext <-> filename_on.ext ]              */
/*                                                              */
/* ------------------------------------------------------------ */
(function($){
  $.fn.extend({
    imghover: function() {
      return this.each(function() {
        var node = $(this);
        if (!node.is('img')&&!node.is(':image')){
          node.find('img,:image').imghover();
          return;
        }
        node.hover(function() {
          node.addClass('hover');
          if (!node.hasClass('on')) $.fn.imgOn(node);
        },function() {
          node.removeClass('hover');
          if (!node.hasClass('on')) $.fn.imgOff(node);
        });
      });
    },
    imgtoggle: function() {
      return this.each(function() {
        var node = $(this);
        if (!node.is('img')&&!node.is(':image')){
          node.find('img,:image').imgtoggle();
          return;
        }
        node.click(function() {
          if (node.hasClass('on')) {
            $.fn.imgOff(node);
          } else {
            if (!node.hasClass('hover')) $.fn.imgOn(node);
          }
          node.toggleClass('on');
        });
      });
    },
    imgOn: function(node) {
      node.attr('src',node.attr('src').replace(/^(.+)(\.[a-z]+)$/,'$1_on$2'));
    },
    imgOff: function(node) {
      node.attr('src',node.attr('src').replace(/^(.+)_on(\.[a-z]+)$/,'$1$2'));
    }
  });
})(jQuery);

