
function btnMouseOver(imgName, img)
{
    var imgName = templatePath + "/Images/Buttons/btn_" + imgName + "_on.gif";
    
    img.src = imgName;
}

function btnMouseOut(imgName, img)
{
    var imgName = templatePath + "/Images/Buttons/btn_" + imgName + ".gif";
    
    img.src = imgName;
}

function setTheme(themeName)
{
    var newSearch=document.location.search;
    var returnUri = document.location.href;
    
    if(newSearch.length > 0)
        newSearch = newSearch + '&themeName=' + themeName + '&returnUri=' + returnUri;
    else
        newSearch = newSearch + '?themeName=' + themeName + '&returnUri=' + returnUri
    
    var newUri = document.location.host + document.location.pathname + newSearch;
    document.location.href='http://' + newUri;
}


function showSketch()
{
    var elm = document.getElementById("elmSketch");
    elm.style.display = "inline";
    
    var elmWidth = elm.clientWidth;
    var top = document.documentElement.scrollTop;
    var left = eval(document.documentElement.clientWidth/2) - eval(elmWidth);
    
    elm.style.top = top + "px";
    elm.style.left = left + "px";
}

function hideSketch()
{
    var elm = document.getElementById("elmSketch");
    elm.style.display = "none";
}

function addToFavorites()
{
    window.external.AddFavorite(location.href, document.title);
}

function fitImageSize(img,targetWidth,targetHeight)
{
    if(img.clientWidth>targetWidth)
        img.style.width=targetWidth + 'px';
        
    if(img.clientHeight>targetHeight)
        img.style.height=targetHeight + 'px';
}

function findPos(coord, obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            if (coord == 'x') { curleft += obj.offsetLeft; }
            else { curleft += obj.offsetTop }
            obj = obj.offsetParent;
        }
    }
    else if (obj.coord)
        curleft += obj.coord;

    return curleft;
}

function openMenu(divId, menuNum) {
    var btn = document.getElementById("btn_" + menuNum);
    //var btn = menuNum;
    var left = findPos('x', btn);
    var top = eval(findPos('y', btn)) + eval(btn.offsetHeight);
    var div = document.getElementById(divId);
    div.style.display = "block";
    div.style.left = left + "px";
    div.style.top = top + "px";
}

function closeMenu(divId) {
    var div = document.getElementById(divId);
    div.style.display = "none";
}

