var height_ar = new Array(); 
function stock_height(id){		   
	height_ar[id]=document.getElementById("popup_"+id).offsetHeight;
	document.getElementById("popup_"+id).style.display = "none";	 
}

//deroulement

function deroulement(id){
	var objet = document.getElementById("popup_"+id); // entre les deux ' tu mes le nom du div que tu veux faire apparaître !	   
	var objet_contenu = document.getElementById("view_"+id);
	if(objet.style.display == "none" || !objet.style.display){
		objet.style.display = "block";
 
        var hFinal      =	height_ar[id];  //Hauteur finale (la hauteur une fois que ça aura fini de déplier !) 
        var hActuel     =	0;	 	//Hauteur initiale (la hauteur dès le début !)
        var timer;	   
        var fct = function ()
        {
                hActuel  	+= 20;     //Augmente la hauteur de 20px (tu peux modifier) tous les 40ms !	
                objet.style.height			= hActuel + 'px'; 

                if( hActuel > hFinal)
                {
					objet_contenu.style.visibility = "visible";
					clearInterval(timer);   //Arrête le timer
                       
                }
        };
        fct();
		timer = setInterval(fct,40);    //Toute les 40 ms
	}
	else if(objet.style.display == "block")
	{
		
		var hFinal      =   0;  //Hauteur finale (la hauteur une fois que ça aura fini de déplier !)
        var hActuel     =   height_ar[id];	 	//Hauteur initiale (la hauteur dès le début !) 
        var timer;
        objet_contenu.style.visibility = "hidden";
        var fct =        function ()
        {
                hActuel  -=   20;     //Augmente la hauteur de -20px (tu peux modifier) tous les 40ms !	   
				if (hActuel<20)
				   objet.style.height		= '0px'; 
				else
                	objet.style.height		= hActuel + 'px'; 	
					
                if( hActuel < hFinal)
                {
                        objet.style.display     =   "none";
						clearInterval(timer);   //Arrête le timer  
						return false;			
						
                }
        };
        fct();
		timer = setInterval(fct,40);    //Toute les 40 ms
		//lien.innerHTML = "+";
	}
}

//ajax ?!
function topsendData(param, page,div)
{	 
	var content = top.document.getElementById(""+div+"");
	if(content) 
		content.innerHTML = "<br><br><center><img src='./image/ajax-loader.gif'></center>";
	
	if(window.ActiveXObject)
	{
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
		XhrObj.onreadystatechange = function()
		{
			if (XhrObj.readyState == 4 && XhrObj.status == 200)
				if (content)
					content.innerHTML = XhrObj.responseText ; 	
		}	
		XhrObj.open("POST", page, true);
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XhrObj.send(param);			
	}//fin if
	else  if(window.XMLHttpRequest)
	{
	    //Mozilla
		var XhrObj = new XMLHttpRequest();	
		XhrObj.open("POST", page, false);
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XhrObj.send(param);	
		if (XhrObj.readyState == 4 && XhrObj.status == 200) {
			if(content) {
				content.innerHTML = XhrObj.responseText; 
				//longueur=content.innerHTML.length
			}
		}		
	}
	//fin else
}

function sendData(param, page,div)
{	 
	var content = document.getElementById(""+div+"");
	if(content) 
	content.innerHTML = "<br><br><center><img src='./image/ajax-loader.gif'></center>";
	
	if(window.ActiveXObject)
	{
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
		XhrObj.onreadystatechange = function()
		{
			if (XhrObj.readyState == 4 && XhrObj.status == 200)
				if (content)
					content.innerHTML = XhrObj.responseText ; 	
		}	
		XhrObj.open("POST", page, true);
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XhrObj.send(param);			
	}//fin if
	else  if(window.XMLHttpRequest)
	{
	    //Mozilla
		var XhrObj = new XMLHttpRequest();	
		XhrObj.open("POST", page, false);
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XhrObj.send(param);	
		if (XhrObj.readyState == 4 && XhrObj.status == 200) {
			if(content) {
				content.innerHTML = XhrObj.responseText; 
				//longueur=content.innerHTML.length
			}
		}		
	}
	//fin else
}

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

function send_page() {
	document.forms['add'].hiddenbody.value = visu.document.getElementById("entourage").innerHTML;
	document.forms['add'].submit();
}

function OuvrirPopup(page,nom,hauteur,largeur,option) { 
	var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;		
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+option);
} 

function emptyValue (elem, value) {
	if (elem.value == value) {
		elem.value = '';
	}
}

//FONCTION WYSIWYG
//init variables
var isRichText = false;
var rng;
var currentRTE;


function initRTE() {
	//check to see if designMode mode is available
	if (document.getElementById) {
		if (document.all) {
			//check for internet explorer 5.5+
			if (document.URLUnencoded) isRichText = true;
		} else {
			//check for browsers that support designmode
			if (document.designMode) isRichText = true;
		}
	}
}

function writeRichText(rte, html, width, height, buttons) {
	if (isRichText) {
		writeRTE(rte, html, width, height, buttons);
	} else {
		writeDefault(rte, html, width, height, buttons);
	}
}

function writeDefault(rte, html, width, height, buttons) {
	document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;">' + html + '</textarea>');
}

function writeRTE(rte, html, width, height, buttons) {
	if (buttons == true) {
		document.writeln('<style type="text/css">');
		document.writeln('.btnImage {cursor: pointer; cursor: hand;}');
		document.writeln('</style>');
		document.writeln('<table id="Buttons1_' + rte + '">');
		document.writeln('	<tr>');
		document.writeln('		<td>');
		document.writeln('			<select id="formatblock" onchange="Select(\'' + rte + '\', this.id);" class="input">');
		document.writeln('				<option value="<font>">Normal</option>');
		document.writeln('				<option value="<p>">Paragraph</option>');
		document.writeln('				<option value="<h1>">Heading 1 <h1></option>');
		document.writeln('				<option value="<h2>">Heading 2 <h2></option>');
		document.writeln('				<option value="<h3>">Heading 3 <h3></option>');
		document.writeln('				<option value="<h4>">Heading 4 <h4></option>');
		document.writeln('				<option value="<h5>">Heading 5 <h5></option>');
		document.writeln('				<option value="<h6>">Heading 6 <h6></option>');
		document.writeln('				<option value="<address>">Address <ADDR></option>');
		document.writeln('				<option value="<pre>">Formatted <pre></option>');
		document.writeln('			</select>');
		document.writeln('		</td>'); 
		document.writeln('	</tr>');
		document.writeln('</table>');
		
		document.writeln('<table id="Buttons2_' + rte + '" cellpadding="1" cellspacing="0">');
		document.writeln('	<tr>');
		document.writeln('		<td><img class="btnImage" src="image/bold.gif" width="25" height="24" alt="Bold" title="Bold" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/italic.gif" width="25" height="24" alt="Italic" title="Italic" onClick="FormatText(\'' + rte + '\', \'italic\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/underline.gif" width="25" height="24" alt="Underline" title="Underline" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/strike.gif" width="25" height="24" alt="Underline" title="Underline" onClick="FormatText(\'' + rte + '\', \'StrikeThrough\', \'\')"></td>');		
		document.writeln('		<td>&nbsp;</td>');
		document.writeln('		<td><img class="btnImage" src="image/justifyleft.gif" width="25" height="24" alt="Align Left" title="Align Left" onClick="FormatText(\'' + rte + '\', \'justifyleft\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/justifycenter.gif" width="25" height="24" alt="Center" title="Center" onClick="FormatText(\'' + rte + '\', \'justifycenter\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/justifyright.gif" width="25" height="24" alt="Align Right" title="Align Right" onClick="FormatText(\'' + rte + '\', \'justifyright\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/justifyfull.gif" width="25" height="24" alt="Justify Full" title="Justify Full" onclick="FormatText(\'' + rte + '\', \'justifyfull\', \'\')"></td>');		
		document.writeln('		<td>&nbsp;</td>');
		document.writeln('		<td><img class="btnImage" src="image/hr.gif" width="25" height="24" alt="Horizontal Rule" title="Horizontal Rule" onClick="FormatText(\'' + rte + '\', \'inserthorizontalrule\', \'\')"></td>');		
		document.writeln('		<td><img class="btnImage" src="image/orderedlist.gif" width="25" height="24" alt="Ordered List" title="Ordered List" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/unorderedlist.gif" width="25" height="24" alt="Unordered List" title="Unordered List" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"></td>');
		document.writeln('		<td>&nbsp;</td>');
		document.writeln('		<td><img class="btnImage" src="image/outdent.gif" width="25" height="24" alt="Outdent" title="Outdent" onClick="FormatText(\'' + rte + '\', \'outdent\', \'\')"></td>');
		document.writeln('		<td><img class="btnImage" src="image/indent.gif" width="25" height="24" alt="Indent" title="Indent" onClick="FormatText(\'' + rte + '\', \'indent\', \'\')"></td>');
//		document.writeln('		<td><div id="forecolor"><img class="btnImage" src="image/forecolor.gif" width="25" height="24" alt="Text Color" title="Text Color" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"></div></td>');
//		document.writeln('		<td><div id="hilitecolor"><img class="btnImage" src="image/backcolor.gif" width="25" height="24" alt="Background Color" title="Background Color" onClick="FormatText(\'' + rte + '\', \'hilitecolor\', \'\')"></div></td>');
		document.writeln('		<td>&nbsp;</td>');
		document.writeln('		<td><img class="btnImage" src="image/link.gif" width="25" height="24" alt="Insert Link" title="Insert Link" onClick="FormatText(\'' + rte + '\', \'createlink\',\'\')"></td>');
//		document.writeln('		<td><img class="btnImage" src="image/link.gif" width="25" height="24" alt="Add Image" title="Add Application" onClick=\'OuvrirPopup("see_multimedia.php?type=application&myidsession=' + myidsession + '","image", "640", "480","menubar=no, status=no, scrollbars=yes, menubar=no, resizable=no, location=no");return false;\'></td>');								
//		
//		document.writeln('		<td><img class="btnImage" src="image/image.gif" width="25" height="24" alt="Add Image" title="Add Image" onClick="AddImage(\'' + rte + '\')"></td>');
//		if (document.all) document.writeln('		<td><img class="btnImage" src="image/spellcheck.gif" width="25" height="24" alt="Add Image" title="Add Image" onClick="checkspell()"></td>');
//		document.writeln('		<td>&nbsp;</td>');
//		document.writeln('		<td><img class="btnImage" src="image/post_button_cut.gif" width="25" height="24" alt="Cut" title="Cut" onClick="FormatText(\'' + rte + '\', \'cut\')"></td>');
//		document.writeln('		<td><img class="btnImage" src="image/post_button_copy.gif" width="25" height="24" alt="Copy" title="Copy" onClick="FormatText(\'' + rte + '\', \'copy\')"></td>');
//		document.writeln('		<td><img class="btnImage" src="image/post_button_paste.gif" width="25" height="24" alt="Paste" title="Paste" onClick="FormatText(\'' + rte + '\', \'paste\')"></td>');
//		document.writeln('		<td>&nbsp;</td>');
//		document.writeln('		<td><img class="btnImage" src="image/post_button_undo.gif" width="25" height="24" alt="Undo" title="Undo" onClick="FormatText(\'' + rte + '\', \'undo\')"></td>');
//		document.writeln('		<td><img class="btnImage" src="image/post_button_redo.gif" width="25" height="24" alt="Redo" title="Redo" onClick="FormatText(\'' + rte + '\', \'redo\')"></td>');
		document.writeln('	</tr>');
		document.writeln('</table>');
	}
	document.writeln('<iframe id="' + rte + '" width="' + width + 'px" height="' + height + 'px" src="blank.htm""></iframe>');
//	document.writeln('<br /><input type="checkbox" id="chkSrc' + rte + '" onclick="toggleHTMLSrc(\'' + rte + '\');" />&nbsp;Mode HTML');
//	document.writeln('<iframe width="500" height="300" id="cp' + rte + '" src="palette.php" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; position: absolute;"></iframe>');
	document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + rte + '" value="">');
	document.getElementById('hdn' + rte).value = html;
	setTimeout('enableDesignMode(\'' + rte + '\', \'' + html + '\')', 250);
}

function enableDesignMode(rte, html) {
	if (document.all) {
		frames[rte].document.open();
		frames[rte].document.write(html);
		frames[rte].document.close();
		frames[rte].document.designMode = "On";
	}
	else {
		var updateHTML = "document.getElementById('" + rte + "').contentWindow.document.body.innerHTML = '" + html + "';";
		setTimeout(updateHTML + "document.getElementById('" + rte + "').contentDocument.designMode = 'On';", 500);
		//attach a keyboard handler for Mozilla to make keyboard shortcuts for formatting text work
		document.getElementById(rte).contentWindow.document.addEventListener("keypress", kb_handler, true);
	}
}

function updateRTE(rte) {
	//set message value
	var oHdnMessage = document.getElementById('hdn' + rte);
	var oMessageFrame = document.getElementById(rte);
	
	if (isRichText) {
		if (oHdnMessage.value == null) oHdnMessage.value = "";
		oHdnMessage.value = oMessageFrame.contentWindow.document.body.innerHTML;
		//exception for Mozilla
		if (oHdnMessage.value.indexOf('<br>') > -1 && oHdnMessage.value.length == 8) oHdnMessage.value = "";
	}
}

function toggleHTMLSrc(rte) {
	//contributed by Bob Hutzel (thanks Bob!)
	var doc = document.getElementById(rte).contentWindow.document;
	
	if (document.getElementById("chkSrc" + rte).checked) {
	
		document.getElementById("Buttons1_" + rte).style.visibility = "hidden";
		document.getElementById("Buttons2_" + rte).style.visibility = "hidden";
		if (document.all) {
			doc.body.innerText = doc.body.innerHTML;
		} else {
			var htmlSrc = doc.createTextNode(doc.body.innerHTML);
			doc.body.innerHTML = "";
			doc.body.appendChild(htmlSrc);
		}

	} else {
		document.getElementById("Buttons1_" + rte).style.visibility = "visible";
		document.getElementById("Buttons2_" + rte).style.visibility = "visible";
		if (document.all) {
			doc.body.innerHTML = doc.body.innerText;
		} else {
			var htmlSrc = doc.body.ownerDocument.createRange();
			htmlSrc.selectNodeContents(doc.body);
			doc.body.innerHTML = htmlSrc.toString();
		}
	}
}	 



//Function to format text in the text box
function FormatText(rte, command, option) {
	if ((command == "forecolor") || (command == "hilitecolor")) {
		parent.command = command;
		buttonElement = document.getElementById(command);
		document.getElementById('cp' + rte).style.left = getOffsetLeft(buttonElement) + "px";
		document.getElementById('cp' + rte).style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
		if (document.getElementById('cp' + rte).style.visibility == "hidden")
			document.getElementById('cp' + rte).style.visibility="visible";
		else {
			document.getElementById('cp' + rte).style.visibility="hidden";
		}
		
		//get current selected rte
		currentRTE = rte;
		
		//get current selected range
		var sel = document.getElementById(rte).contentWindow.document.selection; 
		if (sel!=null) {
			rng = sel.createRange();
		}
	}
	else if (command == "createlink") { // && browser.isIE55up == false
		var szURL = prompt("Enter a URL:", "Http://"+option);
		document.getElementById(rte).contentWindow.document.execCommand("Unlink",false,null);
		document.getElementById(rte).contentWindow.document.execCommand("CreateLink",false,szURL);
	}
	else if (command == "createlinkapp") { // && browser.isIE55up == false
		var szURL = option
		document.getElementById(rte).contentWindow.document.execCommand("Unlink",false,null);
		document.getElementById(rte).contentWindow.document.execCommand("CreateLink",false,szURL);
	}	
	else {
		document.getElementById(rte).contentWindow.focus();
	  	document.getElementById(rte).contentWindow.document.execCommand(command, false, option);
		document.getElementById(rte).contentWindow.focus();
	}
}
//Function to add image
function AddImage(rte,url) {
	imagePath = url;				
	if ((imagePath != null) && (imagePath != "")) {
		document.getElementById(rte).contentWindow.focus();
		document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath);
	}
	document.getElementById(rte).contentWindow.focus();
}
//Function to set color
function setColor(color) {
	var parentCommand = parent.command;
	var rte = currentRTE;
	
	if (document.all) {
		//retrieve selected range
		var sel = document.getElementById(rte).contentWindow.document.selection; 
		if (parentCommand == "hilitecolor") parentCommand = "backcolor";
		if (sel!=null) {
			var newRng = sel.createRange();
			newRng = rng;
			newRng.select();
		}
	}
	else {
		document.getElementById(rte).contentWindow.focus();
	}
	document.getElementById(rte).contentWindow.document.execCommand(parentCommand, false, color);
	document.getElementById(rte).contentWindow.focus();
	document.getElementById('cp' + rte).style.visibility="hidden";
}



//function to perform spell check
function checkspell() {
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		tmpis.CheckAllLinkedDocuments(document);
	}
	catch(exception) {
		if(exception.number==-2146827859) {
			if (confirm("ieSpell not detected.  Click Ok to go to download page."))
				window.open("http://www.iespell.com/download.php","DownLoad");
		}
		else
			alert("Error Loading ieSpell: Exception " + exception.number);
	}
}

function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	
	return mOffsetTop;
}

function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	
	return mOffsetLeft;
}

function Select(rte, selectname)
{
	var cursel = document.getElementById(selectname).selectedIndex;
	// First one is always a label
	if (cursel != 0) {
		var selected = document.getElementById(selectname).options[cursel].value;
		document.getElementById(rte).contentWindow.document.execCommand(selectname, false, selected);
		document.getElementById(selectname).selectedIndex = 0;
	}
	document.getElementById(rte).contentWindow.focus();
}

function kb_handler(evt, rte) {
	//contributed by Anti Veeranna (thanks Anti!)
	if (evt.ctrlKey) {
		var key = String.fromCharCode(evt.charCode).toLowerCase();
		var cmd = '';
		switch (key) {
			case 'b': cmd = "bold"; break;
			case 'i': cmd = "italic"; break;
			case 'u': cmd = "underline"; break;
		};

		if (cmd) {
			evt.target.ownerDocument.execCommand(cmd,false,true);
			// stop the event bubble
			evt.preventDefault();
			evt.stopPropagation();
		}
 	}
}

initRTE();


function check_date(ladate)
{
reg = /[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4,4}/

 if (ladate.match(reg))
 {
 
 d = ladate.substring(0, ladate.indexOf("/"));
 rest = ladate.substring(ladate.indexOf("/") + 1, 100);
 m = rest.substring(0, rest.indexOf("/"));
 y = rest.substring(rest.indexOf("/") + 1, 100);
  if (d==""&&m==""&&y=="")return 0;
 	else if (d>0&&d<=31&&m>0&&m<=12&&y>0){if (m==4||m==6||m==9||m==11)
 if (d!=31) return 1; else return -1;
 	else if (m!=2) return 1; else{if (d<=28) return 1;
		 else if (d==29){if (y%4==0)if (y%400==0||y%100!=0) return 1;
 			else return -1; else return -1; }else return -1;} }else return -1;
			
 }
	else
	{
	return -1;  
	}

}

//Check le formulaire pour ajouter des editos
function checkedito(f) {
	StrMessage = "";
	f.hiddenbody.value = document.getElementById('contenudiv').contentWindow.document.body.innerHTML;
	if (f.titre_ev)
		if (f.titre_ev.value == "")
			StrMessage += "• Indiquez un titre.\n";			
	if (f.date_ev)
		if (check_date(f.date_ev.value) != 1)
			StrMessage += "• Date non valide.\n";
	if (f.elements['categorie_id'].options[f.elements['categorie_id'].selectedIndex].value==0)
		StrMessage += "• Met une catégorie connard ! et la bonne de préference !.\n";		
	if (f.hiddenbody)			
	   if (f.hiddenbody.value == "")
		  StrMessage += "• Indiquez un message.\n";
		
	if (StrMessage.length)	{
		alert("Erreur :\n" + StrMessage);
		return false;
	} else 	{
		f.Envoi.style.visibility='hidden';	
		Info.innerHTML = '<br><font class="tinytext"><div align="center"><b>Envoie en cours. Patientez...<br></b>';
		return true;	
	}	 				
}
function checkgalleryv(f) {
	StrMessage = "";
	f.hiddenbody.value = document.getElementById('contenudiv').contentWindow.document.body.innerHTML;
	if (f.titre_gvc)
		if (f.titre_gvc.value == "")
			StrMessage += "• Indiquez un titre.\n";			
	if (f.date_gvc)
		if (check_date(f.date_gvc.value) != 1)
			StrMessage += "• Date non valide.\n";
	if (f.hiddenbody)			
	   if (f.hiddenbody.value == "")
		  StrMessage += "• Indiquez un message.\n";
		
	if (StrMessage.length)	{
		alert("Erreur :\n" + StrMessage);
		return false;
	} else 	{
		f.Envoi.style.visibility='hidden';	
		Info.innerHTML = '<br><font class="tinytext"><div align="center"><b>Envoie en cours. Patientez...<br></b>';
		//alert(f.hiddenbody.value);
		return true;	
	}	 				
}

function checkgallerya(f) {
	StrMessage = "";
	if (f.titre_gar)
		if (f.titre_gar.value == "")
			StrMessage += "• Indiquez un titre.\n";			
	if (f.date_gar)
		if (check_date(f.date_gar.value) != 1)
			StrMessage += "• Date non valide.\n";
		
	if (StrMessage.length)	{
		alert("Erreur :\n" + StrMessage);
		return false;
	} else 	{
		f.Envoi.style.visibility='hidden';	
		Info.innerHTML = '<br><font class="tinytext"><div align="center"><b>Envoie en cours. Patientez...<br></b>';
		//alert(f.hiddenbody.value);
		return true;	
	}	 				
}
   

function check_conversion_video() {
	sendData('p=bib_conv_file','./ajax/ajax_loader.ajx.php','file_traitement');
	setTimeout('check_conversion_video()',30000);	
} 		  



//jeux
var magicsymbol = 0;
var commonsymbol = 0;
var innertext = '';
var symbols = new Array('A','C','D','F','G','H','J','K','M','P','R','S','T','W','X','Z','#','^','_','[',']','{','}','&sect;','&copy;','&reg;','&#8364;','&pound;','&yen;','&aelig;','&Oslash;','&para;','&#338;','&szlig;');
function makeSymbolTable() {
	magicsymbol = Math.round(Math.random()*33);
	innertext = '<table id="symboltable" style="margin: 1 auto; border: 1px dotted #c0c0c0;border-collapse:collapse" border="1" bordercolor="#c0c0c0">';
	for (var i = 0; i < 100; i++) {
		if ((i + 1)%10 == 1) {
			innertext += '<tr>';
		}
		commonsymbol = Math.round(Math.random()*33);
		if (i%9 == 0 && i < 89) {
			commonsymbol = magicsymbol;
		}
		innertext += '<td class="tinytext" align="center">&nbsp;&nbsp;<b>'+i+'</b></td><td class="tinytext" align="center">'+symbols[commonsymbol]+'&nbsp;&nbsp;</td>';
		if ((i + 1)%10 == 0) {
			innertext += '</tr>';
		}
	}
	innertext += '</table>';
	document.getElementById('symboltablecontener').innerHTML = innertext;
	document.getElementById('button').innerHTML = '';
}
function showAnswer() {
	document.getElementById('button').innerHTML = symbols[magicsymbol];
	document.getElementById('symboltablecontener').innerHTML = '<a href="#" onclick="javascript:makeSymbolTable(); return(false);" style="font-family: Arial, sans-serif; font-weight: bold; color: #C63;">Réessayer</a>';
}
//fin jeux

//scrooll
var loop;
var direction;
var speed;	
var scrolltimer;
var where;
function verScroll(dir, spd, who) {	
	
	loop = true;
	direction = "up";
	speed = 5;
	
	scrolltimer = null;	 	
	direction = dir;
	speed = parseInt(spd);
	where = who;
	var y_pos = parseInt(document.getElementById(who).scrollTop);
	
	if (loop == true) 
	{
	 
	   if (direction == "dn") 
		  document.getElementById(who).scrollTop = (y_pos + (speed));
	   else  if (direction == "up" && y_pos > 0) 
	  	   	 document.getElementById(who).scrollTop = (y_pos - (speed));
	   scrolltimer = setTimeout("verScroll(direction,speed,where)", 2);	   
	}	  
}	   



function stopScroll() {
	 loop = false;
	 clearTimeout(scrolltimer);
}


function setVote(id,n) {
  sendData('p=vote_article&id_ev='+id+'&note='+n,'./ajax/ajax_loader.ajx.php','etoile');

}


function chooseVote(id) {
	myResult = id.split("-");	
	for (var i = 0; i<=myResult[1]; i++) {		
		if (document.getElementById('vote-'+i)) { document.getElementById('vote-'+i).src='./image/vote_sel.png'; }
		else if (document.getElementById('novote-'+i)) { document.getElementById('novote-'+i).src='./image/vote_sel.png'; }   
	}  
	/*
	j=myResult[1];
	j++;
	for (var i=j; i<=10;i++) {			   
		if (document.getElementById(myResult[0]+'-'+i)) {document.getElementById(myResult[0]+'-'+i).src='./image/vote_off.png';}
	}	 
	*/

}

function initVote(s) {
	for (var i=s; i>=0;i--) {	

		if (document.getElementById('vote-'+i)) { document.getElementById('vote-'+i).src='./image/vote_on.png'; }
		else if (document.getElementById('novote-'+i)) { document.getElementById('novote-'+i).src='./image/vote_off.png'; }	 

	}
}  

function settags(f) {	
	if (f.elements["tags_list_ev"].value.length > 0)
		f.elements["tags_list_ev"].value=f.elements["tags_list_ev"].value+", "+f.elements['tags_id'].options[f.elements['tags_id'].selectedIndex].value;
	else
	   f.elements["tags_list_ev"].value=f.elements['tags_id'].options[f.elements['tags_id'].selectedIndex].value;	 

}	

function setAlert(id) {
  sendData('p=alert_article&id_ev='+id,'./ajax/ajax_loader.ajx.php','alertMod');

}		 

// <![CDATA[
function fixed_back(select,offX,offY){
	if (offX.lastIndexOf("%") != -1){
		var img = new Image();
		img.src = select.currentStyle.backgroundImage.substring(5,Number(select.currentStyle.backgroundImage.length-2));
		var tempX = Number(offX.substring(0,offX.lastIndexOf("%")));
		tempX = Number((((document.documentElement.clientWidth-img.width)*tempX)/100)+document.documentElement.scrollLeft-select.offsetLeft)+'px';
	} else {
		var tempX = Number(offX.split("px")[0]);
		tempX = Number(tempX+document.documentElement.scrollLeft-select.offsetLeft)+'px';
	}
	if (offY.lastIndexOf("%") != -1){
		var img = new Image();
		img.src = select.currentStyle.backgroundImage.substring(5,Number(select.currentStyle.backgroundImage.length-2));
		var tempY = Number(offY.substring(0,offY.lastIndexOf("%")));
		tempY = Number((((document.documentElement.clientHeight-img.height)*tempY)/100)+document.documentElement.scrollTop-select.offsetTop)+'px';
	} else {
		var tempY = Number(offY.split("px")[0]);
		tempY = Number(tempY+document.documentElement.scrollTop-select.offsetTop)+'px';
	}
	return tempX+' '+tempY;
}
// ]]>
