// JavaScript Document
function mgChangeProduktImg(path, imgNum)
{
    newImage = new Image();
    newImage.src = path;
    document.getElementById('product_img').src = newImage.src;
    document.getElementById('actpic').value = imgNum;
}

function openZoomPopup()
{
  var actpic = document.getElementById('actpic').value-1;

  oxid.popup.zoom();
  oxid.image('zoom_img', openZoomPopup.arguments[actpic]);
  resizePopUp();  
}

function resizePopUp()
{
  window.setTimeout("resizePopUpNow()",500);
}

function resizePopUpNow()
{
  sollHeight = document.getElementById('imgContainer').clientHeight;
  sollWidth = document.getElementById('imgContainer').clientWidth;

  document.getElementById('botZoom').style.width = sollWidth+"px";
  
  newWidth = document.getElementById('zoom_img').width;

  document.getElementById('midPart').style.width = newWidth+"px";
  document.getElementById('zoomMiddleTop').style.width = newWidth+"px";  
  
  document.getElementById('midLeft').style.height = sollHeight+"px";
  document.getElementById('midRight').style.height = sollHeight+"px";  
}
//------------------------------------------------------------------------------
// startseite Blendeffekt
//------------------------------------------------------------------------------
var speed = 5000;
var aktionid = 1;
var percentIn  = 0;
var percentOut  = 100;
var divIn;
var divOut;

function startAktionAnimation()
{
  aktionInterval = window.setInterval("startBlending()", speed);
}

function startBlending()
{
  count = getAktionArticleCount();
  
  divOut = document.getElementById('startAktionAnimation_' + aktionid);
  
  aktionid++;
  if(aktionid==count) { aktionid=1; }

  divIn = document.getElementById('startAktionAnimation_' + aktionid);
  divIn.style.display = 'block';

  percentIn  = 0;
  percentOut  = 100;

  fade();
}

function fade()
{
  if(percentOut>0) { percentOut = percentOut - 5; }
  else { divOut.style.display = 'none'; }
  
  if (window.navigator.userAgent.indexOf("MSIE ") > -1 && parseFloat(navigator.appVersion) >= 4) 
  { divOut.style.display = 'none'; }
  
  divOut.style.opacity = percentOut/100;
  
  // IE lässt text verschwimmen ? warum weiß ich ned also kein Blend effeckt!
  //divOut.style.filter = "Alpha(opacity="+percentOut+")";
  
  
  if(percentIn<100) { percentIn = percentIn + 5; }
  
  divIn.style.opacity = percentIn/100;
  
  // IE lässt text verschwimmen ? warum weiß ich ned also kein Blend effeckt!
  //divIn.style.filter = "Alpha(opacity="+percentIn+")";
  
  if(percentIn<100 && percentOut>0)
    window.setTimeout("fade()", 100); 
}

function getAktionArticleCount()
{
  count = 1;
  while(div = document.getElementById('startAktionAnimation_' + count)) {
    count++;    
  }
  
  return count;
}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Startseite Artikel Scroller
//------------------------------------------------------------------------------

var swidth  = 143;   //slider's width
var sheight = 225;   //slider's height
var sspeed  = 2;     //slider's speed;
var thel    = 0; 

function startScroller() {
  aktioncount = document.getElementById('TippsderWocheCount').value;
  tdiv6 = document.getElementById('slider');
  tdiv6.style.left = 0 + "px";
  thel=swidth*aktioncount;
  scroll6();

}

function scroll6() {
  tdiv6 = document.getElementById('slider');

  if( parseInt(tdiv6.style.left) >= thel*(-1) ) {
    tdiv6.style.left = parseInt(tdiv6.style.left) - sspeed + "px";
    setTimeout("scroll6()", 50);
  } else {
    tdiv6.style.left = 0 + "px";
    scroll6();
  }
}
//------------------------------------------------------------------------------
