var actualWidth = 0;
var actualHeight = 0;
var message; 
var b_fullsize = 0;

function tableWidth ()
{
    return windowWidth()-100;
}

function windowWidth ()
{
    if (navigator.appName=="Netscape")
        return window.innerWidth;

    return document.body.offsetWidth;
}

function scaleImg ()
{
    var imagescaled = document.getElementById('imagescaled');
    var imagesizetext = document.getElementById('imagesizetext');
    what = document.getElementById('image');

    actualHeight = what.height;
    actualWidth = what.width;
    
    if (fitsInWindow()) {
      imagescaled.style.display='none';
      return;
    }
    
    if(what.width == tableWidth()) {
        what.width = actualWidth;what.height=actualHeight;
        imagescaled.style.display='none';
    } else{
        what.style.cursor = "pointer";
        what.width = tableWidth();
        what.height = (actualHeight/actualWidth) * what.width;
 	 imagescaled.style.display='block';
	 imagesizetext.innerHTML = actualWidth+'x'+actualHeight+'px';
    }
}

function showOnclick() {
    what = document.getElementById('image');
    
    if (actualWidth == what.width)
        return scaleImg();
        
    else if (actualWidth > what.width) {
        what.width = actualWidth;
        what.height = actualHeight;
        imagescaled.style.display='none';
    }
}

function liveResize ()
{
    what = document.getElementById('image');
    actualHeight = what.height; 
    actualWidth = what.width;
    if (fitsInWindow()) {
       imagescaled.style.display='none';
       return;
    }
    
    if (what.width != actualWidth) {
        what.width = tableWidth();
        what.height = (actualHeight/actualWidth) * what.width;
 	 imagescaled.style.display='block';
	 imagesizetext.innerHTML = actualWidth+'x'+actualHeight+'px';    
    }
}

function setImgWidth ()
{
    if (fitsInWindow())
        return;
        
    document.getElementById('image').width = tableWidth();
}

function fitsInWindow ()
{
    what = document.getElementById('image');
    var actualWidth = what.width;

    if (actualWidth<tableWidth()) {
        displayWarning("none");
        return true;
    } else {
        return false;
    }
}

