/* ----------------------------------------------------------------------------------------------------

Code source appartenant à Wixblog.com
Toutes reproductions totales ou partielles est interdite.

Code source déposé chez la SCAM

Auteur: Wixblog.com
Date: Janvier 2007
Version: 1.1

---------------------------------------------------------------------------------------------------------- */

function historique ()
{

	this._hash = ""; 
	this._to = 400; 
	this._en = '';
}

/**
  * Rajout : met à jour le Hash courrant
  */
historique.prototype.majHashCourant = function(h) {
	 this._hash=h;
 }

  
/**
 * go to the specified page - override this function to handle specific actions
 * @param h		hash (#)
 */
historique.prototype.go = function (h)
{
	//  Cas de la page d'accueil :
	if (h=="Tous") {
		showPage("0");
		return;
	}
	
		// /Page/".recode(stripslashes($categorie))."/".$cat."/".$courant;

	
	//  les autres cas, syntaxe : #id-page/action-description
	var wix = h.split('/');
		
	if (!wix.length) return;
	
		page=wix[1].toLowerCase();
			
		switch (page) {
			case "page":
				showNextPage(wix[3], wix[4]);	
			break;
			case "article": 		
				showPost(wix[3]);
			break;
		}
		
	return;
}

/**
 * history initialization
 * @param name		hame of history object
 */
historique.prototype.init = function (name)
{
	this._en = name;

	this.handleHist ();
	window.setInterval(this._en + ".handleHist()", this._to);

	return true;
}

/**
 * handle history (ontimer function)
 */
historique.prototype.handleHist =  function ()
{
	if ( window.location.hash != this._hash )
	{		
		this._hash = window.location.hash;
		var h = this._hash.substr(1);			
		if (h.length) this.go (h);
	}
	return true;
}

/**
 * record history
 * @param h	hash
 */
historique.prototype.makeHist = function (h)
{
	if (h.charAt(0) != '#') h = '#' + h;
	
	if (window.location.hash == h) return;

		window.location.hash = h;
		this._hash = window.location.hash;


	return true;
}