﻿function izImgZoom_setImage(src) {
    try {
        var img = document.getElementById('izImgZoom_imgMain');
        img.removeAttribute('width'); img.src = src;
    }
    catch (e)
        { alert('setImage error: ' + e.message); }
}
function izImgZoom_zoomIn() {
    try {
        var img = document.getElementById('izImgZoom_imgMain');
        img.width = img.width * 1.25;
    }
    catch (e) { alert('zoomIn error: ' + e.message); }
}
function izImgZoom_zoomOut() {
    try {
        var img = document.getElementById('izImgZoom_imgMain');
        img.width = img.width * 0.75;
    } catch (e) { alert('zoomOut error: ' + e.message); }
}
function izImgZoom_actualSize() {
    try {
        var img = document.getElementById('izImgZoom_imgMain');
        img.removeAttribute('width');
    }
    catch (e) { alert('actualSize error: ' + e.message); }
}
function izImgZoom_bestFit() {
    try {
        //debugger;
        var iz = document.getElementById('izImgZoom');
        var img = document.getElementById('izImgZoom_imgMain');
        var cw = iz.clientWidth;
        while (cw == 0) {
            iz = iz.parentElement; cw = iz.clientWidth;
        } var ch = iz.clientHeight;
        img.removeAttribute('width');
        var ar = img.width / img.height;
        if (ar >= 1.0)
        { img.width = cw - 2; }
        else {
            img.width = Math.floor(ch * ar) - 2;
        }
    } catch (e)
   { alert('bestFit error: ' + e.message); }
}
function bestFit(clientID) {
    try {
        //debugger;
        var iz = document.getElementById(clientID + '_izImgZoom');
        var img = document.getElementById(clientID + '_izImgZoom_imgMain');
        var cw = iz.clientWidth;
        while (cw == 0) {
            iz = iz.parentElement; cw = iz.clientWidth;
        } var ch = iz.clientHeight;
        img.removeAttribute('width');
        var ar = img.width / img.height;
        if (ar >= 1.0)
        { img.width = cw - 2; }
        else {
            img.width = Math.floor(ch * ar) - 2;
        }
    } catch (e)
   { alert('bestFit error: ' + e.message); }
  }
  function bestFitNo(clientID, No) {
  	try {
  		//debugger;
  		var iz = document.getElementById(clientID + '_izImgZoom_' + No);
  		var img = document.getElementById(clientID + '_izImgZoom_' + No + '_imgMain');
  		var cw = iz.clientWidth;
  		while (cw == 0) {
  			iz = iz.parentElement;
  			cw = iz.clientWidth;
  		}
  		var ch = iz.clientHeight;
  		img.removeAttribute('width');
  		var ar = img.width / img.height;
  		if (ar >= 1.0) {
  			img.width = cw - 2;
  		}
  		else {
  			img.width = Math.floor(ch * ar) - 2;
  		}
  	} catch (e)
   { alert('bestFit error: ' + e.message); }
  }
function actualSize(clientID) {
    try {
        var img = document.getElementById(clientID + '_izImgZoom_imgMain');
        img.removeAttribute('width');
    }
    catch (e) { alert('actualSize error: ' + e.message); }
}
function zoomOut(clientID) {
    try {
        var img = document.getElementById(clientID + '_izImgZoom_imgMain');
        img.width = img.width * 0.75;
    } catch (e) { alert('zoomOut error: ' + e.message); }
}
function zoomIn(clientID) {
    try {
        var img = document.getElementById(clientID + '_izImgZoom_imgMain');
        img.width = img.width * 1.25;
    }
    catch (e) { alert('zoomIn error: ' + e.message); }
}
