/**
 * @author shgraph (ajaxUI team)
 */

(function(className) {

	SPS[className] = $Class({
		_o : null,

		$init : function(sEl, arg) {

			var oEl = $(sEl);

			this._o = {
				setActive : $$('.setActive', oEl)[0]
			};
			
			this._bindEvents(arg);
			
		},
		
		_bindEvents : function (arg) {
		
			var o = this._o;
			var sUrl = new String();
			var sSwitchString = new String();
		
			if( o.setActive ){

				$Fn(function(oEvent) {

					if (!o.setActive) return;
					
					if (o.setActive.innerHTML.match('Private')){
						sSwitchString = "Set 'My Activity' to Public";
						sUrl = arg[0];
					} else {
						sSwitchString = "Set 'My Activity' to Private";
						sUrl = arg[1];
					}

					var oAjax = $Ajax( sUrl, {
						onload : function(res) {
							o.setActive.innerHTML = sSwitchString;
						}
					});

					oAjax.request({});					
					oEvent.stop();

				}).attach(o.setActive, 'click');
			
			}
		}
	
	});

})('cm_title01');
