/*
     IpaScript
     Copyright (c) - Ipanema Software
                     Erwin De Grande
                     http://www.ipanema.de
                     info@ipanema.de
     All rights reserved. Alle Rechte vorbehalten
*/

TabRandColor='yellow';
TabHTGColor="#F6AC11";


function LyBoxPrintCaption(Caption)
{   Text="";
     Text+='<p style="font-weight:bold">'+Caption+'</p>';
    return Text;
}

function InfoBoxAn(e,xText,xLeft,xTop,xWidth)
    {

 if (xLeft) {xLeft=xLeft;} else {xLeft=20;}
        if (xTop) {xTop=xTop;} else {xTop=0;}
        if (xWidth) {xWidth='width="'+xWidth+'"' } else { xWidth=''}
        var PositionX = 0;
        var PositionY = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)
        {
                PositionX = e.pageX;
                PositionY = e.pageY;

        }
        else if (e.clientX || e.clientY)
        {
                PositionX = e.clientX + document.documentElement.scrollLeft;
                PositionY = e.clientY + document.documentElement.scrollTop;
        }

        thisLeft=PositionX+xLeft
        thisTop=PositionY+xTop
        document.getElementById("InfoBoxText").innerHTML='<table '+xWidth+' border="0" cellspacing="0" cellpadding="0"><tr><td>'+xText+'</td></tr></table>';
        document.getElementById('InfoBox').style.left = thisLeft+"px";
        document.getElementById('InfoBox').style.top = thisTop+"px";
        document.getElementById('InfoBox').style.display = "block";
    }




function InfoBoxAus()
  {
    document.getElementById('InfoBox').style.display = "none";

  }
function LayerAus(id)
{ document.getElementById(id).style.display = "none";
}
function BrowserScroolTop()
  {
		  var scrollPos;
		if (typeof window.pageYOffset != 'undefined') {
		   scrollPos = window.pageYOffset;
		}
		else if (typeof document.compatMode != 'undefined' &&
		     document.compatMode != 'BackCompat') {
		   scrollPos = document.documentElement.scrollTop;
		}
		else if (typeof document.body != 'undefined') {
		   scrollPos = document.body.scrollTop;
		}

		return (scrollPos);
}

function FotoZoomStart(thisWidth,thisZoomMax)
 {
   zoomMax=thisZoomMax
   zoomWidth = thisWidth;
   zoomAktiv=true;

   FotoZoom();
 }
function FotoZoom()
  {  if(zoomAktiv==false) { return;}

     if (zoomWidth < zoomMax)
       {
         zoomWidth += 10;
         document.getElementById("thisFoto").style.width=zoomWidth+"px";

          window.setTimeout("FotoZoom()",0);
       }
   }

function FotoZoomClose(ZoomWidth)
{  zoomAktiv=false;
   //document.getElementById('LayerShow').style.width='10px'
   document.getElementById("thisFoto").style.width=ZoomWidth+"px";
}

function FotoShow(FotoName)
{  zoomAktiv=false;
   document.getElementById("thisFoto").src="/Fotos/Artikel/"+FotoName+".jpg"
}

function FotoModellAn(FotoName)
 {
    document.getElementById('FotoModelle').style.visibility='visible'
    document.getElementById('Fotosrc').src=FotoName
 }
function FotoModellAus()
 { document.getElementById('Fotosrc').src="images/global/blanc.gif"
   document.getElementById('FotoModelle').style.visibility='hidden'
 }

function OptionValue(objName)
  { for (var i=0; i<objName.length; i++)
      {if (objName[i].checked) { return objName[i].value;  }
      }
      return false
  }

function IsChecked(objName)
{ return objName.checked
}

function toSubmitWarten(AktionValue)
  {
    toWarten()
    toSubmit(AktionValue)

  }

function toWarten()
  {
    document.getElementById("ThickBoxMeldung").innerHTML='<p><table ><tr><td align="center" >Bitte warten...<br /><br /><img src="/system/ThickBox/loadingAnimation.gif" width="208" height="13" /></td></tr></table></p>';
    tb_show('Info','#TB_inline?height=80&width=215&inlineId=ThickBoxMeldung&hiddenModalContent&modal=true')

  }

function ESC()
  {
  }
  function TabWrite(TabMax,thisPfad,TabBreite)
 {

alert()
   TabAktiv=1
    Pfad=thisPfad;
TabHTGColor="white";
TabRandColor="gray";
   esc="'"
   tmp="";
   tmp+='<table border="0" cellpadding="0" cellspacing="0"><tr><td>'
   tmp+='<table border="0" cellpadding="0" cellspacing="0" style="width: 100%"><tr>'
   AN="An"
   for(j=1;j<TabMax+1;j++)
        { IMG=Pfad+"tab"+AN+j+".gif";
          tmp+='<td ><a href="javascript:TabChange('+j+')"><img id="TabImg'+j+'" border="0" alt="" src="'+IMG+'"  /></a></td>'
          AN="Aus"
        }
   tmp+='<td  style="width:100%;background-image: url(\''+thisPfad+'tabLeer.gif\');text-align:right"><img src="'+thisPfad+'tabEnde.gif"></td>'
   tmp+='</tr></table>'
   tmp+='<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;border-left: 1px '+TabRandColor+' solid;border-right: 1px '+TabRandColor+' solid;border-bottom: 1px '+TabRandColor+' solid;"><tr><td style="background-color:'+TabHTGColor+'">'
   Display="block"
   for(j=1;j<TabMax+1;j++)
        {    tmp+='<div id="LayerTab'+j+'" style="display:'+Display+';margin:20px;width:'+TabBreite+'px;">'
             obj="tmpTab"+j
             tmp+=document.getElementById(obj).innerHTML

             tmp+='</div>'
             Display="none"
             alert(j)

        }
   tmp+='</td></tr></table>';
   tmp+='</td></tr></table>'
   document.write(tmp);
 }

 function TabChange(TabNr)
  {
     if(TabNr==2 && isLogin=="1") { TabNr=3}
    if(TabNr==3)
     {  toPruefen();
        if (KasseOK!=1) { TabChange(2); return }
        WriteKasseDaten()
     }

    obj="LayerTab"+TabAktiv
    document.getElementById (obj).style.display ="none"
    obj="TabImg"+TabAktiv
    img=Pfad+"tabAus"+TabAktiv+".gif"
    document.getElementById(obj).src=''+img

    TabAktiv=TabNr
    obj="LayerTab"+TabAktiv
    document.getElementById (obj).style.display ="block"
    obj="TabImg"+TabAktiv
    img=Pfad+"tabAn"+TabAktiv+".gif"
    document.getElementById(obj).src=''+img
   self.location="#wTop";
  }


  function FormularInit()
  {
    toKundenArt()
    toLiefer()
    toLandVorwahl()
    if (document.fmFormular.noKasse.value=="1")
        { document.getElementById("LieferAnschrift").style.display="none"
        } else
        { document.getElementById("RowSend").style.display="none"
        }

  }

function addMwSt(Wert,MwSt)
  {  return toZahlRunden(Wert+(Wert*MwSt/100))

  }

function toZahlRunden(wert)
   { tmp = (Math.round(100 * (wert + 0.00001)) / 100 + 0.001) + '';
     tmp = tmp.substring(0, tmp.indexOf('.') + 3);
     return parseFloat(tmp); }

function FormatEUR(Wert)
   {
     aktWert=String(toZahlRunden(Wert));
     tmp = aktWert.indexOf(".");
     if (tmp!=-1) aktWert=aktWert.substring(0,tmp)+","+aktWert.substring(tmp+1)+"00";
     tmp = aktWert.indexOf(",");
     if (tmp==-1) aktWert+=",000";
     tmp = aktWert.indexOf(",");
     aktWert=aktWert.substring(0,tmp+3);
     if (aktWert.length >6) aktWert=aktWert.substring(0,tmp-3)+"."+aktWert.substring(tmp-3);
     return aktWert;
   }

    function KombiSelect(objName,Wert)  // select anhand des values
  {  for (var i=0; i<objName.length; i++)  if (objName[i].value == Wert)
        { objName[i].selected=true;
          return;
        }
  }

  function KombiText(objName)
 { return objName.options[objName.selectedIndex].text;
 }


 function KombiValue(objName)
 { return objName.options[objName.selectedIndex].value;
 }
