
var toScroll=new Array()

var ie=document.all

var dom=document.getElementById

var firstNews_obj;

var secondNews_obj;



function newsScroll(name){

  var c=this; c.name=name; c.mc=0; c.i=2;

  return this;

}



newsScroll.prototype.addItem = function(text,link,font,fontSize,fontStyle){

  var c = this;

  if (link !=''){

    if (font != '')

      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";

    else

      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";

  }

  else {

    if (font != '')

      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";

    else

      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";

  }

  c.mc++;

}



newsScroll.prototype.construct = function(){

  var c = this; theWidth = c.scrollerwidth; theHeight=c.scrollerheight; thebgColor = c.scrollerbgcolor; theBackground =c.scrollerbackground; theDelay=c.scrollerdelay;

  scroll_obj=eval(c.name);

  if (ie||dom){

    document.writeln('<div id="main2" style="position:relative;width:'+theWidth+';height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')

    document.writeln('<div style="position:absolute;width:'+theWidth+';height:'+theHeight+';clip:rect(0 '+theWidth+' '+theHeight+' 0);left:0;top:0">')

    document.writeln('<div id="firstNews" style="position:absolute;width:'+theWidth+';left:0;top:1">')

    document.write(toScroll[0])

    document.writeln('</div>')

    document.writeln('<div id="secondNews" style="position:absolute;width:'+theWidth+';left:0;top:0;visibility:hidden">')

    document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])

    document.writeln('</div>')

    document.writeln('</div>')

    document.writeln('</div>')

  }

}



newsScroll.prototype.move = function(whichdiv){

  var c = this; theDelay = c.scrollerdelay; theHeight = c.scrollerheight;

  scroll_obj=eval(c.name);

  tdiv=eval(whichdiv)



  if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){

    tdiv.style.top=0+"px"

    setTimeout("scroll_obj.move(tdiv)",theDelay)

    setTimeout("scroll_obj.move2(secondNews_obj)",theDelay)

    //document.write('Got Milk?')

  return

  }

  if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){

    tdiv.style.top=parseInt(tdiv.style.top)-5+"px"

    setTimeout("scroll_obj.move(tdiv)",50)

  }

  else {

    tdiv.style.top=parseInt(theHeight)+"px"

    tdiv.innerHTML=toScroll[c.i]

    if (c.i==toScroll.length-1)

      c.i=0

    else

      c.i++

  }

}



newsScroll.prototype.move2 = function(whichdiv){

  var c = this; theDelay = c.scrollerdelay; theHeight= c.scrollerheight;

  scroll_obj=eval(c.name);

  tdiv2=eval(whichdiv)



  if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){

    tdiv2.style.top=0+"px"

    setTimeout("scroll_obj.move2(tdiv2)",theDelay)

    setTimeout("scroll_obj.move(firstNews_obj)",theDelay)

    return

  }

  if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){

    tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"

    setTimeout("scroll_obj.move2(secondNews_obj)",50)

  }

  else {

    tdiv2.style.top=parseInt(theHeight)+"px"

    tdiv2.innerHTML=toScroll[c.i]

    if (c.i==toScroll.length-1)

      c.i=0

    else

      c.i++

  }

}



newsScroll.prototype.startScroll = function(){

  var c = this;

  scroll_obj=eval(c.name);



  if (toScroll.length >2)

    c.i = 2;

  else

    c.i = 0;



  firstNews_obj=ie? firstNews : document.getElementById("firstNews")

  secondNews_obj=ie? secondNews : document.getElementById("secondNews")

  setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);

  secondNews_obj.style.top=theHeight;

  secondNews_obj.style.visibility='visible'

}



var speicher = new Array();

function checkEingabe(num,einzelPreis)
{
      var formSize = document.forms[0].elements.length-1;
      var sum = new Array(formSize);
	 
      var x = (document.forms[0].elements[num].value);
	  if(isNaN(x) || x==0)
	  {
	    document.forms[0].elements[num].value = "";		         
		document.forms[0].elements[num+1].value = kaufm(einzelPreis);
	  } 

	  else
	  { 
		   document.forms[0].elements[num+1].value = kaufm(parseInt(x)*einzelPreis);
		   //sum[num] = sum[num]+ document.forms[0].elements[num+1].value;		   		 		  
	  }	 
}
 


function kaufm(x) 
{
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  var p = k.indexOf('.');
  
  return k.substring(0, p) + '.' + k.substring(p+1,p+3);
}

function checkSum()
{
   var sum = 0;   
   var anz = 0;
   
   
   
   var length = document.forms[0].elements.length-1;
   self.name = "";
   
   for (var i = 0;i<length;i+=2)
   {
         
         if(document.forms[0].elements[i].value != "")
	     {
		   anz+=parseInt(document.forms[0].elements[i].value);
		  
		  sum = sum +  parseFloat(document.forms[0].elements[i+1].value);
		  for (var j = 0;j<3;j++)
		  {
		     speicher[i] = new Array(3);
             
			 speicher[i][j] =  "<span style = 'word-spacing:100px'>"+parseInt(document.forms[0].elements[i].value);
			 
			 
			 if(j==1)
			 {
			 
			    speicher[i][j] = "</span>"+document.forms[0].elements[i].name;
			 }
			 if(j==2)
			 {
			    speicher[i][j] = "<div align = 'right'>"+kaufm(document.forms[0].elements[i+1].value)+" &#8364;"+"</div>";
			 }
			 
			 self.name = self.name +speicher[i][j]+" ";			 
		  }		 
	   }
	  
   }   
     self.name = self.name + "<br><div align = 'right' style = 'text-decoration:underline'><b>Gesamt: "+kaufm(sum)+" &#8364;</div>"; 	 	   
	  if(sum<30)
       alert("Sie haben noch nicht den Mindestbestellwert von 30 € erreicht.\nIhr aktueller Bestellwert beträgt "+kaufm(sum)+" €");
	 else
	  self.location.href = "confirm.htm";  
	  
	 if(anz >= 12)
	   self.name +="<div align = 'right'><br>Lieferung frei Haus!</br></div>";  
	 else
	   self.name +="<div align = 'right'><br>zuzügl. "+anz+" &#8364; Versand</br></div>";  
	
	 

}

   	// var speicher = new Array(count);
			
/*	
	
	for(var i = 0;i<document.forms[0].elements.length-1;i+=2)
	{	   
	   if(document.forms[0].elements[i].value != "")
	   {	   
	       for (var j = 0; j < 3; j++)
		   {         
//	          speicher[i][j] = parseInt(document.forms[0].elements[i].value);
			  speicher[i] = new Array();
			  speicher[i][j] =  parseInt(document.forms[0].elements[i].value);
			 if(j==1)
			 {
			    speicher[i][j] = document.forms[0].elements[i].name;
			 }
			 if(j ==2)
			 {
			   speicher[i][j] = kaufm(parseFloat(document.forms[0].elements[i+1].value));
			   //speicher[i][j] = 10;
			 }
			// self.name = self.name + speicher[i]+"--";
			 self.name += speicher[i][j]+"--";
		   }
	   }
	   	  
	}
	
	self.name = self.name + " " +kaufm(sum);
	alert(self.name);
	//alert(count);
   
		//alert(kaufm(sum));
//		self.name = (kaufm(sum));
	//	self.location.href = "bestellbestätigung.htm";
     
}
*/

//-->


