function toggle(x) {
    xTog = document.getElementById(x);
    xState = xTog.style.display;
    // if(xState=='none') xState = 'table';
    if(xState=='none') xState = '';
    else xState = 'none';
    xTog.style.display = xState;
}


function getContainerHt()
{
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
        winH = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
        winH = document.body.offsetHeight;
    }
  }
  return winH;
}

function getContainerWd(container)
{
   box  = document.getElementById(container);
   winW = box.clientWidth;
   return winW;
}


function scaleImage(container, location, imgPath, imgH, imgW, title, fullImagePath, us)
{
    // Get container's dimensions (i.e., the "wrapper div")
    boxH = Math.round(getContainerHt() * .75);
    boxW = getContainerWd(container);

    // Find which dimension is scaled the most
    var scaleH = boxH / imgH;
    var scaleW = boxW / imgW;
    //alert( imgH + " " + imgW + " " + boxH + " " + boxW + " " + scaleH + " " + scaleW);
    
    // Image scaling Logic 
    if (scaleH < scaleW) {
        var newH  = boxH;
        var newW  = Math.round(imgW * scaleH);
    } else {
        var newW  = boxW;
        var newH  = Math.round(imgH * scaleW);
    }

    // Check if we are allowed to upscale ... if not, then revert if necessary
    if(!us && (newH > imgH) && (newW > imgW) ) {
        var newH  = imgH;
        var newW  = imgW;
    }

    // Now stringify ...
    newH += "px";
    newW += "px";
    
    // create image
    var html = '<img src="' + imgPath + '" alt="' + title + 
               '" width="' + newW + '" height="' + newH + '"/>';

    // Logic (to be fixed) if we want to allow link to full image!
    /* var html = '<a href="' + "http://www.jx3design.com/gallery/emboss.php" + '">' +
               '<img src="' + imgPath + '" alt="' + title + 
               '" width="' + newW + '" height="' + newH + '"/>' +
               "</a>";
    */

    // insert the additional HTML to the location (i.e., the "image div") for the
    // scaled image
    // alert(html);
    document.getElementById(location).innerHTML = html;
    
}

