//
// wf_main.js
//
// 05.01.22 äöü

/*
p_Main_Popup_zu
p_Main_resize
p_Main_machKanton
p_Main_SpickWin
p_Main_SpickPrn
p_Main_obBlitz
p_Main_Separate
p_Main_Separate_Sub
p_Main_KrokiWin
p_Main_KrokiPrn
p_Main_Hinweis_starten
p_Main_Hinweis_zeigen
p_Main_Retour
p_Main_Retour_PosNeu
p_Main_Snob_PosNeu
p_Main_Confirm_PosNeu
p_Main_Bild_PosNeu
p_Main_Taste_auf
p_Main_Taste_weg
p_Main_MaxTextVolumen
p_Main_Bild
p_Main_Bild_zeigen
p_Main_StatusFix
p_Main_Dummy
*/


/////
/////
function p_Main_Popup_zu()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.oWinInfo!=null
      &&
      typeof top.oWinInfo.close!="undefined")
    {
    top.oWinInfo.close();
    }  //endIf

  if (top.oWinBlitz!=null
      &&
      typeof top.oWinBlitz.close!="undefined")
    {
    top.oWinBlitz.close();
    }  //endIf

  if (top.oWinDummy!=null
      &&
      typeof top.oWinDummy.close!="undefined")
    {
    top.oWinDummy.close();
    }  //endIf

  if (top.oWinSeparat!=null
      &&
      typeof top.oWinSeparat.close!="undefined")
    {
    top.oWinSeparat.close();
    }  //endIf

  if (top.oWinBild!=null
      &&
      typeof top.oWinBild.close!="undefined")
    {
    top.oWinBild.close();
    }  //endIf

  if (top.oWinEnde!=null
      &&
      typeof top.oWinEnde.close!="undefined")
    {
    top.oWinEnde.close();
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_resize(cID)
{

//Variablen leer

//Variablen füllen


//verarbeiten
top.document.getElementById(cID).height=this.document.body.scrollHeight;

return;
}  //endProz


/////
/////
function p_Main_machKanton(nTaste,cKanton)
{

//Variablen leer
var i;

//Variablen füllen
top.aSystem[9]=cKanton;
//
var cBranche  ="alles";


//verarbeiten
  if (top.aSystem[12]==0)  //Vorgänger ist also schon total sichtbar
    {
    top.aSystem[12]=1;  //weitere sperren bis self vollständig sichtbar
    top.document.getElementById("WartenLayer").style.visibility="visible";

    iframe_liste.location.href="./kanton/kanton.php?pKanton="+cKanton+
                                                  "&pBranche="+cBranche;

//    top.document.getElementById("sound_Higru").src="./sound/dingdong.wav";

     for (i=111; i<=140; i++)  //Zahl aus Menu Kantone (index.htm)
        {
        top.aMenu[i]=0;
        eval('top.taste_'+i+'.style.backgroundColor="#C0C0C0"');  //grau
        }  //endFor

    top.aMenu[nTaste]=1;
    eval('top.taste_'+nTaste+'.style.backgroundColor="#FFFF99"');  //gelblich
    }
  else
    {
    top.document.getElementById("sound_Higru").src="./sound/wf8.wav";
    window.alert("warten bis Vorgänger-Seite vollständig aufgebaut ist  ");
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_SpickWin(cAdrNum,cKanton)
{

//Variablen leer

//Variablen füllen
var nAbTop      =70;
top.aSystem[8]  ="alles";


//verarbeiten
top.oWinInfo=window.open("./../spick/spick.php"+
                         "?pAdrNum="+cAdrNum+
                         "&pKanton="+cKanton+
                         "&pBranche="+top.aSystem[8],
                         "WinInfo",
                         "width =500,"+
                         "height=550,"+
                         "left  =270,"+
                         "top   ="+nAbTop+","+
                         "noresizable");

return;
}  //endProz


/////
/////
function p_Main_SpickPrn()
{

//Variablen leer

//Variablen füllen


//verarbeiten
window.print();

return;
}  //endProz


/////
/////
function p_Main_obBlitz(cVorspann,cEmail)
{

//Variablen leer
var niO;

//Variablen füllen
var nAbTop      =20;


//verarbeiten
  if (top.kTrittbrett==1)  //ist nicht MSIE
   {
    nAbTop=0;
    }  //endIf

  if (top.IsLocal=="nein")
    {
      if (top.oWinBlitz==null)
        {
        niO=0;
        }
      else  //top.oWinBlitz!=null
        {
          if (top.oWinBlitz.closed==true)
           {
            niO=0;
            }
          else  //top.oWinBlitz.closed!=true
            {
            niO=1;
            top.document.getElementById("sound_Index").src="./sound/dingdong.wav";
            window.alert("erst geöffnete Blitznachricht schliessen  ");
           }  //endIf  top.oWinBlitz.closed
        }  //endIf  oWinBlitz
    }
  else  //top.IsLocal!="nein"
    {
    niO=4;
    top.document.getElementById("sound_Index").src="./sound/dingdong.wav";
    window.alert("offline, daher keine Blitznachricht möglich  ");
    }  //endIf  top.IsLocal
//
  if (niO==0)
    {
      if (cEmail.length!=0)
        {
        top.aSystem[10]=1;
        top.aSystem[11]=cEmail;
        top.oWinBlitz=window.open("./"+cVorspann+"blitz/blitz.htm",
                                  "WinBlitz",
                                  "width =490,"+
                                  "height=620,"+
                                  "left  =250,"+
                                  "top   ="+nAbTop+","+
                                  "noresizable");
        }
      else  //hat noch keine
        {
        top.document.getElementById("sound_Index").src="./sound/wf8.wav";
        window.alert("per eMail noch nicht erreichbar  ");
        }  //endIf

    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Separate(nTyp,cWWW)
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (nTyp==1)
    {
    top.document.getElementById("sound_Higru").src="./sound/wf3.wav";
    }  //endIf
  if (nTyp==2)
    {
    top.document.getElementById("sound_Higru").src="./sound/battle.wav";
    }  //endIf
  if (nTyp==3)
    {
    top.document.getElementById("sound_Higru").src="./sound/woow.wav";
    }  //endIf
  if (nTyp==4)
   {
    top.document.getElementById("sound_Higru").src="./sound/dingdong.wav";
    }  //endIf
  if (nTyp==5)
    {
    top.document.getElementById("sound_Higru").src="./sound/beifall.wav";
    }  //endIf

top.oWinSeparat=window.open(cWWW,
                            "WinSeparat",
                            "width     ="+top.kWinBaussen+","+
                            "height    ="+top.kWinHredu+","+
                            "left      =0,"+
                            "top       ="+top.kAbTop+","+
                            "menubar   =yes,"+
                            "location  =yes,"+
                            "resizable =yes,"+
                            "scrollbars=yes,"+
                            "status    =yes,"+
                            "toolbar   =yes");

return;
}  //endProz


/////
/////
function p_Main_Separate_Sub(nTyp,cWWW)
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (nTyp==1)
    {
    opener.top.document.getElementById("sound_Higru").src="./sound/wf3.wav";
    }  //endIf
  if (nTyp==2)
    {
    opener.top.document.getElementById("sound_Higru").src="./sound/battle.wav";
    }  //endIf
  if (nTyp==3)
    {
    opener.top.document.getElementById("sound_Higru").src="./sound/woow.wav";
    }  //endIf
  if (nTyp==4)
    {
    opener.top.document.getElementById("sound_Higru").src="./sound/dingdong.wav";
    }  //endIf
  if (nTyp==5)
    {
    opener.top.document.getElementById("sound_Higru").src="./sound/beifall.wav";
    }  //endIf

opener.top.oWinDummy=window.open(cWWW,
                                 "WinDummy",
                                 "width     ="+opener.top.kWinBaussen+","+
                                 "height    ="+(opener.top.kWinHredu-
                                                (opener.top.kAbTop*2+4))+","+
                                 "left      =0,"+
                                 "top       ="+(opener.top.kAbTop*2+4)+","+
                                 "menubar   =yes,"+
                                 "location  =yes,"+
                                 "resizable =yes,"+
                                 "scrollbars=yes,"+
                                 "status    =yes,"+
                                 "toolbar   =yes");

return;
}  //endProz


/////
/////
function p_Main_KrokiWin(cAdrNum)
{

//Variablen leer

//Variablen füllen
var nAbTop      =50;
top.aSystem[8]  ="alles";


//verarbeiten
  if (top.kTrittbrett==1)  //ist nicht MSIE
   {
    nAbTop=0;
    }  //endIf

top.oWinInfo=window.open("./../lage/lage.php"+
                         "?pAdrNum="+cAdrNum+
                         "&pKanton="+top.aSystem[9]+
                         "&pBranche="+top.aSystem[8],
                         "WinInfo",
                         "width =720,"+
                         "height=600,"+
                         "left  =200,"+
                         "top   ="+nAbTop+","+
                         "noresizable");

return;
}  //endProz


/////
/////
function p_Main_KrokiPrn()
{

//Variablen leer

//Variablen füllen


//verarbeiten
window.print();

return;
}  //endProz


/////
/////
function p_Main_Hinweis_starten(nWahl)
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (nWahl==1)
    {
    top.document.getElementById("HinweisLayer").style.visibility="visible";
    top.xHinweis=window.setInterval("p_Main_Hinweis_zeigen()",10);
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Hinweis_zeigen()
{

//Variablen leer

//Variablen füllen
top.aSystem[19]++;


//verarbeiten
top.document.getElementById("HinweisLayer").style.left=
  parseInt(top.document.getElementById("HinweisLayer").style.left)+1;

  if (top.aSystem[19]>=750)
    {
    top.document.getElementById("HinweisLayer").style.visibility="hidden";
    window.clearInterval(top.xHinweis);
    top.xHinweis="";
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Retour()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.aSystem[8]==1)
    {
    top.aSystem[8]=0;  //Ebene 2 wieder zurücksetzen
    }
  else
    {
    top.document.getElementById("sound_Retour").src="./sound/camera.wav";
    }  //endIf

p_Main_Popup_zu();

return;
}  //endProz


/////
/////
function p_Main_Retour_PosNeu()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.aSystem[1]==1)
    {
    top.document.getElementById("RetourLayer").style.posTop=5;
    top.document.getElementById("RetourLayer").style.left=5+top.aSystem[3];

    top.document.getElementById("RetourLayer").style.visibility="visible";
    }

  else  //kein Rücksprung nötig
    {
    top.document.getElementById("RetourLayer").style.visibility="hidden";
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Snob_PosNeu()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.aSystem[2]==1)
   {
    //rechts
    top.document.getElementById("SnobLayerR").style.posTop=
      this.document.body.scrollTop+top.document.body.offsetHeight-60;
    top.document.getElementById("SnobLayerR").style.left=
      top.document.body.offsetWidth-67+top.aSystem[4];
    top.document.getElementById("SnobLayerR").style.visibility="visible";

    //links
/*
    top.document.getElementById("SnobLayerL").style.posTop=
      this.document.body.scrollTop+top.document.body.offsetHeight-60;
    top.document.getElementById("SnobLayerL").style.left=9+top.aSystem[5];
    top.document.getElementById("SnobLayerL").style.visibility="visible";
*/
    }

  else  //kein Sprung nach oben nötig
    {
    top.document.getElementById("SnobLayerR").style.visibility="hidden";
    top.document.getElementById("SnobLayerL").style.visibility="hidden";
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Confirm_PosNeu()
{

//Variablen leer

//Variablen füllen


//verarbeiten
    top.document.getElementById("ConfirmLayer").style.posTop=
      this.document.body.scrollTop+10;

return;
}  //endProz


/////
/////
function p_Main_Bild_PosNeu()
{

//Variablen leer

//Variablen füllen


//verarbeiten
    top.document.getElementById("BildLayer").style.posTop=
      this.document.body.scrollTop+10;

return;
}  //endProz


/////
/////
function p_Main_Taste_auf(xTaste)
{

//Variablen leer

//Variablen füllen


//verarbeiten
xTaste.style.backgroundColor="#FFFF99";  //gelblich

return;
}  //endProz


/////
/////
function p_Main_Taste_weg(xTaste,nTaste)
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.aMenu[nTaste]==0)
    {
    xTaste.style.backgroundColor="#C0C0C0";  //grau
    }
  else
    {
    xTaste.style.backgroundColor="#FFFF99";  //gelblich
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_MaxTextVolumen(xTextArea,nMaxZeilen,nMaxKolonne)
{

//Variablen leer
var i,n;
var aDummy    =new Array();

//Variablen füllen
var nAnzahl   =0;
var cDummy    =xTextArea.value;
var nDummy    =parseInt(cDummy.length);


//verarbeiten
aDummy[0]=1;
  for (i=1; i<nDummy; i++)
    {
    //immer nach RETURN  (\n = chr(13)+chr(10) = %0D,%0A)
      if (cDummy.charCodeAt(i)==10 &&
          cDummy.charCodeAt(i-1)==13)
        {
        nAnzahl++;
        aDummy[nAnzahl]=i;
        }  //endIf
    }  //endFor


//nur nach Bedarf freigeben
  if (nMaxKolonne>0)
    {

    //erste Zeile beim ersten mal zu lang
      if (aDummy.length==1)
        {
          if (cDummy.length-aDummy[aDummy.length-1]>nMaxKolonne-1)
            {
            window.alert("1. Zeile zu lang, auf sichtbaren Bereich kürzen");
            }  //endIf
        }  //endIf

    //letzte Zeile zu lang (immer die aktuelle zu unterst)
      else
        {
          if (cDummy.length-aDummy[aDummy.length-1]>nMaxKolonne+1)
            {
            window.alert(aDummy.length+". Zeile zu lang, auf sichtbaren Bereich kürzen");
            }  //endIf
        }  //endIf

    //Zeile dazwischen zu lang, oder auch die erste nachträglich (Eintrag geändert)
      for (i=1; i<aDummy.length; i++)
        {

        //erste Zeilenlänge hat am Angang nicht \n
          if (i==1)
            {
              if (aDummy[i]-aDummy[i-1]>nMaxKolonne)
                {
                window.alert(i+". Zeile zu lang, auf sichtbaren Bereich kürzen");
                }  //endIf
            }

        //alle weiteren Zeilenlängen
          else
            {
              if (aDummy[i]-aDummy[i-1]>nMaxKolonne+2)
                {
                window.alert(i+". Zeile zu lang, auf sichtbaren Bereich kürzen");
                }  //endIf

            }  //endIf

        }  //endFor

    }  //endIf


//zuviele Zeilen
  if (nAnzahl>nMaxZeilen-1)
    {
    window.alert("Die anschliessend aktivierte Zeile liegt ausserhalb  \n\n"+
                 "der Auswertung und würde nicht verwendet/verarbeitet.  \n\n\n"+
                 "Bitte diese ganze Zeile entfernen/löschen !  ");
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Bild(cLageDatei,cBildName)
{

//Variablen leer

//Variablen füllen


//verarbeiten
top.document.getElementById("BildInhalt").src=cLageDatei;
top.document.getElementById("BildTitel").innerText=" "+cBildName;

setTimeout("p_Main_Bild_zeigen()",3000);

return;
}  //endProz


/////
/////
function p_Main_Bild_zeigen()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.document.getElementById("BildInhalt").height>500)
    {
    top.document.getElementById("BildInhalt").height=500;
    }  //endIf

top.document.getElementById("BildLayer").style.left=
  parseInt((screen.availWidth-top.document.getElementById("BildInhalt").width)/2);

top.document.getElementById("BildLayer").style.visibility=
  "visible";

return;
}  //endProz


/////
/////
function p_Main_StatusFix()
{

//Variablen leer

//Variablen füllen


//verarbeiten
  if (top.aSystem[17]==1)
    {
    window.status="Popupblocker dauerhaft deaktivieren, Seite sonst eingeschränkt";
    setTimeout("p_Main_StatusFix()",500);
    }
  else
    {
    window.status="";
    }  //endIf

return;
}  //endProz


/////
/////
function p_Main_Dummy()
{

//Variablen leer

//Variablen füllen


//verarbeiten


return;
}  //endProz

