// JavaScript Document

/***************************/
//  [1] Basics
//  chromeCurrentPosition=3;		// Current Tab [1-11]
//  chromeBGcolor='#FFFFFF';		// Background Color [Color]
//  chromeBGimage ='http://local.disney.co.jp/APAC/ja-JP/media/mid_chrome/bg_blue.png'; // Background Picture [URL]

//  [2] Hitbox
//  hbxAccounts="DM510528KKFV38JA3;DM5105282OZE38EN3;DM5103083LCA38EN3";
//  pagename="home";
//  pageName="/home";
//  mlc="/LightYear/home;/JP/LightYear/home;/APAC/JP/LightYear/home";

// [3] Development
//  dcomDomain = "home.disney.co.jp";
//  mediaCacheDomain = "apac-media.disneyinternational.com";
//  wwwDomain = "www.diseney.co.jp";
//  gamesDomain = "www.disneygames.jp";

/**************************/
localmode = false; //debug mode

// Basics
var flashPlayerVersion='9,0,45,0', chromeHeight=36, chromePath='/APAC/ja-JP/swf/mid_chrome_shared_090910.swf';
var chromeCurrentPosition,  chromeBGcolor, chromeSize, chromeBGimage, hbxAccounts, pagename, mlc;
//var chromeBGimage, hbxAccounts, pagename,  mlc;
var dcomDomain, mediaCacheDomain, wwwDomain, gamesDomain, chromePathPrefix ="";

// Domain
host = window.location.hostname;
if ( dcomDomain == undefined  || dcomDomain == null ) {
	if (host.indexOf('dev.') != -1)  {
		dcomDomain = "gopubdev.disney.co.jp";
	} else if (host.indexOf('staging.') != -1 || host.indexOf('preview.') != -1)  {
		dcomDomain = "preview.home.disney.co.jp";
	} else {
		dcomDomain = "home.disney.co.jp"; 
	}
}

if ( wwwDomain == undefined  || wwwDomain== null ) { 
	if (host.indexOf('dev.') != -1)  {
		wwwDomain = "dev.disney.co.jp";
	} else if (host.indexOf('staging.') != -1 || host.indexOf('preview.') != -1)  {
		wwwDomain = "staging.disney.co.jp";
	} else {
		wwwDomain = "www.disney.co.jp";
	}
}

if ( gamesDomain == undefined  || gamesDomain == null ) {
	if (host.indexOf('dev') !=-1 || host.indexOf('staging') || host.indexOf('preview.') ){
		gamesDomain = "staging.disneygames.jp";
	} else {
		gamesDomain = "www.disneygames.jp"; 
	}
}

if ( mediaCacheDomain != undefined && mediaCacheDomain != null ) {
	if (mediaCacheDomain.charAt(0) != "/") {
		chromePathPrefix = "http://" + mediaCacheDomain;
	} else {
		chromePathPrefix = mediaCacheDomain;
	}
} else if (host.indexOf('staging.') != -1 || host.indexOf('preview.') != -1 || host.indexOf('staging28.') != -1)  {
	mediaCacheDomain = "staging.apac-media.disneyinternational.com";
	chromePathPrefix = "http://" + mediaCacheDomain;
} else if (host.indexOf('dev.') != -1){
	mediaCacheDomain = "dev.apac-media.disneyinternational.com";
	chromePathPrefix = "http://" + mediaCacheDomain;
} else {
	mediaCacheDomain = "apac-media.disneyinternational.com";
	chromePathPrefix = "http://" + mediaCacheDomain;
}

if (localmode){
	chromePathPrefix =''; //debug
}

//Force Fix current tab postion with menu order changes in 2008.11.18
var cUrl = window.location.href;
if (cUrl.indexOf("disneygames") != -1){
	// game
	chromeCurrentPosition=1;
	if (chromeSize == undefined || chromeSize == null) {
		chromeSize=994;
	}
} else if (cUrl.indexOf("/download") != -1){
	// download
	chromeCurrentPosition=3;
	if (chromeSize == undefined || chromeSize == null) {
		chromeSize=994;
	}
} else if (cUrl.indexOf("familytime") != -1){
	// familytime
	chromeCurrentPosition=5;
	if (chromeSize == undefined || chromeSize == null) {
		chromeSize=994;
	}
}

if (chromeSize == undefined || chromeSize == null) {
		chromeSize=994;
}

// Function
function generateCode(str) {
	document.write(str);
}

// Generate | START
//generateCode('<script language="javascript" src="' + chromePathPrefix +'/APAC/ja-JP/dcom/js/track_flashmedia.js"  type="text/javascript"></script>');


var trackingScript = document.createElement('script');
trackingScript.type='text/javascript';
trackingScript.charset = 'UTF-8';
trackingScript.src = chromePathPrefix +'/APAC/ja-JP/dcom/js/track_flashmedia.js';
document.getElementsByTagName('head')[0].appendChild(trackingScript);

generateCode('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flashPlayerVersion + '" width="'+chromeSize+'" height="'+chromeHeight+'">');
generateCode('<param name="movie" value="' + chromePathPrefix + chromePath + '" />');
//generateCode('<param name="movie" value="' + chromePath + '" />');
generateCode('<param name="quality" value="high" />');
generateCode('<param name="allowScriptAccess" value="always" />');
generateCode('<param name="scale" value="noScale" />');
generateCode('<param name="salign" value="t" />');
generateCode('<param name="menu" value="false" />');

if (chromeBGcolor != undefined && chromeBGcolor != null ){
	if (chromeBGcolor.length == 7 && chromeBGcolor.charAt(0) == "#") {
		generateCode('<param name="BGCOLOR" value="' + chromeBGcolor +'" />');
	}
}

// Generate - flashVars | START
flv = new Array();
var i =-1, flvstr="", et ="";

if (chromeCurrentPosition > 0 && chromeCurrentPosition < 12) {
	i++;	 flv[i] = "chromeCurrentPosition="+chromeCurrentPosition;
}
if (chromeSize != undefined && chromeSize != null) {
	i++;	 flv[i] = "chromeSize="+chromeSize;
}
if (mediaCacheDomain != undefined  && mediaCacheDomain != null) {
	i++; flv[i] = "mediaCacheDomain="+mediaCacheDomain;
}
if (pagename != undefined  && pagename != null) {
	i++; flv[i] = "pagename="+pagename;
}
if (mlc != undefined  && mlc != null) {
	i++; flv[i] = "mlc="+mlc;
}

if (i > -1 ) {
	var et="";
	for (j=0; j < i ; j++) {
		flvstr = flvstr + et + flv[j];
		et ="&amp;";
	}
}

if (hbxAccounts != undefined  && hbxAccounts != null) {
	flvstr= flvstr + et + 'hbxAccounts='+ hbxAccounts;
	et ="&amp;";
}
if (mlc != undefined  && mlc != null) {
	flvstr= flvstr + et +"mlc="+mlc;
	et ="&amp;";
}

if (chromeBGimage != undefined && chromeBGimage != null ) {
	flvstr= flvstr + et +"chromeBGimage="+chromeBGimage;
}

if (chromeBGcolor != undefined && chromeBGcolor != null ) {
	if (chromeBGcolor.length == 7 && chromeBGcolor.charAt(0) == "#") {
		chromeBGcolorCode = "0x" + chromeBGcolor.substr(1,6);
		flvstr= flvstr + et +"chromeBGcolor="+chromeBGcolorCode;
	}
}
// Generate - flashVars | END

generateCode('<param name="flashVars" value="' + flvstr +'" />');
generateCode('<embed src="' + chromePathPrefix + chromePath +'" width="'+ chromeSize +'" height="'+ chromeHeight +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="' + chromeBGcolor +'" flashvars="' + flvstr + '" allowscriptaccess="always" scale="noScale" salign="t" menu="false"></embed>');
generateCode('<param name="wmode" value="opaque" /><param name=wmode value=Opaque></object>');

// Generate | END