//Javascript function for Image Preview functionality
//created by Oleg Butov, March 2008  
document.write("<script type='text/javascript' SRC='includes/fadeTransition.js'></script>"); //include
// width to resize large images to
var maxWidth=190;
  // height to resize large images to
var maxHeight=170;
  // the id of the preview image tag
var outImage="slide";
  // what to display when the image is not valid
var defaultPic="";

var originalPic;
var globalPic;
var changeTimer;

function preview(filename){
if (changeTimer) clearTimeout(changeTimer);
  changeOpac(100, outImage)
  shiftOpacity(outImage, 20);
  var source=filename;//document.getElementById(what).value;
  globalPic=new Image();
  globalPic.src=source;
  changeTimer = setTimeout("applyChanges()",30);
}

function applyChanges(){
  var field=document.getElementById(outImage);
  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  //resizing
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";  
  field.src=globalPic.src;
  field.width=x;
  field.height=y;
  shiftOpacity(outImage, 40);
}


