function ArticleListViewUpdated() {
	doPostBack('', '');
}

function ArticleListViewOnInit()
{
    try
	{
	    var data = this.GetContent().split("|");
	    if (data != null && data.length >= 5 && data[4].toLowerCase() == "true")
	        AddFooter(this.GetControlObject().id);

	    var controlID = this.GetControlID();

	    if (data != null && data.length >= 6 && data[5].toLowerCase() == "true") {
	        ALWFilter(0);
	    }

    }
	catch(e)
	{
	}
}

function ALWFilter(categoryID) {
    
    var link = $(".ALWHeaderLinks a[selectedCategoryID^=ALWCategory]").first();
    if (link.attr("selectedCategoryID")) {
        var categoryID = parseInt(link.attr("selectedCategoryID").replace("ALWCategory", ""));
        link.removeAttr("selectedCategoryID");
    }

    $(".ALWHeaderLinks a[categoryID=ALWCategory" + categoryID + "]").parent().parent().find("a").removeClass("ALWSelected");
    $(".ALWHeaderLinks a[categoryID=ALWCategory" + categoryID + "]").addClass("ALWSelected");

    if (categoryID == 0) {
        //Hide onlineBoxes
        categories = $("div.ALWOnlineBoxes div.divBox");
        categories.removeClass("ALWVisible");

        //Show all boxes
        var categories = $("div.ALWBoxes div.divBox");
        categories.addClass("ALWVisible");
    }
    else if (categoryID == -1) {
        //Hide all boxes
        var categories = $("div.ALWBoxes div.divBox");
        categories.removeClass("ALWVisible");

        //Show online boxes
        categories = $("div.ALWOnlineBoxes div.divBox");
        categories.addClass("ALWVisible");
    }
    else {
        //Hide onlineBoxes
        categories = $("div.ALWOnlineBoxes div.divBox");
        categories.removeClass("ALWVisible");
        
        //Hide all divs and show only the ones with the supplied categoryID
        var categories = $("div.ALWBoxes div.divBox[categoryID=ALWCategory" + categoryID + "]");
        categories.siblings().removeClass("ALWVisible");
        categories.addClass("ALWVisible");
    }

    UpdateFooters();
    try {
        setTimeout(backgroundFunction(), 1050);
    }
    catch (ex) { }
    
}

function ArticleListContextMenu(contentType) {
	if (contentType == "EditDesign")
	    return CONTROLCONTEXTMENU_ENABLEDISABLE | CONTROLCONTEXTMENU_EDIT | CONTROLCONTEXTMENU_PROPERTIES | CONTROLCONTEXTMENU_CLEAR | CONTROLCONTEXTMENU_DEPTHORDERING | CONTROLCONTEXTMENU_DELETERESTORE;
        if (contentType == "EditContent")
		return CONTROLCONTEXTMENU_EDIT | CONTROLCONTEXTMENU_CLEAR | CONTROLCONTEXTMENU_DELETERESTORE;
	return 0;
}
function InitializeArticleListViewControl(controlID, contentType) {
    var control = eval("_" + controlID);

    control.OnInitialized = ArticleListViewOnInit;

	if (contentType != "View") {
		control.GetEditorControlID = function() { return "ArticleListViewEditor"; }
		control.ContentUpdated = ArticleListViewUpdated;
		control.OnContextMenu = ArticleListContextMenu;
	}
}
