/*
    Type=CATEGORY,DISCUSSION,ALL;
    ElementID=x (DiscussionID,CategoryID,0)
    Value=1/0 (1=set, 0=unset)
                                  */
function SetNotifi(Type,ElementID,Value,Elem,Class,NewText)
{
    var Vanilla = new PathFinder();
    var ajax = new Ajax.Request(Vanilla.webRoot = Vanilla.getRootPath('script', 'src', 'js/global.js')+'extensions/Notifi/ajax.php',    {
        parameters:'PostBackAction=ChangeNotifi&Type='+Type+'&ElementID='+ElementID+'&Value='+Value,
        onSuccess: function(r)
        {
            Element.removeClassName(Elem,Class);
            if (NewText != '') Elem.innerHTML = NewText;
            $(Elem).innerHTML = NewText;
         }
    });
    return true;
}

function NotifiCat(CategoryID)
{
    Element.addClassName('NotifiCatCont_'+CategoryID,'PreferenceProgress');
    if ($('NotifiCat_'+CategoryID).checked == true) Value = 1;
    else Value = 0;
    SetNotifi('CATEGORY',CategoryID,Value,'NotifiCatCont_'+CategoryID,'PreferenceProgress','');
}
function NotifiDiscussion(DiscussionID)
{
    Element.addClassName('NotifiDiscussionCont_'+DiscussionID,'PreferenceProgress');
    if ($('NotifiDiscussion_'+DiscussionID).checked == true) Value = 1;
    else Value = 0;
    SetNotifi('DISCUSSION',DiscussionID,Value,'NotifiDiscussionCont_'+DiscussionID,'PreferenceProgress','');
}
function PNotifiAll(SetText,UnSetText)
{
    Element.addClassName('SetNotifiAll','Progress');
    if ($('SetNotifiAll').innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotifi('ALL',0,Value,'SetNotifiAll','Progress',NewText);
}
function PNotifiCategory(CategoryID,SetText,UnSetText)
{
    Element.addClassName('SetNotifiCategory_'+CategoryID,'Progress');
    if ($('SetNotifiCategory_'+CategoryID).innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotifi('CATEGORY',CategoryID,Value,'SetNotifiCategory_'+CategoryID,'Progress',NewText);
}
function PNotifiDiscussion(DiscussionID,SetText,UnSetText)
{
    Element.addClassName('SetNotifiDiscussion_'+DiscussionID,'Progress');
    if ($('SetNotifiDiscussion_'+DiscussionID).innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotifi('DISCUSSION',DiscussionID,Value,'SetNotifiDiscussion_'+DiscussionID,'Progress',NewText);
}

function NotifiAll()
{
    Element.addClassName('NotifiAllCont','PreferenceProgress');
    if ($('NotifiAllField').checked == true) Value = 1;
    else Value = 0;
    SetNotifi('ALL',0,Value,'NotifiAllCont','PreferenceProgress','');
}

function NotifiOwn()
{
    Element.addClassName('NotifiOwnCont','PreferenceProgress');
    if ($('NotifiOwnField').checked == true) Value = 1;
    else Value = 0;
    SetNotifi('OWN',0,Value,'NotifiOwnCont','PreferenceProgress','');
}