//%20--------------------------------------------------------------------%0D//%20Javascript%20Magnifier%20v%200.94%0D//%20Written%20by%20Dino%20Termini%20-%20termini@email.it%20-%20April%2025%2C%202003%0D//%20This%20script%20is%20freeware%20%28GPL%29%20but%20if%20you%20use%20it%2C%20please%20let%20me%20know%21%0D//%0D//%20Portions%20of%20code%20by%20zoomIN%2C%20zoomOUT%0D//%20Author%3A%20Nguyen%20Duong%20Minh%20%28Obie%29%20-%20obie4web@yahoo.com%0D//%20WWW%3A%20http%3A//ObieWebsite.SourceForge.net%0D//%20License%3A%20GNU%20%28GPL%29%0D//%20--------------------------------------------------------------------%0D//%0D//%20Please%20refer%20to%20README.html%20file%20for%20details%20and%20usage%0D//%0D//%20--------------------------------------------------------------------%0D%0D//%20Configuration%20parameters%0D//%20------------------------%0D//%20Measure%20unit%20in%20pixel%20%28px%29%20or%20points%20%28pt%29%0D//%20measureUnit%20%3D%20%22px%22
measureUnit = "pt"
// Min sizes allowed
minSize = 1;
minStyleSize = 10;
// Max sizes allowed
maxSize = 6;
maxStyleSize = 30;
//%20Start%20size%20for%20text%20displayed
startSize = 2;
startStyleSize = 10;
//%20Start%20size%20for%20text%20displayed
stepSize = 1;
stepStyleSize = 2;
//%20Start%20size%20for%20text%20displayed
var keyin = 43;
var keyinCAPS = 43;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var keyout = 45;
var keyoutCAPS = 45;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var keyinIe = 62;
var keyinIeCAPS = 62;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var keyoutIe = 60;
var keyoutIeCAPS = 60;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var zoomFactor = 1.1;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var maxZoom = 4.096;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var minZoom = 0.625;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var startDecZoom = 0.7;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
var startIncZoom = 1.3;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
function searchTags(childTree, level) {
  var retArray = new Array();
  var tmpArray = new Array();
  var j = 0;
  var childName = "";
  for (var i=0; i<childTree.length; i++) {
    childName = childTree[i].nodeName;
    if (childTree[i].hasChildNodes()) {
      if ((childTree[i].childNodes.length == 1) && (childTree[i].childNodes[0].nodeName == "#text"))
        retArray[j++] = childTree[i];
      else {
        tmpArray = searchTags(childTree[i].childNodes, level+1);
        for (var k=0;k<tmpArray.length; k++)
          retArray[j++] = tmpArray[k];
        retArray[j++] = childTree[i];
      }
    }
    else
      retArray[j++] = childTree[i];
  }
  return(retArray);
}
function changeFontSize(stepSize, stepStyleSize) {
  myObj = searchTags(document.body.childNodes, 0);
  myObjNumChilds = myObj.length;
  for (i=0; i<myObjNumChilds; i++) {
    myObjName = myObj[i].nodeName;
//%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
    if (myObjName != "#text" && myObjName != "HTML" &&
        myObjName != "HEAD" && myObjName != "TITLE" &&
        myObjName != "STYLE" && myObjName != "SCRIPT" &&
        myObjName != "BR" && myObjName != "TBODY" &&
        myObjName != "#comment") {
      size = parseInt(myObj[i].getAttribute("size"));
      styleSize = parseInt(myObj[i].style.fontSize);
      if (isNaN(size) || (size < minSize) || (size > maxSize))
        size = startSize;
      if (isNaN(styleSize) || (styleSize < minStyleSize) || (styleSize > maxStyleSize))
        styleSize = startStyleSize;
      if ( ((size > minSize) && (size < maxSize)) || 
           ((size == minSize) && (stepSize > 0)) || 
           ((size == maxSize) && (stepSize < 0)) ) {
        myObj[i].setAttribute("size", size+stepSize);
      }
      if ( ((styleSize > minStyleSize) && (styleSize < maxStyleSize)) || 
           ((styleSize == minStyleSize) && (stepStyleSize > 0)) ||
           ((styleSize == maxStyleSize) && (stepStyleSize < 0)) ) {
        newStyleSize = styleSize+stepStyleSize;
        myObj[i].style.fontSize = newStyleSize+measureUnit;
      }
    } //%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
  } //%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
} //%20Keys%20for%20%22hard%22%20zooming%20in%20%28with%20and%20without%20CAPS%20lock%29.%20Default%3A%20%22%3E%22
function increaseFontSize() {
  changeFontSize(stepSize, stepStyleSize);
}
function decreaseFontSize() {
  myStepSize = -stepSize;
  myStepStyleSize = -stepStyleSize;
  changeFontSize(myStepSize, myStepStyleSize);
}
function zoomin() {
  if (window.parent.document.body.style.zoom < maxZoom) {
    if (window.parent.document.body.style.zoom > 0) {
      window.parent.document.body.style.zoom *= zoomFactor; 
    }
    else { 
      window.parent.document.body.style.zoom = startIncZoom;
    }
  }
  else {
    alert("Warning: Max size reached");
  }
}
function zoomout() {
  if ( (window.parent.document.body.style.zoom > minZoom) ||
       (window.parent.document.body.style.zoom == 0) ) {
    if (window.parent.document.body.style.zoom > 0) {
      window.parent.document.body.style.zoom /= zoomFactor; 
    }
    else {
      window.parent.document.body.style.zoom = startDecZoom;
    }
  }
  else {
    alert("Warning: Min size reached");
  }
}
function checkzoom(e) {
  if (document.all) {
    myEvent = event.keyCode;
  }
  else {
    myEvent = e.which;
  }
  switch(myEvent) {
    case keyinIe:
    case keyinIeCAPS:
      zoomin();
      break;
    case keyoutIe:
    case keyoutIeCAPS:
      zoomout();
      break;
    case keyin:
    case keyinCAPS:
      increaseFontSize();
      break;
    case keyout:
    case keyoutCAPS:
      decreaseFontSize();
      break;
    default:
      break;
  }
}
if (document.layers) {
  document.captureEvents(Event.KEYPRESS);
}
document.onkeypress = checkzoom;

