
/*
function SetNotify(AjaxUrl, CurrentSwitchVal,Method, Identifier, NotifyText , UnNotifyText) {
var Sender = document.getElementById('SetNotifyAll');
	if (Sender) {
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? CurrentSwitchVal : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = (FlipSwitch == 0 ? NotifyText : UnNotifyText);
		dm.RequestCompleteEvent = NotifyComplete;
		dm.RequestFailedEvent = NotifyFailed;
		dm.LoadData(AjaxUrl+"?Type=Notify&Switch="+FlipSwitch+"&SelectID="+Identifier+"&Method="+Method);
	}
}
function NotifyComplete(Request) {
	setTimeout("ApplyNotify('SetNotifyAll', 'Complete', '"+this.Param+"');", 400);
}

function ApplyNotify(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}
}
function NotifyFailed(Request) {
	var Button = document.getElementById('SetNotifyAll');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}

function SetNotifyCategory(AjaxUrl, CurrentSwitchVal,Method, Identifier, NotifyText , UnNotifyText) {
var Sender = document.getElementById('SetNotifyCategory');
	if (Sender) {
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? CurrentSwitchVal : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = (FlipSwitch == 0 ? NotifyText : UnNotifyText);
		dm.RequestCompleteEvent = NotifyCompleteCategory;
		dm.RequestFailedEvent = NotifyFailedCategory;
		dm.LoadData(AjaxUrl+"?Type=Notify&Switch="+FlipSwitch+"&SelectID="+Identifier+"&Method="+Method);
	}
}
function NotifyCompleteCategory(Request) {
	setTimeout("ApplyNotify('SetNotifyCategory', 'Complete', '"+this.Param+"');", 400);
}

function ApplyNotifyCategory(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}	
}
function NotifyFailedCategory(Request) {
	var Button = document.getElementById('SetNotifyCategory');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}


function SetNotifyDiscussion(AjaxUrl, CurrentSwitchVal,Method, Identifier, NotifyText , UnNotifyText) {
var Sender = document.getElementById('SetNotifyDiscussion');
	if (Sender) {
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? CurrentSwitchVal : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = (FlipSwitch == 0 ? NotifyText : UnNotifyText);
		dm.RequestCompleteEvent = NotifyCompleteDiscussion;
		dm.RequestFailedEvent = NotifyFailedDiscussion;
		dm.LoadData(AjaxUrl+"?Type=Notify&Switch="+FlipSwitch+"&SelectID="+Identifier+"&Method="+Method);
	}
}
function NotifyCompleteDiscussion(Request) {
	setTimeout("ApplyNotify('SetNotifyDiscussion', 'Complete', '"+this.Param+"');", 400);
}

function ApplyNotifyDiscussion(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}	
}
function NotifyFailedDiscussion(Request) {
	var Button = document.getElementById('SetNotifyDiscussion');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}


function SetNotifyDelete(AjaxUrl, NotifyText , UnNotifyText) {
var Sender = document.getElementById('SetNotifyDelete');
	if (Sender) {
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? 0 : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = (FlipSwitch == 0 ? NotifyText : UnNotifyText);
		dm.RequestCompleteEvent = NotifyCompleteDelete;
		dm.RequestFailedEvent = NotifyFailedDelete;
		dm.LoadData(AjaxUrl+"?Type=DeleteAll");
	}
}
function NotifyCompleteDelete(Request) {
	setTimeout("ApplyNotifyDelete('SetNotifyDelete', 'Complete', '"+this.Param+"');", 400);
}

function ApplyNotifyDelete(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}	
}
function NotifyFailedDelete(Request) {
	var Button = document.getElementById('SetNotifyDelete');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}

function SetNotifyAdminDelete(AjaxUrl,UserID, NotifyText , UnNotifyText) {
var Sender = document.getElementById('SetNotifyAdminDelete');
	if (Sender) {
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? 0 : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = (FlipSwitch == 0 ? NotifyText : UnNotifyText);
		dm.RequestCompleteEvent = NotifyCompleteAdminDelete;
		dm.RequestFailedEvent = NotifyFailedAdminDelete;
		dm.LoadData(AjaxUrl+"?SelectID="+UserID+"&Type=AdminDeleteAll");
	}
}
function NotifyCompleteAdminDelete(Request) {
	setTimeout("ApplyNotifyDelete('SetNotifyAdminDelete', 'Complete', '"+this.Param+"');", 400);
}

function ApplyNotifyAdminDelete(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}	
}
function NotifyFailedAdminDelete(Request) {
	var Button = document.getElementById('SetNotifyAdminDelete');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}



function DeleteNotify(AjaxUrl, Method, NotifyID) {

var Sender = document.getElementById('NotifyCategory'+NotifyID);
	if (Sender) {
		Sender.style.display = 'none';
		Sender.className = 'Progress';
		var Switch = Sender.name == '' ? 1 : Sender.name;
		var FlipSwitch = Switch == 1 ? 0 : 1;
		Sender.name = FlipSwitch;
		var dm = new DataManager();
		dm.Param = ('unset');
		dm.RequestCompleteEvent = DeleteNotifyComplete;
		dm.RequestFailedEvent = DeleteNotifyFailed();
		if(dm.LoadData(AjaxUrl+"?Type=Delete&NotifyID="+NotifyID)) alert('1');
	}
}
function DeleteNotifyComplete(Request) {
	setTimeout("DeleteApplyNotify('DeleteNotify', 'Complete', '"+this.Param+"');", 400);
}

function DeleteApplyNotify(Element, ClassName, Text) {
	var Button = document.getElementById(Element);
	if (Button) {
		Button.className = ClassName;
		Button.innerHTML = Text;
	}
}
function DeleteNotifyFailed(Request) {
	var Button = document.getElementById('NotifyCategory');
	if (Button) {
		Button.className = 'Complete';
		alert("Failed: ("+Request.status+") "+Request.statusText);
	}
}
*/

/* New Functions */
/*
    Type=CATEGORY,DISCUSSION,ALL;
    ElementID=x (DiscussionID,CategoryID,0)
    Value=1/0 (1=set, 0=unset)
                                  */
function SetNotify(Type,ElementID,Value,Elem,Class,NewText)
{
    var ajax = new Ajax.Request('extensions/Notify/ajax.php',
    {
        parameters:'PostBackAction=ChangeNotify&Type='+Type+'&ElementID='+ElementID+'&Value='+Value,
        onSuccess: function(r)
        {
            Element.removeClassName(Elem,Class);
         }
    });
    return true;
}

function NotifyCat(CategoryID)
{
    Element.addClassName('NotifyCatCont_'+CategoryID,'PreferenceProgress');
    if ($('NotifyCat_'+CategoryID).checked == true) Value = 1;
    else Value = 0;
    SetNotify('CATEGORY',CategoryID,Value,'NotifyCatCont_'+CategoryID,'PreferenceProgress','');
}
function NotifyDiscussion(DiscussionID)
{
    Element.addClassName('NotifyDiscussionCont_'+DiscussionID,'PreferenceProgress');
    if ($('NotifyDiscussion_'+DiscussionID).checked == true) Value = 1;
    else Value = 0;
    SetNotify('DISCUSSION',DiscussionID,Value,'NotifyDiscussionCont_'+DiscussionID,'PreferenceProgress','');
}
function PNotifyAll(SetText,UnSetText)
{
    Element.addClassName('SetNotifyAll','Progress');
    if ($('SetNotifyAll').innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotify('ALL',0,Value,'SetNotifyAll','Progress',NewText);
}
function PNotifyCategory(CategoryID,SetText,UnSetText)
{
    Element.addClassName('SetNotifyCategory_'+CategoryID,'Progress');
    if ($('SetNotifyCategory_'+CategoryID).innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotify('CATEGORY',CategoryID,Value,'SetNotifyCategory_'+CategoryID,'Progress',NewText);
}
function PNotifyDiscussion(DiscussionID,SetText,UnSetText)
{
    Element.addClassName('SetNotifyDiscussion_'+DiscussionID,'Progress');
    if ($('SetNotifyDiscussion_'+DiscussionID).innerHTML == SetText)
    {
        Value = 1;
        NewText = UnSetText;
    }
    else
    {
        Value = 0;
        NewText = SetText;
    }
    SetNotify('DISCUSSION',DiscussionID,Value,'SetNotifyDiscussion_'+DiscussionID,'Progress',NewText);
}

function NotifyAll()
{
    Element.addClassName('NotifyAllCont','PreferenceProgress');
    if ($('NotifyAllField').checked == true) Value = 1;
    else Value = 0;
    SetNotify('ALL',0,Value,'NotifyAllCont','PreferenceProgress','');
}

function NotifyOwn()
{
    Element.addClassName('NotifyOwnCont','PreferenceProgress');
    if ($('NotifyOwnField').checked == true) Value = 1;
    else Value = 0;
    SetNotify('OWN',0,Value,'NotifyOwnCont','PreferenceProgress','');
}