var siteUrl = "http://www.myclubbingstore.com/";

function changeAnchor(anchor) {
	//alert('changeAnchor');
	// Si l'url possède déjà une ancre
	if (window.location.href.match(new RegExp('#.*$')))
	{
		window.location = window.location.href.replace(
			new RegExp('#.*$'),
			'#' + anchor
		);
	}
	// Sinon, il suffit de l'ajouter à la fin
	else
	{
		window.location = window.location.href + "#" + anchor
	}
	return window.location;
}

//Lors de l'arrivée sur la page, si l'url a une ancre, on la supprime !
function deleteAnchor() {
	// Si l'url possède une ancre
	if (window.location.href.match(new RegExp('#.*$')))
	{
		var startParams = getAnchor().split('#');
		var oldUrl = new Array(25);
		oldUrl = startParams[0].split('/');
		//adresse du type http://127.0.0.1/artiste/sunday#artiste/calinda
		if(oldUrl.length > 3){
			newUrl = siteUrl.concat(startParams[1]);
			window.location = window.location.href.replace(new RegExp('.*'), newUrl );
		}
		//adresse du type http://127.0.0.1/#artiste/calinda
		else{
			window.location = window.location.href.replace(new RegExp('#.*$'), startParams[1]);
		}
	}
	//document.getElementById("left").style.visibility  = 'visible';	
}

function getAnchor()
{
	return window.location.href;
}


function ancreLoad () {
	// Je récupère l'ancre et la splite sur le '#' car
	// j'ai décidé de séparer mes paramètres par des '
	
	var startParams = getAnchor().split('#');
	var ancre = startParams[1];
	var ancre0 = startParams[0];	
		
	if(startParams[1]!=undefined) 
	{
		
		
		var param = ancre.split("/");
		//alert(param[0]);
		var paramPage = param[1].split(",");
		
		// Je teste le premier paramètre
		
		switch (param[0])
		{
			case 'artiste': goto_fiche_artiste(param[1]); break;
			case 'playlist': goto_fiche_playlist(param[1]); break;
			case 'actualite': goto_detail_actualite(param[1]); break;
			case 'label': goto_fiche_label(paramPage[0], paramPage[1]); break;
			case 'morceau': goto_fiche_morceau(param[1]); break;
			case 'rubrique_aide.html': goto_aide(); break;
			case 'nouveautes': goto_nouveaute(); break;
			case 'actualite.html': actualite(); break;
			case 'artistes': goto_artistes(); break;
			case 'genres': goto_genres(paramPage[0], paramPage[1]); break;
			case 'compilation': goto_compilation(paramPage[0], paramPage[1]); break;				
			case 'album': goto_album(paramPage[0], paramPage[1]); break;				
			case 'biographie': goto_biographie(param[1]); break;				
			case 'jaquette': goto_jaquette(param[1]); break;				
			case 'remixes': goto_remixes(param[1]); break;				
			case 'prevenir_amis': goto_prevenir_amis(param[1]); break;				
			case 'quisommesnous.html': goto_quisommesnous(); break;				
			case 'compilations.html': goto_compilations(); break;				
			case 'albums.html': goto_albums(); break;				
			case 'confidentialite.html': goto_conditions(); break;				
			case 'labels.html': goto_labels(); break;				
			case 'conditions.html': goto_conditions(); break;				
			case 'partenaires.html': goto_partenaires(1); break;				
			case 'partenaires': goto_partenaires(param[1]); break;				
			case 'search': searche(paramPage[0], paramPage[1]); break;				
			case 'charts.html': goto_charts(); break;				
			case 'charts-details.html': goto_charts_details(); break;				
			case 'recapitulatif_commande.html': goto_recapitulatif_commande(); break;				
			case 'panier.html': goto_panier(); break;				
			default:goto_accueil();break;
		}
	}	
	else {
		//alert("ancreLoad - else");
		var param = ancre0.split("/");
		
		// Je teste le premier paramètre
		switch (param[3])
		{
			case 'artiste': goto_fiche_artiste(param[4]); break;
			case 'label': goto_fiche_label(param[4]); break;
			case 'morceau': goto_fiche_morceau(param[4]); break;
			case 'prevenir_amis': goto_prevenir_amis(param[4]); break;				
			case 'rubrique_aide.html': goto_aide(); break;
			case 'nouveautes': goto_nouveaute(); break;
			case 'actualite.html': actualite(); break;
			case 'artistes': goto_artistes(); break;
			case 'genres': goto_genres("house", 4); break;
			case 'compilation': goto_compilation(); break;				
			case 'album': goto_album(param[4]); break;				
			case 'biographie': goto_biographie(param[4]); break;				
			case 'remixes': goto_remixes(param[4]); break;				
			case 'quisommesnous.html': goto_quisommesnous(); break;				
			case 'confidentialite.html': goto_conditions(); break;				
			case 'conditions.html': goto_conditions(); break;				
			case 'panier.html': goto_panier(); break;
			case 'charts.html': goto_charts(); break;					
			default:goto_accueil();break;
		}
	}
}