function startPriceCounter()
{ setInterval("UpdatePrice()",100);    
}

function formatCurrencies( PreisVar)
{
  var Dezimalstellen = "2";
//  var Dezimalpunkt = ",";
  var Dezimalpunkt = ".";
//  var Dezimalzeichen    = ".";  
  var Dezimalzeichen    = ",";  
  
  if ( Dezimalstellen.length > 0)
  {   if ( Dezimalpunkt.length > 0 && Dezimalzeichen.length > 0)
      {   ValueZurueck = ""; 
          pos = PreisVar.indexOf(".");
          if (pos > 0)
          {   PreisKomma = PreisVar.substring( 0, pos);
              Kommapos = PreisVar.substring( pos + 1, PreisVar.length);
          }    
          else
          {   PreisVar = PreisVar + ".00";
              pos = PreisVar.indexOf(".");
              PreisKomma = PreisVar.substring( 0, pos);
              Kommapos = PreisVar.substring( pos + 1, PreisVar.length);               
          }

          if ( PreisKomma.length > 3)
          {   ZeitderSich = Math.floor(PreisKomma.length/3);
              nachStart  = PreisKomma.length % 3;
              ValueDerSich = PreisKomma;
              if (nachStart > 0)
              {   ValueZurueck = PreisKomma.substring( 0, nachStart) + Dezimalzeichen;
                  ValueDerSich = PreisKomma.substring( nachStart, PreisKomma.length);
              }
                     
              while ( ValueDerSich.length > 0)
              {   if ( ValueDerSich.length > 3)
                      ValueZurueck = ValueZurueck + Dezimalzeichen + ValueDerSich.substring(0, 3);
                  else      
                      ValueZurueck = ValueZurueck + ValueDerSich.substring(0, 3);
                  ValueDerSich = ValueDerSich.substring(3, ValueDerSich.length);
              }
              ValueZurueck = ValueZurueck + Dezimalpunkt + Kommapos.substring( 0, parseInt(Dezimalstellen));                  
          }
          else
          {   ValueZurueck = PreisKomma + Dezimalpunkt + Kommapos.substring( 0, parseInt(Dezimalstellen));
          }
          return ValueZurueck;
      }
      else if ( Dezimalpunkt.length > 0 && Dezimalzeichen.length == 0)
      {   ValueZurueck = ""; 
          pos = PreisVar.indexOf(".");
          if (pos > 0)
          {   PreisKomma = PreisVar.substring( 0, pos);
              Kommapos = PreisVar.substring( pos + 1, PreisVar.length);
          }    
          else
          {   PreisVar = PreisVar + ".00";
              pos = PreisVar.indexOf(".");
              PreisKomma = PreisVar.substring( 0, pos);
              Kommapos = PreisVar.substring( pos + 1, PreisVar.length);               
          }
          ValueZurueck = PreisKomma + Dezimalpunkt + Kommapos.substring( 0, parseInt(Dezimalstellen));
          return ValueZurueck;
      }
  }
  return PreisVar;
}
//
function UpdatePrice()
{
  var flash = document.getElementById("flash");
  var lprice1 = document.getElementById("StartPrice");
  var lprice2 = document.getElementById("EndPrice");
  if ( flash != null && ( EndPrice < PriceVar) && ZaehlStop == false )
  {
      PriceVar = PriceVar - Vprice;
      if ( PriceVar < EndPrice )
          PriceVar = EndPrice;
      str = PriceVar + "";
      pcprice = str; 
      str = formatCurrencies(str);


      pos = pcprice.indexOf(",");
      pcprice = pcprice.substring(0,(pos+3));
      
      flash.value = str;
      if (lprice1 != null)
          lprice1.value = pcprice;
      if (lprice2 != null)
          lprice2.value = pcprice;            
      if ( PriceVar <= EndPrice)
          document.location.reload();    
  }
}



function startSynchron()
{  setInterval("loadScript()",10000);
}

//
function loadScript()
{  if (!ZaehlStop)
   {   var sec = new Date();
       var url = "&cur=" + 0 + "&" + sec.getTime();
       var e = document.createElement("script");     
       e.src = url;
       e.type="text/javascript";
       document.getElementsByTagName("head")[0].appendChild(e);       
   } 
}

