function HP_loadTab(number)
{
    //$('.categories').fadeOut();
    $('.age li a').removeClass();
    $('#categories_option' + parseInt(number)+' a').attr('class', 'selected');
    $(".categories").empty();
    $('#categories' + parseInt(number)).children().clone().appendTo(".categories");
    
	$('#content .categories > div').bind( 'mouseover', function(){ $('#content .categories > div.active').removeClass('active');$(this).addClass('active') } )
    //$('.categories').fadeIn();   
}

function flashMsg(message, status) {
    /*
    $(".flashMessenger").text(message);
    if (status == 0)
        $(".flashMessenger").addClass("info");
    else
        $(".flashMessenger").addClass("error");

    $(".flashMessenger").fadeIn('fast');
    */
    alert(message);
}

function addToFavorites(nodes_id) {
    $.ajax({
        type: "POST",
        url: "/Documents/Services/Favorites.asmx/Add",
        data: "{Nodes_Id: " + parseInt(nodes_id) + "} ",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {

            flashMsg(data.d.Message, data.d.Status);
        }
    });

}

function removeFromFavorites(nodes_id) {
    $.ajax({
        type: "POST",
        url: "/Documents/Services/Favorites.asmx/Remove",
        data: "{Nodes_Id: " + parseInt(nodes_id) + "} ",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {

            flashMsg(data.d.Message, data.d.Status);
            $('#node-' + parseInt(nodes_id)).hide();
        }
    });

}

function addToAbuse(nodes_id) {
    $.ajax({
        type: "POST",
        url: "/Documents/Services/AbuseList.asmx/Add",
        data: "{Nodes_Id: " + parseInt(nodes_id) + "} ",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {

            flashMsg(data.d.Message, data.d.Status);
        }
    });

}
   
 function lock(nodes_id, enabled) {
    $.ajax({
        type: "POST",
        url: "/Documents/Services/Nodes.asmx/Lock",
        data: "{Nodes_Id: " + parseInt(nodes_id) + ", enabled: "+ ((parseInt(enabled) == 1)? 'false':'true') + "} ",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {

            flashMsg(data.d.Message, data.d.Status);
        }
    });

}

function browserAddToFavorites() { if (window.external) { window.external.AddFavorite("http://kursusability.pl/","Kurs Usability") 
} else { alert("Twoja przeglądarka nie obsługuje tej funkcji!"); 
} } // --></script>

function tg(div)
{
}

function urlencode(str) {
    str = (str + '').toString();
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
                                                                    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}


var ImageDescriptionsEditor = {
    inuse: false,
    curr: null,
    returned: false,
    cancel: function () {

        with (this) {
            //    if (returned) return;
            curr = null;
            returned = false;
            inuse = false;
        }
    },
    save: function () {
        $('#EditedDescription').val($('#EditedDescriptionText').val());
        //this.returned = true;
        // $('#EditedDescriptionPrompt').dialog('close');
        //$(this.curr).click(function(){return true;});
        //$(this.curr).click();
        //eval($(this.curr).attr.('href'));
    },
    edit: function (el) {
        if (this.inuse && !this.returned) return false;
        if (!this.inuse) {
            this.curr = el;
            this.inuse = true;
            var content = $(el).next('span.description').html();
            $('#EditedDescriptionText').val(content);
            $('#EditedDescriptionPrompt').dialog('open');
            $('#EditedDescriptionPrompt_Saver').attr('href', $(el).attr('href'));
            return false;
        }
        return true;
        //var re = prompt("Opis:", content);
        //if (re === null) return false;
        //$('#EditedDescription').val(re);
        //return true;
    },
    init: function () {
        $('#EditedDescriptionPrompt').dialog({
            autoOpen: false,
            modal: true,
            height: 125,
            minHeight: 125,
            title: 'Zmiana opisu obrazka',
            close: function (event, ui) {
                ImageDescriptionsEditor.cancel();
            }
        });


        $('#EditedDescriptionPrompt_Saver').hover(
					function () { $(this).addClass('ui-state-hover'); },
					function () { $(this).removeClass('ui-state-hover'); }
				);

        $('#EditedDescriptionPrompt_Saver').click(function () {
            ImageDescriptionsEditor.save();
            return true;
        });

        $('#EditedDescriptionPrompt_Canceler').click(function () {
            $('#EditedDescriptionPrompt').dialog('close');
            return false;
        });


        //$('#EditedDescriptionPrompt_Saver').button();

    }
}