var maxWidthT=100;
var maxHeightT=100;
var fileTypesT=["bmp","gif","png","jpg","jpeg"];
var outImageT="previewFieldT";
var defaultPicT="spacer.gif";

/***** DO NOT EDIT BELOW *****/

function previewT(whatT){
  var sourceT=whatT.value;
  var extT=sourceT.substring(sourceT.lastIndexOf(".")+1,sourceT.length).toLowerCase();
  for (var i=0; i<fileTypesT.length; i++) if (fileTypesT[i]==extT) break;
  globalPicT=new Image();
  if (i<fileTypesT.length) globalPicT.src=sourceT;
  else {
    globalPicT.src=defaultPicT;
    alert("This is not a valid image\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
  }
  setTimeout("applyChangesT()",200);
}
var globalPicT;
function applyChangesT(){
  var fieldT=document.getElementById(outImageT);
  var xT=parseInt(globalPicT.width);
  var yT=parseInt(globalPicT.height);
  if (xT>maxWidth) {
    yT*=maxWidthT/xT;
    xT=maxWidthT;
  }
  if (yT>maxHeightT) {
    xT*=maxHeightT/yT;
    yT=maxHeightT;
  }
  fieldT.style.display=(xT<1 || yT<1)?"none":"";
  fieldT.src=globalPicT.src;
  fieldT.widthT=xT;
  fieldT.heightT=yT;
}
