var LIFEWAY = {};

LIFEWAY.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=LIFEWAY;

        for (j=(d[0] == "LIFEWAY") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }
    return o;
};

LIFEWAY.initNamespaces = function() {
    this.namespace("worship.worshipplanlist", "common", "dialog", "medialibrary", "worship.previewplayer", "mediaplayer", "worshipplan", "songmapper", "admin");
};

LIFEWAY.initNamespaces();

/*
  If this page is including prototype.js for Ajax functionality 
  (Ajax.Request, Ajax.Updater, or Ajax.PeriodicalUpdater) we're
  going to register a global Ajax.Responder that will handle
  any responses that indicate that the user's session has 
  timed-out (status code = 403).
*/
if (typeof Ajax != "undefined" && typeof Ajax.Responders != "undefined") {
	Ajax.Responders.register({
	  onComplete: function(request) {
	  	if(403 == request.transport.status) {
	      alert("Due to inactivity your session has expired. Please login to proceed.");
	      location.href = "/home/logonForm?url=/home/index";
	    }
	  }
	});
}

function sendAjaxRequest(url, httpVerb, asynch, params, successMethod, failureMethod) {
	var myAjax = new Ajax.Request(url, 
		{method: httpVerb, 
		asynchronous: asynch, 
		parameters: params, 
		onFailure: failureMethod, 
		onSuccess: successMethod });
}

function getAjaxProcessor(ajp_page) {
	var ajp = new AjaxPages();
    ajp.load(ajp_page);
	return ajp.getProcessor();	    
}

function ajaxFailure(oReq){
	LIFEWAY.common.displayAlertDialog(oReq.responseText);
}