  function calcChange()
  {
    var calc = document.getElementById("calc");
    var widthBox = document.getElementById("widthdiv");
    var heightBox = document.getElementById("heightdiv");
    var arBox = document.getElementById("ardiv");
    
    var width = document.getElementById("width");
    var height = document.getElementById("height");
    var ar = document.getElementById("ar");
    
    switch(findSelected(calc).value)
    {
      case 'width':
        widthBox.style.display = "none";
        heightBox.style.display = "block";
        arBox.style.display = "block";
        width.value = "";
        height.value = "";
        ar.selectedIndex = 0;
        break;
      case 'height':
        heightBox.style.display = "none";
        arBox.style.display = "block";
        widthBox.style.display = "block";
        width.value = "";
        height.value = "";
        ar.selectedIndex = 0;
        break;
      case 'ar':
        arBox.style.display = "none";
        widthBox.style.display = "block";
        heightBox.style.display = "block";
        width.value = "";
        height.value = "";
        ar.selectedIndex = 0;
        break;
    }
  }

  function presetChangeDim()
  {
    var ele = findSelected(document.forms[0].preset);
    var json = eval('('+(Base64.decode(ele.attributes['value'].nodeValue))+')');

    var ratio = json.ratio;
    var width = json.width;
    var height = json.height;
    
    document.getElementById("width").value = width;
    document.getElementById("height").value = height;
    
    var ars = document.getElementById("ratio");
    for(var i=0; i<ars.length; i++)
    {
      if (ars[i].value == ratio)
      {
        ars.selectedIndex = i;
        return;
      }
    }
    
  }
