//D-Gate Project Version 6.1.1
//Power by Tangyb
var _ServerPath = "http://www.d-gate.jp/WebDGate/dog";
var _SystemFolder = "panda";
var _Start = 0;
var winWidth = 0;
var winHeight = 0;
var MascotNum = 10;
var Mascot = new Array(MascotNum);
var _Mascot = new Array(MascotNum);
var MascotT,MascotB,MascotL,MascotR;
var winT,winB,winL,winR;
var screenT,screenB,screenL,screenR;
var st = new Array(MascotNum);
var ft = new Array(MascotNum);

function LoadFlash(MascotID,Nid,Url,Width,Height){
MascotID.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+Width+"' height='"+Height+"' id='myflash"+Nid+"'><param name='movie' value='"+_ServerPath+"/"+Url+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='"+_ServerPath+"/"+Url+"' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='"+Width+"' height='"+Height+"' name='myflash"+Nid+"' wmode='transparent' allowScriptAccess='sameDomain'></embed></object>";
}

function AutoConfig(ID) { 
_Mascot[ID].left = String(winWidth-10)+"px";
_Mascot[ID].top = String(winHeight-140)+"px";
}

function Config(ID,L,T) { 
_Mascot[ID].left = L+"px";
_Mascot[ID].top = T+"px";
}

function callok() {
alert("ok~!");
}

function callExternalInterface(ID) {
var _temp = String("myflash"+ID);
thisMovie(_temp).goflash(ID);
}

function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
//alert("Microsoft");
return window[movieName];
}
else {
//alert("Netscape");
return document[movieName];
}
}

function LoadAction() {
//window.resizeTo(1024,700);
var getbody = document.getElementsByTagName("body")[0];
getbody.style.overflow="hidden";
getbody.bgcolor="#FF0000";
getbody.scroll="no";
Settings();

for(i=0;i<MascotNum;i++){
var divobj = "Mascot"+i;
Mascot[i] = document.getElementById(divobj);	
_Mascot[i] = document.getElementById(divobj).style;
AutoConfig(i);
LoadFlash(Mascot[i],i,'mgate.swf',160,160);
//the_timeout2= setTimeout('callExternalInterface('+i+');',2000);
}
}

function starting(){
_Start++;
//alert(_Start);
if(_Start==1){
for(i=0;i<MascotNum;i++){
the_timeout2= setTimeout('callExternalInterface('+i+');',1000);
//callExternalInterface(i);
}}
}

function Move(ID,Direct,Speed,Stoped) {
var MascotID=_Mascot[ID];
var Re="Move("+ID+","+Direct+","+Speed+","+Stoped+")";
if(Direct==1){
MascotID.left=String(parseInt(MascotID.left)-Speed)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.left)<Stoped){
clearTimeout(the_timeout1);
return callExternalInterface(ID)}}
if(Direct==2){
MascotID.left=String(parseInt(MascotID.left)+Speed)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.left)>Stoped){
clearTimeout(the_timeout1);
return callExternalInterface(ID)}}
}

function ChangeAct(ID,Stoped) {
st[ID]++;
the_timeout1= setTimeout('ChangeAct('+ID+','+Stoped+')',50);
if (st[ID]>Stoped){
st[ID] = 0;
clearTimeout(the_timeout1);
return callExternalInterface(ID);
}
}

function Climb(ID,Direct,Speed,Stoped) {
var MascotID=_Mascot[ID];
var Re="Climb("+ID+","+Direct+","+Speed+","+Stoped+")";	
if(Direct==1){
MascotID.top=String(parseInt(MascotID.top)-Speed)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.top)<=Stoped){
clearTimeout(the_timeout1);
return callExternalInterface(ID)}}
if(Direct==2){
MascotID.top=String(parseInt(MascotID.top)+Speed)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.top)>=Stoped){
clearTimeout(the_timeout1);
return callExternalInterface(ID)}}
}

function Jump(ID,Direct,Speed,Hight) {
var MascotID=_Mascot[ID];
var Re="Jump("+ID+","+Direct+","+Speed+","+Hight+")";	
if(Direct==1){
st[ID]=st[ID]+10;
if(st[ID]>=Hight){
MascotID.left=String(parseInt(MascotID.left)-Speed)+"px";
MascotID.top=String(parseInt(MascotID.top)+10)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.top)>=winB){
clearTimeout(the_timeout1);
st[ID]=0;
return callExternalInterface(ID)}}
else{
MascotID.left=String(parseInt(MascotID.left)-Speed)+"px";
MascotID.top=String(parseInt(MascotID.top)-10)+"px";
the_timeout1=setTimeout(Re,50);
}}

if(Direct==2){
st[ID]=st[ID]+10;
if(st[ID]>=Hight){
MascotID.left=String(parseInt(MascotID.left)+Speed)+"px";
MascotID.top=String(parseInt(MascotID.top)+10)+"px";
the_timeout1=setTimeout(Re,50);
if(parseInt(MascotID.top)>=winB){
clearTimeout(the_timeout1);
st[ID]=0;
return callExternalInterface(ID)}}
else{
MascotID.left=String(parseInt(MascotID.left)+Speed)+"px";
MascotID.top=String(parseInt(MascotID.top)-10)+"px";
the_timeout1=setTimeout(Re,50);
}}
}

function Speak(ID,Msg,rst){
var MascotID=_Mascot[ID];
var msgtext = document.getElementById("showmsg");
msgtext.style.left = String(parseInt(MascotID.left)+70)+"px";
msgtext.style.top = String(parseInt(MascotID.top)-20)+"px";
msgtext.style.visibility = "visible";
var fontColor = 'black';
msgtext.innerHTML = "<table width='202' border='0' cellspacing='0' cellpadding='0' style='font-size:12px;color:#000000'><tr><td width='200' height='69' align='center' valign='middle'><font color="+fontColor+">"+Msg+"</font></td></tr></table>";
//var getsound = document.getElementsByTagName("bgsound")[0];
//getsound.src="bg.mp3";
var st = rst*1000;
the_timeout0=setTimeout("ClsSpeak("+ID+");",parseInt(st));
}

function ClsSpeak(ID){
var msgtext = document.getElementById("showmsg").style;
msgtext.visibility = "hidden";
//var getsound = document.getElementsByTagName("bgsound")[0];
//getsound.src="";
//the_timeout0=setTimeout("callExternalInterface("+ID+");",1000);
return callExternalInterface(ID);
}

function CallOther(ID,CALLID){
callExternalInterface(CALLID);	
return callExternalInterface(ID);
}

function Stop(ID){
return AutoConfig(ID);
}

function GetDown(Type){
//window.location = "setup.rar";
if(Type == 1){
var msgtext = document.getElementById("showmsg").style;
msgtext.visibility = "hidden";
return callExternalInterface(0);	
}else{
var msgtext = document.getElementById("showmsg").style;
msgtext.visibility = "hidden";}
}

function MsgBox(ID,Msg,Yes,No,YesH){
var MascotID=_Mascot[ID];
var msgtext = document.getElementById("showmsg");
msgtext.style.left = String(parseInt(MascotID.left)+70)+"px";
msgtext.style.top = String(parseInt(MascotID.top)-20)+"px";
msgtext.style.visibility = "visible";
var fontColor = 'red';
msgtext.innerHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='font-size:12px;color:#000000'><tr><td colspan='3' height='41' align='center'>"+Msg+"</td></tr><tr><td align='right'><b><span style='font-weight: bold; text-decoration:underline; cursor:pointer' onClick='"+YesH+";'>"+Yes+"</span></b></td><td align='center'>&nbsp;</td><td align='center'><b><span style='font-weight: bold; text-decoration:underline; cursor:pointer' onClick='ClsSpeak("+ID+");'>"+No+"</span></b></td></tr></table>";
//the_timeout0=setTimeout("ClsSpeak("+ID+");",3000);
}

function ShowBox(Type,Url,Link,ifShow){
var pl = document.getElementById("preload");
pl.style.left = (winWidth-400)/2+"px";
pl.style.top = (winHeight-300)/2+"px";
//alert(pl.style.left);
pl.style.visibility = "visible";
if(Type == 1){
pl.innerHTML = "<a href='"+Link+"' target='_blank'><img src='"+Url+"' width='400'></a>";
}else{
pl.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='400' height='300'><param name='movie' value='"+Url+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='"+Url+"' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='400' height='300' wmode='transparent' allowScriptAccess='sameDomain'></embed></object>";}
if(ifShow == 'null'){
var msgtext = document.getElementById("showmsg").style;
msgtext.visibility = "hidden";	
}else{
var msgtext = document.getElementById("showmsg");
msgtext.innerHTML = "<table width='202' border='0' cellspacing='0' cellpadding='0'><tr><td width='200' height='69' align='center' valign='middle'><span style='font-size:12px;color:#000000'>"+ifShow+"</span></font></td></tr></table>";	
}
the_timeout0=setTimeout("HideBox();",20000);
}

function iff(){
var msgtext = document.getElementById("showmsg");
msgtext.style.visibility = "hidden";
//pl.innerHTML = "";
var ff = document.getElementById("iff");
ff.style.visibility = "visible";
the_timeout0=setTimeout("hiff();",30000);
return callExternalInterface(1);
}

function hiff(){
var ff = document.getElementById("iff");
ff.style.visibility = "hidden";
}

function HideBox(){
var pl = document.getElementById("preload");
pl.style.visibility = "hidden";
pl.innerHTML = "";
return callExternalInterface(1);
}

function CreateDiv() {	
for(i=0;i<MascotNum;i++){
document.write("<div id='Mascot"+i+"' style='position:absolute; width:160px; height:160px; left:0px; top:0px; z-index:2; visibility:visible; border: 1px none #000000;'></div>");}
document.write("<div id='preload' style='position:absolute; width:400px; height:300px; left:0px; top:0px; z-index:2; visibility:hidden; border: 1px none #000000;'></div>");
document.write("<div id='showmsg' style='position:absolute; width:202px; height:69px; left:0px; top:0px; z-index:2; visibility:hidden; border: 1px #000000; background-image: url("+_ServerPath+"/"+"swf/sbg.gif);'></div>");
}

function Settings() {
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;

if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;            

if (document.documentElement  && document.documentElement.clientHeight && 
document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}

for(i=0;i<MascotNum;i++){
st[i]=0;
ft[i]=0;}

MascotT = -40;
MascotL = -40;
MascotR = winWidth-120;
MascotB = winHeight-140;

screenT = -160;
screenL = -160;
screenR = winWidth;
screenB = winHeight;

winT = -40;
winL = -60;
winR = winWidth-100;
winB = winHeight-140;
}

function sc5(){
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;

if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;            

if (document.documentElement  && document.documentElement.clientHeight && 
document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}

MascotR = winWidth-120;
MascotB = winHeight-140;
screenR = winWidth;
screenB = winHeight;
winR = winWidth-100;
winB = winHeight-140;

for(i=0;i<MascotNum;i++)
_Mascot[i].top = String(winHeight-140)+"px";
}

window.onresize=sc5;
window.onload=LoadAction;CreateDiv();