﻿
function showFloatingPrompt(elementId, placeNextTo) {
    var element = document.getElementById(elementId);
    if (placeNextTo != null) {
        var position = new Array(2);
        position = findPos(placeNextTo);
        element.style['left'] = position[0]+'px';
        element.style['top'] = position[1]+'px';
    }
    if (element.style.display == "none") {
        element.style.display = "";
    }
    else {
        element.style.display = "none";
    }
}

function toggleComboBoxOptions(element, textBox) {
    if (textBox != null) {
        var position = new Array(2);
        position = findPos(textBox);
        element.style['left'] = position[0] + 'px';
        element.style['top'] = position[1] + 20 + 'px';
    }
    if (element.style.display == "none") {
        element.style.display = "";
    }
    else {
        element.style.display = "none";
    }
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft, curtop];
    }
}

function toggleCheckboxOptions(checkBoxListId, link) {
    var rows = document.getElementById(checkBoxListId).childNodes[1].childNodes;
    for (var r = 0; r < rows.length; r++) {
        var cells = rows[r].childNodes;
        for (var c = 0; c < cells.length; c++) {
            try {
                if (link.innerHTML == 'Uncheck All') {
                    cells[c].childNodes[0].checked = false;
                }
                else {
                    cells[c].childNodes[0].checked = true;
                }
            }
            catch (e) {
            }
        }
    }
    if (link.innerHTML == 'Uncheck All') {
        link.innerHTML = 'Check All';
    }
    else {
        link.innerHTML = 'Uncheck All';
    }
}

function hideElement(elementId) {
    try {
        var element = document.getElementById(elementId);
        element.style.display = "none";
    }
    catch (e) { }
}

function showElement(elementId) {
    try {
        var element = document.getElementById(elementId);
        element.style.display = "";
    }
    catch (e) { }
}

function openInstallerWindow() {
    try {
        _playerWindow = window.open('http://watch.slingbox.com/watch/slingPlayer/install', 'SlingPlayer', 'width=1050,height=700,menubar=no,status=yes,location=no,toolbar=no,scrollbars=yes,resizable=yes,directories=no,location=no');
        _playerWindow.focus();
    }
    catch (e) { }
}

$(document).ready(function() {
    contentRotator($("ul#rotator > li:first"));
});

var doAnimate = true;

function contentRotator(content) {
    if (doAnimate) {
        content.fadeOut("fast", function(content) {
            return function() {
                /* HIDE ALL ITEMS */
                $("ul#rotator > li").hide();

                content.fadeIn(2500, function() {
                    /* GO BACK TO FIRST ITEM */
                    if ($(this).attr("id") == $("ul#rotator > li:last").attr("id")) {
                        setTimeout(function() {
                            contentRotator($("ul#rotator > li:first"));
                        }, 5000);
                    }
                    else { /* FADE IN NEXT ITEM  */
                        setTimeout(function() {
                            contentRotator($(content.next()));
                        }, 5000);
                    }
                });
            };
        } (content));
    }
}

