/*
Copyright (c) - Ipanema Software
                Constance De Grande
                http://www.ipanema.de
                info@ipanema.de
                All rights reserved. Alle Rechte vorbehalten
*/



 function KombiValue(objName)
 { return objName.options[objName.selectedIndex].value;
 }


 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 IsChecked(objName)
{ return objName.checked
}
function OptionNr(objName)
  {for (var i=0; i<objName.length; i++)
       {  if (objName[i].checked) { return i; }
       }
   return "false"
  }
function OptionValue(objName)
  { for (var i=0; i<objName.length; i++)
      {if (objName[i].checked) { return objName[i].value;  }
      }
      return false
  }

  function OptionAn(objName,Wert)
{ for (var i=0; i<objName.length; i++) if (objName[i].value == Wert)
        { objName[i].checked=true;
          return;
        }

}

 function FormatEUR(Wert)
   {
     aktWert=""+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;
   }


// IpaBox


function IpaBoxShow(event,Titel,msg)
  {

	msg=msg.replace(/~/g,'"');
    esc='"';
	thisMsg="<div class='IpaBoxStandard' >"
	if (Titel!='') { thisMsg+="<p class='IpaBoxTitelStandard'>"+Titel+"</p>";}
	thisMsg+="<p style='padding:5px;margin:0;height:150px;width:150px;background-color:yellow'>"+msg+"</p>";
	thisMsg+="</div>";

//    LayerWriteMaus(event,"IpaBox",thisMsg,0,20)
    LayerWrite("IpaBox",thisMsg)
    LayerMove("IpaBox",250,250)
    LayerAn("IpaBox")

}


// Layer Funktionen
 function LayerIsVisible(LayerID)
  {if( document.getElementById(LayerID).style.display=='block')
     { return true;
     } else
     {return false;
     }
  }
 function LayerAn(LayerID)
  { document.getElementById(LayerID).style.display='block';
  }

function LayerAus(LayerID)
  { document.getElementById(LayerID).style.display='none';
  }

function LayerMove(LayerID,thisTop,thisLeft)
  { document.getElementById(LayerID).style.left=thisLeft+"px";
    document.getElementById(LayerID).style.top=thisTop+"px";
  }



function LayerMoveMaus(e,LayerID,thisTop,thisLeft)
  {
    if (!e) var e = window.event;

    if (e.pageX || e.pageY)
        {
                MausLeft = e.pageX;
                MausTop = e.pageY;
        }
        else if (e.clientX || e.clientY)
        {
                MausLeft = e.clientX + document.body.scrollLeft;
                MausTop = e.clientY +MouseScroolTop();

        }

    document.getElementById(LayerID).style.left=(thisLeft+MausLeft)+"px";
    document.getElementById(LayerID).style.top=(MausTop+thisTop)+"px";

  }

function LayerWrite(LayerID,Text)
  {
	document.getElementById(LayerID).innerHTML = Text;
  }

function LayerWriteMaus(event,LayerID,Text,thisTop,thisLeft)
  {
    LayerMoveMaus(event,LayerID,thisTop,thisLeft)
	document.getElementById(LayerID).innerHTML = Text;
	LayerAn(LayerID)
  }

function MouseScroolTop()
  {
		  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);
}





aktFotoZoomBreite=0
isFotoReset=0;

function FotoZoomReset(FotoWidth)
  { isFotoReset=0;
    document.getElementById('FotoZoom').style.width=FotoWidth+"px";
  }
function FotoZoomStart(FotoWidth)
  { aktFotoWidth = 170;
    aktFotoZoomBreite=parseInt(FotoWidth) //400
    document.getElementById('FotoZoom').style.display="block";
    document.getElementById('FotoZoom').style.width=aktFotoWidth+"px";
    isFotoReset=1;
    FotoZoom();
}

function FotoZoom()
  {  if(isFotoReset==0) {return;}
     if (aktFotoWidth < aktFotoZoomBreite)
       {  document.getElementById('FotoZoom').style.width=aktFotoWidth+"px";
          aktFotoWidth += 10;
          window.setTimeout("FotoZoom()",0);
       }  else
       {  document.getElementById('FotoZoom').style.display="block";
       }
}

function LayerDetailsAn(Nr)
  {
    if (aktLayerDetails>0) { LayerDetailsAus(aktLayerDetails)}

    obj="LayerDetail["+Nr+"]"
    LayerAn(obj)
    aktLayerDetails=Nr
  }

function LayerDetailsAus(Nr)
  {
    obj="LayerDetail["+Nr+"]"
    LayerAus(obj)
    aktLayerDetails=0
  }






function ToZahl(wert)
 { wert=wert.replace(/\./g,"")
   wert=wert.replace(/\,/g,".")
   if(wert==parseFloat(wert))
    { return wert
    }else
    { return false
    }
}

function toZahlRunden(wert)
   { tmp = (Math.round(100 * (wert + 0.00001)) / 100 + 0.001) + '';
     tmp = tmp.substring(0, tmp.indexOf('.') + 3);
     return parseFloat(tmp); }


function RundenEUR(Wert)
   {
     tmp = (Math.round(100 * (Wert + 0.00001)) / 100 + 0.001) + '';
     tmp = tmp.substring(0, tmp.indexOf('.') + 3);
     return parseFloat(tmp);
   }


  function toAbschicken()
  { if(IsChecked(document.fmFormular.chkAGB)==false)
       { alert('Bitte bestätigen Sie, dass Sie die AGB gelesen haben.');
         return;
       }
    toSubmit('Kasse')
  }
   function ShopKundenDatenPruefen()
  { var fm=document.fmFormular
    tmp=""

   if(fm.Name.value=="") { tmp+="- Name muß ausgefüllt sein.\n";}
   if(fm.Vorname.value=="") { tmp+="- Vorname muß ausgefüllt sein.\n";}
   if(fm.Strasse.value=="") { tmp+="- Straße muß ausgefüllt sein.\n";}
   if(fm.PLZ.value=="") { tmp+="- Postleitzahl muß ausgefüllt sein.\n";}
   if(fm.Ort.value=="") { tmp+="- Ort muß ausgefüllt sein.\n";}
   if(fm.Email.value=="" )
       { tmp+="- Email muß ausgefüllt werden.\n" }
   if(fm.Email.value!="")
           {  if (fm.Email.value.indexOf ('@',0) == -1 || fm.Email.value.indexOf ('.',0) == -1)
                     {  tmp+="- Die Emailadresse ist nicht korrekt.\n"  }
           }
   if(tmp!="") { tmp="Bitte korrigieren Sie:\n\n"+tmp; alert(tmp);return;}

  return "ok";


  }

    function get_window_size()
 { var myWidth = 0, myHeight = 0;
 if (typeof( window.innerWidth ) == 'number')
 {  myWidth = window.innerWidth;  myHeight = window.innerHeight;
 } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
 {    myWidth = document.documentElement.clientWidth;  myHeight = document.documentElement.clientHeight;
 } else if (document.body && (document.body.clientWidth || document.body.clientHeight))
 {  myWidth = document.body.clientWidth;  myHeight = document.body.clientHeight;

 }
    return myWidth+','+myHeight;
 }
 function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}
FotoLoad=false;
function FotoOpacity(obj, opacity) {
  
   
  if(FotoLoad==true) { return}
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function FotoEinblenden(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      FotoOpacity(obj, opacity);
      opacity += 3;
      window.setTimeout("FotoEinblenden('"+objId+"',"+opacity+")", 1);
    }
  }
}


