// JavaScript Document
/*
var isIE = document.all && !window.opera;
var enqueteText = null;

function getWidth()
{
    return screen.width;
}
function getHeight()
{
    return screen.height;
}

function getX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}

function generateTaskBarHelp()
{
	var divParent = document.createElement("div");
	if (document.getElementById('TaskBarHelp'))
	{
	    var tmp = document.getElementById('TaskBarHelp');
	    tmp.parentNode.removeChild(tmp);
	}
	var divElement = document.createElement("div");
	// largeur, hauteur de la fenetre client
	var hWindow = 0;
	var lWindow = 0;
	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			lWindow = document.documentElement.clientWidth;
		}
		else
		{
			lWindow = self.innerWidth;
		}
		hWindow = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		lWindow = document.documentElement.clientWidth;
		hWindow = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		lWindow = document.body.clientWidth;
		hWindow = document.body.clientHeight;
	}
	// hauteur, largeur de la fenetre d'aide
	var hauteur = 325;
	var largeur = 200;
	// atributs de style
	var position = "";
	if (!window.opera)
	    position = "position: absolute;";
	else
		position = "position: fixed;";
	var width = "width: " + largeur + "px;";
	var top = "top: " + (hWindow - hauteur - 35) + "px;";
	var left = "left: 10px;";
	if (arguments.length == 2)
	    left = "left: " + arguments[1] + "px;";
	var height = "height: " + hauteur + "px;";
	var zindex = "z-index: 9000;";
	var background = "background-color: #feffcf;";
	var border = "border-bottom: 1px solid #b5b5b5;";
	

	divParent.name = "TaskBarHelp";
	divParent.id = "TaskBarHelp";
	var style = position + top + left + width + height + zindex;
	if (isIE)
	    divParent.style.setAttribute("cssText", style);
	else
		divParent.setAttribute("style", style);
		
	vAlignment = "display: table; vertical-align: bottom;";
	var style = vAlignment + width + height;
	if (isIE)
	    divElement.style.setAttribute("cssText", style);
	else
		divElement.setAttribute("style", style);


	var content = "";
	if (arguments.length >= 1)
	    content = content +
			"<div style='" + background +  "'>" +
				arguments[0] +
			"</div>";
	else
		content = content +
		"<div style='" + background +  "'>" +
			"<div style='font-size: 15px; border-bottom: 1px solid #dcdcdc; text-align: center;'>" +
				"Aide sur la barre" +
			"</div>" +
			"<div style='" + background +  "'>" +
			    "Contenu de l'aide...bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla " +
			"</div>" +
		"</div>";
		
	content = content +
		"<div style='text-align: right; line-height: 36px;" + background +  "'>" +
		    "<a href='javascript: void(0);' onclick='document.getElementById(\"TaskBarHelp\").style.display = \"none\";'>Fermer</a>" +
		"</div>";

	var divContent = document.createElement("div");
	style = "display: table-cell; vertical-align: bottom;" + width;
	style_ie = "z-index: 9001; position: absolute; bottom: 0px;" + width;
	if (isIE)
	    divContent.style.setAttribute("cssText", style_ie);
	else
		divContent.setAttribute("style", style);
	
	divContent.innerHTML = content;
	divElement.appendChild(divContent);

	divParent.appendChild(divElement);
	var divArrow = document.createElement("div");
	var style = "z-index: 9002;";
	if (isIE)
	
	    divArrow.style.setAttribute("cssText", style);
	else
		divArrow.setAttribute("style", style);
	var imgArrow = document.createElement("img");
	imgArrow.setAttribute("src", RELPATH + "/modules/tchat/fleche.gif");
	imgArrow.setAttribute("width", "200");
	divArrow.appendChild(imgArrow);
	divParent.appendChild(divArrow);
	

	// ajout de la barre dans la page
	var body = document.getElementsByTagName("body")[0];
	body.appendChild(divParent);
	
}

function generateTaskBar()
{
	if (document.getElementById('TaskBar'))
	{
	    var tmp = document.getElementById('TaskBar');
	    tmp.parentNode.removeChild(tmp);
	}
	var divElement = document.createElement("div");
	// largeur, hauteur de la fenetre client
	var hWindow = 0;
	var lWindow = 0;
	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			lWindow = document.documentElement.clientWidth;
		}
		else
		{
			lWindow = self.innerWidth;
		}
		hWindow = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		lWindow = document.documentElement.clientWidth;
		hWindow = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		lWindow = document.body.clientWidth;
		hWindow = document.body.clientHeight;
	}


	// teste de la scrollbar verticale
	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;
	}
	// ne marche pas avec opera et safari
	
	//if (yScroll > hWindow)
	//	lWindow = lWindow - 18;
	//if (xScroll > lWindow + 2)
	//	hWindow = hWindow - 18;

    // hauteur de la barre
	var hauteur = 24;
	
	// atributs de style
	var position = "";
	if (!window.opera)
	    position = "position: absolute;";
	else
		position = "position: fixed;";
	var width = "width: " + lWindow + "px;";
	var top = "top: " + (hWindow - hauteur) + "px;";
	var left = "left: 0px;";
	var height = "height: " + hauteur + "px;";
	var zindex = "z-index: 9000;"
	var border = "border: 1px solid #b5b5b5;";
	var background = "background-color: #e5e5e5;";
	
	divElement.name = "TaskBar";
	divElement.id = "TaskBar";
	var style = position + top + left + width + height + border + background + zindex;
	if (isIE)
	    divElement.style.setAttribute("cssText", style);
	else
		divElement.setAttribute("style", style);

	// image en bas, avant les onglets de la barre
    var divImg = document.createElement("div");
    var imgElement = document.createElement("img");
    imgElement.setAttribute("src", RELPATH + "/modules/tchat/logotaskbar.gif");
	// attributs de style
	var position = "position: relative;";
	var top = "top: " + 0 + "px;";
	var left = "left: 0px;";
	var width = 'width: 80px;';
	var zindex = "z-index: 9001;";
	var _float = "float: left;";
	var alignment = "text-align: center;";
	var styleImg = position + top + left + zindex + _float + width;
	if (isIE)
	    divImg.style.setAttribute("cssText", styleImg);
	else
		divImg.setAttribute("style", styleImg);
    divImg.appendChild(imgElement);
    divElement.appendChild(divImg);
    
    var divContent = document.createElement("div");
	divContent.name = "TaskBarContent";
	divContent.id = "TaskBarContent";
    var width = "width: " + (lWindow - 120) + "px;";
	var zindex = "z-index: 9002;";
	var _float = "float: left;";
	var style = position + width + zindex + _float;
	if (isIE)
	    divContent.style.setAttribute("cssText", style);
	else
		divContent.setAttribute("style", style);
		
	// les parties qu'on a envie de rajouter.
	createNewInformation("enquete", divContent);
	createNewInformation("vmi", divContent);
	createNewInformation("tchat", divContent);
	

	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);
	//createNewInformation("temp", divContent);


	divElement.appendChild(divContent);
	
	createDownloadElement(divElement);
	
	// ajout de la barre dans la page
	var body = document.getElementsByTagName("body")[0];
	body.appendChild(divElement);
	divElement.ondblclick = configureTaskBar;
	
}

function createDownloadElement(parentElement)
{
    var divElement = document.createElement("div");
	// atributs de style
	var position = "position: relative;";
	var width = "";
	var top = "";
	var left = "";
	var height = "height: " + 18 + "px; line-height: 18px;";
	var zindex = "z-index: 9001;";
	var border = "";
	var background = "background-color: #e5e5e5;";
	var _float = "float: right;";
	var alignment = "text-align: center;"
	var margin = "margin: 1px; margin-right: 15px;";

	if (document.getElementById("downloadDiv") )
	{
	    var tmp = document.getElementById("downloadDiv");
	    tmp.parentNode.removeChild(tmp);
	}

	divElement.name = "downloadDiv";
	divElement.id = "downloadDiv";
	var style = position + top + left + width + height + border + background + zindex + _float + alignment + margin;
	if (isIE)
	    divElement.style.setAttribute("cssText", style);
	else
		divElement.setAttribute("style", style);
	
	divElement.onmouseover = function()
	{
	    this.style.cursor = "pointer";
	}
	divElement.onclick = function()
	{
	    alert('Telechargement');
	}
	
	divElement.innerHTML = "<img src='" +RELPATH + "/modules/tchat/download.gif' border='0' />";
	
	
	parentElement.appendChild(divElement);
}

function createNewInformation(arg, parentElement)
{
    var divElement = document.createElement("div");

	// atributs de style
	var position = "position: relative;";
	var width = "width: " + 100 + "px;";
	var top = "top: " + 0 + "px;";
	var left = "left: 0px;";
	var height = "height: " + 18 + "px; line-height: 18px;";
	var zindex = "z-index: 9001;"
	var border = "border: 1px solid #b5b5b5;";
	var background = "background-color: #e5e5e5;";
	var _float = "float: left;";
	var alignment = "text-align: center;"
	var margin = "margin: 1px;";
	
	if (document.getElementById(arg + "Div") )
	{
	    var tmp = document.getElementById(arg + "Div");
	    tmp.parentNode.removeChild(tmp);
	}

	divElement.name = arg + "Div";
	divElement.id = arg + "Div";
	var style = position + top + left + width + height + border + background + zindex + _float + alignment + margin;
	if (isIE)
	    divElement.style.setAttribute("cssText", style);
	else
		divElement.setAttribute("style", style);

	divElement.onmouseover = function()
	{
	    this.style.cursor = "pointer";
	    this.style.backgroundColor = "#ffffff";
	};
	divElement.onmouseout = function()
	{
	    this.style.backgroundColor = "#e5e5e5";
	    this.style.cursor = "default";
	};
	divElement.onmousedown = function()
	{
	    this.style.backgroundColor = "#e5e5ff";
	};
	divElement.onmouseup = function()
	{
	    this.style.backgroundColor = "#e5e5e5";
	};

    divElement.innerHTML = arg;
    
	switch(arg)
	{
	    case "vmi":
    		divElement.innerHTML = "Les VMI&reg;";
			divElement.onclick = function()
			{
		        var text = A_retrieve(RELPATH + "/shared/skins/pratis_med/modules/vmi/listevminonvu.php", "", false);
		        generateTaskBarHelp(text, getX(this));
			};
	        break;
		case "tchat":
		    var img = "<img src='" +RELPATH + "/modules/tchat/logophoto.gif' align='absmiddle' />";
		    divElement.innerHTML = img + "Tchat";
		    divElement.onclick = function()
		    {
		        var w = (getWidth()-750) / 2;
				var h = (getHeight()-500) / 2;
				window.open(RELPATH + "/modules/tchat/chat.php", "chat", "top=" + h + ", left=" + w + ", width=750, height=500, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no");
		    };
		    break;
		case "enquete":
		    divElement.innerHTML = "Enqu&ecirc;tes";
			divElement.onclick = function()
			{
		        var text = A_retrieve(RELPATH + "/modules/questionnaires/listeenquetenonrepondu.php", "", false);
				// on sauvegarde le texte
		        enqueteText = text;
		        generateTaskBarHelp(text, getX(this));
			};
		    break;
		default:
		    break;
	}
    parentElement.appendChild(divElement);
}

// Verification des nouveautés sur Pratis.com
// ici, les enquetes, toutes les 5 minutes
setInterval(checkNewQuest, 300000);
function checkNewQuest()
{
	var text = A_retrieve(RELPATH + "/modules/questionnaires/listeenquetenonrepondu.php", "", false);
	if (enqueteText == null)
		enqueteText = text;
    if (text != enqueteText)
    {
        enqueteText = text;
        var content = ""+
            "<div>" +
                "De nouvelles enquêtes sont disponibles sur Pratis.com." + "<br />" +
				"<a href='" + RELPATH + "/modules/questionnaires/index.php'>Cliquez-ici pour les découvrir</a>";
            "</div>";
        generateTaskBarHelp(content);
    }
}

function configureTaskBar()
{
	var w = getWidth();
	var h = getHeight();
	
	var divParent = document.createElement("div");
	if (document.getElementById('TaskBarConfig'))
	{
	    var tmp = document.getElementById('TaskBarConfig');
	    tmp.parentNode.removeChild(tmp);
	}
	var lWindow = 0;
	// hauteur, largeur de la fenetre d'aide
	var hauteur = 350;
	var largeur = 500;
	// atributs de style
	var position = "";
	if (!window.opera)
	    position = "position: absolute;";
	else
		position = "position: fixed;";
	var width = "width: " + largeur + "px;";
	var top = "top: " + parseInt((h - hauteur)/2) + "px;";
	var left = "left: " + parseInt((w - largeur)/2) + "px;";
	var height = "height: " + hauteur + "px;";
	var zindex = "z-index: 9000;";
	var background = "background-color: #f5f5f5;";
	var border = "border-bottom: 1px solid #b5b5b5; border-right: 1px solid #b5b5b5; border-left: 1px solid #b5b5b5;";


	divParent.name = "TaskBarConfig";
	divParent.id = "TaskBarConfig";
	var style = position + top + left + width + height + zindex + background + border;
	if (isIE)
	    divParent.style.setAttribute("cssText", style);
	else
		divParent.setAttribute("style", style);


	var content = "";
	content = content +
		"<div style='width: 30px; height: 24px; background-image: url("+ RELPATH + "/modules/tchat/fermer.png); background-repeat: repeat-x; float: right;' onmouseover='this.style.cursor=\"pointer\";' onclick='document.getElementById(\"TaskBarConfig\").style.display = \"none\";'>" +
			"<img src='fermer.png' border='0'>" +
		"</div>" +
		"<div style='padding-left: 10px; height: 24px; background-image: url("+ RELPATH + "/modules/tchat/fond-fenetre.jpg); background-repeat: repeat-x; left: 0px; line-height: 24px;'>" +
			"Configuration" +
		"</div>" +
	"<div>" +
		"<div style='margin: 5px;'>" +
		    "<input type='checkbox' name='enqueteCheck' id='enqueteCheck' value='' /> Enquête Pratis" +
		    "<br />" +
		    "<input type='checkbox' name='vmiCheck' id='vmiCheck' value='' /> VMI Pratis" +
		    "<br />" +
		    "<input type='checkbox' name='webtvCheck' id='webtvCheck' value='' /> Pratis TV" +
		    "<br />" +
		    "<input type='checkbox' name='tchatCheck' id='tchatCheck' value='' /> Tchat Pratis" +
		    "<br />" +
		    "<div style='text-align: center'>" +
		    	"<input type='button' name='valider' value='Valider' onclick='checkActive(); document.getElementById(\"TaskBarConfig\").style.display = \"none\";' />" +
			"</div>" +
		"</div>" +
	"</div>";

	divParent.innerHTML = content;


	// ajout de la barre dans la page
	var body = document.getElementsByTagName("body")[0];
	body.appendChild(divParent);
}

function checkActive()
{
	// enquete
	if (document.getElementById('enqueteCheck').checked)
        createNewInformation("enquete", document.getElementById('TaskBarContent'));
	else
	{
		if (document.getElementById("enqueteDiv") )
		{
		    var tmp = document.getElementById("enqueteDiv");
		    tmp.parentNode.removeChild(tmp);
		}
	}
	// les vmi
	if (document.getElementById('vmiCheck').checked)
        createNewInformation("vmi", document.getElementById('TaskBarContent'));
	else
	{
		if (document.getElementById("vmiDiv") )
		{
		    var tmp = document.getElementById("vmiDiv");
		    tmp.parentNode.removeChild(tmp);
		}
	}
	// la webtv
	if (document.getElementById('webtvCheck').checked)
        createNewInformation("webtv", document.getElementById('TaskBarContent'));
	else
	{
		if (document.getElementById("webtvDiv") )
		{
		    var tmp = document.getElementById("webtvDiv");
		    tmp.parentNode.removeChild(tmp);
		}
	}
	// le tchat
	if (document.getElementById('tchatCheck').checked)
        createNewInformation("tchat", document.getElementById('TaskBarContent'));
	else
	{
		if (document.getElementById("tchatDiv") )
		{
		    var tmp = document.getElementById("tchatDiv");
		    tmp.parentNode.removeChild(tmp);
		}
	}
	
}

window.onresize = generateTaskBar;
*/

