// Custom utility functions

function toTitleCase(str) {
    return str.substr(0,1).toUpperCase() + str.substr(1).toLowerCase();
}      

function formatTitle(title) {
    return (title != '/' ? ' / ' + toTitleCase(title.substr(1, title.length - 2).replace(/\//g, ' / ')) : '');
}

// Custom SWFAddress and Ajax handling
function handleChange(event) {
	var tabUrl = event.path;
	tabUrlTab =  new Array();
    tabUrlTab = tabUrl.split('/');
	
	switch(tabUrlTab[1])
	{
		case "accueil":
						doAjax('accueil');
						break;
		case "catalogue":
						doAjax('catalogue');
						break;
		case "artistes":
						doAjax('artistes')
						break;
		case "artiste":
						doAjax('artiste', tabUrlTab[2])
						break;
		case "contact":
						doContact();
						break;
		default:
						doAjax('accueil');
						break;
	}
}

SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleChange);
