/**
 * @author Roger FREBAULT
 */
		dojo.require("dojo.back");
    dojo.require("dijit.layout.ContentPane");
    dojo.require("dijit.layout.LayoutContainer");

		ApplicationState = function(url, title, outputDivId, bookmarkValue){
			this.url = url;
			this.title = title
			if (outputDivId != "")     {
				_self = this;
				var dfd = dojo.xhrGet( {
				          url: url,
				          handleAs: "text",
									sync : true,
				          load: function(data, ioArgs) {
										_self.stateData = data;
									},
				          error: function(response, ioArgs) { 
				            return response; 
				          }
				});
			} else {
				this.stateData = "";
			}
			this.outputDivId = outputDivId;
			this.changeUrl = bookmarkValue || false;
		}
	
		dojo.extend(ApplicationState, {
			back: function(){
				this.showStateData();
			},
			forward: function(){
				this.showStateData();
			},
			showStateData: function(){
				if (this.stateData) {
					dojo.byId(this.outputDivId).innerHTML = this.stateData;
					// xiti(this.title, this.url);
				}
			}
		});
		
		dojo.addOnLoad(function(){
			
			dojo.back.setInitialState(null);
		});

function appel(url, title, id_rubrique) {

	var appState = new ApplicationState(url, title, "content", url);
	appState.showStateData();
console.log(appState.showStateData());
	dojo.back.addToHistory(appState);

	if (id_rubrique) {
		dojo.forEach(dojo.query('.menuOn'), function(node) {
			dojo.removeClass(node, 'menuOn');
			dojo.addClass(node, 'menuOff');
		});
		dojo.removeClass(dojo.byId('rub'+id_rubrique), 'menuOff');
		dojo.addClass(dojo.byId('rub'+id_rubrique), 'menuOn');
		if (id_rubrique == 11) {
			dojo.addClass(dojo.byId("centerClient"), "noScroll");
		} else {
			dojo.removeClass(dojo.byId("centerClient"), "noScroll");
		}
	}
}

function xiti(title, url) {

	var xiti = dojo.byId("xiti");
  removeAllChildren(xiti);
	
	_aA = document.createElement("a");
	_aA.href = "http://www.xiti.com/xiti.asp?s=354156";
	_aA.title = "WebAnalytics";
	xiti.appendChild(_aA);
	
	Xt_param = 's=354156&p='+title;
	try {Xt_r = top.document.referrer;}
	catch(e) {Xt_r = document.referrer; }
	Xt_h = new Date();
	Xt_i = '<img width="80" height="15" border="0" alt="" ';
	Xt_i += 'src="http://logv145.xiti.com/rcg.xiti?'+Xt_param;
	Xt_i += '&hl='+Xt_h.getHours()+'x'+Xt_h.getMinutes()+'x'+Xt_h.getSeconds();
	if(parseFloat(navigator.appVersion)>=4)
	{Xt_s=screen;Xt_i+='&r='+Xt_s.width+'x'+Xt_s.height+'x'+Xt_s.pixelDepth+'x'+Xt_s.colorDepth;}
	_aA.innerHTML = Xt_i+'&ref='+Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$')+'" title="Internet Audience">';

}
function removeNode(node) {
    utils.removeAllChildren(node); 
    node.parentNode.removeChild(node);
} 
function removeAllChildren(node) {
    while (node.firstChild) { 
      node.removeChild(node.firstChild);
    };
} 
function onChangeRecherche(champ) {

	appel('spip.php?page=recherche&recherche='+champ.value, 'Recherche',-1);

}
