
function remplirListBoxEmission(typeMedia, chaine, emission)
{

    var emissionByXHR;

	emissionByXHR = new httpRequest("/rdv_media/emissionsearch.aspx", "idTypeMedia=" + typeMedia + "&idChaine=" + chaine + "&idemission=" + emission + "&isEmission=1", "get");
		
	emissionByXHR.createRequestObject();
	emissionByXHR.sendPostReq();

	emissionByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (emissionByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
			eval(emissionByXHR.xmlhttp.responseText);
		}
	}
	
}


function remplirListChaine(typeMedia, chaine)
{

    var chaineByXHR;

	chaineByXHR = new httpRequest("/rdv_media/emissionsearch.aspx", "idTypeMedia=" + typeMedia + "&idChaine=" + chaine, "get");
		
	chaineByXHR.createRequestObject();
	chaineByXHR.sendPostReq();

	chaineByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (chaineByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
			eval(chaineByXHR.xmlhttp.responseText);			
			
		}
	}
	
}

function viderListeDeroulante(listeDeroulante)
{
	// arponnage de la liste déroulante
	mySelect = $('#' + listeDeroulante)[0]
	
	// on boucle sur toutes les options
	for (i=0; i <= mySelect.options.length;i++)
	{mySelect.options[i] = null;}
	
	// on met à jour la liste 
	refreshTitresChoisis();
	
	// si il y a des restes (bug bizarre mais bon.... utile ;))
	if (mySelect.options.length > 0)
	{viderListeDeroulante(listeDeroulante);}
}


/* ============================================================================
    Pour le bo (la nouvelle version de la newsletter 
    Modif by Tristan - 09/08/2010 : ajout paramPage (foliotage) 
============================================================================ */
function loadList(paramChoix, paramIdNews, paramPage)
{
    var listByXHR;
    
    var xhr_url = "/backOffice/Newsletter_Express/ajaxLoadBlocNews.aspx";
    
    var xhr_params = "rdbChoice=" + paramChoix + "&idNews=" + paramIdNews;
    
    if (paramPage && paramPage > 0) {
        xhr_params += "&page=" + paramPage;
    }

	listByXHR = new httpRequest(xhr_url, xhr_params, "get");
		
	listByXHR.createRequestObject();
	listByXHR.sendPostReq();

	listByXHR.xmlhttp.onreadystatechange = function ()
	{
		if (listByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
		    document.getElementById('content_list').innerHTML = listByXHR.xmlhttp.responseText;
		}
	}	
}


function loadListCol2(paramChoix, paramIdNews)
{

   var listByXHR;

	listByXHR = new httpRequest("/backOffice/Newsletter_Express/ajaxLoadBlocNews.aspx", "rdbChoice=" + paramChoix + "&idNews=" + paramIdNews, "get");
		
	listByXHR.createRequestObject();
	listByXHR.sendPostReq();

	listByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (listByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
		
		document.getElementById('content_list_col2').innerHTML = listByXHR.xmlhttp.responseText;
			
		}
	}	
}


/* ============================================================================
    Pour le bo (la nouvelle version de la newsletter 
    Modif by Tristan - 09/08/2010 : ajout paramPage (foliotage) 
============================================================================ */
function maj_elemtChecked(paramChoix, paramIdNews, paramIdElemt, paramChecked, paramPage)
{
    var xhr_url = "/backOffice/Newsletter_Express/ajaxLoadBlocNews.aspx";
    
    var xhr_params = "rdbChoice=" + paramChoix + "&idNews=" + paramIdNews + "&idElemt=" + paramIdElemt + "&checked=" + paramChecked;
    
    if (paramPage && paramPage > 1) {
        xhr_params += "&page=" + paramPage;
    }
    //alert('Trace xhr_params :\n' + xhr_params);

	listByXHR = new httpRequest(xhr_url, xhr_params, "get");
	
    //listByXHR = new httpRequest(xhr_url, xhr_params, "get");

	listByXHR.createRequestObject();
	listByXHR.sendPostReq();

	listByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (listByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
		
		document.getElementById('content_list').innerHTML = listByXHR.xmlhttp.responseText;
			
		}
	}	
}

function maj_elemtCheckedPopupCol2(paramChoix, paramIdNews, paramIdElemt, paramChecked)
{
    listByXHR = new httpRequest("/backOffice/Newsletter_Express/ajaxLoadBlocNews.aspx", "rdbChoice=" + paramChoix + "&idNews=" + paramIdNews + "&idElemt=" + paramIdElemt + "&checked=" + paramChecked, "get");

	listByXHR.createRequestObject();
	listByXHR.sendPostReq();

	listByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (listByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
		
		document.getElementById('content_list_col2').innerHTML = listByXHR.xmlhttp.responseText;
			
		}
	}	
}


function move_item_news(paramIdNews,paramIdElemt,paramChoix,sens)
{
		
	listByXHR = new httpRequest("/backOffice/Newsletter_Express/ajaxLoadBlocNews.aspx", "rdbChoice=" + paramChoix + "&idNews=" + paramIdNews + "&idElemt=" + paramIdElemt + "&sens=" + sens, "get");
		
	listByXHR.createRequestObject();
	listByXHR.sendPostReq();

	listByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (listByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
		
		document.getElementById('content_blocItem_'+paramChoix).innerHTML = listByXHR.xmlhttp.responseText;
			
		}
	}	
}




//function openActuNews()
//{
//	document.getElementById('actuNews_ouverte_1').style.display='block';
//	document.getElementById('actuNews_fermee_1').style.display='none';
//}

//function closeActuNews()
//{
//	document.getElementById('actuNews_ouverte_1').style.display='none';
//	document.getElementById('actuNews_fermee_1').style.display='block';
//}

function openEditNews()
{
	document.getElementById('editNews_ouverte_1').style.display='block';
	document.getElementById('editNews_fermee_1').style.display='none';
}

function closeEditNews()
{
	document.getElementById('editNews_ouverte_1').style.display='none';
	document.getElementById('editNews_fermee_1').style.display='block';
}

function openSomNews()
{
	document.getElementById('somNews_ouverte_1').style.display='block';
	document.getElementById('somNews_fermee_1').style.display='none';
}

function closeSomNews()
{
	document.getElementById('somNews_ouverte_1').style.display='none';
	document.getElementById('somNews_fermee_1').style.display='block';
}

function openMvNews()
{
	document.getElementById('mvNews_ouverte_1').style.display='block';
	document.getElementById('mvNews_fermee_1').style.display='none';
}

function closeMvNews()
{
	document.getElementById('mvNews_ouverte_1').style.display='none';
	document.getElementById('mvNews_fermee_1').style.display='block';
}

function openCouvNews()
{
	document.getElementById('couvNews_ouverte_1').style.display='block';
	document.getElementById('couvNews_fermee_1').style.display='none';
}

function closeCouvNews()
{
	document.getElementById('couvNews_ouverte_1').style.display='none';
	document.getElementById('couvNews_fermee_1').style.display='block';
}

function openServiceNews()
{
	document.getElementById('serviceNews_ouverte_1').style.display='block';
	document.getElementById('serviceNews_fermee_1').style.display='none';
}

function closeServiceNews()
{
	document.getElementById('serviceNews_ouverte_1').style.display='none';
	document.getElementById('serviceNews_fermee_1').style.display='block';
}


/* fin fonction bo de la newsletter */

function InfoElectre()
{
	// verif format isbn ou ean valide
	var infoElectreByXHR;
	
	infoElectreByXHR = new httpRequest("isbn_search.aspx", "isbn=" + document.getElementById('txtIsbn').value, "get");
	infoElectreByXHR.createRequestObject();
	infoElectreByXHR.sendPostReq();


	infoElectreByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (infoElectreByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
			eval(infoElectreByXHR.xmlhttp.responseText);
		}
	}
	
}


var monTabLivre = new tabLivre();

function Add_Livre()
{
	// verif format isbn ou ean valide
	var addLivreByXHR;
	
	addLivreByXHR = new httpRequest("add_livre.aspx", "isbn=" + document.getElementById('txtIsbn').value + "&titre=" + document.getElementById('txtTitre').value + "&auteur=" + document.getElementById('txtAuteur').value + "&editeur=" + document.getElementById('txtEditeur').value + "&invite=" + document.getElementById('txtInvite').value, "get");
	addLivreByXHR.createRequestObject();
	addLivreByXHR.sendPostReq();


	addLivreByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (addLivreByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
			eval(addLivreByXHR.xmlhttp.responseText);
		}
	}

}

function Suppr_Livre(isbn)
{

	monTabLivre.suppr(isbn);
	document.getElementById('Livres').innerHTML = monTabLivre.show();
}

function Modif_Livre(isbn,titre,auteur,editeur,invite)
{
	monTabLivre.modif(isbn,titre,auteur,editeur,invite);
	document.getElementById('Livres').innerHTML = monTabLivre.show();
	
}


/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/* add d.guillard, le 10/03/2009 : Tags BO */
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
function addTag(thisTag,typeOfObj,this_id_obj)
{

    if (trim(thisTag) != '')
    {
	    var addTagByXHR;
    	
	    addTagByXHR = new httpRequest("/ajax/ajax_Tags.aspx", "action=1&thisTag=" + thisTag + "&typeOfObj=" + typeOfObj + "&this_id_obj=" + this_id_obj, "get");
	    addTagByXHR.createRequestObject();
	    addTagByXHR.sendPostReq();

	    addTagByXHR.xmlhttp.onreadystatechange = function ()
	    {
		    if (addTagByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		    {
            document.getElementById('show_tags_in_BO').innerHTML = addTagByXHR.xmlhttp.responseText;
		    }
	    }
	} else {
	    alert('D\351sol\351, vous ne pouvez pas ajouter un "Mot cl\351" vide');
	}
}

 
// Supprime les espaces inutiles en début et fin de la chaîne passée en paramètre.
function trim(maChaine)
{
    var regExpBeginning = /^\s+/;
    var regExpEnd       = /\s+$/;
    
    return maChaine.replace(regExpBeginning, "").replace(regExpEnd, ""); 
}


function deleteTag(thisTag,typeOfObj,this_id_obj)
{
	var deleteTagByXHR;
	
	deleteTagByXHR = new httpRequest("/ajax/ajax_Tags.aspx", "action=2&thisTag=" + thisTag + "&typeOfObj=" + typeOfObj + "&this_id_obj=" + this_id_obj, "get");
	deleteTagByXHR.createRequestObject();
	deleteTagByXHR.sendPostReq();

	deleteTagByXHR.xmlhttp.onreadystatechange = function ()
	{
		if (deleteTagByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
        document.getElementById('show_tags_in_BO').innerHTML = deleteTagByXHR.xmlhttp.responseText;
		}
	}
}

/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */

/*fonction qui nous permet d'afficher/masquer un div*/
function Bascule(elem)
{
    etat=document.getElementById(elem).style.visibility;
    
	if(etat=="hidden")
	{
		document.getElementById(elem).style.visibility="visible";
		}else{
		document.getElementById(elem).style.visibility="hidden";
	}

}

function updatePhotoDiapo(idToShow)
{
//pour afficher les photos dans le diapo V2
	var infoPhotoByXHR;
	
	infoPhotoByXHR = new httpRequest("/ajax/ajax_DiapoV2.aspx", "curImg=" + idToShow, "get");
	infoPhotoByXHR.createRequestObject();
	
	infoPhotoByXHR.ShowWaitingMessage('diapos','En cours de chargement');
	
	infoPhotoByXHR.sendPostReq();

	infoPhotoByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (infoPhotoByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{            
			document.getElementById('diapos').innerHTML = infoPhotoByXHR.xmlhttp.responseText;				
		}
	}
	
}


function updatePetitePhotoGalerie(albumToShow, positionToShow)
{
//pour afficher les photos dans le diapo V2
	var galeriePhotoByXHR;
		
	galeriePhotoByXHR = new new_httpRequest("/ajax/ajax_DiapoV2.aspx", "idAlbum=" + albumToShow + "&POSITION_START=" + positionToShow, "get");
	galeriePhotoByXHR.idElmt_forWaitingMsg = 'petites_Photos'; 
    galeriePhotoByXHR.LoadContent("petites_Photos","En cours de chargement");     
    
	
}


/* remplir la dropdown liste des albums correspondants à un diapo choisi, pour la page de recherche de l'écran diaporama */
function remplirListBoxAlbum(vIdDiapo, vIdAlb)
{

    var diapoByXHR;

	diapoByXHR = new httpRequest("/diaporamasV2/diapoSearch.aspx", "idDiapo=" + vIdDiapo + "&idAlbum=" + vIdAlb, "get");
	
	diapoByXHR.createRequestObject();
	diapoByXHR.sendPostReq();

	diapoByXHR.xmlhttp.onreadystatechange = function ()
	{

		if (diapoByXHR.xmlhttp.readyState == 4) /* 4 : état "complete" */
		{
			eval(diapoByXHR.xmlhttp.responseText);
		}
	}
	
} 
     
// en variable global le diaporama porte le nom :: currentDiaporama
function js_Diaporama(nombre_image_total,album_id)
{
    this.noAction = false;
    var pathToDiapo = "/ajax/ajax_DiapoV2.aspx";
    var toLeft = true;
    var toRight = false;
    this.toFirst = false;
    this.toLast = false;
    this.currentPosition = 0;
    this.totalImage = nombre_image_total;
    this.currentAlbum = album_id;
    this.timeElasped = 5000;
    this.currentTimer = null;
    
    this.setToLeft = function()
    {
     toLeft = true;
     toRight = false;
    }
    
    this.setToRight = function()
    {
     toLeft = false;
     toRight = true;
    }
    
    // lors du passage en mode manuel on libére les ressources liées au timer
    this.setToManual = function()
    {
       clearInterval(this.currentTimer);
       document.getElementById('toto').innerHTML = '<a href="#" onclick="currentDiaporama.setToAutomatic()">Automatique</a>';
        //afficherWaitingMessage('diapos','En cours de chargement');
	    var infoPhotoByXHR = new new_httpRequest(pathToDiapo, "", "get");
        infoPhotoByXHR.idElmt_forWaitingMsg = 'div_onePhoto_diapo';
        infoPhotoByXHR.hideWaitingMessage();
       
    }
    
    // lors du passage en mode automatic on initialise notre timer avec la fonction suivante :: changeTo()
    this.setToAutomatic = function()
    { 
    
        document.getElementById('toto').innerHTML = '<a href="#" onclick="currentDiaporama.setToManual()">Stop</a>';  
        
	    var infoPhotoByXHR = new new_httpRequest(pathToDiapo, "", "get");
        infoPhotoByXHR.idElmt_forWaitingMsg = 'div_onePhoto_diapo';
        infoPhotoByXHR.ShowWaitingMessage("En cours de chargement"); 
          
       
              
        if (currentDiaporama.currentPosition != 0)
        {
            currentDiaporama.currentPosition = -1;            
        }
        
        
        if (currentDiaporama.currentPosition + 1 < currentDiaporama.totalImage)
        {
            this.setToRight();
            this.currentTimer = setInterval("currentDiaporama.changeTo(0)" , this.timeElasped);            
        }
    }
    
    
    //aller à la fin du diapo
    this.setToLast = function()
    {
        this.setToRight();
        this.currentPosition=this.totalImage-2;
        this.changeTo();}
    
     //aller au début du diapo
    this.setToFirst = function()
    {
        this.setToLeft();
        this.currentPosition=1;
        this.changeTo();}
    
    //afficher cette petite image
    //si on veut la 2ème photo, c'est comme si on lui dit à partir de la 1ère va à droite et affiche la suivante
    this.showPetitePhoto = function(positionPetitePhoto)
    {   this.setToRight();
        this.currentPosition=positionPetitePhoto-2;
        this.changeTo();        
    }
    
    
    this.changeTo = function(mode_Auto)
    {
    
    var vAuto = 1;
    
    //tester si on est dans le cas de automatique
    if (mode_Auto == 0 )
    {vAuto = 0;}           
    
       
    if (!this.noAction && ((  toRight && this.currentPosition + 1 < this.totalImage) || (toLeft && this.currentPosition - 1 >= 0)))
    {  
              
        this.noAction =true;
        var infoPhotoByXHR;
	    var strDirection = "right";
	    
	  	    
	    if (toLeft)
	    {
	        strDirection="left";
	    }
	    
	    infoPhotoByXHR = new new_httpRequest(pathToDiapo, "currentPosition=" + currentDiaporama.currentPosition + "&currentAlbum=" + this.currentAlbum+ "&direction=" + strDirection + "&afficher_auto=" + vAuto, "get");
	    infoPhotoByXHR.idElmt_forWaitingMsg = 'div_onePhoto_diapo';
	    infoPhotoByXHR.LoadContent("diapos","En cours de chargement","currentDiaporama.onXHR()");
    } 
    
    }
    
    this.onXHR = function()
    {    	        

        if(toLeft)
        { currentDiaporama.currentPosition --;}
        else
        { currentDiaporama.currentPosition ++;}
       
      			       
        currentDiaporama.noAction =false;
        if (currentDiaporama.totalImage <= currentDiaporama.currentPosition +1)
        {
            currentDiaporama.setToManual();    		          
        }
    
    }
}
