 // switch image src
var imgLoader,imgLoaderZoom,oldX,oldY;
var slideInit=false;


function SwitchImage(id,src,srcZoom)
{
  oldX=$('ZoomImage').width;
  oldY=$('ZoomImage').height;
  $('ZoomImage').src=srcZoom;

/*  imgtmp = new Image();
  srcZoom.onload = function() {alert(this.width + 'x'+ this.height);};
  imgtmp.src=srcZoom;*/

/*@cc_on
   /*@if (@_jscript_version < 5.7)
      if(img.complete) img.onload(); // IE 6 Bug
   /*@end
@*/


  imgLoader = new Image();
  imgLoader.src=src;
  StartAnimationOpacity(333,10,1,'product_img',100,0)
  window.setTimeout("$('product_img').src=imgLoader.src; StartAnimationOpacity(500,10,1,'product_img',0,100);",333);

}
function DisplayHoverDetails()
{
  $('lupe').style.display='none';
  $('ZoomImageDiv').style.display='block';


  if (!slideInit)
  { slideInit=true;
    SlidePanelInit('slidepanel',0,0);
    //SlidePanelExtMausMove('slidepanel','product_img',0.5,100,100,2000,75);
    window.setInterval("SlidePanelExtMausMoveTimer('slidepanel','product_img');", 30);
  }

}

function HideHoverDetails()
{
  $('lupe').style.display='block';
  $('ZoomImageDiv').style.display='none';
}

//Bewege Ausschnitt durch Maus
//speed z.B. 0.5
function SlidePanelExtMausMove(slidepanelID,ControlElementID,speed,PosXFallback,PosYFallback,dauer, schritte)
{
  var o=$(slidepanelID);
  o.speed=speed;
  o.PosXFallback=PosXFallback;
  o.PosYFallback=PosYFallback;
  o.dauer=dauer;
  o.schritte=schritte;
}


function SlidePanelExtMausMoveTimer(slidepanelID,ControlElementID)
{
  var c=$(ControlElementID);
  var o=$(slidepanelID);

  var w=c.offsetWidth;
  var h=c.offsetHeight;

//  var w2=$('ZoomImage').width-290; //Verbleibende versteckte Breite =>Bereich möglicher StartOffsets
//  var h2=$('ZoomImage').height-300;
  var w2=$('ZoomImage').width-470; //Verbleibende versteckte Breite =>Bereich möglicher StartOffsets
  var h2=$('ZoomImage').height-300;
//  if (w2<0)w2=0; if (h2<0)h2=0;

  var pos=getPositionRelative(c);

  if (MausY<pos.y){return;}//Mauswerte noch außerhalb des Objektes
  if (MausX<pos.x){return;}
  if (MausY>pos.y+h){return;}
  if (MausX>pos.x+w){return;}

  //Positionsmarken als Werte 0...100%
  var px=(MausX-pos.x-50)/(w-100); //25+25px Rand
  var py=(MausY-pos.y-50)/(h-100);

  var newX=parseInt(w2*px);
  var newY=parseInt(h2*py);

//  $('debug').innerHTML=pos.x+","+pos.y+" ("+w+"/"+h+")<br>"+MausX+"-"+MausY+"<br>"+parseInt(px*100)+"%-"+parseInt(py*100)+"%<br>"+w2+"/"+h2+"<br>"+newX+" "+newY;

   $('slidepanelContent').Breite=$('ZoomImage').width;
   $('slidepanelContent').Hoehe=$('ZoomImage').height;

  SlidePanelSetPos1(slidepanelID,newX,newY);
  //SlidePanelMoveToPos(slidepanelID,newX,newY,1,1);


}


function SlidePanelSetPos1(ObjektID,PosX,PosY)
{ var slidepanelObj=$(ObjektID);
  var LeinwandObj=$(ObjektID+"Content");
  var ViewPortBreite=parseInt(slidepanelObj.offsetWidth);
  var ViewPortHoehe=parseInt(slidepanelObj.offsetHeight);

  var LeinwandBreite=LeinwandObj.Breite;
  var LeinwandHoehe=LeinwandObj.Hoehe;
  if (PosX<0){PosX=0;}
  if (PosY<0){PosY=0;}
  if (PosX>LeinwandBreite-ViewPortBreite){PosX=LeinwandBreite-ViewPortBreite;}
  if (PosY>LeinwandHoehe-ViewPortHoehe){PosY=LeinwandHoehe-ViewPortHoehe;}

  if (LeinwandBreite<ViewPortBreite) PosX=-parseInt((ViewPortBreite-LeinwandBreite)/2);
  if (LeinwandHoehe<ViewPortHoehe) PosY=-parseInt((ViewPortHoehe-LeinwandHoehe)/2);

  LeinwandObj.style.left=-PosX+'px';
  LeinwandObj.style.top =-PosY+'px';
}

