
function o(id){
	try{
		return document.getElementById(id);
	}
	catch(err){
		return null;
	}
}

function trim(myString){
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
} 
	
function createXHR(){ 
	var request = false;
	try {
		request = new ActiveXObject('Msxml2.XMLHTTP');
	}
       catch (err2) {
		try {
       		request = new ActiveXObject('Microsoft.XMLHTTP');
	       }
       	catch (err3) {
			try {
				request = new XMLHttpRequest();
		    	}
		    	catch (err1) {
				request = false;
		    	}
	       }
       }
	return request;
}


function postAndLoad( filename, args ){
	var xhr = createXHR();
	if ( xhr ){
		xhr.open("POST", filename, false);		
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send(args);
		return xhr.responseText;
	} else {
		return false;
	}
}

function loadCaroussel(){
 	 //$(document).ready(
        //     function (){
                    $("#pikame").PikaChoose({showTooltips:true, showCaption:false, transition:[0], text: {previous: "", next: "" }});

                    $("#pikame").jcarousel({scroll:4,
                                            vertical:true,
                                           initCallback: function(carousel) 
                        {
                            $(carousel.list).find('img').click(function() {
                                //console.log($(this).parents('.jcarousel-item').attr('jcarouselindex'));
                                carousel.scroll(parseInt($(this).parents('.jcarousel-item').attr('jcarouselindex')));
                            });
                        }
                    });
       //       });
}

function loadElement( id ){
	o("listeImage").innerHTML   = postAndLoad("module/diaporama/listeImage.php","id="+id);
	o("ficheArtiste").innerHTML = postAndLoad("module/diaporama/ficheArtiste.php","id="+id);
	loadCaroussel();
}

function loadCategorie( id ){
	o("listeElement").innerHTML = postAndLoad("module/diaporama/listeCategorie.php","id="+id);
}

function loadFicheArtiste( id ){
	o("ficheArtiste").innerHTML = postAndLoad("module/diaporama/ficheArtiste.php","id="+id);
}
