/********************************************************************************************************/

//Les variables globales
var colorCellsBeforeMouseOver    = new Array(); //Tableau contenant les couleurs d'orogine de chaque cellule d'une ligne lorsque l'on passe la souris dessus
var colorCellsBeforeMouseOverCol = new Array(); //Tableau contenant les couleurs d'orogine de chaque cellule d'une ligne lorsque l'on passe la souris dessus
var _msgboxVisible               = false;
var _currentColname              = null;
var _isSavedCache                = false;
var _changeOnglet                = true;
var _numCurrentOnglet            = 0; //Numéro de l'onglet courant
//var _oldNumOnglet             = null;
//var _oldPage                  = null;
//var _pageHasChanged           = false;

/********************************************************************************************************/
window.onload=montre;

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

/********************************************************************************************************/

/**
 * Change d'onglet
 */
function changeOnglet( _page, _index, _numOnglet)
{
	_functionAExecuter = new Array();
	_functionAExecuter.push('__changeOnglet("'+_page+'",'+ _index+', '+_numOnglet+')');
	//alert(document.getElementsByName('valid')[0]);
	if( document.getElementsByName('nom_client')[0] )
	{
		saveCacheSite();
	}
	else if( document.getElementsByName('code')[0] )
	{
		saveCacheIngredient();
	}
	else if( document.getElementsByName('listeNutriments')[0] && document.getElementsByName('valid')[0])
	{
		saveCacheArrayNutrious();
	}
	else if( document.getElementById('listeAllergenes') &&  document.getElementsByName('valid')[0] )
	{
		saveCacheAllergene();
	}
	else
	{
		eval(_functionAExecuter.pop());
	}
}

function __changeOnglet( _page, _index, _numOnglet)
{	
	_index = document.getElementsByName('idProduct_hidden')[0].value != '' ? document.getElementsByName('idProduct_hidden')[0].value : 'auto';
	
	if(!_msgboxVisible)
	{
		try
		{
			msgtmp('<img src="img/acc/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...', null);
			var _check      = null;
			var _lesOnglets = null;
			var _content    = null;
			
			//Récupère les cellules de la ligne
			if (typeof(document.getElementsByTagName) != 'undefined') 
			{
				if (document.getElementById('checkButton') != null)
				{
					_check =  '<div id="checkButton">' + document.getElementById('checkButton').innerHTML + '</div>';
				}
				_lesOnglets =  '<div id="onglets">' + document.getElementById('onglets').innerHTML + '</div>';
				_content = document.getElementById('main');
			}
			else if (typeof(document.getElementById) != 'undefined') 
			{
				if (typeof(document.getElementById('checkButton')) != 'undefined')
				{
					_check =  '<div id="checkButton">' + document.all.checkButton.innerHTML + '</div>';
				}
				_lesOnglets =  '<div id="onglets">' + document.all.onglets.innerHTML + '</div>';
				_content    = document.all.main;
			}
			else 
				return false
				
			var _xhrOnglet = getXhr();
			_xhrOnglet.onreadystatechange = function()
			{
				if(_xhrOnglet.readyState == 4 && _xhrOnglet.status == 200)//Si tout est ok
				{
					hidden_msgtmp();
					var _reponse       = _xhrOnglet.responseText;
					if(_check == null)
						_reponse = _lesOnglets + _reponse;
					else
						_reponse = _check + _lesOnglets + _reponse;
					_content.innerHTML = _reponse;
					_numCurrentOnglet = _numOnglet;
					//alert('Onglet changé !');
				}
			}
			
			var _data = 'id=' + _index; //Données à envoyer			
			//Envoie des données par la méthode POST
			_xhrOnglet.open('POST', _page, true);
			_xhrOnglet.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			_xhrOnglet.send(_data);		
			//_oldNumOnglet     = _numCurrentOnglet;			
			//_pageHasChanged   = false;
		}
		catch(e){msgbox(e.message);}
	}
}//End changeOnglet


/********************************************************************************************************/

/**
 * Permet de surligné une ligne d'un tableau lorsque l'on passe la souris dessus
 *
 * @param theRow : ligne a surligner
 * @param thePointerColor : couleur du surlignage
 */
function setOverMouse( theRow, thePointColor )
{
	if (typeof(theRow.style) == 'undefined')
	{
        return false;
	}

	//Récupère les cellules de la ligne
    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        theCells = theRow.getElementsByTagName('td'); 
    }
    else if (typeof(theRow.cells) != 'undefined')
    {
        theCells = theRow.cells;
    }
    else 
    {
        return false;
  	}
  	
    var nbCells = theCells.length; //Nombre cellules sur la ligne
    
    if(typeof(window.opera) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') 
    {
        domDetect    = true;
    }
    else 
	{
        domDetect    = false;
    } 
	
    if(domDetect) 
	{
		for (c = 0; c < nbCells; c++)
		{
            var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				theCells[c].setAttribute('bgcolor', thePointColor, 0);
			}
		}
	}
    else 
	{
        for (c = 0; c < nbCells; c++)
        {
           	var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				if(_currentColname == null || theCells[c].getAttribute('colname') != _currentColname)
				{
					colorCellsBeforeMouseOver[c] = theCells[c].style.backgroundColor;
				}
				theCells[c].style.backgroundColor = thePointColor;				
			}
		}
	}
}//End function setOverMouse

/********************************************************************************************************/

/**
 * Permet de surligné une ligne d'un tableau lorsque l'on passe la souris dessus
 *
 * @param theCol : colonne à surligner
 * @param thePointerColor : couleur du surlignage
 */
function setOverMouseCol( theCol, thePointColor )
{
	var _numColname = theCol.getAttribute('colname');
	_currentColname = _numColname;
	var _allTD = document.getElementsByTagName('td');
	var _allTH = document.getElementsByTagName('th');
	var theCells = new Array();
	var _nbTD = _allTD.length;
	var _nbTH = _allTH.length;
	var _cpt = 0;
	for (a = 0; a < _nbTD; a++)
    {
		if(_allTD[a].getAttribute('colname') == _numColname)
		{
			theCells[_cpt++] = _allTD[a];
		}
	}
	for (a = 0; a < _nbTH; a++)
    {
		if(_allTH[a].getAttribute('colname') == _numColname)
		{
			theCells[_cpt++] = _allTH[a];
		}
	}
	 if(typeof(window.opera) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') 
    {
        domDetect    = true;
    }
    else 
	{
        domDetect    = false;
    } 
	var nbCells = theCells.length;
    if(domDetect) 
	{
		for (c = 0; c < nbCells; c++)
		{
            var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				theCells[c].setAttribute('bgcolor', thePointColor, 0);
			}
		}
	}
    else 
	{
        for (c = 0; c < nbCells; c++)
        {
           	var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
            	colorCellsBeforeMouseOverCol[c] = theCells[c].style.backgroundColor;
				theCells[c].style.backgroundColor = thePointColor;			
			}
		}
	}
}//End _setOverMouseCol

/********************************************************************************************************/

/**
 * Restaure la couleur de la ligne qui vient d'etre surligné quand la souris sort du champ
 *
 * @param theRow : la ligne qui est affecté
 */
function setOutMouse( theRow )
{
	if (typeof(theRow.style) == 'undefined')
	{
        return false;
	}
	
	//Récupère les cellules de la ligne
    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        theCells = theRow.getElementsByTagName('td');  
    }
    else if (typeof(theRow.cells) != 'undefined')
    {
        theCells = theRow.cells;
    }
    else 
    {
        return false;
  	}
  	
    var nbCells   = theCells.length; //Nombre cellules sur la ligne
    
    if(typeof(window.opera) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') 
    {
        domDetect = true;
    }
    else 
	{
        domDetect = false;
    } 
	
    if(domDetect) 
	{
		var colorTheRow = theRow.getAttribute('bgcolor');
		for (c = 0; c < nbCells; c++)
		{
            var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				theCells[c].setAttribute('bgcolor', theCellsBeforeMouseOver[c].getAttribute('bgcolor'), 0);
			}
		}
	}
    else 
	{
		var colorTheRow = theRow.style.backgroundColor;
        for (c = 0; c < nbCells; c++)
        {
           	var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				if(colorCellsBeforeMouseOver[c] != null)
				theCells[c].style.backgroundColor = colorCellsBeforeMouseOver[c];
			}
		}
	}
}//End function setOutMouse

/********************************************************************************************************/

/**
 * Restaure la couleur de la ligne qui vient d'etre surligné quand la souris sort du champ
 *
 * @param theRow : la ligne qui est affecté
 */
function setOutMouseCol( theCol )
{
	if (typeof(theCol.style) == 'undefined')
	{
        return false;
	}
	
	var _numColname = theCol.getAttribute('colname');	
	var _allTD = document.getElementsByTagName('td');
	var _allTH = document.getElementsByTagName('tH');
	var theCells = new Array();
	var _nbTD = _allTD.length;
	var _nbTH = _allTH.length;
	var _cpt = 0;
	for (a = 0; a < _nbTD; a++)
    {
		if(_allTD[a].getAttribute('colname') == _numColname)
		{
			theCells[_cpt++] = _allTD[a];
		}
	}
  	for (a = 0; a < _nbTH; a++)
    {
		if(_allTH[a].getAttribute('colname') == _numColname)
		{
			theCells[_cpt++] = _allTH[a];
		}
	}
    var nbCells   = theCells.length; //Nombre cellules sur la ligne
    
    if(typeof(window.opera) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') 
    {
        domDetect = true;
    }
    else 
	{
        domDetect = false;
    } 
	
    if(domDetect) 
	{
		var colorTheRow = theCol.getAttribute('bgcolor');
		for (c = 0; c < nbCells; c++)
		{
            var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				theCells[c].setAttribute('bgcolor', theCellsBeforeMouseOver[c].getAttribute('bgcolor'), 0);
			}
		}
	}
    else 
	{
		var colorTheRow = theCol.style.backgroundColor;
        for (c = 0; c < nbCells; c++)
        {
           	var idCell = theCells[c].id;
            if(idCell != 'noPointer')
            {
				theCells[c].style.backgroundColor = colorCellsBeforeMouseOverCol[c];
			}
		}
	}
}//End function setOutMouse

/********************************************************************************************************/

/**
 * Vérifie si la chaine de caractère est un numéric
 */
function isNumeric( _x )
{
	var _checkOk   = "0123456789.";
	var _checkStr  = _x;
	var _allValid  = true;
	var _decPoints = 0;
	var _allNum    = '';
	var _hasPoint  = false;
	
	for(i = 0; i < _checkStr.length; i++)
	{
		_ch = _checkStr.charAt(i);
		for(j = 0; j < _checkOk.length; j++)
		{
			if( _ch == _checkOk.charAt(j) )
			{
				if( _ch == '.')
				{
					if(_hasPoint == true)
					{
						return false;
					}
					else
					{
						_hasPoint = true;
					}
				}
				break;			
			}
			
		}
		if(j == _checkOk.length)
		{
			_allValid = false;
			break;
		}
		_allNum += _ch;
	}
	if(!_allValid)
	{
		return false;
	}
	
	return true;
}//End function isNumeric

/********************************************************************************************************/

function exportation( _to, _id, _type, _listOk, _etat)
{
	html = '<p>';
	html += '<ul>';
	html += '<li><input type="checkbox" class="checkbox" name="info" checked="checked" onclick="_info = this.checked;"/>&nbsp;Les informations</li>';
	if( (_type == 'recipecomposed' || _type == 'ingredientcomposed')  && _listOk == true)
	{
		html += '<li><input type="checkbox" class="checkbox" name="list" checked="checked" />&nbsp;La liste des ingr&eacute;dients</li>';
	}
	
	if(IS_NUTRITIONNEL)
		html += '<li><input type="checkbox" class="checkbox" name="array" checked="checked" />&nbsp;Le tableau nutritionnel</li>';
	
	if(IS_ALLERGENE)
		html += '<li><input type="checkbox" class="checkbox" name="allergen" checked="checked" />&nbsp;S&eacute;curit&eacute; des aliments</li>';
	
	html += '</ul>';
	html += '</p>';
	//dialogBox(html, 'Exporter vers ' + _to, '__exportation(\'' + _to + '\', ' + _id + ',\'' + _type + '\', document.getElementsByName(\'info\')[0].checked , document.getElementsByName(\'list\')[0] , document.getElementsByName(\'array\')[0].checked, document.getElementsByName(\'allergen\')[0].checked, '+ _etat +' )');
	if( (_type == 'recipecomposed' || _type == 'ingredientcomposed')  && _listOk == true)
	{
		dialogBox(html, 'Exporter vers ' + _to, '__exportation(\'' + _to + '\', ' + _id + ',\'' + _type + '\', document.getElementsByName(\'info\')[0].checked , document.getElementsByName(\'list\')[0].checked , '+ ( IS_NUTRITIONNEL ? 'document.getElementsByName(\'array\')[0].checked' : 'false' ) +' , '+ ( IS_ALLERGENE ? 'document.getElementsByName(\'allergen\')[0].checked' : 'false' ) +', '+ _etat +' )');	
	}
	else
	{
		dialogBox(html, 'Exporter vers ' + _to, '__exportation(\'' + _to + '\', ' + _id + ',\'' + _type + '\', document.getElementsByName(\'info\')[0].checked , false, '+ ( IS_NUTRITIONNEL ? 'document.getElementsByName(\'array\')[0].checked' : 'false' ) +' , '+ ( IS_ALLERGENE ? 'document.getElementsByName(\'allergen\')[0].checked' : 'false' ) +', '+ _etat +' )');	
	}
}//End exportExcel

/********************************************************************************************************/

function __exportation( _to, _id, _type, _info, _list, _array, _allergen, _etat)
{
	if(_to == 'excel')
	{
	//alert("id : "+ _id + "\ntype : " + _type + "\nliste info : " +  _info + "\nlist ingredient : " + _list + "\nlist nutriment : " + _array + "\nlist allergen :" + _allergen + "\nEtat : " + _etat);
		location = 'include/admin/ajaxExcel.php?id=' + _id + '&type=' + _type + '&info=' + _info + '&list=' + _list + '&array=' + _array + '&allergen=' + _allergen + '&etat=' + _etat; 
	//	location = 'include/admin/ajaxExcel.php?id=' + _id + '&type=' + _type + '&info=' + _info + '&list=' + ((_list != null || typeof(_list) != 'undefined') ? _list.checked : false  ) + '&array=' + _array + '&allergen=' + _allergen + '&etat=' + _etat; 
	}
	else if( _to == 'pdf')
	{
	//alert("id : "+ _id + "\ntype : " + _type + "\nliste info : " +  _info + "\nlist ingredient : " + _list + "\nlist nutriment : " + _array + "\nlist allergen :" + _allergen + "\nEtat : " + _etat);

//		location = 'include/admin/ajaxPDF.php?id=' + _id + '&type=' + _type + '&info=' + _info + '&list=' + ( (_list != null || typeof(_list) != 'undefined') ? _list.checked : false  ) + '&array=' + _array + '&allergen=' + _allergen + '&etat=' + _etat; 
		location = 'include/admin/ajaxPDF.php?id=' + _id + '&type=' + _type + '&info=' + _info + '&list=' + _list + '&array=' + _array + '&allergen=' + _allergen + '&etat=' + _etat; 
	}
	else if( _to == 'word')
	{
//	alert("id : "+ _id + "\ntype : " + _type + "\nliste info : " +  _info + "\nlist ingredient : " + _list + "\nlist nutriment : " + _array + "\nlist allergen :" + _allergen + "\nEtat : " + _etat);
		location = 'include/admin/ajaxRTF.php?id=' + _id + '&type=' + _type + '&info=' + _info + '&list=' + _list + '&array=' + _array + '&allergen=' + _allergen + '&etat=' + _etat; 
	}
}//End functin __exportation

/********************************************************************************************************/

/**
 * Affichage d'un message en bas à gauche pendant X milliseconde
 */
function msgtmp( _text, _time, _add )
{
	if( _isIE )
	{
		document.getElementById('msgtmp').style.bottom = 0;
	}
	if( _add == true)
		document.getElementById('msgtmp').innerHTML += _text;
	else
		document.getElementById('msgtmp').innerHTML = _text;
	document.getElementById('msgtmp').style.visibility = "visible";
	if( _time != null)
	{
		setTimeout('hidden_msgtmp()', _time);
	}
}//End function msgtmp

/********************************************************************************************************/
var _cptNews = 0;
var _aff = new Array();
_aff[0] = '<span style="visibility:hidden">&rsaquo;</span>&rsaquo;&rsaquo;';
_aff[1] = '<span style="visibility:hidden">&rsaquo;</span><span style="visibility:hidden">&rsaquo;</span>&rsaquo;';
_aff[2] = '<span style="visibility:hidden">&rsaquo;</span><span style="visibility:hidden">&rsaquo;</span><span style="visibility:hidden">&rsaquo;</span>';
_aff[3] = '&rsaquo;<span style="visibility:hidden">&rsaquo;</span><span style="visibility:hidden">&rsaquo;</span>';
_aff[4] = '&rsaquo;&rsaquo;<span style="visibility:hidden">&rsaquo;</span>';
_aff[5] = '&rsaquo;&rsaquo;&rsaquo;';
function clignote()
{
	var _new = document.getElementsByName('news');
	for(var _aa = 0; _aa < _new.length; _aa++)
	{
		_new[_aa].innerHTML = _aff[_cptNews];
	}
	_cptNews++;
	if(_cptNews	==  6)
		_cptNews = 0;
	setTimeout('clignote()', 500);
}

setTimeout('clignote()', 500);
/**
 * Cache le message
 */
function hidden_msgtmp()
{
	document.getElementById('msgtmp').style.visibility = "hidden";
}//End function _hiddenMsgtmp

/********************************************************************************************************/
var timer;
/**
 *
 */
function dialogBox( _text, _title, _functionName)
{
	var crossObj           = null;
	var horizontalPosition = null;
	var verticalPosition   = null;
	
	if(document.all)
        crossobj = document.all.msgbox;
	else if(document.getElementById)
      crossobj = document.getElementById('msgbox'); 
	
	if (document.all)
    {
	   //alert('document.documentElement.clientHeight : ' + document.documentElement.clientHeight  );
   		horizontalPosition = document.body.offsetWidth / 2;
        verticalPosition   = (document.documentElement.clientHeight / 2) + document.documentElement.scrollTop ;

    }
    else if (document.getElementById) 
    {
	    //alert('window.innerWidth ' + window.innerHeight  );
	    //alert('document.documentElement.scrollTop ' + document.documentElement.scrollTop );
		horizontalPosition = window.innerWidth / 2;
	    verticalPosition   = (window.innerHeight / 2) + document.documentElement.scrollTop ;
    }
  
    var html = '<div id="dragbar" >';
    html += '<div id="noClick"><div class="titreMsgbox">'+ ( _title == null ? 'ExtranetDEV' : _title ) +'</div>';
    html += '<p>'
    html += _text;
    html += '<br /><br /><input id="buttonMsgbox"  type="submit" class="button" name="valider" value="Confirmer" onclick="' + _functionName + '; closeMsgbox(); " />&nbsp;&nbsp;<input id="buttonMsgbox"  type="submit" class="button" name="valider" value="Annuler" onclick="closeMsgbox(); return false;" /></p>';
    html += '</div></div>';
    
     //crossObj.style.width = 30;
	
    crossobj.innerHTML  = html;
    
	div = document.getElementById('dragbar');    
	horizontalPosition = ( horizontalPosition - ( div.offsetWidth / 2 ) );
	verticalPosition = ( verticalPosition - ( div.offsetHeight / 2 ) );
    crossobj.style.left = horizontalPosition + 'px';
    crossobj.style.top  = verticalPosition + 'px';
    
	if(_isIE)
	{
		document.getElementById('framemessage').height = div.offsetHeight + 'px';
		document.getElementById('framemessage').width = div.offsetWidth + 'px';
		document.getElementById('framemessage').style.top = verticalPosition + 'px';
		document.getElementById('framemessage').style.left = horizontalPosition + 'px';
	}
	//crossobj.height = div.offsetHeight + 'px';
	//crossobj.width = div.offsetWidth + 'px';	
	
    crossobj.style.visibility = "visible";
}//End function dialogBox


/********************************************************************************************************/

function playWithMyFreebox99( _rub, _ident, _streamstate )
{
			//alert(_rub);
	var _xhr = getXhr();
	var _content = document.getElementById("ident_"+ _ident);
	var _actualIdentDiv = document.getElementById("actualIdent");
	var _actualIdent = _actualIdentDiv.innerHTML;
	if (_actualIdent != "undefined") {
	var _contentOld = document.getElementById("ident_"+ _actualIdent);
	}
	//alert(_actualIdent);
	//document.getElementById("listeProduit").innerHTML = '<p><img src="images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...</p>';
	msgtmp('<img src="images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...', null);
	//Ce qu'on fait quand on aura la réponse du serveur
	_xhr.onreadystatechange = function()
	{
		if(_xhr.readyState == 4 && _xhr.status == 200)//Si tout est ok
		{
			hidden_msgtmp();

			var _reponse = _xhr.responseText;
			_content.innerHTML = _reponse;
			_actualIdentDiv.innerHTML = _ident;
			if (_actualIdent != "undefined" && _actualIdent != "" && _actualIdent != _ident) {
			_contentOld.innerHTML = '<a href="#'+_actualIdent+'" onClick="playWithMyFreebox99(\'tvperso\', \''+_actualIdent+'\', \'play\');"  ><img src="../img/acc/btn_play.png" alt="voir sur Myfreebox" width="28" height="28" /></a>';
			}
			
		}
	}
	
	var _data = 'rub2up='+ _rub +'&ident2up=' + _ident +'&streamstate2up=' + _streamstate ; //Données à envoyer	
	var _page = './include/scripts/myFreeboxControl.php'; //Page vers laquelle on envoie les données

	//Envoie des données par la méthode POST
	_xhr.open('POST', _page, true);
	_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_xhr.send(_data);
}//End function changeIndexListProduct

/********************************************************************************************************/
function playWithMyFreebox994page( _rub, _ident, _streamstate )
{
			//alert(_rub);
	var _xhr = getXhr();
	var _content = document.getElementById("ident_"+ _ident);
	var _actualIdentDiv = document.getElementById("actualIdent");
	var _actualIdent = _actualIdentDiv.innerHTML;
	if (_actualIdent != "undefined") {
	var _contentOld = document.getElementById("ident_"+ _actualIdent);
	}
	//alert(_actualIdent);
	//document.getElementById("listeProduit").innerHTML = '<p><img src="images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...</p>';
	msgtmp('<img src="../images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...', null);
	//Ce qu'on fait quand on aura la réponse du serveur
	_xhr.onreadystatechange = function()
	{
		if(_xhr.readyState == 4 && _xhr.status == 200)//Si tout est ok
		{
			hidden_msgtmp();

			var _reponse = _xhr.responseText;
			_content.innerHTML = _reponse;
			_actualIdentDiv.innerHTML = _ident;
			if (_actualIdent != "undefined" && _actualIdent != "" && _actualIdent != _ident) {
			_contentOld.innerHTML = '<a href="#'+_actualIdent+'" onClick="playWithMyFreebox99(\'tvperso\', \''+_actualIdent+'\', \'play\');"  ><img src="../img/acc/btn_play.png" alt="voir sur Myfreebox" width="28" height="28" /></a>';
			}
			
		}
	}
	
	var _data = 'rub2up='+ _rub +'&ident2up=' + _ident +'&streamstate2up=' + _streamstate ; //Données à envoyer	
	var _page = '../include/scripts/myFreeboxControl.php'; //Page vers laquelle on envoie les données;

	//Envoie des données par la méthode POST
	_xhr.open('POST', _page, true);
	_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_xhr.send(_data);
}//End function changeIndexListProduct

/********************************************************************************************************/
	function closeCurrentQuestion( _quizzId, _quizzSet, _questId, _gr, _etat )
{
			//alert(_rub);
	var _xhr = getXhr();
	var _content = document.getElementById("countDown");
	//alert(_actualIdent);
	//document.getElementById("listeProduit").innerHTML = '<p><img src="images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...</p>';
	//msgtmp('<img src="images/loading.gif" title="Chargement" witdh="16" height="16" />&nbsp;Chargement ...', null);
	//Ce qu'on fait quand on aura la réponse du serveur
	_xhr.onreadystatechange = function()
	{
		if(_xhr.readyState == 4 && _xhr.status == 200)//Si tout est ok
		{

				
					var _reponse = _xhr.responseText;
					var _content = document.getElementById("countDown");
					_content.innerHTML = _reponse;
		}
	}
	
	var _data = 'quizzId='+ _quizzId +'&quizzSet='+ _quizzSet +'&questId=' + _questId +'&gr=' + _gr +'&questStatus=' + _etat ; //Données à envoyer	
	var _page = './include/AjaxSetQuestionStatus.php'; //Page vers laquelle on envoie les données

	//Envoie des données par la méthode POST
	_xhr.open('POST', _page, true);
	_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_xhr.send(_data);
}//End function changeIndexListProduct

/**
 *
 *
 *
 */
function msgbox( text, title, nameButton )
{
	var crossObj           = null;
	var horizontalPosition = null;
	var verticalPosition   = null;
	if(document.all)
        crossobj = document.all.msgbox;
	else if(document.getElementById)
      crossobj = document.getElementById('msgbox'); 
	  
	if (document.all)
    {
	   //alert('document.documentElement.clientHeight : ' + document.documentElement.clientHeight  );
   		horizontalPosition = document.body.offsetWidth / 2;
        verticalPosition   = (document.documentElement.clientHeight / 2) + document.documentElement.scrollTop ;

    }
    else if (document.getElementById) 
    {
	    //alert('window.innerWidth ' + window.innerHeight  );
	    //alert('document.documentElement.scrollTop ' + document.documentElement.scrollTop );
		horizontalPosition = window.innerWidth / 2;
	    verticalPosition   = (window.innerHeight / 2) + document.documentElement.scrollTop ;
    }
    else 
    {
        return false;
  	}

    var html = '<div id="dragbar" >';
    html += '<div id="noClick"><div class="titreMsgbox">'+ (title == null ? 'ExtranetDEV' : title ) +'</div>';
    html += '<p>'
    html += text;
    html += '<br /><center><input id="buttonMsgbox"  type="submit" class="button" name="valider" value="'+ (nameButton == null ? '&nbsp;&nbsp;OK&nbsp;&nbsp;' : nameButton) +'" onclick="closeMsgbox();" /><center></p>';
    html += '</div></div>';
    
     //crossObj.style.width = 30;
	
    crossobj.innerHTML  = html;
    
	div = document.getElementById('dragbar');    
	horizontalPosition = ( horizontalPosition - ( div.offsetWidth / 2 ) );
	verticalPosition = ( verticalPosition - ( div.offsetHeight / 2 ) );
    crossobj.style.left = horizontalPosition + 'px';
    crossobj.style.top  = verticalPosition + 'px';
    
	if(_isIE)
	{
		document.getElementById('framemessage').height = div.offsetHeight + 'px';
		document.getElementById('framemessage').width = div.offsetWidth + 'px';
		document.getElementById('framemessage').style.top = verticalPosition + 'px';
		document.getElementById('framemessage').style.left = horizontalPosition + 'px';
	}
	
    crossobj.style.visibility = "visible";
    
    _msgboxVisible = true;
}//End function msgbox



/********************************************************************************************************/

/**
 * Cache le message
 */
function closeMsgbox()
{
	crossobj.style.left = '-1000px';
	if(_isIE)
	{
		document.getElementById('framemessage').style.left = '-1000px';
	}
	//crossobj.style.visibility = "hidden";
	_msgboxVisible = false;
	timer = null;
	return false;
}//End function closeMsgbox

/********************************************************************************************************/

/**
 * Empèche a l'utilisateur de cliquer sur un lien si un message est affiché
 */
function noClick(e)
{
	if (_msgboxVisible)
	{
		return false;
	}
	//alert('T\'as cliqué quelque part sur cette page !!!');
}//End function noClick

/********************************************************************************************************/

/**
 * Empèche a l'utilisateur de taper sur une touche du clavier si un message est affiché
 */
function noKey(e)
{
	if (_msgboxVisible)
	{
	    return false;	
	}
}//End function noKey

/********************************************************************************************************/

document.onclick   = noClick;
document.onkeydown = noKey;

/********************************************************************************************************/
