var origLargePhoto = '';
var lastCaseSel = null;
var lastTextId = '';
var lastThumbsId = '';
var curLargePhoto = '';


function show(itemId, url, largeurl)
{
    var obj = document.getElementById(itemId);
    if (obj)
        obj.src = url;    
        
    if (largeurl != undefined ) {
        curLargePhoto = largeurl;
    }
}

function setClass(itemId, cssclass)
{
    var obj = document.getElementById(itemId);
    if (obj)
        obj.className = cssclass;
}

function caseMouseOver(what, textid, rightImage, thumbsId, largePhoto)
{
    // Set the orange color
    if (lastCaseSel) 
	lastCaseSel.className = 'casebox';
    else 
        setClass('origcasesel', 'casebox');
    what.className = 'casebox currentcase';
    
    // Set the textbox visible
    if (lastTextId != '')
        setClass(lastTextId, 'casedescription hidden');
    else
        setClass('descriptionorig', 'casedescription hidden');
    setClass(textid, 'casedescription');
    
    // Set the right hand image
    //var obj = document.getElementById('rightimage');
    origLargePhoto = document.getElementById('rightimage').src;
    document.getElementById('rightimage').src = rightImage;
    curLargePhoto = largePhoto;

    // Set the thumbnails
    if (lastThumbsId != '')
        setClass(lastThumbsId, 'casethumb hidden');
    else
        setClass('thumbsorig', 'casethumb hidden');
    setClass(thumbsId, 'casethumb');


    lastCaseSel = what;
    lastTextId = textid;
    lastThumbsId = thumbsId;
}

function getWindowHeight()
{
    var scnWid,scnHei;
    if (self.innerHeight) // all except Explorer
    {
        scnWid = self.innerWidth;
        scnHei = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
    {
        scnWid = document.documentElement.clientWidth;
        scnHei = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        scnWid = document.body.clientWidth;
        scnHei = document.body.clientHeight;
    }
    
    return scnHei;
}

function getWindowWidth()
{
    var scnWid,scnHei;
    if (self.innerHeight) // all except Explorer
    {
        scnWid = self.innerWidth;
        scnHei = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
    {
        scnWid = document.documentElement.clientWidth;
        scnHei = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        scnWid = document.body.clientWidth;
        scnHei = document.body.clientHeight;
    }
    
    return scnWid;
}


function largeRightImage(startPhoto)
{
    var imghref;
    if (curLargePhoto == '')
        imghref = startPhoto;
    else
        imghref = curLargePhoto;
        
    width = getWindowWidth() - 150;
    height = getWindowHeight() - 100;

    
    url = '/umbraco/ImageGen.aspx?image=' + imghref + '&width=' + width + '&height=' + height + '&constrain=true';
    
    
    //document.getElementById("zoomimage").src = '#';
    document.getElementById("zoomimage").src = '/images/loader.gif';
    //mTop = getWindowHeight() / 2;
    document.getElementById("zoomimage").src = url;
    document.getElementById("zoomimage").style.visibility = 'visible';
    document.getElementById("trans").style.visibility = 'visible';
}


function adjustTable()
{
    maxH = getWindowHeight();
    document.getElementById("main_table").style.height=maxH + 'px';
}

function hideTrans()
{
    document.getElementById('trans').style.visibility = 'hidden';
    document.getElementById('zoomimage').style.visibility = 'hidden';
}

window.onload = function(){adjustTable();};

