function NavigateToSelectedValue(valObj)
{
    if (typeof(valObj.value) != 'undefined' && valObj.value != '') {
        document.location = valObj.value;
    }
}

function ShowAttributeValueList(attributeName, attributeNavigationData, optionsSelectId)
{
    var sel = document.getElementById(optionsSelectId);
    if (sel != null) {
        // Clearing select options
        while (sel.lastChild != null) {
            sel.removeChild(sel.lastChild);
        }
        // Adding new options
        var opt = document.createElement("option");
        opt.innerHTML = "Выберите значение"; // NOTE: Not part of specification
        sel.appendChild(opt);
        
        if (attributeNavigationData[attributeName] != null) {
            for (attributeOption in attributeNavigationData[attributeName]) {
                opt = document.createElement("option");
                opt.value = attributeNavigationData[attributeName][attributeOption];
                opt.innerHTML = attributeOption; // NOTE: Not part of specification
                sel.appendChild(opt);
            }
            sel.disabled = false;
        }
        else {
            sel.disabled = true;
        }
    }        
}

function StartPhotoViewer()
{
    if (photoNavigationData.length > 0) {
        var image = document.getElementById('photoImage');
        var controls = document.getElementById('photoControls');

        image.style.visibility = "visible";
        controls.style.visibility = "visible";
        ShowNextPhoto();
    }
}

function ShowNextPhoto()
{
    var image = document.getElementById('photoImage');
    image.src = photoNavigationData[++currentPhoto];
    SetPhotoButtonsState();
}

function ShowPrevPhoto()
{
    var image = document.getElementById('photoImage');
    image.src = photoNavigationData[--currentPhoto];
    SetPhotoButtonsState();

}

function SetPhotoButtonsState()
{
    if (currentPhoto < photoNavigationData.length - 1) {
        document.getElementById('photoButtonNext').disabled = false;
    }
    else {
        document.getElementById('photoButtonNext').disabled = true;
    }
    if (currentPhoto > 0) {
        document.getElementById('photoButtonPrev').disabled = false;
    }
    else {
        document.getElementById('photoButtonPrev').disabled = true;
    }
}