// copyright by edv-organisation thomas päpenmöller gen. peppmöller, Bielefeld, www.edv-organisation.de

// const
var lastMsgAccess=0;
var sessInva=false;

// classes

function wTypeInfo(){
  classType='wTypeInfo';
  this.setup = function(id,head){
    this.inherited(wTypeInfo.prototype.setup).method(id,head);
    with (this){
      //bgImg         = 'alpha/blue.gif';
      self.bgAlpha='blue';
      self.cssClass='win1';
      self.headerSize=19;
      
      head.cssClass='';
      head.optRight = fnClose(this.idStr);

      body.padding=3;
      body.borderSize=2;
      body.bgAlpha=noAlphaImg?"1":"black20";
      body.style='overflow:hidden; border: 2px solid; border-color: #000033 #0000B0 #0000B0 #000033; font-family:Verdana; color:#77CCFF; font-size:10px';
      
      //body.cssClass = 'wmsgb';
    };
  };
};
regClass(wTypeInfo,TWin);

function wTypeAni(){
  classType='wTypeAni';
  this.setup = function(id,head){
    this.inherited(wTypeAni.prototype.setup).method(id,head);
    with (this){
      cssClass ='win1'
      bgAlpha='blue';
      headerSize=34;

      with (head){
        img ='aniEarth.gif';
        head.cssClass='';
      };
      body.padding=3;
      body.borderSize=2;
      body.bgAlpha=noAlphaImg?"1":"black20";
      body.style='overflow:hidden; border: 2px solid; border-color: #000033 #0000B0 #0000B0 #000033; font-family:Verdana; color:#77CCFF; font-size:10px';
    };
  };
};
regClass(wTypeAni,TWin);

function wTypeStd(){
  classType='wTypeStd';
  this.setup = function(id,head){
    this.inherited(wTypeStd.prototype.setup).method(id,head);
    with (this){
      self.headerSize=19;
      self.cssClass='win1';
      self.bgAlpha="blue";
      self.padding=3;
      self.borderSize=1;
      head.optRight = fnClose(idStr);
      head.cssClass='';

      body.fieldEffect="sbg";
      body.padding=3;
      body.borderSize=2;
      body.bgAlpha=noAlphaImg?"1":"black20";
      body.style='overflow:hidden; border: 2px solid; border-color: #000033 #0000B0 #0000B0 #000033; font-family:Verdana; color:#77CCFF; font-size:11px';
    };
  };
};
regClass(wTypeStd,TWin);



with (TMsgBox.prototype){
  headerSize=16;
};
with (TMsgBoxInfo.prototype){
  cssClass="win1";
  bodyStyle='overflow:hidden; color:#77CCFF; background-color:#000044';
  bgImg='alpha/blue.gif';
  headClass='';
  actionStr='weiter';
};
with (TMsgBoxWait.prototype){
  cssClass="win1";
  defHeight=130
  msgHeader='Bitte warten';
  bodyStyle='overflow:hidden; color:#77CCFF; background-color:#000044';
  bgImg='alpha/blue.gif';
  headClass='';
  actionStr='abbrechen';
  headerSize=34;
  TMsgBoxWait.prototype.msgBoxWaitSetup=setup;
  setup = function(msg,fnc){
                 this.msgBoxWaitSetup(msg,fnc);
                 with (this.head){
                   img ='aniEarth.gif';
                   optRight='';
                 };
               };
};

with (TMsgBoxWarning.prototype){
  cssClass="win2";
  msgHeader='Achtung';
  bgImg='alpha/4.gif';
  bodyStyle='overflow:hidden; color:#FFCC66; background-color:#330000';
  headClass='';
  actionStr='weiter';
  //color:#FFCC99;

};


function TComChannel(){
  this.classType='wTypeStd';
  this.channel=0;
  this.headerSize=22;
  this.bgImg='skin/01/bgatt.png';
  this.bgAlpha='';

  this.setup = function(sid,c,cName,game,art){
    this.channel=c;
    this.game=game;
    this.art=art;
    this.msgData=new Array();
    this.contactName=cName;
    this.time=0;
    this.chId=c>0?c:'x'+(-c);
    this.inherited(TComChannel.prototype.setup).method('comChannel'+this.chId,'Gespr&auml;ch mit '+cName);

    //bgAlpha='dgreen80';

    with (this){
      pos(160,90,400,500);
      //style+=';background-color:#000000;';
      head.topOfs=2;
      with (body){
        margin=6;
        style+=';background-color:#001100;';
        bgImg='';
        fixHtml='<div style="position:absolute;left:0;top:0;width:'+(position.w-15)+';height:'+(position.h-18)+';overflow:auto;scrollbar-track-color:#002200"><table id="SB'+idStr+'" cellpassing="0" cellspacing="0"><tr height="'+(position.h-19)+'"><td class="msgData" valign="bottom"><div id="innerChannel'+this.chId+'">'+
               '</div><table cellpadding="0" cellspacing="1"><tr><td><input type="text" id="sndComChannel'+this.chId+'" onKeyDown="if(event.keyCode==13)'+this.idStr+'.send()" class="inp1" style="width:'+(position.w-64)+'" ></td><td><input type="button" class="inp1" style="width:25;height:20" value="->" onClick="'+this.idStr+'.send()"></td></tr></table></td></tr></table></div>';
      };
    };
  };

  this.run=function(){
    with(this){
      show();
      var x=time?'&time='+time:'';
      ldData(window.all.portal.mainWin,'mail','p=channel&channel='+channel+x+'&game='+game+'&art='+art+'&object='+idStr,true);
    };
  };

  this.setMsg=function(name1,date,msg,id,gId){
    var o=new Object();
    o.oname=name1;
    o.time=date;
    o.text=msg;
    o.mid=id;

    with (this)msgData[msgData.length]=o;
  };

  this.send=function(){
    with(this){
      var n='sndComChannel'+this.chId,f=document.getElementById(n);
      var x=time?'&time='+time:'';
      var h=f.value;f.value='';
      ldData(window.all.portal.mainWin,'mail','channel='+channel+'&p=post&art=1&object='+idStr+x+'&inhalt='+escape(h),true);
    };
  };

  this.set = function(){
    with (this){
      var h='';
      for (var i=0;i<msgData.length;i++)
      with (msgData[i]){
        var ti=time.split(' ');
        h+=('<table class="msgData" cellpadding=0 cellspacing=0 border=0><tr><td width="82"><i title="'+time+'">'+ti[0].substr(0,5)+' '+ti[1].substr(0,5)+'</i></td><td width="20"><img src="'+imgpath+'kill.gif" style="cursor:pointer" onclick="'+idStr+'.deleteMsg('+mid+')" alt="Nachricht löschen" title="Nachricht löschen"></td><td width="100">[<u >'+oname+'</u>]</td></tr></table><br><font color="#AAFF99">'+text+'</font><br>');
      };

      document.getElementById('innerChannel'+this.chId).innerHTML=h;
      nextFocus='sndComChannel'+this.chId;
      setFocus();
    };
  };
  this.deleteMsg=function (mid){
    with (this){
      msgData=new Array();
      ldData(window.all.portal.mainWin,'mail','p=delMsg&channel='+channel+'&mid='+mid+'&game='+game+'&art='+art+'&object='+idStr,true);
    };
  };
};
regClass(TComChannel,wTypeStd);


function openChannel(ch,cName,game,art){
   var chId=ch>0?ch:'x'+(-ch);
   openForm(window.all.portal,'comChannel'+chId,'TComChannel',ch,cName,game,art);
};


function addContact(name){
  ldData(this,'mail','p=add&name='+name);
};
function doAddContact(){
  var a=document.getElementById('mAddContact');
  if(a&&a.value>''){
    addContact(a.value);
    a.value='';
  };
};


// intro   *************************************************************************************
var portalMusic='xLE_Login_03.mp3';

function PlayIntro(){
  with (this){
    setup('playIntro','Nachricht wird abgespielt');
    pos(10,10,814,655);

    with (body.add(TLnk)){pos(10,608); setup('btSkip','Ende','window.all.playIntro.onClose()'); title='Intro schließen'};

    body.fixHtml='<iframe id="movie@intro" frameborder="0" border=0 src="intro/load.html" width="805" height="605"></iframe>';
  };
  this.onClose=function(){
    this.hide();
    skipIntro=true;
    portalStart();
  };
};
regClass(PlayIntro,wTypeInfo);


function Intro(){
  this.setup=function(){
    with (this){
      inherited(Intro.prototype.setup).method('intro','eingehende Nachricht, bitte warten:');
      pos(200,200,500,300);
      isStarted=false;

      with (body.add(TLnk)){pos(10,225); setup('btSkip','skip intro','window.all.intro.onClose()'); title='Intro schließen'};

      body.fixHtml=
        '<b><div id="waitTxt" class="TTxtFont1" style="position:absolute; left:10; top:10; color:#8888FF"></div></b>'+
        '<iframe style="visibility:hidden;" src="intro/load.html" width="1px" height="1px"></iframe>'+
        hImg(415,175,'leRuneA.gif');
    };
  };
  this.startMovie= function (){
    //document.getElementById('movie@intro').style.visibility='visible'
    if(!this.isStarted){
      this.isStarted=true;
      var n=new PlayIntro();
      this.hide();
      n.show();
    };
  };
  this.wait = function (){
    if (this.isVisible&&!this.isStarted){
      document.getElementById('waitTxt').innerHTML+='-';
      setTimeout('all.intro.wait()',1000);
    };
  };
  this.run  = function(){
    cookieData['intro']="OFF"; 
    saveCookie();
    this.isStarted=false;
    this.show();
    this.wait();
  };
  this.onClose=function(){
    this.hide();
    skipIntro=true;
    portalStart();
  };
};
regClass(Intro,wTypeAni);


function BasicSetup(){
  this.setup=function(){
    with(this){
      inherited(BasicSetup.prototype.setup).method('basicSetup','Grundeinstellungen');
      pos(180,200,600,320);
      var px=10,py=110,ts=260;
      with(body){
        with(add(TABtn)){setup('impressum','Impressum',                  'openForm(window.all.portal,\'impressum\',\'TMImpressum\')');         pos(505,0)};
        with(add(TCheckBox)){
          setup('btAlpha',ts+20,cookieData['pngAlpha']=='1'?'ON':'OFF'); pos(px,(py+=20)); text='bessere Transparenzeffekte (PNG): '; 
          textWidth=ts; 
          onClick="cookieData['pngAlpha']="+idStr+".state?'1':'0';saveCookie();document.location.reload()";
        };
        with(add(TText))    {setup('txt1'); value='<i>(Fehler im Internet Explorer 6) -> <a href="http://forum.zockwelten.de/thread.php?threadid=938" style="color:#77CCFF"; target="blank"> Infos hier</a></i>'; pos(px+ts+30,py,300,20)};
        /*with(add(TCheckBox)){setup('btSound',ts+20,cookieOpt('sound','ON')); pos(px,(py+=20)); text='Multimedia - Sound aktivieren: ';  textWidth=ts; onClick="cookieData['sound']="+idStr+".getValue();saveCookie();"};
        with(add(TCheckBox)){setup('btMovie',ts+20,cookieOpt('movie','ON')); pos(px,(py+=20)); text='Multimedia - Videos aktivieren: '; textWidth=ts; onClick="cookieData['movie']="+idStr+".getValue();saveCookie();"};
        with(add(TCheckBox)){setup('btChat', ts+20,cookieOpt('chat', 'ON')); pos(px,(py+=20)); text='Multimedia - Chat aktivieren: ';   textWidth=ts; onClick="cookieData['chat']="+ idStr+".getValue();saveCookie();"};
        */
        with(add(TCheckBox)){setup('btIntro',ts+20,cookieOpt('intro','ON')); pos(px,(py+=20)); text='Zockwelten - Intro aktivieren: ';  textWidth=ts; onClick="cookieData['intro']="+ idStr+".getValue();saveCookie();"};
        with(add(TButton))  {
          setup('btNot',  100,'im Fehlerfall');pos(this.position.w-225,this.position.h-63,100,24)
          this.hide;
          onClick="this.win.notfall()";
        };
        with(add(TButton))  {
          setup('btStart',100,'START');style="font-weight:bold"; pos(this.position.w-122,this.position.h-63,100,24);
          onClick="this.win.onClose()";
        };
        fixHtml='<b><font size=4>Hinweis zu Ladezeiten:</font></b><br>&nbsp;<br><b>zockWelten</b> ist sehr Modular aufgebaut. Viele Module werden nur <i><u>einmal</u></i> geladen und verbleiben im Cache auf ihrem Rechner. Nach dem Laden von Masken und Modulen, wird somit eine hohe Geschwindigkeit erreicht.<br>&nbsp;<br>&nbsp;<br><b>Optionen: </b>';
      };

/*
      with(body){
        //style+=';background-color:#000033;';
        fixHtml='<br> &#9658; Vebindungsgeschwindigkeit (Soundqualität)? '+
                      '<select size="1" ID="speed" style="width:100; border:0px solid blue; background-color:#AAEEFF"><option value="LO" >ISDN</option><option selected value="MI">DSL normal</option><option value="HI">DSL schnell</option></select>'+
                      '<br><br><br><b>Wichtiger Hinweis:</b><p>lastEvolution ist sehr Modular aufgebaut. Viele Module werden nur <i>einmal</i> geladen und verbleiben im Cache auf ihrem Rechner.</p>Dadurch ist auch mit ISDN, nach dem einmaligem Laden von Masken und Modulen, eine hohe Spielgeschweindigkeit erreichbar.';
      };
      with (body.add(TLnk)){pos(this.body.position.w/2-40,body.position.h-28); setup('btOk','weiter',this.idStr+'.onClose()'); title='OK, weiter ...'};
*/
      this.onClose=function(){
        if(cookieOpt('movie','ON')!='ON')skipIntro=1;
        if(cookieOpt('intro','ON')!='ON')skipIntro=1;
        
        this.hide();
        skipSetup=1;
        portalStart();
      };
    };
  };
  this.notfall=function (){
    skipIntro=1;
    modulesLoaded=1;
    skipSetup=1;
    this.hide();
    portalStart();
  };
};
regClass(BasicSetup,wTypeStd);

function LoadFrame(sid,msg,l,t,w,h,href){
  var i=new wTypeInfo();
  with(i){
    setup(sid,msg);
    pos(l,t,w,h);
    //style+=';background-color:#006699;';

    body.fixHtml='<iframe id="fr_'+idStr+'" frameborder="0" border=0 ALLOWTRANSPARENCY src="'+href+'" style="position:absolute;left:0;top:0;width:'+(w-10)+';height:'+h+'"></iframe>';
    show();
  };
  return h;
};                                  


function respHttpReq(ch){
  if(all.ldData)all.ldData.onClose();
  var ans=xmlHttp[ch].responseText; // mit dem antwortcode könnte eine neue Anfrage gesendet werden
  httpClose(ch);
  document.body.style.cursor='';
  var o=document.getElementById('isLoading');
  if(o)o.style.visibility='hidden';
//alert(ans);
  window.eval(ans);
};

var reqTimeout1 = 0;
function ldData(dobj,req,param,async,ch){
  //async=false;
  reqTimeout1=0;
  var src='php/com/'+req+'.php'; if(!ch)ch=0;
  src+='?s='+user.sess+'&mail=show&msgsync='+window.lastMsgAccess+'&reqCount='+xmlReqCount+'&'+param+'&DBGSESSID=1@localhost:7869;d=0';

  if(async){
    document.body.style.cursor='wait';
    if(async!=2){
      document.getElementById('isLoading').style.visibility='';
    }
    else{
      var i=new wTypeAni();
      with(i){
        setup('ldData','<span style="line-height:30px">&nbsp;Portal NET-Funk</span>');
        //self.bgAlpha  ='black80';
        self.bgAlpha='';
        //self.bgImg='';
        var w=350,h=100;
        pos(200,200,w,h);
        self.style+=';background-color:#000066;';
        //body.bgAlpha="blue";
        body.fixHtml=' <br>&nbsp; Anfrage gesendet, erwarte Antwort ...';
        show();
      };
    };
    httpGet(src,respHttpReq,true,ch);
  }
  else{
    var m=window.status;
    window.status='Lade Daten, bitte warten !!!!';
    httpGet(src,0,false,ch);
	if (xmlHttp[ch].readyState == 4) {
      var ans=xmlHttp[ch].responseText; // mit dem antwortcode könnte eine neue Anfrage gesendet werden
      httpClose(ch);
      window.eval(ans);
    };
    window.status=m;
  };
};

function PortalLogin(){
  this.setup=function(){
    with(this){
      inherited(PortalLogin.prototype.setup).method('mainWin','&#9500;&#9679; Portal &#9679;&#9508; Anmeldung');
      pos(mainLeft,mainTop+73,mainWidth,appHeight-mainTop-73);

      head.optRight = fnClose(idStr);
      body.fieldEffect="sbg";
      if(isOpera){
        bgAlpha='';
        bgImg='alpha/blue.gif';
      };
      body.style='overflow:hidden; border: 2px solid; border-color: #000033 #0000B0 #0000B0 #000033; font-family:Verdana; color:#77CCFF; font-size:12px';
      with(body){
        if(isOpera){
          bgAlpha='';
          bgImg='alpha/1.gif';
        };
        //style+=';background-color:#000033;';
        var hp='';
        var ofs=0;
        function i(l,t,n,p,a){
          if(p)hp=p;
          return '<img src="'+gameImg+hp+n+'.gif" '+((a)?' alt="'+a+'" title="'+a+'" style="cursor:help;':'style="')+'position:absolute;left:'+(l+ofs-170)+';top:'+(110+t)+'">';
        };
        function nofs(o){ofs=o;return ''};
        body.fixHtml=hImg(1,-10,'efria2.gif')+
                 '<div style="position:absolute; left:200;top:10;width:500"><b>Hallo mein Freund,<br><br>bitte Identifiziere Dich.</b></div>'+
                 '<div style="position:absolute;left:200;top:120"></div>'+
		//erste Zeile ist unten
                 nofs(400)
		+i(-32,236,'swater1','areas/')+i(32,236,'sdIce1')+i(96,236,'sIce4')+i(160,236,'sBank2')+i(224,236,'sForesth')+i(288,236,'sHMountain4')+i(352,236,'sHMountain4')
		+i(0,220,'swater1')+i(64,220,'sIce2')+i(128,220,'sdIce4')+i(192,220,'sField1')+i(256,220,'sMeadow2')+i(320,220,'sHMountainH')+i(384,220,'sHMountain4')
		+i(32,204,'swater1')+i(96,204,'sIce3')+i(160,204,'sField3')+i(224,204,'sForest5')+i(288,204,'sHMountain4')+i(352,204,'sHMountain1')+i(352,172,'sHMountain2')
		+i(0,188,'swater1')+i(64,188,'swater1')+i(128,188,'sField4')+i(192,188,'sLake3')+i(256,188,'sForest1')+i(320,188,'sLake5')
   		+i(32,172,'swater1')+i(96,172,'swater1')+i(160,172,'sSwamp1')+i(224,172,'sForest4')+i(288,172,'sLake4')+i(352,172,'sForest2')
		+i(64,156,'swater1')+i(128,156,'swater1')+i(192,156,'sLake4')+i(256,156,'sForest1')+i(320,156,'sForest4')
		+i(96,140,'swater5')+i(160,140,'sMeadow2')+i(224,140,'sMeadow1')+i(288,140,'plane')+i(352,140,'planel')
		+i(128,124,'swater1')+i(192,124,'swater1')+i(256,124,'swater1')+i(320,124,'sForest1')
		+i(160,108,'swater1')+i(224,108,'swater1')+i(288,108,'swater1')+i(352,108,'swater1')
		+i(192,92,'swater1')+i(256,92,'sOase2')+i(320,92,'swater1')
		+i(224,76,'swater1')+i(288,76,'sdDesert5')+i(352,76,'swater1')
		+i(192,60,'swater1')+i(256,60,'mountain')+i(320,60,'sOase1')
		+i(224,44,'swater1')+i(288,44,'mountain')+i(352,44,'swater1')
		+i(256,28,'swater1')+i(320,28,'swater1')
		+i(288,12,'swater1')+i(352,12,'swater1')
//animiert
		+i(150,34,'aniship','creatures/')
		+i(64,200,'geomesq','creatures/','Geomes"  onClick="LoadFrame(\'info\',\'Rasse Geomes\',595,132,300,270,\'/faq/test.php?faq_id=23\')')
                 +i(310,60,'humans','creatures/','Humans"  onClick="LoadFrame(\'info\',\'Rasse Humans\',595,132,300,270,\'/faq/test.php?faq_id=14\')')
                 +i(250,150,'relons','creatures/','Relons"  onClick="LoadFrame(\'info\',\'Rasse Relons\',595,132,300,270,\'/faq/test.php?faq_id=22\')')
                 +i(300,160,'gorgones','creatures/','gorgones"  onClick="LoadFrame(\'info\',\'Rasse Gorgones\',595,132,300,270,\'/faq/test.php?faq_id=24\')')
                 +i(130,150,'fleet','creatures/','Schiff"  onClick="LoadFrame(\'info\',\'Schiff\',595,132,300,270,\'/faq/test.php?faq_id=21\')')
		+i(192,220,'centero','build/','Zentrum"  onClick="LoadFrame(\'info\',\'Zentrum\',595,132,300,270,\'/faq/test.php?faq_id=20\')')



        +nofs(0)
		+i(392,245,'swater1')+i(352,236,'sdIce1','areas/')+i(288,236,'sIce4')+i(224,236,'sBank2')+i(160,236,'sForesth')+i(96,236,'sHMountain4')+i(32,236,'mountain')+i(-32,236,'mountain')
		+i(384,220,'swater1')+i(320,220,'sIce2')+i(256,220,'sdIce4')+i(192,220,'sField1')+i(128,220,'sMeadow2')+i(64,220,'mountain')+i(0,220,'mountain')
		+i(352,204,'sIce2')+i(288,204,'sIce4')+i(224,204,'sBank2')+i(160,204,'sSwamp1')+i(96,204,'sForest4')+i(32,204,'sHMountain4')+i(-32,204,'sHMountain4')
		+i(392,192,'swater1')+i(384,188,'swater1')+i(320,188,'sBank4')+i(256,188,'sBank2')+i(192,188,'sSwamp2')+i(128,188,'sLake4')+i(64,188,'sForest4')+i(0,188,'sForest4')
		+i(352,172,'swater1')+i(288,172,'sMeadow4')+i(224,172,'sLMountain4')+i(160,172,'sMeadow3')+i(96,172,'sForest1')+i(32,172,'sForest1')+i(-32,172,'sLake5')
		+i(320,156,'swater1')+i(256,156,'sLMountain2')+i(192,156,'sLMountain5')+i(128,156,'sLake3')+i(64,156,'sLake5')+i(0,156,'sForest4')
		+i(288,140,'swater1')+i(224,140,'sLMountain1')+i(160,140,'sLake5')+i(96,140,'sForest3')+i(32,140,'sForest2')+i(-32,140,'sForest5')
		+i(256,124,'swater1')+i(192,124,'swater1')+i(128,124,'sMeadow2')+i(64,124,'sForest4')+i(0,124,'sForest5')
		+i(224,108,'swater1')+i(160,108,'swater1')+i(96,108,'swater1')+i(32,108,'swater1')+i(-32,108,'swater1')
		+i(192,92,'swater1')+i(128,92,'swater1')+i(64,92,'swater1')+i(0,92,'swater1')
		+i(288,180,'krieger27','archive/figuren/')+i(255,122,'krieger22')
		+i(172,180,'panzer12','archive/KFZ/')
		+i(172,92,'ship16','archive/Ships/')
        //+'<div style="position:absolute;left:100;top:280;font-size:16px;font-weight:bold">Achtung: Das neue Portal ist noch nicht fertig!<br><a href="decision2/login/"><font color="red"><u><b> -> Alte The-Decision Lobby</b></u></font></a></div>'                 ;
        sound(portalMusic,-12+backgroundVolume,1);
        var h=body.position.h-28, tStyle="font-family:Verdana;font-size:12px;font-weight:bold";
        with(add(TInput)){setup('uName',160,cookieOpt('userName',''));textWidth=80;text='Name';     textStyle=tStyle; style="font-weight:bold; border-left:1px dashed #AABBFF;border-top:0px;border-bottom:1px dashed #AABBFF;border-right:0px;"; pos(200, 80)};
        with(add(TInput)){setup('uPass',160,'');                      textWidth=80;text='Kennwort'; textStyle=tStyle; style="font-weight:bold; border-left:1px dashed #AABBFF;border-top:0px;border-bottom:1px dashed #AABBFF;border-right:0px;"; pos(200,102);self.password=true};
        with(add(TButton)){
          setup('btLogin',80,'Login');style="font-weight:bold"; pos(380,102);          
          onClick=this.idStr+".doLogin()";
        };
        with(add(TCheckBox)){
          setup('sData',200,cookieData['userName']>''?'ON':'OFF');textWidth=180;text='automatisch Anmelden ?';textStyle=tStyle; pos(200,124)
        };
        //with (add(TLnk)){pos(580,100); setup('btGuest','<font color="#FFFF88">&#8594; <b><u>sofort als Gast spielen</u></b></font>',win.idStr+'.guest(2)')};
        //with (add(TLnk)){pos(580,120); setup('btGuest2','<font color="#FFFF88">&#8594; <b><u>als Gast ins Portal</u></b></font>',win.idStr+'.guest(1)')};
        with (add(TLnk)){pos(420, 20); setup('btReg','<font color="#FFCC00">&#8594; <b><u>Spieler registieren</u></b></font>','openForm(window,"reg","TRegister")')};//this.idStr+'.onClose()')};
        with (add(TLnk)){pos(420, 40); setup('btNPW','<font color="#FFCC00">&#8594; <b><u>Kennwort vergessen</u></b></font>','openForm(window,"reg","TPass")')};//this.idStr+'.onClose()')};
      };
      //with (body.add(TLnk)){pos(350,180); setup('btOk','Zugang als Gast gewähren','alert("Das neue Portal ist noch nicht fertig!\\nDaher werden Sie an die alte Lobby weiter geleitet.");window.document.location.assign("http://zockwelten.de/decision2/login/")')};//this.idStr+'.onClose()')};
      this.doLogin=function(){
        with(this.body){
          var uN=uName.getValue(), uP=uPass.getValue();
          ldData(null,'lobby1','fnc=login&uname='+escape(uN)+'&code='+escape(uP),1);
        };
      };
      this.onClose=function(){
        this.hide();
        //skipLogin=true;
        //setTimeout('portalStart()',400);
      };
    };
  };
  this.guest=function(fnc){
    if(fnc==2){
      window.guestGame=window.open('','guestGame','resizable=1,status=0,width=1000,height=620,screenX=1,screenY=1');
      window.guestGame.document.write('lade Game vom Gastserver ... bitte warten');
      ldData(null,'lobby1','fnc=login&uname=guest&direktStart=true&code=',2);
    }
    else ldData(null,'lobby1','fnc=login&uname=guest&code=',2);
  };
};
regClass(PortalLogin,wTypeStd);

function loginError(){
  alert('Benutzer umbekannt, oder Kennwort falsch!');
};

function sessionInvalid(){
  if(!sessInva){
    sessInva=true;
    alert('Die Session ist abgelaufen, bitte erneut einloggen');
    //document.location.assign('http://www.the-decision.de/index.php?open=login');
    document.location.reload();
  };
};

function setSession(uname,usess,md5){
  user.name=uname;
  user.sess=usess;
  var o=document.getElementById('zwMember');
  window.all.portal.setUser();
  if(o){
    if(window.all.portal.mainWin)
    with (window.all.portal.mainWin.body){
      if(sData.state){
        cookieData['userName']=uname;
        cookieData['userPass']=md5;
      }
      else {
        cookieData['userName']='';
        cookieData['userPass']='';
      };
      saveCookie();
    };
  }
  else {
    skipLogin=true;
    setTimeout('portalStart()',400);
  };
};

function sortMsgs(a,b){return b.timeStamp-a.timeStamp;};

function TShoutBox(oObj,name){
  this.data=new Array();
  this.changed=false;
  this.oObj=oObj;
  this.name=name;

  this.set = function(){
    var sd=arguments;
    this.data=new Array();
    this.changed=true;
    for (i=0;i<sd.length-1;i+=5){
      var o=new Object();
      o.timeStamp=sd[i];
      o.id=sd[i+1];
      var hname=sd[i+2].split(';');
      o.name=hname[0];
      o.volk=hname[1];
      o.time=sd[i+3];
      o.squad=o.time.indexOf(':SQUAD')>0;
      o.text=sd[i+4];
      this.data[this.data.length]=o;
    };
    this.view(sd[sd.length-1]==''?1:2);
  };

  this.view = function(mode){
    with(this)if(changed||(mode==2)){
      var iw,ih;
      with(oObj.owner){
        self.vmode=mode;
        if(mode==2){
          position.h=position.h1;          
          position.t=position.t1;
          iw=position.w-28;
          ih=position.h-25;
        }
        else {
          if(!position.w1){
            position.h1=position.h;
            position.t1=position.t;
          }
          else {
            position.h=position.h1;
            position.t=position.t1;
          };
          iw=position.w-10;
          ih=position.h-10;
        };
        oObj.position.w=position.w-8;
        oObj.position.h=position.h-21;
      };
      this.data=data.sort(sortMsgs);
      var h='', s=data.length-1; //if(s>5)s=5;
      for(var i=s;i>=0;i--){
        with(data[i]){
          var ti=time.split(' '),txt=text, hname='';
          //if(volk)hname='<font color="'+colors[volk]+'">'+name+':'+bundsb[volk]+'</font>';
          //if(volk)hname='Nation '+volk;
          hame='';
          if(squad)txt='<span style="color:#DDFF88"><span style="color:#FF6600;cursor:pointer" onClick="event.cancelBubble=true;info(6,10)">SQUAD:</span>'+text+'</span>';
          h+='<div style="width:'+(iw-10)+'"><i title="'+time+'">'+ti[1].substr(0,5)+'</i> [<u style="cursor:pointer" onClick="showUser('+id+',\''+name+'\')">'+name+'</u>] '+hname+'<br><span class="msgTxt">'+txt+'</span><br></div>';
        };
      };
      with (oObj){
        fixHtml='<div style="position:absolute;left:5;top:5;width:'+(oObj.position.w-8)+';height:'+(position.h-34)+';overflow:'+((mode==2)?'auto':'hidden')+'"><table id="SB'+idStr+'" style="position:absolute;'+((mode==2)?'':'bottom:0;')+'" cellpassing="0" cellspacing="0"><tr><td class="msgData" valign="bottom">'+h+'</td></tr></table>'+
        ((mode==2)?'</div>':'<img src="'+imgpath+'upGreen.gif" title="mehr..." onClick="ldData(window,\'zwSystem\',\'shout=refresh&large='+name+'\',true)" style="position:absolute;top:-4;left:'+(iw-27)+';cursor:pointer;"></div>');
        update();
      };
      changed=false;
    };
  };
};


function sbSnd(id){
  var f=document.getElementById('window.all.portal.comChat.shi');
  nextFocus='window.all.portal.comChat.shi';
  if (f.value>''){
    var h=f.value;
    f.value='';
    ldData(window,'zwSystem','shout=post&art=3&inhalt='+escape(h),true);
  }
  else ldData(window,'zwSystem','shout=refresh',true);
};

function updateSBox(){
  reqTimeout1++;
  
  var c=window.all.portal.comChat;
  if(reqTimeout1>30&&c.isVisible&&c.vmode!=2){
    
    ldData(window,'zwSystem','shout=refresh',true);
  };
};


function setFocus(){
  if(nextFocus){
    setTimeout('document.getElementById("'+nextFocus+'").focus()');nextFocus=null;
  };
};

function showUser(id,name){
  openForm(window.all.portal,'userData','TUserInfo',id,name);
};


function sbg(o,f){
  switch (f){
    case 0: with(o.style){backgroundColor='';zIndex=0;backgroundImage=''};break;
    case 1:;
    case 5: with(o.style){backgroundImage='url('+imgpath+'anibg3.gif)';
                          };break;
    case 2: with(o.style){backgroundImage='url('+imgpath+'anibg4.gif)';
                          };break;
    case 3: with(o.style){backgroundColor='transparent';zIndex=0};break;
    case 4: with(o.style){backgroundColor='#220000';zIndex=0};break;
  };
};
