// selbid = "";
showmode = "";

$karussellartnr = "";

$seloption = "";
$seloptionval = "";
$seloptionname = "";

$holdlay = "";

function initrotator(bid)
  {
   $('body').css('overflow', 'auto');
   showmode = 'rotator';
   etrackajax(bid,'',showmode);

   document.images['button_karrussel'].src = 'modulimages/button_karrussel_off.gif';
   document.images['button_rotator'].src = 'modulimages/button_rotator_on.gif';
   if (bid && selbid)
      {var $lastnavi = '#module_shopnavilinks a #link'+selbid;
       $($lastnavi).css('color','#5D5855');
       $($lastnavi).css('background-image','url(modulimages/navidot_off.gif)');
      }
   // Hier per Ajax die Artikel des ausgewähten Bereichs (oder eben alle) in den gallery-Layer schreiben.
   var url = 'ajax.php?mode=loadroatatorpics';
   if (bid)
      {url += '&bid='+bid;
       selbid = bid;
      }
   else if (selbid)
	   {url += '&bid='+selbid;
	   }

   $.ajax({
   type: "GET",
   url: url,
   dataType: "html",
   success: function(html)
   {$('.gallery').empty().append(html);
    $("#gallerycontainer").fadeIn("slow");
   }
   });
  }




function initkarrussel(bid,selmodel,jump)
  {
   document.getElementById('htmlcontent').style.display = 'none';

   showmode = 'karrussel';
   etrackajax(bid,selmodel,showmode);

   document.images['button_karrussel'].src = 'modulimages/button_karrussel_on.gif';
   document.images['button_rotator'].src = 'modulimages/button_rotator_off.gif';
   if (bid && selbid)
      {var $lastnavi = '#module_shopnavilinks a #link'+selbid;
       $($lastnavi).css('color','#5D5855');
       $($lastnavi).css('background-image','url(modulimages/navidot_off.gif)');
      }

   var $showkarussel = 'ja';
   // PRÜFEN, OB MEHR ALS EIN ARTIKEL IM BEREICH VORHANDEN:
   if   (bid && bid > 10000)
        {selbid = bid;
	 var $newnavi = '#module_shopnavilinks a #link'+selbid;
	 $($newnavi).css('color','#7B0629');
	 $($newnavi).css('background-image','url(modulimages/navidot_on.gif)');

	 var url = 'ajax.php?mode=countprods&bid='+bid;
	 $.ajax({
	 type: "GET",
	 url: url,
	 dataType: "html",
	 success: function(html)
	 {
	 if   (html != 'showkarussel')
	      {
	       selmodel = html;
	       showproddetail('',selmodel,'solo');
	      }
	 else {var url = 'ajax.php?mode=loadpics&bid='+bid;
	       if (selmodel)
		  {url += '&selmodel='+selmodel;
		  }
	       $.ajax({
	       type: "GET",
	       url: url,
	       dataType: "html",
	       success: function(html)
	       {
	        $('.gallery').empty().append(html);
//	        if   (secret)	// weitersprung verhindern
//		     {karrussel();}
//	        else {karrussel(selmodel);
//		     }
	        karrussel(selmodel,jump);
	       }
	       });
	      }
	 }
	 });
       }

   else	{var url = 'ajax.php?mode=loadpics';
	 if (bid)
	    {url += '&bid='+bid;
	     selbid = bid;
	    }
	 else if (selbid)
		 {url += '&bid='+selbid;
		 }
	 if (selmodel)
	    {url += '&selmodel='+selmodel;
	    }

	 $.ajax({
	 type: "GET",
	 url: url,
	 dataType: "html",
	 success: function(html)
	 {
	  $('.gallery').empty().append(html);
//	  if   (secret)	// weitersprung verhindern
//	       {karrussel();}
//	  else {karrussel(selmodel);
//	       }
	  karrussel(selmodel,jump);
	 }
	 });
	}
  }




function switchbereich(bid)
  {
   etrackajax(bid,'','');
   var $aktnavi = '#module_shopnavilinks a #link'+bid;
   //var layerlink = '#auswahl_'+layer + ' a';
   $($aktnavi).css('color','#7B0629');
   $($aktnavi).css('background-image','url(modulimages/navidot_on.gif)');
   if (selbid)
      {var $lastnavi = '#module_shopnavilinks a #link'+selbid;
       $($lastnavi).css('color','#5D5855');
       $($lastnavi).css('background-image','url(modulimages/navidot_off.gif)');
      }
   if   (showmode == 'rotator')
	{initrotator(bid);
	}
   else {initkarrussel(bid,'','')
	}
  }



function karrussel(selmodel,jump)
  {
   $(function(){
   var zoomFunc = function(dimension) {
   return dimension * 1.5;
   }
   var shrinkFunc = function(dimension) {
   return dimension * 0.5;
   }
   $('div.gallery img').slidingGallery({'slideSpeed':'slow','Lzoom':zoomFunc, 'Pzoom':zoomFunc,'Lshrink':shrinkFunc,'Pshrink':shrinkFunc});


   // DIREKT ZUM ARTIKEL SPRINGEN - ABGESCHALTET
   if   (selmodel && jump)
        {showproddetail('',selmodel,'link');
        }
   else {$("#gallerycontainer").fadeIn("slow");
	}
   });

  }



function showproddetail(o,model,mode)
  {
   $seloption = "";
   $seloptionval = "";
   $seloptionname = "";

   etrackajax(selbid,model,'Detailansicht');

   $karussellartnr = model;

   // Back-Button-Info:
   $.history( {'aufruf':'showproddetail','mode':mode,'model':model} );

   r = "";

   if (mode == 'dyn')
      {var r = getdivpos(o);
      }

// alert(mode);

   if (mode == 'solo')
      {
       var url = 'ajax.php?mode=proddetail&model='+model;
	     $.ajax({
	     type: "GET",
	     url: url,
	     dataType: "html",
	     success: function(html)
	     {
	     $('#produktdetailcontainer').empty().append(html);
	     $("#produktdetailcontainer").fadeIn("slow");
	     }
	     });
      }

   if (mode == 'link' || mode == 'step' || (r.left > 300 && r.left < 700))
      {
       var prev = "";
       var next = "";
       if (Picinfo[model])
	  {
	   if (Picinfo[model][0])
	      {var prev = Picinfo[model][0];}
	   if (Picinfo[model][1])
	      {var next = Picinfo[model][1];
	      }
	  }
       var url = 'ajax.php?mode=proddetail&model='+model+'&prev='+prev+'&next='+next;
       if   (mode == 'step')
	    {
//	     $("#produktdetailcontainer").fadeOut("slow");
	     $.ajax({
	     type: "GET",
	     url: url,
	     dataType: "html",
	     success: function(html)
	     {
	     $('#produktdetailcontainer').empty().append(html);
	     $("#produktdetailcontainer").fadeIn("slow");
	     }
	     });
	    }
       else {
//	     $("#produktinfo").fadeOut("slow");
	     $("#produktinfo").hide('fast');
//	     $("#gallerycontainer").fadeOut("slow");
	     $.ajax({
	     type: "GET",
	     url: url,
	     dataType: "html",
	     success: function(html)
	     {
	     $('#produktdetailcontainer').empty().append(html);
	     $("#produktdetailcontainer").fadeIn("slow");
	     $("#gallerycontainer").fadeOut("slow");
	     }
	     });
	    }
      }
  }


function switchprod(model)
  {
   $seloption = "";
   $seloptionval = "";
   $seloptionname = "";

   etrackajax(selbid,model,'Detailansicht');

//   if (showmode != 'rotator')
//      {
       $("#prodpic").fadeOut("slow");
//      }

   // Back-Button-Info:
   $.history( {'aufruf':'switchprod','mode':'','model':model} );

   var prev = Picinfo[model][0] || "";
   var next = Picinfo[model][1] || "";

   var url = 'ajax.php?mode=proddetail&model='+model+'&prev='+prev+'&next='+next;
   $.ajax({
   type: "GET",
   url: url,
   dataType: "html",
   success: function(html)
   {
   $('#produktdetailcontainer').empty().append(html);
//   if (showmode != 'rotator')
//      {
//   // Karussel weiterdrehen
//       initkarrussel(selbid,model,'secret');
       $("#prodpic").fadeIn("slow");
//      }

   }
   });

  }





function switchansicht(pic)
  {
   var $ansichtpic = 'dynimages/artikel/10000/'+pic+'.gif';
   document.images['prodpic'].src = $ansichtpic;
  }





function closeproddetail(model)
  {
   if   (showmode != 'rotator' && $karussellartnr != model)
        {
         // Karussel weiterdrehen
         initkarrussel(selbid,model,'');
	 $("#produktdetailcontainer").fadeOut("slow");
        }
   else {$("#produktdetailcontainer").fadeOut("slow");
	 $("#gallerycontainer").fadeIn("slow");
        }
  }




function showzoom(model)
  {

   etrackajax(selbid,model,'Zoom');

   var url = 'ajax.php?mode=prodzoom&model='+model;
   $.ajax({
   type: "GET",
   url: url,
   dataType: "html",
   success: function(html)
   {
   $('#produktdetailzoom').empty().append(html);
   $("#produktdetailzoom").fadeIn("slow");
   startZoom();
   }
   });
  }

function closezoom(model)
  {
   $("#produktdetailzoom").fadeOut("slow");
  }



function nehmen(id)
  {

   if   ($optionsmode && !$seloptionval)
	{
	 var warnbutton = $buttonpfad+'/button_select_'+$optionsmode+'_left_warn.gif';
	 var buttonid = '#button_select_'+$optionsmode+'_left';
	 $(buttonid).attr("src", warnbutton);
	 var warnbutton = $buttonpfad+'/button_select_'+$optionsmode+'_warn.gif';
	 var buttonid = '#button_select_'+$optionsmode;
	 $(buttonid).attr("src", warnbutton);
	 var warnbutton = $buttonpfad+'/button_select_right_warn.gif';
	 $("#button_select_right").attr("src", warnbutton);
	}
   else {var mengenfeld = 'menge' + id;
	 var menge = document.produktdetail.elements[mengenfeld].value;
	 var url = 'ajax.php?shop_aktion=inwarenkorb&shopping_cart='+id;
	 if ($seloption && $seloptionval)
	    {url += '_'+$seloption+'_'+$seloptionval;
	    }
	 url += '-'+menge;
	 $.ajax({
	 type: "GET",
	 url: url,
	 dataType: "script",
	 success: function(script)
	 {
	 $('#detailbereich').fadeOut("slow");
	 $('#zusatzartikel').fadeIn("slow");

	 // WARENKORB REIN- UND WIEDER RAUSSCROLLEN:
	 $holdlay = 'dropcart';
	 slidelay('dropcart');
	 setTimeout(nehmenclosecart, 2000);
	 }
	 });
	}
  }


function zusatznehmen()
  {
   var $getzusatz = "";

   // ACHTUNG: DA DER IE (NUR BEI JAVASCRIPT-FUNKTIONEN?) EINEN BUCHSTABEN IM FORMFELD-NAMEN VERLANGT, 
   // WURDE IHNEN EIN m VORANGESTELLT, DASS HIER WIEDER ENTFERNT WIRD!

   if (Zsfarbids)
      {
       for (var i = 0; i < Zsfarbids.length; i++)
	   {
	    if (document.produktdetail.elements[Zsfarbids[i]] && document.produktdetail.elements[Zsfarbids[i]].value != '')
	       {
		var menge = document.produktdetail.elements[Zsfarbids[i]].value;
		var feld = Zsfarbids[i].substring(1);
		// alert(menge);
		if ($getzusatz)
		   {$getzusatz += '--';}
		$getzusatz += feld+'-'+menge;
	       }
	   }
      }
   if (Zsids)
      {
       for (var i = 0; i < Zsids.length; i++)
	   {
	    if (document.produktdetail.elements[Zsids[i]] && document.produktdetail.elements[Zsids[i]].value != '')
	       {
		var menge = document.produktdetail.elements[Zsids[i]].value;
		var feld = Zsids[i].substring(1);
		// alert(menge);
		if ($getzusatz)
		   {$getzusatz += '--';}
		$getzusatz += feld+'-'+menge;
	       }
	   }
      }

   url = 'ajax.php?shop_aktion=inwarenkorb&shopping_cart='+$getzusatz;

   $.ajax({
   type: "GET",
   url: url,
   dataType: "script",
   success: function(script)
   {
    $('#zusatzartikel').fadeOut("slow");
    $('#zusatzordered').fadeIn("slow");

    // WARENKORB REIN- UND WIEDER RAUSSCROLLEN:
    $holdlay = 'dropcart';
    slidelay('dropcart');
    setTimeout(nehmenclosecart, 2000);
   }
   });

  }



function switchgeschenk(bestpos)
  {
   var geschenk = 'nein';
   var grusstext = '';
   if (bestpos == 'proddetail')
      {
       if (document.produktdetail.grusstext)
	  {var grusstext = document.produktdetail.grusstext.value;
	  }
       if (document.produktdetail.geschenkzusatz.checked == true)
	  {var geschenk = 'ja';
	  }
      }
   if (bestpos == 'cart')
      {
       if (document.cart_quantity.grusstext)
	  {var grusstext = document.cart_quantity.grusstext.value;
	  }
       if (document.cart_quantity.geschenkzusatz.checked == true)
	  {var geschenk = 'ja';
	  }
      }

   url = 'ajax.php?mode=savegeschenk&wrapgift='+geschenk+'&grusstext='+grusstext;
   $.ajax({
   type: "GET",
   url: url,
   dataType: "html",
   success: function(html)
   {}
   });
   // document.formular.testfeld1.value=aktiviert;
  }


function nehmenclosecart()
  {
   $holdlay = '';
    slidelay('dropcart');
  }




// LAYER DARSTELLEN ODER NICHT
function onofflay(lname,mode)
  {
   if (document.getElementById(lname))
      {
      if   (mode == 'on')
	   {document.getElementById(lname).style.display = 'block';
	   }
      else {document.getElementById(lname).style.display = 'none';
	   }

     }
  }

// LAYER EINSCROLLEN ODER NICHT
function slidelay(lname,mode)
  {
   if (document.getElementById(lname))
      {
       var $layer = '#' + lname;
       if   (mode)
	    {if (document.getElementById(lname).style.display == 'block' && mode == 'off')
		{$($layer).slideUp("slow");}
	     if (document.getElementById(lname).style.display != 'block' && mode == 'on')
		{$($layer).slideDown("slow");
		}
	    }
       else {if   (document.getElementById(lname).style.display == 'block' && (!$holdlay || $holdlay != lname))
		  {$($layer).slideUp("slow");}
	     else {$($layer).slideDown("slow");
		  }
	    }
     }
  }

// LAYER EINFADEN ODER NICHT
function fadelay(lname,tempo)
  {
   var fadetempo = 'slow';
   var layer = '#'+lname;
   if (tempo)
      {var fadetempo = tempo;
      }
   if (document.getElementById(lname))
      {
       if   (document.getElementById(lname).style.display == 'block')
	    {$(layer).fadeOut(fadetempo);
	    }
       else {$(layer).fadeIn(fadetempo);
	    }
// var test = ;
// alert (test);
//      if   (mode == 'on')
//	   {$(layer).fadeIn(fadetempo);
//	   }
//      else {$(layer).fadeOut(fadetempo);
//	   }

     }
  }



function showtopdrop(o,layer,selx,sely)
  {
   if (document.getElementById(layer))
      {
       var r = getdivpos(o);
       if      (layer == 'dropkonto')
	       {$x = (r.left - 260);
		$y = (r.top + 20);
	       }
       else if (layer == 'dropcart')
	       {$x = (r.left - 150);
		$y = (r.top + 20);
	       }
       else if (selx || sely)
	       {
		if   (selx)
		     {$x = (r.left - selx);}
		else {$x = r.left;
		     }
		if   (sely)
		     {$y = (r.top + sely);}
		else {$y = r.top;
		     }
	       }
       else    {$x = (r.left - 30);
		$y = (r.top + 20);
	       }
       // $test = layer + ' ' + $x;
       // alert($test);

       // document.getElementById(layer).style.display = 'block';
       // document.getElementById(layer).style.marginLeft = $x;
       // document.getElementById(layer).style.marginTop = $y;
       document.getElementById(layer).style.marginLeft = $x;
       //  document.getElementById(layer).style.Top = $y;
       fadelay(layer);
      }
  }


// PRODUKT-INFO-OVERLAY
function showproduktinfo(o,model,titel,text,preis,mode,anzahl,tpic)
  {
   var r = getdivpos(o);

   if   (navigator.userAgent.indexOf('Safari') != -1)
	{$div = '<a href="javascript:;"><div class="produktinfo" onclick="showproddetail('+"'','"+model+"','link'"+');"><div class="produktinfotitel">' + titel + '</div><div class="produktinfotext">'  + text + '</div><div class="produktinfopreis">€ ' + preis  + '</div></div></a>';
	}
   else {$div = '<a href="javascript:'+"showproddetail('','"+model+"','link');"+'"><div class="produktinfo" onclick="showproddetail('+"'','"+model+"','link'"+');"><div class="produktinfotitel">' + titel + '</div><div class="produktinfotext">'  + text + '</div><div class="produktinfopreis">€ ' + preis  + '</div></div></a>';
	}

   if (mode == 'rotator' || (r.left > 300 && r.left < 700))
      {
       document.getElementById('produktinfo').innerHTML=$div;
       document.getElementById('produktinfo').style.display = 'block';
       if   (mode == 'rotator')
	    {
	     if   (anzahl < 9)
		  {$x = (r.left + 70);
		   $y = (r.top + 90);
		  }
	     else {$x = (r.left + 50);
		   $y = (r.top + 80);
		  }
	    }
       else {$x = 705;
	     $y = 498;
	    }
       document.getElementById('produktinfo').style.left = $x;
       document.getElementById('produktinfo').style.top = $y;
      }
  }




function switchtopicon(pic,mode,sprache)
  {
   var iconpic = 'modulimages/detail_icon_'+pic+'_'+mode+'.gif';
   if   (mode == 'on')
        {var textpic = 'modulimages/detail_text_'+pic+'_'+sprache+'.gif';}
   else {var textpic = 'modulimages/transp.gif';
	}
   $picname = 'detail_icon_'+pic;
   document.images[$picname].src = iconpic;
   document.images['detail_text'].src = textpic;
  }




function closetopdrops()
  {
   for (var i = 0; i < $Topdrops.length; i++)
       {
	lname = $Topdrops[i];
//	document.getElementById(lname).style.display = 'none';
	if (document.getElementById(lname).style.display == 'block' && (!$holdlay || $holdlay != lname))
	   {
	    var $layer = '#' + lname;
	    $($layer).slideUp("slow");
	   }
       }
  }



function switchber(link)
  {
   $("#maincontent").fadeIn("slow");
   var tmpjumpdelay=500;
   jumppage = link;
   doRedirect(tmpjumpdelay);
  }

function doRedirect(jumpdelay)
  {
   setTimeout( "window.location.href = jumppage", jumpdelay );
  }





function showseldrop($layer)
  {
   var $aussenlayer = $layer + 'cont';
   if   (document.getElementById($aussenlayer).style.display == 'block')
	{
	 var $aussenlayer = '#' + $layer + 'cont';
	 $($aussenlayer).slideUp("slow");
	}
   else {var $aussenlayer = '#' + $layer + 'cont';
	 $($aussenlayer).slideDown("slow");
	 var $innenlayer = '#' + $layer;
	 $($innenlayer).jScrollPane({showArrows:false, scrollbarWidth: 14,dragMinHeight : 37, dragMaxHeight : 37});
	}
  }


function doselectdrop(mode,options_id,options_values_id,options_values_name,sortorder,language,farbpic)
  {
   var $aussenlayer = '#dropselect' + mode + 'cont';
   $seloption = options_id;
   $seloptionval = options_values_id;
   $seloptionname = options_values_name;
   $($aussenlayer).slideUp("slow");
   var $button = '#button_select_' + mode;
//   var $pic = 'modulimages/button_select_' + mode + options_values_name + '.gif';
   var $pic = 'templates/xtc4/buttons/'+language+'/button_select_' + mode + options_values_name + '.gif';
   $($button).attr("src", $pic);

   if (mode == 'farbe' && farbpic)
      {
       var $pic = 'dynimages/artikel/10000/'+farbpic+'.gif';
       $("#prodpic").attr("src", $pic);
      }
  }


function showerweitert(layer)
  {
   if ($seldetail && $seldetail != layer)
      {var layerout = '#'+$seldetail;
       $(layerout).fadeOut("slow");
       var layerlink = '#auswahl_'+$seldetail+ ' a';
       $(layerlink).css('color','#5D5855');
      }
   var layerin = '#'+layer;
   $(layerin).fadeIn("slow");
   $seldetail = layer;
   var layerlink = '#auswahl_'+layer + ' a';
   $(layerlink).css('color','#7B0629');

   if (layer == 'passend')
      {initscroller('passendinner','passendcont','buttonscrollleft','buttonscrollright',207,30) 
      }
  }





function showdetailinfo(o,layer,titel,text)
  {
   var divinhalt = '<div class="titel">'+titel+'</div>'+text;

   var r = getdivpos(o);
   $x = (r.left + -20);
   $y = (r.top + -90);
   document.getElementById(layer).style.left = $x;
   document.getElementById(layer).style.top = $y;
   // document.getElementById('detail_content').innerHTML=divinhalt;
   $('.detail_content').empty().append(divinhalt);
   document.getElementById(layer).style.display = 'block';
  }




function showdetgrusstext(chkbox)
   {
    $boxgrusstext = chkbox;
    $('#grusstext').fadeIn("slow");
   }




function savegrusstext(id)
   {
    var $grusstext = "";
    var geschenk = 'nein';
    if (document.produktdetail.geschenkzusatz.checked == true)
       {var geschenk = 'ja';
       }
    if (document.produktdetail.grusstext)
       {
	if   (document.produktdetail.grusstext.value != "")
	     {
	      $grusstext = document.produktdetail.grusstext.value;
	      var checkbox = '#'+$boxgrusstext;
	      $(checkbox).attr('checked','checked')
	      // $(checkbox).removeAttr('checked')
	      $('.grusstextlinktxtoff').hide('fast');
	      $('.grusstextlinktxton').show('fast');

	      var url = 'ajax.php?mode=savegrusstext&product_id='+id+'&wrapgift='+geschenk+'&grusstext='+$grusstext;
	      $.ajax({
	      type: "GET",
	      url: url,
	      dataType: "html",
	      success: function(html)
	      {
	       $('#grusstext').fadeOut("slow");
	      }
	      });
	     }
	else {$('.grusstextlinktxton').hide('fast');
	      $('.grusstextlinktxtoff').show('fast');

	      var url = 'ajax.php?mode=savegrusstext&product_id='+id+'&wrapgift='+geschenk+'&grusstext='+$grusstext;
	      $.ajax({
	      type: "GET",
	      url: url,
	      dataType: "html",
	      success: function(html)
	      {
	      $('#grusstext').fadeOut("slow");
	      }
	      });
	     }
       }
   }





function CountMax(formfield)
  {
   var wert,max;

   max = 70;
   if   (formfield)
        {
   wert = max-document.cart_quantity.grusstext.value.length;
   if   (wert < 0)
	{alert("Es dürfen nicht mehr als " + max + " Zeichen eingegeben werden!");
	 document.cart_quantity.grusstext.value=document.cart_quantity.grusstext.value.substring(0,max);
	 wert = max-document.cart_quantity.grusstext.value.length;
	 document.cart_quantity.rv_counter.value=wert;
	}
   else {document.cart_quantity.rv_counter.value=max - document.cart_quantity.grusstext.value.length;
	}

        }

   else {

   wert = max-document.produktdetail.grusstext.value.length;
   if   (wert < 0)
	{alert("Es dürfen nicht mehr als " + max + " Zeichen eingegeben werden!");
	 document.produktdetail.grusstext.value=document.produktdetail.grusstext.value.substring(0,max);
	 wert = max-document.produktdetail.grusstext.value.length;
	 document.produktdetail.rv_counter.value=wert;
	}
   else {document.produktdetail.rv_counter.value=max - document.produktdetail.grusstext.value.length;
	}
        }
  }









function showpop(o,layer,xplus,yplus)
  {
   var r = getdivpos(o);
   $x = (r.left + xplus);
   $y = (r.top + yplus);
   document.getElementById(layer).style.left = $x;
   document.getElementById(layer).style.top = $y;
   document.getElementById(layer).style.display = 'block';
  }






function getdivpos(o)
  {
   var r = { top:0, left:0, width:0, height:0 };
   if	   (!o)
	   {return r;}
   else if (typeof o == 'string' )
           {o = document.getElementById(o);
	   }
   if ( typeof o != 'object' )
      {return r;}

   if (typeof o.offsetTop != 'undefined')
      {
       r.height = o.offsetHeight;
       r.width = o.offsetWidth;
       r.left = r.top = 0;
       while (o && o.tagName != 'BODY')
	     {
              r.top  += parseInt( o.offsetTop );
              r.left += parseInt( o.offsetLeft );
              o = o.offsetParent;
	     }
      }
   return r;
  }








var layer;
var timer;

// Initialisieren des Scriptes
function initscroller(inner,outer,button1,button2,scrollsize,scrollposl) 
  {layer = document.getElementById(inner);
   layerouter = document.getElementById(outer);
   layer.style.left = 0;

   // var $test = layer.offsetWidth + ' ' + layerouter.offsetWidth;
   // alert($test);

   // WENN HÖHE DES INNEREN LAYERS GROESSER DER DES CONTAINERS, SCROLLBUTTONS EINBLENDEN.
   if (layer.offsetWidth > layerouter.offsetWidth)
      {
       if (scrollsize)
	  {document.getElementById(outer).style.width = scrollsize+'px';}
       if (scrollposl)
	  {document.getElementById(outer).style.left = scrollposl+'px';
	  }
       document.getElementById(button1).style.display = 'block';
       document.getElementById(button2).style.display = 'block';
      }
  }
	
// Ermittelt die Höhe des inneren Layers und gibt sie zurück
function getwidth() 
  {return layer.offsetWidth;
  }
// Ermittelt die Höhe des äußeren Layers und gibt sie zurück
function getouterwidth() 
  {return layerouter.offsetWidth;
  }

	
// Nach unten scrollen. Mit speed wird gesteuert wie schnell gescrollt
// werden soll (Pixel/25ms)
function scrollleft(speed) 
  {
   // Solange wie wir noch nicht alles gesehen haben scrollen wir nach unten.
   if ( getwidth() + parseInt(layer.style.left) > getouterwidth()) 
      {layer.style.left = parseInt(layer.style.left) - parseInt(speed) + 'px';
       timer = window.setTimeout("scrollleft('"+speed+"')",25);
      }
  }

// Nach oben scrollen. Mit speed wird gesteuert wie schnell gescrollt
// werden soll (Pixel/25ms)
function scrollright(speed) 
  {
   // Solange wir die Ausgangsposition noch nicht wieder erreicht haben
   // scrollen wir nach oben.
   if ( parseInt(layer.style.left) < 0) 
      {layer.style.left = parseInt(layer.style.left) + parseInt(speed) + 'px';
       timer = window.setTimeout("scrollright('"+speed+"')",25);
      }
  }

// Den Timer der das Hoch- oder Runterscrollen steuert anhalten.
function stopscroll() 
  {
   window.clearTimeout(timer);
  }





function etrackajax(ebid,emodel,eextra)
   {
    // var $test = ekey+'|'+emodel+'|'+ebid;
    // alert($test);
    // et_eC_Wrapper( ekey, epagename, ebereich, 0, '', '', 0, 0, 0, 0, 0, 0, 0)

   var url = 'ajax.php?mode=etrackajax&bid='+ebid;
   if (emodel)
      {url += '&model='+emodel;
      }
   if (eextra)
      {url += '&extra='+eextra;
      }
   $.ajax({
   type: "GET",
   url: url,
   dataType: "script",
   success: function(script)
   {
   }
   });

   }





function showprint(model)
  {
   var link = 'print_product_'+model+'.htm';
   window.open(link, 'popup', 'toolbar=0, width=660, height=600, scrollbars=yes');
  }


function showsend(model)
  {
   var link = 'bereich-empfehlung-st-Empfehlungslink-'+model+'.htm';
   window.open(link, 'popup', 'toolbar=0, width=571, height=509');
  }


function gettheight(layername)
  {
   var layer;
   layer = document.getElementById(layername);
   var test = layername +':'+layer.offsetHeight;
   alert(test);
  }



