var AjaxRequest = {

	goIoBind: 	function(url,id){
					dojo.byId("loading").style.display="";
					this.doApplicationStateBind(url, "nav", "container", id);
					dojo.byId("loading").style.display="none";
				},

	doApplicationStateBind: 	function(url, navigationDivId, containerDivId, bookmarkValue){
    								dojo.io.bind({
										// Standard dojo.io.bind parameter
										url: url,

										//Standard dojo.io.bind parameter.
										mimetype: "text/html",

										// Standard dojo.io.bind parameter: if this is a value that evaluates
										// to true, then the page URL will change (by adding a fragment identifier
										// to the URL)
										changeUrl: bookmarkValue,

										// Data for use once we have data for an ApplicationState object
										navigationDivId: navigationDivId,
										containerDivId: containerDivId,

										// A holder for the application state object.
										// It will be created once we have a response from the bind request.
										appState: null,

										// Standard dojo.io.bind parameter. The ioRequest object is returned
										// to the load function as the fourth parameter. The ioRequest object
										// is the object we are creating and passing to this dojo.io.bind() call.

										back: function(){
                                            this.appState.back();
										},

										forward: function(){
                                            this.appState.forward();
										},

									    handle: function(type, data, evt){
									        if (type == "load"){
												var navi = AjaxRequest.splitData(data, "Navigation");
                                                var cont = AjaxRequest.splitData(data, "Logic");
                                                evt.appState = new ApplicationState("nav", "container", navi, cont);
												evt.appState.showStateData();
									        }
										}
									});
   								},

	splitData: 	function(EntireString, id){
			var strStart = "START" + id ;
			var strStop = "STOP" + id ;
			return EntireString.substring(EntireString.indexOf(strStart) + strStart.length, EntireString.indexOf(strStop));
		}
	}


