function RealRegisterEnter(textBox) {
    
}

function checkEnter() {
    if (event.which || event.keyCode) {if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}}else {return true; }
}

function Navigation_Click(sender, eventArgs) {

    var node = eventArgs.get_node();
    if (node != null) {
        window.location.href = '/ShowResults.aspx?action=showfolder&folderid=' + node.get_value();
    }
}

function CheckFolderChildren(sender, args) {
    var node = args.get_node();
    var attributes = node.get_attributes();
    if (attributes.getAttribute("ItemType") == null) {
        CheckChildren(node);
    }

}
function CheckChildren(node) {
    if (node) {
        for (var i = 0; i < node.get_nodes().get_count(); i++) {
            var node2 = node.get_nodes().getNode(i);
            if (node2.get_attributes().getAttribute("ItemType")) {
                node2.set_checked(node.get_checked());
            }
        }
    }
}

function numbersonly(myfield, e) {
    var key;
    var keychar;

    if (window.event)
        key = window.event.keyCode;
    else if (e)
        key = e.which;
    else
        return true;
    keychar = String.fromCharCode(key);

    // control keys
    if ((key == null) || (key == 0) || (key == 8) ||
    (key == 9) || (key == 13) || (key == 27))
        return true;

    // numbers
    else if ((("0123456789").indexOf(keychar) > -1))
        return true;
    else
        return false;
}

function setWidthByAspect(values) {
    //Sets the image width by using the image aspect and the entered height

    var values = values.toString().split("|");
    var heightId = values[0];
    var widthId = values[1];
    var aspect = values[2].replace(",", ".");

    var height = document.getElementById(heightId);
    var width = document.getElementById(widthId);

    var result = parseFloat(height.value) * parseFloat(aspect);

    width.value = Math.round(result);
}

function setHeightByAspect(values) {
    //Sets the image height by using the image aspect and the entered width

    var values = values.toString().split("|");
    var heightId = values[0];
    var widthId = values[1];
    var aspect = values[2].replace(",", ".");

    var height = document.getElementById(heightId);
    var width = document.getElementById(widthId);

    var result = parseFloat(width.value) / parseFloat(aspect);

    height.value = Math.round(result);
}

function selectAllText(id) {
    //Highlight text
    document.getElementById(id).select();
}

/** CATEGORY TOOLS **/

function ViewCategoryChooser() {
    $("#categoryChooser").toggle();
}

/** LAYOUT TOOLS **/

function ToggleCollaps(aDiv, button) {
    if (aDiv.style.display == 'none') {
        aDiv.style.display = 'block';
        button.className = 'CollapsButtonExpanded';
        var cookieValue = readCookie('bbCookie');
        if (cookieValue != null) {
            cookieValue = cookieValue.replace($(aDiv).attr('id'), "");
            setCookie('bbCookie', cookieValue, 90);
        }
    }
    else {
        aDiv.style.display = 'none';
        button.className = 'CollapsButtonCollapsed';

        var cookieValue = readCookie('bbCookie');
        if (cookieValue != null) {
            if (cookieValue.indexOf($(aDiv).attr('id')) == -1) {
                setCookie('bbCookie', cookieValue + "" + $(aDiv).attr('id'), 90);
            }        
        } else {
            setCookie('bbCookie', $(aDiv).attr('id'), 90);
        }
    }
}


/** SKIN TOOLS **/

function SkinScalableBoxHead(styleclass) {
    document.write('<table class="' + styleclass + '" cellpadding="0" cellspacing="0" border="0"><tr><td class="SkinTopLeftCorner">&nbsp</td><td class="SkinTopFill">&nbsp</td><td class="SkinTopRightCorner">&nbsp</td></tr><tr><td class="SkinLeftFill">&nbsp</td><td class="SkinCenterContent">');
}

function SkinScalableBoxFoot(styleclass) {
    document.write('</td><td class="SkinRightFill">&nbsp</td></tr><tr><td class="SkinBottomLeftCorner">&nbsp</td><td class="SkinBottomFill">&nbsp</td><td class="SkinBottomRightCorner">&nbsp</td></tr></table>');
}

/** TREE MENU **/

function toggleMenu(element, menuID) {
    if($(element).attr("class")=="tmPlus_show"){
        $(element).attr("class","tmMinus_show");
    }else{
        $(element).attr("class","tmPlus_show");
    };
    
    $("#menuItem_" + menuID).toggle();
}

/** COOKIE TOOLS **/
function setCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function ShowColorbox(itemID) {
    $(document).ready(function() {
        $.colorbox({
            href: '/ajaxtools/showitemdetails.aspx?itemid=' + itemID,
            onComplete: function() { $(this).colorbox.resize(); } 
        });
    });
}
