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);
	}
}
