	Event.observe(window, 'load', function() {
		changeFont();
	});
	

/********************************************************************************************************************************************************************************/
/*	CUFON	*/
/********************************************************************************************************************************************************************************/

	changeFont = function() {
		Cufon.replace( '.Haetten', { fontFamily: 'Haetten' } );
	}

/********************************************************************************************************************************************************************************/
/*	MAD SHOT	*/
/********************************************************************************************************************************************************************************/

	function loadShot( myID )
	{
		$('big-image-madshot').innerHTML = '<table style="width: 100%; height: 100%; background: #ff0000;"><tr><td class="vam tac"><img src="medias/img/load-madshot.gif" alt="Chargement ..." /><br />Chargement en cours ...</td></tr></table>' ;
		var options = { 
						method: "post" ,
						postBody: 'id=' + myID , 
						onSuccess: function ( xhr )
						{
							var xml 	= xhr.responseXML ;
							var video 	= xm(xml,"link-video") ;
							var flash 	= '' ;
							var domain 	= '' ;
							
							if ( video == 'null' )
							{
								$('big-image-madshot').innerHTML = '<table style="height: 100%;"><tr><td class="tac vam"><a href="' + xm(xml,"lien") + '" id="link-madshot" title="#titre"><img id="img-madshot" src="1-620-386-0-contents_images/' + xm(xml,'image_principale') + '" alt="' + xm(xml,"titre") + '" /></a></td></tr></table>' ;
							}
							else
							{
								flash += '<div style="width: 620px; height: 324px; background: url(1-620-386-0-contents_images/' + xm(xml,'image_principale') + ') top left no-repeat;">' ;
								flash += '<a class="display" style="width: 620px; height: 324px; background: url(medias/img/bt-play.png) center center no-repeat;" href="' + xm(xml,'lien') + '?autoplay=1#player"></a>' ;
								flash += '</div>' ;
								
								$('big-image-madshot').innerHTML = flash ;
							}
							
							$('txt-madshot').innerHTML 	 	 = xm(xml,'corps') ;
							$('titre-madshot').innerHTML 	 = xm(xml,"titre")  ;
							$('stitre_1-madshot').innerHTML	 = xm(xml,"stitre_1") ;
							
							Cufon.refresh();
						}
					  } 

		var ajaxCall = new Ajax.Request( "madshot.php", options );
	}

	function loadNextShot( numero )
	{
		$('liste-madshot').innerHTML = '<table style="width:560px; height: 100%; background: #ff0000;"><tr><td class="vam tac"><img src="medias/img/load-madshot.gif" align="absmiddle" alt="Chargement ..." /> Chargement en cours ...</td></tr></table>' ;
		var options = { 
						method: "post" ,
						postBody: 'numero=' + numero , 
						onSuccess: function (xhr)
						{
							var prev = numero - 5 ;
							var next = numero + 5 ;
							
							var texte 	= '' ;
							var xml 	= xhr.responseXML ;
							var items 	= xml.getElementsByTagName("article") ;
							
							// Si aucun enregistrement n'est présent pour les 5 prochain madshot
							if ( xm( xml , 'countNext' ) == 0 )
							{
								// On désactive le bouton next
								$('bt-load-next').innerHTML = '<img src="medias/img/bt-madshot-right-off.png" />' ;
							}
							else
							{
								$('bt-load-next').innerHTML = '<a href="javascript:void(0);" onclick="loadNextShot(' + next + ');"><img src="medias/img/bt-madshot-right.gif" /></a>' ;
							}
							
							// Si on est au départ
							if ( numero == 0 )
							{
								// On désactive le bouton previous
								$('bt-load-prev').innerHTML = '<img src="medias/img/bt-madshot-left-off.png" />' ;
							}
							else
							{
								$('bt-load-prev').innerHTML = '<a href="javascript:void(0);" onclick="loadNextShot(' + prev + ');"><img src="medias/img/bt-madshot-left.gif" /></a>' ;
							}
							
							for ( i = 0; i < items.length; i++ )
							{
								texte += '<a href="javascript:void(0);" onclick="loadShot(' + xmI( xml , "id_art" , i ) + ');">' ;
								texte += '<img src="1-0-53-0-contents_images/' + xmI( xml , "image_principale" , i ) + '" alt="" /></a>' ;
							}
							
							$('liste-madshot').innerHTML = texte ;
						
						}
					  } 

		var ajaxCall = new Ajax.Request( "nextMadshot.php", options );
	}
	
	function xm( xmlFile , champ )
	{
		return xmlFile.getElementsByTagName( champ )[0].firstChild.data ;
	}
	
	function xmI( xmlFile , champ , i )
	{
		return xmlFile.getElementsByTagName( champ )[ i ].firstChild.data ;
	}


