// ------------------------------------------------------------------------------------------------------------------------
// 	JAVASCRIPT.JS
// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Dachowski Fryderyk
//	Date: 11.09.09
//	Lieu: Ste Croix
//	But: Page contenant toutes les commandes et fonctions javascript personnelles utilisées dans le site 
// ------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Dachowski Fryderyk
//	Date: 11.09.09
//	Lieu: Ste Croix
//	Paramètres: -
//	Retour: Retourne la chaîne en ayant supprimé les espaces en début et fin de chaine
//	But: Supprime les espaces en début et fin d'une chaine de caractères qui sont redondants et inutiles
// ------------------------------------------------------------------------------------------------------------------------
String.prototype.trim = function () {
	// On remplace zero ou plusieurs (*) chaînes de caractères considérées comme des espaces (\s) au début (^) ou (|) à la fin ($) avec rien ("")
   return this.replace(/^\s*|\s*$/,"");
}


// ------------------------------------------------------------------------------------------------------------------------
//	envoieRequete()
// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Dachowski Fryderyk
//	Date: 11.09.09
//	Lieu: Ste Croix
//	Paramètres: id = Id de l'élément dans lequel la page va etre incluse
//	 		url = Url de la page a integrer
//	But:  Integre du code html ou php dans une div
// ------------------------------------------------------------------------------------------------------------------------
function envoieRequete(url,id)
{
	var xhr_object = null;
	var position = id;
	var contenu_actuel = document.getElementById(position).innerHTML;
	
	if(window.XMLHttpRequest) 
		xhr_object = new XMLHttpRequest();
	else
	if (window.ActiveXObject) 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");

	// On ouvre la requete vers la page désirée
	xhr_object.open("GET", url, true);
	xhr_object.onreadystatechange = function()
	{
		if ( xhr_object.readyState == 4 )
		{
			document.getElementById(position).style.display = "none";
			// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
			Effect.Appear(position, {duration:1});
			if(contenu_actuel != xhr_object.responseText)
				document.getElementById(position).innerHTML = xhr_object.responseText;
		}
	}
	// dans le cas du get
	xhr_object.send(null);
}

// ------------------------------------------------------------------------------------------------------------------------
//	getPageSize()
// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Framework  LightBox
//	Date: 29.06.09
//	Lieu: Domicile
//	Paramètres: -
//	But:  Récupère la hauteur et la largeur courante de la page 
// ------------------------------------------------------------------------------------------------------------------------
function getPageSize()
{
	 var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

// ------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------  Artistes Show/Hide Scripts -----------------------------------------
// ------------------------------------------------------------------------------------------------------------------------

//	ShowBio()
// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Dachowski Fryderyk
//	Date: 11.09.09
//	Lieu: Ste-Croix
//	Paramètres: -
//	But:  Show the selected artist's bio
// ------------------------------------------------------------------------------------------------------------------------
function ShowBio(strIdBio,strShow,strHide)
{
	Effect.SlideDown(strIdBio, {duration:0.5}); 
	$(strShow).fade({ duration: 0.1, from: 1, to: 0 }); 
	setTimeout('$(\''+strHide+'\').appear({ duration: 0.3, from: 0, to: 1 })',550);
}
// ------------------------------------------------------------------------------------------------------------------------
//	HideBio()
// ------------------------------------------------------------------------------------------------------------------------
//	Auteur: Dachowski Fryderyk
//	Date: 11.09.09
//	Lieu: Ste-Croix
//	Paramètres: -
//	But:  Hide the selected artist's bio
// ------------------------------------------------------------------------------------------------------------------------
function HideBio(strIdBio,strShow,strHide)
{
	Effect.SlideUp(strIdBio, {duration:0.5}); 
	$(strHide).fade({ duration: 0.1, from: 1, to: 0 }); 
	setTimeout('$(\''+strShow+'\').appear({ duration: 0.3, from: 0, to: 1 })',550);
}

