	//D-Gate Project Version 6.1.1
//Power by Tangyb
/*var _ServerPath = "http://www.event-guide.jp/qiqiu/p1/flash/";
var _SystemFolder = "http://www.event-guide.jp/qiqiu/p1/flash/";
var _tantouPath="qiqiu/p1/flash/swf/left.swf";
var _tantouPath2="qiqiu/p1/flash/swf/right.swf";*/
/*var _ServerPath = "http://192.168.1.25/customer/p1/flash/";
var _SystemFolder = "http://192.168.1.25/customer/p1/flash/";
var _tantouPath="flash/swf/left.swf";
var _tantouPath2="flash/swf/right.swf";*/
/*var _ServerPath = "http://127.0.0.1/customer/p1/flash/";
var _SystemFolder = "http://127.0.0.1/customer/p1/flash/";
var _tantouPath="flash/swf/left.swf";
var _tantouPath2="flash/swf/right.swf";*/

var _ServerPath = "http://www.mizcadeco.net/customer/p5/flash/";
var _SystemFolder = "http://www.mizcadeco.net/customer/p5/flash/";
var _tantouPath="flash/swf/left.swf";
var _tantouPath2="flash/swf/right.swf";

var _Start = 0;
var winWidth = 0;
var winHeight = 0;        
var MascotNum = 11;
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);
var NeedPost=false;
var the_timeout1;
var cmid = 0;
var iConut = 0;

function LoadFlash(MascotID,Nid,Url,Width,Height){
_Mascot[Nid].width = Width+"px";	
_Mascot[Nid].height = Height+"px";	
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='"+Url+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='allowScriptAccess' value='always'><embed src='"+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='always'></embed></object>";
}

function AutoConfig(ID) {
_Mascot[ID].left = "0px";
_Mascot[ID].top = "0px";
}

function Config(ID,L,T) { 
_Mascot[ID].left = L+"px";
_Mascot[ID].top = T+"px";
}

function GetPageWidth(id) {
thisMovie("myflash"+id).set_screen_width(winWidth);
}

function GetPageHeight(id) {
thisMovie("myflash"+id).set_screen_height(winHeight);
}

function SetDivX(id,X) {
_Mascot[id].left = X+"px";
}

function SetDivY(id,Y) {
_Mascot[id].top = Y+"px";
}

function SetDivW(id,W) {
_Mascot[id].width = W+"px";	
//document.getElementById("myflash"+id).width = W;
thisMovie("myflash"+id).width = W;
}

function SetDivH(id,H) {
_Mascot[id].height = H+"px";
//document.getElementById("myflash"+id).height = H;
thisMovie("myflash"+id).height = H;
}

function ChangeNickName(id,name) {
thisMovie("myflash"+id).changenickName(name);
}

function init(_FormName,_LCName,_XMLurl,_nickname,play_mode) {
/*	_XMLurl="Dog";
thisMovie("myflash"+_FormName).init(_FormName,_LCName,_XMLurl,_nickname,_SystemFolder,play_mode);*/
}
function ToStart() {
//MGate_callPHP()
	var index=Math.floor(Math.random()*2);
	if(index==0){
							_XMLurl="script//TV_Balloon_1";
						}else{
							_XMLurl="script//TV_Balloon_2";				
						}
//	_XMLurl="script//TV_Balloon_1";
	//_XMLurl="script//TV_Balloon_2";
	/*thisMovie("myflash10").set_screen_width(winWidth);
	thisMovie("myflash10").set_screen_height(winHeight);*/
	thisMovie("myflash10").init(10,10,_XMLurl,"",_SystemFolder,true);
	
}

var lock_popo=false;
function showSleepPopo(direction) {
	switch(direction){
		case "l":
		_Mascot[9].left = String(parseInt(_Mascot[10].left)-145)+"px";
		_Mascot[9].top = String(parseInt(_Mascot[10].top)-150)+"px";
		break;
		case "r":
		_Mascot[9].left = String(parseInt(_Mascot[10].left)+40)+"px";
		_Mascot[9].top = String(parseInt(_Mascot[10].top)-150)+"px";
		break;
	}
	lock_popo=true;
	thisMovie("myflash9").show();	
	setTimeout("JS_hideSleepPopo();",5000);
}
function hideSleepPopo() {
	lock_popo=false;
	thisMovie("myflash9").hide();	
}
//js自己调用的隐藏和显示popo的方法  循环显示popo
function JS_showSleepPopo() {
	if(lock_popo){
	thisMovie("myflash9").show();	
	setTimeout("JS_hideSleepPopo();",5000);
	}
}
function JS_hideSleepPopo() {
	thisMovie("myflash9").hide();
	if(lock_popo){
	    setTimeout("JS_showSleepPopo();",5000);
	}
}
function get_platform_info(id) {
thisMovie("myflash"+id).get_platform_info(id,parseInt(_Mascot[id].left),parseInt(_Mascot[id].top),parseInt(_Mascot[id].width),parseInt(_Mascot[id].height),winWidth,winHeight);
}

function changeXML(id,xml) {
thisMovie("myflash"+id).changeXML(xml);
}

function callStart() {
thisMovie("myflash8").restart();
}

function callTimer() {
thisMovie("myflash8").start_timer();
}

function hidemenu(id) {
thisMovie("myflash"+id).hidemenu();
}

function callPHP() {
	thisMovie("myflash9").callPHP(document.URL,document.URL);
}
function MGate_callPHP() {
	thisMovie("myflash10").callPHP(document.URL,document.URL);
}
function checklr(id) {
	//alert(id);
if(parseInt(_Mascot[id].left)>winHeight/2){
	//alert("l");
	thisMovie("myflash"+id).changeXML("script//TV_Balloon_12")
}else{
	//alert("r");
	thisMovie("myflash"+id).changeXML("script//TV_Balloon_13")
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
 window.open(theURL,winName,features);
  //window.open( theURL,winName,'status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes ');
}

function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
}else {
return document[movieName];}
}

function LoadAction() {
Settings();

for(i=0;i<MascotNum;i++){
var divobj = "Mascot"+i;
Mascot[i] = document.getElementById(divobj);	
_Mascot[i] = document.getElementById(divobj).style;
AutoConfig(i);
drag(Mascot[i]);
}

LoadFlash(Mascot[10],10,_SystemFolder+'M_Gate.swf',10,10);
LoadFlash(Mascot[9],9,_SystemFolder+'sleep_popo.swf',300,300);
//_Mascot[10].background = '#669933';

var _p = parseInt(Math.random()*2)+1;
var _p1 = parseInt(Math.random()*2)+1;
var _p2 = parseInt(Math.random()*winHeight*0.5);

if(_p==1){
LoadFlash(Mascot[8],8,_SystemFolder+'probe_l.swf?guid='+_tantouPath,500,400);
Config(8,0,-390);
}else{
LoadFlash(Mascot[8],8,_SystemFolder+'probe_r.swf?guid='+_tantouPath2,500,400);
Config(8,winWidth-500,-390);
}
}

function addMascot(id,xml,nk){
LoadFlash(Mascot[id],id,_SystemFolder+'M_Gate.swf?FormName='+id+'&XMLURL='+xml+'&nickname='+nk+'&guid='+getguid(),600,280);
drag(Mascot[id]);
iConut++;
}

function hideBg(){
document.getElementById("M2").style.visibility = "hidden";
}

function showBg(){
document.getElementById("M2").style.visibility = "visible";
}

function hideMascot(id){
Mascot[id].style.visibility = "hidden";
}

function showMascot(id){
Mascot[id].style.visibility = "visible";
}

function changeMascot(id,xml){
thisMovie("myflash"+id).ChangeXML(xml);	
}

function dragMascot(id){
drag(Mascot[id]);
}

function show2(){
thisMovie("myflash0").show2();	
}

function getguid(){
var guid = "";
for(var i = 1; i <= 32; i++){
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";}
return guid;	
}

function getCookie(){
var getCk=document.cookie.split("; ");

for(var i=0;i<getCk.length;i++){ 
var arr=getCk[i].split("=");
if("uid"==arr[0]){ 
return arr[1]; 
break; } 
}}

function ClsSet(){
clearTimeout(the_timeout1);
}

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 ChatBox(Url,Width,Height){
var pl = document.getElementById("chatbox");
pl.style.left = "0px";
pl.style.top = winHeight+"px";
pl.style.visibility = "visible";
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='"+Width+"' height='"+Height+"' id='showbox'><param name='movie' value='"+_ServerPath+Url+"' /><param name='quality' value='high' /><param name='wmode' value='window' /><param name='allowScriptAccess' value='always' /><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+"' wmode='window' allowScriptAccess='always'></embed></object>";
//return BoxEffect("chatbox",1,24,1);
}

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))+"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='130' height='130' align='center' valign='middle'><font color="+fontColor+">"+Msg+"</font></td></tr></table>";
var st = rst*1000;
the_timeout0=setTimeout("ClsSpeak("+ID+");",parseInt(st));
}

function ClsSpeak(ID){
var msgtext = document.getElementById("showmsg").style;
msgtext.visibility = "hidden";
}

function Speak2(ID,Msg,rst){
var MascotID=_Mascot[ID];
var msgtext = document.getElementById("showmsg2");
msgtext.style.left = String(parseInt(MascotID.left)+70)+"px";
msgtext.style.top = String(parseInt(MascotID.top))+"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 st = rst*1000;
the_timeout0=setTimeout("ClsSpeak2("+ID+");",parseInt(st));
}

function ClsSpeak2(ID){
var msgtext = document.getElementById("showmsg2").style;
msgtext.visibility = "hidden";
}

function BoxEffect(id,type,Height,spd){
if(type==1){
var pl = document.getElementById(id);
if(parseInt(pl.style.top)+Height>winHeight){
pl.style.top = String(parseInt(pl.style.top)-spd)+"px";
//pl.style.top = (winHeight-Height)+"px";
return setTimeout("BoxEffect('"+id+"',1,"+Height+","+spd+");",20);
}}
if(type==2){
var pl = document.getElementById(id);
if(parseInt(pl.style.top)<=winHeight){
pl.style.top = String(parseInt(pl.style.top)+spd)+"px";
//pl.style.top = (winHeight-Height)+"px";
return setTimeout("BoxEffect('"+id+"',2,"+Height+","+spd+");",20);
}else{
var pl = document.getElementById("dia");
pl.style.visibility = "hidden";
}}
}

function ShowDia(s){
var pl = document.getElementById("dia");
pl.style.left = "0px";
pl.style.top = winHeight+"px";
pl.style.visibility = "visible";
pl.innerHTML = s;
return BoxEffect("dia",1,226,3);
}

function AddDia(s){
var pl = document.getElementById("dia");
pl.innerHTML = s;
}

function HideDia(){
return BoxEffect("dia",2,226,3);
}

function ClsShowBox(){
var msgtext = document.getElementById("showbox").style;
msgtext.visibility = "hidden";
}

function HideBox(){
var pl2 = document.getElementById("dia");
pl2.style.visibility = "hidden";
pl2.innerHTML = "";
BoxEffect("chatbox",2,24,1);
}

function mousePosition(ev){ 
     if(ev.pageX || ev.pageY){ 
      return {x:ev.pageX, y:ev.pageY}; 
      } 
      return { 
       x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
       y:ev.clientY + document.body.scrollTop  - document.body.clientTop 
       }; 
}

function getEvent() {
return window.event || arguments.callee.caller.arguments[0];
}

function mouseMove(ev){ 
    ev = ev || window.event; 
    var mousePos = mousePosition(ev);
	var x1 = mousePos.x - parseInt(_Mascot[1].left);
	var y1 = mousePos.y - parseInt(_Mascot[1].top);
	if(x1<15){
	//_Mascot[1].left = (parseInt(_Mascot[1].left) + 15) + "px";
	x1 = winWidth + parseInt(_Mascot[1].width);
	}
	else{
	//_Mascot[1].left = (parseInt(_Mascot[1].left) - 15) + "px";
	x1 = 0 - parseInt(_Mascot[1].width);}
	if(y1<15){
	//_Mascot[1].top = (parseInt(_Mascot[1].top) + 15) + "px";
	y1 = winHeight + parseInt(_Mascot[1].height);
	}
	else{
	//_Mascot[1].top = (parseInt(_Mascot[1].top) - 15) + "px";
	y1 = 0 - parseInt(_Mascot[1].height);}
	//thisMovie("myflash1").receive_Position(x1,y1)
} 

function drag(o){
/* var moveX = 0;
 var moveY = 0;
 var moveTop = 0;
 var moveLeft = 0;
 var moveable = false;
 var docMouseMoveEvent = document.onmousemove;
 var docMouseUpEvent = document.onmouseup;
 
 o.onmousedown = function() {
  var evt = getEvent();
  moveable = true; 
  moveX = evt.clientX;
  moveY = evt.clientY;
  moveTop = parseInt(o.style.top);
  moveLeft = parseInt(o.style.left);
  
  document.onmousemove = function() {
   if (moveable) {
    var evt = getEvent();
    var x = moveLeft + evt.clientX - moveX;
    var y = moveTop + evt.clientY - moveY;
    if (x > 0  && (x + parseInt(o.style.width) < winWidth)  &&  y > 0  &&  (y + parseInt(o.style.height) < winHeight) ) {
     o.style.left = x + "px";
     o.style.top = y + "px";
    }
   } 
  };
  
  document.onmouseup = function () { 
   if (moveable) { 
    document.onmousemove = docMouseMoveEvent;
    document.onmouseup = docMouseUpEvent;
    moveable = false; 
    moveX = 0;
    moveY = 0;
    moveTop = 0;
    moveLeft = 0;
   } 
  };
}*/
}

function CreateDiv() {	
for(i=0;i<MascotNum;i++){
document.write("<div id='Mascot"+i+"' style='position:absolute; width:2px; height:2px; left:0px; top:0px; z-index:200;'></div>");}
document.write("<div id='Menu' style='position:absolute; width:133px; height:25px; left:0px; top:0px; z-index:3; visibility:hidden; border: 1px none #000000;' onselectstart='return false'></div>");
document.write("<div id='chatbox' style='position:absolute; width:380px; height:24px; left:0px; top:0px; z-index:2;'></div>");
document.write("<div id='dia' style='position:absolute; width:318px; height:200px; left:0px; top:440px; z-index:2;'></div>");
document.write("<div id='showmsg' style='position:absolute; width:130px; height:130px; left:0px; top:0px; z-index:4; visibility:hidden; border: 1px #000000;background-repeat:no-repeat; background-image: url("+_ServerPath+"Message.png);'></div>");
document.write("<div id='showmsg2' style='position:absolute; width:130px; height:130px; left:0px; top:0px; z-index:4; visibility:hidden; border: 1px #000000;background-repeat:no-repeat; background-image: url("+_ServerPath+"Message2.png);'></div>");
}

function Settings() {
	
	winHeight = document.body.clientHeight;
	winWidth = document.body.clientWidth;
/*if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth){
	
	winHeight = document.documentElement.clientHeight;
	winWidth = document.documentElement.clientWidth;
}else{
	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;  	
}*/

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 (document.documentElement  && document.documentElement.clientHeight && 
document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}else{
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;  	
}

MascotR = winWidth-120;
MascotB = winHeight-140;
screenR = winWidth;
screenB = winHeight;
winR = winWidth-100;
winB = winHeight-140;

document.getElementById("chatbox").style.top = winHeight+"px";
for(i=1;i<=9;i++){
if(parseInt(_Mascot[i].top)>=winHeight-140){
_Mascot[i].top = String(winHeight-140)+"px";}
if(parseInt(_Mascot[i].left)>=winWidth-120){
_Mascot[i].left = String(winWidth-120)+"px";}
}
sc3();
}

function sc3(){
 _Mascot[10].top=(document.documentElement.scrollTop+document.documentElement.clientHeight-Mascot[10].offsetHeight)+"px";
 _Mascot[10].left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-Mascot[10].offsetWidth)+"px";
}

window.onscroll=sc3;
window.onresize=sc5;*/
window.onload=LoadAction;CreateDiv();
//window.onbeforeunload=beforeclose;
//window.onunload=pclose;
