// JavaScript Document
lM=1;
lU=0;
lS=0;

var GR="";
var NW="";
var sGR=0;
var Moebel=new Array();
var MM=new Array();
var AnzM=0;
var xoff=0;
var yoff=0;
var xins=0;
var yins=0;
var xdel=215;
var ydel=180;
var xend=0;
var yend=0;
var w0=0;
var h0=0;
var vFact=3.5;
var vStep=1;

function CostIt()
{ VW="/kosten.htm?"+lU;
  self.location=VW;}

function PixWeg(ts)
{ts=ts.replace(/px/,"");
 return(ts);
}
function SelGR(fo)
{fo=gc_findObj("FNavi");
 tGR=gc_findObj("LGrundriss");
 i=fo.SGR.selectedIndex;
 tT = fo.SGR[i].value.split('|');
 if (i==0 || i==1 || i==5 || i==10 ) {vT="&nbsp;";sGR=0;} 
 else 
  {w0=tT[1];h0=tT[2];
   //xoff=tT[3]+xdel;yoff=tT[4]+ydel;xend=tT[5]+xdel;yend=tT[6]+ydel;
   xoff=parseInt(tT[3])+parseInt(xdel);
   yoff=parseInt(tT[4])+parseInt(ydel);
   xend=parseInt(tT[5])+parseInt(xdel);
   yend=parseInt(tT[6])+parseInt(ydel);
   xins=Math.round((parseInt(xoff)+parseInt(xend))/2);
   yins=Math.round((parseInt(yoff)+parseInt(yend))/2);
   vT='<img src="/images/infra/'+tT[0]+'" width="'+w0+'" height="'+h0+'" border="0">';sGR=1;
  }
  if (document.layers) 
  {tGR.document.open();
   tGR.document.write(vT);
   tGR.document.close();
  } else 
  {tGR.innerHTML=vT;
  }

// Hier kommt der IE Teil
}

function Werte(fo)
{i=fo.MTyp.selectedIndex;
 if (i==0){fo.EB.value="";fo.EH.value=""};
 if (i==1){fo.EB.value="100";fo.EH.value="200";}
 if (i==2){fo.EB.value="90";fo.EH.value="150";}
 if (i==3){fo.EB.value="50";fo.EH.value="60";}
 if (i==4){fo.EB.value="60";fo.EH.value="200";}
 if (i==5){fo.EB.value="40";fo.EH.value="100";}
 if (i==6){fo.EB.value="110";fo.EH.value="110";}
 if (i==7){fo.EB.value="90";fo.EH.value="190";}
 if (i==8){fo.EB.value="90";fo.EH.value="95";}
 if (i==9){fo.EB.value="85";fo.EH.value="140";}
 if (i==10){fo.EB.value="80";fo.EH.value="85";}
 if (i==11){fo.EB.value="45";fo.EH.value="140";}
 if (i==12){fo.EB.value="80";fo.EH.value="80";}
 if (i==13){fo.EB.value="80";fo.EH.value="160";}

 }
function PlusMoebel(fo)
{if (sGR==0){alert("Zuerst einen Grundriss wählen !");return(true);}
 i=fo.MTyp.selectedIndex;
 if (i==0){alert("Zuerst einen Möbeltyp wählen !");return(true);}
 if (AnzM > 0) {fo.MO.length=fo.MO.length+1};
  fo.MO[AnzM].text=fo.MTyp[i].value;fo.MO[AnzM].value=AnzM;
 fo.MO.selectedIndex=AnzM;
 tR=0;
if (tR==0 || tR==180){ tB=fo.EB.value;tB=Math.round(tB/vFact); tH=fo.EH.value;tH=Math.round(tH/vFact);}
if (tR==90 || tR==270){ tB=fo.EH.value;tB=Math.round(tB/vFact); tH=fo.EB.value;tH=Math.round(tH/vFact);}
 tNi=fo.MTyp[i].value;
 tZi=1000+AnzM;
 if (tNi=="Tisch") {tZi=200+AnzM};
 if (tNi=="Pflanze") {tZi=300+AnzM};
 tNi=tNi+"-"+tR+"-"+tB+"-"+tH;
 tN=fo.MTyp[i].value+tR+".gif";
 tN='<a href="javaScript:aktivieren('+AnzM+')"><img src="/images/infra/'+tN+'" width="'+tB+'" height="'+tH+'" border="0"></a>';
 MM[AnzM]=tNi;
 if (document.layers)
   {Moebel[AnzM]=new Layer(tB);
    with(Moebel[AnzM]){
    left=xins;
    top=yins;
    width=tB;
    height=tH;
    visibility="show";
    document.open();
    document.write(tN);
    document.close();
    zIndex=tZi;
    };
   }
 else
  { newDiv = document.createElement("DIV");
    newDiv.ID="LM"+AnzM;
    Moebel[AnzM]=newDiv;
    with (newDiv.style)
     {position = "absolute"; 
      visibility="visible";
      left=xins;
      top=yins;
      width=tB;
      height=tH;
      zIndex=tZi;
     }
     newDiv.innerHTML=tN;
     document.body.appendChild(newDiv);     

//-----------------------------------------
//		if (IE5) {
//		}
//		else {
//			elStr = "<DIV ID=" + whichEl + " STYLE='position:absolute'></DIV>";
//			menuLoc.document.body.insertAdjacentHTML("BeforeEnd",elStr);
//		}
//-----------------------------------------
     };

 AnzM=AnzM+1; 
 fo.EB.value="";fo.EH.value="";fo.MTyp.selectedIndex=0;
 if (vStep==0) {toggle()};
 return(true);
}

function aktivieren(was)
{if (document.layers) {fo=document.layers["LNavIn"].document.forms[0];} else   {fo=document.all.LNavIn.document.forms[0];};
 for (ti=0;ti < fo.MO.length ;ti++)
 {if (fo.MO[ti].value==was) {fo.MO.selectedIndex=ti}
 }
}

function toggle()
{if (document.layers) 
    {fo=document.layers["LNavIn"].document.forms[0];
     i1=document.layers["LNavIn"].document.images["igrob"];
     i2=document.layers["LNavIn"].document.images["igenau"];} 
  else 
    {fo=document.all.LNavIn.document.forms[0];
     i1=document.all.igrob;
     i2=document.all.igenau;} 
  if (vStep==1) 
  {vStep=0;i1.src="/images/infra/moveit1.gif";i2.src="/images/infra/moveit.gif";}
  else
  {vStep=1;i1.src="/images/infra/moveit.gif";i2.src="/images/infra/moveit1.gif";}
}

function move(wo)
{ if (document.layers) {fo=document.layers["LNavIn"].document.forms[0];} else {fo=document.all.LNavIn.document.forms[0];};
  lE=fo.MO[fo.MO.selectedIndex].value;
  lM=10;
  if (vStep==0){lM=1};
  if (document.layers)
  { with(Moebel[lE])
    {iT=top;iL=left;iW=width;iH=height;
     hallo="T: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     if (wo=="r" || wo=="ru" || wo=="rd"){iL=iL+lM}
     if (wo=="l" || wo=="lu" || wo=="ld"){iL=iL-lM}
     if (wo=="u" || wo=="ru" || wo=="lu"){iT=iT-lM}
     if (wo=="d" || wo=="rd" || wo=="ld"){iT=iT+lM}
     hallo=hallo+"\nT: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     iRe=iL+iW;iUn=iT+iH;
     if (iT<yoff){iT=yoff};yTest=yend-height;
     if (iL<xoff){iL=xoff};xTest=xend-width
     if (iL > xTest) {iL=xTest};
     if (iT > yTest) {iT=yTest};
     hallo=hallo+"\nT: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     hallo=hallo+"\nX: "+xoff+" Y: "+yoff+" R: "+xTest+" U: "+yTest;
     top=iT;left=iL;
     //alert(hallo);
     //fo.XTX.value=hallo;
    }
  }
  else
  { with(Moebel[lE].style)
    {iT=PixWeg(top);iL=PixWeg(left);iW=PixWeg(width);iH=PixWeg(height);
     hallo="T: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     if (wo=="r" || wo=="ru" || wo=="rd"){iL=parseInt(iL)+parseInt(lM)}
     if (wo=="l" || wo=="lu" || wo=="ld"){iL=parseInt(iL)-parseInt(lM)}
     if (wo=="u" || wo=="ru" || wo=="lu"){iT=parseInt(iT)-parseInt(lM)}
     if (wo=="d" || wo=="rd" || wo=="ld"){iT=parseInt(iT)+parseInt(lM)}
     hallo=hallo+"\nT: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     iRe=iL+iW;iUn=iT+iH;
     if (iT<yoff){iT=yoff};yTest=parseInt(yend)-parseInt(height);
     if (iL<xoff){iL=xoff};xTest=parseInt(xend)-parseInt(width);
     if (iL > xTest) {iL=xTest};
     if (iT > yTest) {iT=yTest};
     hallo=hallo+"\nT: "+iT+" L: "+iL+" W: "+iW+" H: "+iH;
     hallo=hallo+"\nX: "+xoff+" Y: "+yoff+" R: "+xTest+" U: "+yTest;
     //alert(hallo);
     top=iT;left=iL;
     //alert(hallo);
     //fo.XTX.value=hallo;
    }
  }
}

function twist()
{ if (document.layers) {fo=document.layers["LNavIn"].document.forms[0];} else {fo=document.all.LNavIn.document.forms[0];};
  lE=fo.MO[fo.MO.selectedIndex].value;

  tT = MM[lE].split('-');
  tNi=tT[0];
  tR=tT[1];
  tB=tT[3];
  tH=tT[2];
  
  if (tR==0) {tRn=315};
  if (tR==315) {tRn=270};
  if (tR==270) {tRn=225};
  if (tR==225) {tRn=180};
  if (tR==180) {tRn=135};
  if (tR==135) {tRn=90};
  if (tR==90) {tRn=45};
  if (tR==45) {tRn=0};
  tN=tNi+tRn+".gif";
  if (tR==315 || tR==225 || tR==135 || tR==45)
  {  MM[lE]=tNi+"-"+tRn+"-"+tB+"-"+tH; }
  else
  {  MM[lE]=tNi+"-"+tRn+"-"+tH+"-"+tB;
//     tB=parseInt(tB)+parseInt(tH);
//     tB=Math.round(parseFloat(tB)*0.7071);tH=tB} 
     tB=sqrt(pow(tB,2)/2)+sqrt(pow(tH,2)/2);
     tB=Math.round(parseFloat(tB)/vFact);tH=tB}
     tN='<img src="/images/infra/'+tN+'" width="'+tB+'" height="'+tH+'">'; 
  if (document.layers) 
    {with(Moebel[lE])
     { width=tB;
       height=tH;
       document.open();
       document.write(tN);
       document.close();
     }
    }
  else
    {Moebel[lE].innerHTML=tN;
     with(Moebel[lE].style)
     {width=tB;
      height=tH;}
    };
}

function loeschen(fo)
{i=fo.MO.selectedIndex;
 lE=fo.MO[fo.MO.selectedIndex].value;
 while (i<(fo.MO.length-1))
 {vV=fo.MO[i].value;
  vT=fo.MO[i].text;
  fo.MO[i].value=fo.MO[i+1].value;
  fo.MO[i].text=fo.MO[i+1].text;
  fo.MO[i+1].value=vV;
  fo.MO[i+1].text=vT;
  i=i+1;
  }
  if (document.layers)
  {Moebel[lE].visibility="hide"} else {Moebel[lE].style.visibility="hidden"};

 if (fo.MO.length>0) {fo.MO.length=fo.MO.length-1}
}
function PrintIt()
{ if (document.layers) {fo=document.layers["LNavIn"].document.forms[0];} else
     {fo=document.all.LNavIn.document.forms[0];};
  NW=window.open("GrundrissDrucken.htm","FGR");
  NW.focus;
  NW.resizeBy(-150,-150);
  NW.screenX=100;
  NW.screenY=100;
}


