var winCom = null;
function showComment(myURL){
	if(winCom != null){
	}else{
		//alert(myURL);
		winCom = new Window({className: "dialog", title: "Commentaires",
									 width:500, height:400, destroyOnClose: true,
									 minimizable: false, maximizable: false, resizable: false,
									 url: myURL, showEffectOptions: {duration:1.5}})
		winCom.showCenter();
		// Set up a windows observer, check ou debug window to get messages
		myObserver = {
			onDestroy: function(eventName, win) {
				if (win == winCom) {
					winCom = null;
					Windows.removeObserver(this);
				}
			}
		}
		Windows.addObserver(myObserver);
	}
}


/**
* Fonction qui affiche 2 div et qui en cache un
*/
function affiche(div)
{
	var calc = $(div);
	var masquer = $(div+"_masquer");
	var voir = $(div+"_voir");
	//cacheCategories(div);
	
	if (calc.style.display=='none')
	{
		//calc.style.display='block';
		masquer.style.display='block';
		voir.style.display='none';
		Effect.BlindDown(div,{duration:1.15});
		//calc.style.display='inline';
	}
	
}

/**
* Fonction qui cache 2 div et qui en affiche un
*/
function cache(div)
{
	var calc = $(div);
	var masquer = $(div+"_masquer");
	var voir = $(div+"_voir");
	if(!calc)
	{
		return;
	}
	//cacheSubCategories(div);
	Effect.BlindUp(div,{duration:1.15})
	masquer.style.display='none';
	voir.style.display='block';
}


/**
* Ouvre une URL et récupère son contenu
*/
function openFile(url, methodName)
{
			//alert(url);
	 if(window.XMLHttpRequest) // FIREFOX
		  xhr_object = new XMLHttpRequest();
	 else if(window.ActiveXObject) // IE
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	 else
		  return(false);
	 
		xhr_object.open(methodName, url, false);
		xhr_object.send("");
	 if(xhr_object.readyState == 4) {
		 return(xhr_object.responseText);
	 }
	 else {
		 return(false);
	 }
}

function setInnerHTML(div, HTML) {
	$(div).innerHTML=HTML; 
	//var All=$(div).getElementsByTagName("*");
	//for (var i=0; i<All.length; i++) {
	//	All[i].id=All[i].getAttribute("id");
	//	All[i].name=All[i].getAttribute("name");
	//	All[i].className=All[i].getAttribute("class");
	//}
	var AllScripts=$(div).getElementsByTagName("script");
	for (var i=0; i<AllScripts.length; i++) {
		var s=AllScripts[i];
		if (s.src && s.src!="") {
			// PrÈcÈdement asynchrone, mis en synchrone pour Èviter des problËmes de dÈpendances de scripts
		}
		else {
			eval(s.innerHTML);
		}
	}
}

function EcrireCookie(nom, valeur)
{
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}


/**
* action du vote
*/
function aVote(ts,idv) {
	//alert(ts);
	maDate=new Date;
	maDate.setFullYear(maDate.getFullYear()+10);
	//alert(maDate);
	EcrireCookie("dejaVote",ts,maDate,"/");
	openFile('service/service.php?requete=aVote&value='+idv,'GET');
	//setInnerHTML('chooseOfTheMoment','Choix du moment:<b> '+ lvalue +'</b>');
	
	
}


/**
* Scrolling du cadre planning
*/
var Timer;
var Pas = 3;
function moveLayer(Sens) {
	Objet=document.getElementById("contenuPWK");
    if(parseInt(Objet.style.top) + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById("supportPWK").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);
}

