// Document JavaScript de Koora.com
// CopyRight (c) 2008 MEA EQUINOXES


function affichebloc(div) {
if (div=='affiche1'){
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('etranger').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
}
else if (div=='National') {
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('etranger').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
}
else if (div=='etranger') {
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
}
else if (div=='afficheresult') {
document.getElementById('afficheresult').style.display='block';
document.getElementById('afficheclassement').style.display='none';
document.getElementById('resultats').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active2.gif)";
document.getElementById('classement').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive2.gif)";
}
else if (div=='afficheclassement') {
document.getElementById('afficheresult').style.display='none';
document.getElementById('afficheclassement').style.display='block';
document.getElementById('resultats').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive2.gif)";
document.getElementById('classement').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active2.gif)";
}
}
function affichebloc222(div) {

if (div=='affiche1') {
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('etranger').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('blocaffiche').className = "affiche-content";
document.getElementById('blocNational').className = "affiche-content hidden";
document.getElementById('blocetranger').className = "affiche-content hidden";
}
else if (div=='National') {
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('etranger').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('blocaffiche').className = "affiche-content hidden";
document.getElementById('blocNational').className = "affiche-content ";
document.getElementById('blocetranger').className = "affiche-content hidden";

}
else if (div=='etranger') {
document.getElementById('affiche').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('National').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('etranger').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('blocaffiche').className = "affiche-content hidden";
document.getElementById('blocNational').className = "affiche-content hidden";
document.getElementById('blocetranger').className = "affiche-content ";

}
else if (div=='afficheresult') {
document.getElementById('afficheresult').style.display='block';
document.getElementById('afficheclassement').style.display='none';
document.getElementById('resultats').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active2.gif)";
document.getElementById('classement').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive2.gif)";
}
else if (div=='afficheclassement') {
document.getElementById('afficheresult').style.display='none';
document.getElementById('afficheclassement').style.display='block';
document.getElementById('resultats').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive2.gif)";
document.getElementById('classement').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active2.gif)";
}
}


function accordion(div) {
if (div=='tag') {
document.getElementById('tag').style.display='block';
document.getElementById('comments').style.display='none';
document.getElementById('minutes').style.display='none';
document.getElementById('tagtag').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('tabcomment').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('tabminutes').style.backgroundImage = "url(../Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
}
if (div=='comments') {
document.getElementById('comments').style.display='block';
document.getElementById('tabcomment').style.borderTop = "1px solid #fff";
//document.getElementById('tag').style.display='none';
document.getElementById('minutes').style.display='none';
document.getElementById('tabcomment').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
document.getElementById('tagtag').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('tabminutes').style.backgroundImage = "url(../Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
}
if (div=='minutes') {
document.getElementById('minutes').style.display='block';
//document.getElementById('tag').style.display='none';
//document.getElementById('comments').style.display='none';
document.getElementById('tabminutes').style.backgroundImage = "url(../Channels/bewtunisie/Templates/koora/images/bg-affiche-active.gif)";
//document.getElementById('tagtag').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
//document.getElementById('tabcomment').style.backgroundImage = "url(Channels/bewtunisie/Templates/koora/images/bg-affiche-inactive.gif)";
document.getElementById('minutes').style.borderBottom = "1px solid #70D426";
}
}

function changecolor(div) {
document.getElementById(div).style.border="1px solid #FFF";
document.getElementById(div).style.background="#90A80B";
}

function changecolor2(div) {
document.getElementById(div).style.border="1px solid #666561";
document.getElementById(div).style.background="#53524F";
}


function new_xhr(){
	var xhr_object = null;
	if(window.XMLHttpRequest) // Firefox et autres
	   xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject){ // Internet Explorer
	   try {
                xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
            }
	}
	else { // XMLHttpRequest non supporté par le navigateur
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	   xhr_object = false;
	}
	return xhr_object;
}
/*****************************************************
	Fonction qui va recharger le contenu
******************************************************/
function load_page(select) {
	var xhr2 = new_xhr();//On cr?e un nouvel objet XMLHttpRequest
	xhr2.onreadystatechange = function(){
		if ( xhr2.readyState == 4 ){//Actions execut?es une fois le chargement fini
			if(xhr2.status  != 200){//Message si il se preoduit une erreur
				document.getElementById("content-club").innerHTML ="Error code " + xhr2.status;
			} else {//On met le contenu du fichier externe dans la div "content"
				function bla () {
					document.getElementById("content-club").innerHTML = xhr2.responseText;
				}
				setTimeout(bla,1000);
			}
		} else {//Message affich? pendant le chargement
			document.getElementById("content-club").innerHTML = "<img class='loadingajaxmeteo' title='loading' src='Channels/bewtunisie/Templates/koora/images/loader.gif' alt=''/>";
		}
	}
	xhr2.open("GET", select.split('?')[1]+".html", true);//Appel du fichier externe
	xhr2.send(null);
}

function load_page2(select) {
	var xhr2 = new_xhr();//On cr?e un nouvel objet XMLHttpRequest
	xhr2.onreadystatechange = function(){
		if ( xhr2.readyState == 4 ){//Actions execut?es une fois le chargement fini
			if(xhr2.status  != 200){//Message si il se preoduit une erreur
				document.getElementById("content-static").innerHTML ="Error code " + xhr2.status;
			} else {//On met le contenu du fichier externe dans la div "content"
				function bla () {
					document.getElementById("content-static").innerHTML = xhr2.responseText;
				}
				setTimeout(bla,1000);
			}
		} else {//Message affich? pendant le chargement
			document.getElementById("content-static").innerHTML = "<img class='loadingajax' title='loading' src='Channels/bewtunisie/Templates/koora/images/loader2.gif' alt=''/>";
		}
	}
	xhr2.open("GET", select.split('?')[1]+".html", true);//Appel du fichier externe
	xhr2.send(null);
}

function affichebloc2(div) {
document.getElementById('hideclub').style.display="block";
document.getElementById('clubs').style.display="none";

}

function fermer(div) {
document.getElementById('hideclub').style.display="none";
document.getElementById('clubs').style.display="block";
document.getElementById('content-club').innerHTML ="<img class='loadingajax2' title='loading' src='Channels/bewtunisie/Templates/koora/images/loader.gif' alt=''/>";

}

function affichebloc3(div) {
document.getElementById('hidestatic').style.display="block";
}

function affichebloc3(div) {
document.getElementById('hidestatic').style.display="block";
}

function selectmoteur(div) {
document.getElementById(div).style.display="none";
}


function display(div) {
document.getElementById(div).style.display=document.getElementById(div).style.display=="block"?"none":"block";
}


function fadeIn(objId,opacity) {
	if (document.getElementById) {
		//obj = document.getElementById(objId);
		//alert(obj);
		if (opacity <= 100) {
			setOpacity(objId, opacity);
			opacity += 5;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
		}
	}
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	document.getElementById(obj).style.filter = "alpha(opacity="+opacity+")";
	// Safari<1.2, Konqueror
	document.getElementById(obj).style.KHTMLOpacity = opacity/50;
	// Older Mozilla and Firefox
	document.getElementById(obj).style.MozOpacity = opacity/50;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	document.getElementById(obj).style.opacity = opacity/50;
}


function goclubs(bloc) {
if (bloc=='bloc1') {
document.getElementById('bloc1').style.display='none';
document.getElementById('bloc2').style.display='block';
document.getElementById('bloc3').style.display='none';
fadeIn(bloc,0); setOpacity(bloc, 0);
}
if (bloc=='bloc2') {
document.getElementById('bloc1').style.display='block';
document.getElementById('bloc2').style.display='none';
document.getElementById('bloc3').style.display='none';
fadeIn(bloc,0); setOpacity(bloc, 0);
}
if (bloc=='bloc3') {
document.getElementById('bloc1').style.display='none';
document.getElementById('bloc2').style.display='none';
document.getElementById('bloc3').style.display='block';
fadeIn(bloc,0); setOpacity(bloc, 0);
}
}


var t;			
	t = 13;
	function changerTaille(modif) {
		t = t + modif;
		document.getElementById('Show_div').style.fontSize = t + "px";		
	} 	



function affichselect(texte) {
if (texte=='foot') {
document.getElementById('foot-s').style.display='block';
document.getElementById('all-s').style.display='none';
document.getElementById('autres-s').style.display='none';
document.getElementById('euro-s').style.display='none';
document.getElementById('garros-s').style.display='none';
}
else if (texte=='all') {
document.getElementById('foot-s').style.display='none';
document.getElementById('all-s').style.display='block';
document.getElementById('autres-s').style.display='none';
document.getElementById('euro-s').style.display='none';
document.getElementById('garros-s').style.display='none';
}
else if (texte=='autres') {
document.getElementById('foot-s').style.display='none';
document.getElementById('all-s').style.display='none';
document.getElementById('autres-s').style.display='block';
document.getElementById('euro-s').style.display='none';
document.getElementById('garros-s').style.display='none';
}
else if (texte=='euro') {
document.getElementById('foot-s').style.display='none';
document.getElementById('all-s').style.display='none';
document.getElementById('autres-s').style.display='none';
document.getElementById('euro-s').style.display='block';
document.getElementById('garros-s').style.display='none';
}
else if (texte=='garros') {
document.getElementById('foot-s').style.display='none';
document.getElementById('all-s').style.display='none';
document.getElementById('autres-s').style.display='none';
document.getElementById('euro-s').style.display='none';
document.getElementById('garros-s').style.display='block';
}
}


function pop_it(the_form) {
   my_form = eval(the_form)
   window.open("", "popup", "height=250,width=400,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
   my_form.target = "popup";
   my_form.submit();
}

function openpopup()
{
w = window.open("", "popup", "height=250,width=400,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
w.focus();
document.forms['contactform'].target = 'popup';
}


function closecontact() {
document.getElementById('interne').style.display='none';
}




// Document JavaScript de Koora.com
// CopyRight (c) 2008 MEA EQUINOXES
function getrefparent(id){
	var div = "";
	//alert(id);
	div = document.getElementById('lireart').innerHTML ;
		switch (id){
		case 171: 
			div = 'Football >> ' + div;
			document.getElementById('foot').className = 'foot1';	
		break;
		case 172: 
			div = 'Handball >> ' + div;
			document.getElementById('all').className = 'all1';	

		break;
		case 173: 
			div = 'Euro 2008 >> ' + div;
			document.getElementById('even1').className = 'euro1';
		break;
		case 174: 
			div = 'Roland Garros >> ' + div;
			document.getElementById('even2').className = 'garos1';
		break;
		case 175: 
			div = 'Autre sport >> ' + div;
			document.getElementById('autres').className = 'autres1';
		break;
}
document.getElementById('lireart').innerHTML  = div;
}
function Firstarticle(){
	document.getElementById('articleGd1-1').className = 'affiche-content-center';	
}
function changearticle(selecteddiv,id){
	
		switch (selecteddiv.id){
		case 'article1-'+id: 
				document.getElementById('articleGd1-'+id).className = 'affiche-content-center';	
				document.getElementById('articleGd2-'+id).className = 'affiche-content-centerP';	
				document.getElementById('articleGd3-'+id).className = 'affiche-content-centerP';	
		break;
		case 'article2-'+id: 
				document.getElementById('articleGd1-'+id).className = 'affiche-content-centerP';	
				document.getElementById('articleGd2-'+id).className = 'affiche-content-center';	
				document.getElementById('articleGd3-'+id).className = 'affiche-content-centerP';	
			break;
		case 'article3-'+id: 
				document.getElementById('articleGd1-'+id).className = 'affiche-content-centerP';	
				document.getElementById('articleGd2-'+id).className = 'affiche-content-centerP';	
				document.getElementById('articleGd3-'+id).className = 'affiche-content-center';	
		break;
		default :
				document.getElementById('articleGd1-'+id).className = 'affiche-content-center';	
				document.getElementById('articleGd2-'+id).className = 'affiche-content-centerP';	
				document.getElementById('articleGd3-'+id).className = 'affiche-content-centerP';	
		break;
	}
}
function changearticlnews(selecteddiv,id){
	
		switch (selecteddiv.id){
		case 'article1-'+id: 
				document.getElementById('articleGd1-'+id).className = 'actu-gd1';	
				document.getElementById('articleGd2-'+id).className = 'actu-gd';	
				document.getElementById('articleGd3-'+id).className = 'actu-gd';	
		break;
		case 'article2-'+id: 
				document.getElementById('articleGd1-'+id).className = 'actu-gd';	
				document.getElementById('articleGd2-'+id).className = 'actu-gd1';	
				document.getElementById('articleGd3-'+id).className = 'actu-gd';	
			break;
		case 'article3-'+id: 
				document.getElementById('articleGd1-'+id).className = 'actu-gd';	
				document.getElementById('articleGd2-'+id).className = 'actu-gd';	
				document.getElementById('articleGd3-'+id).className = 'actu-gd1';	
		break;
		default :
				document.getElementById('articleGd1-'+id).className = 'actu-gd1';	
				document.getElementById('articleGd2-'+id).className = 'actu-gd';	
				document.getElementById('articleGd3-'+id).className = 'actu-gd';	
		break;
	}
}
function widgetpicture(selecteddiv){
		switch (selecteddiv.id){
		case 'picture1': 
				document.getElementById('picture1P').className = 'viewer';	
				document.getElementById('picture2P').className = 'hidden';	
				document.getElementById('picture3P').className = 'hidden';	
				document.getElementById('picture4P').className = 'hidden';	
		break;
		case 'picture2': 
				document.getElementById('picture1P').className = 'hidden';	
				document.getElementById('picture2P').className = 'viewer';	
				document.getElementById('picture3P').className = 'hidden';	
				document.getElementById('picture4P').className = 'hidden';	
		break;
		case 'picture3': 
				document.getElementById('picture1P').className = 'hidden';	
				document.getElementById('picture2P').className = 'hidden';	
				document.getElementById('picture3P').className = 'viewer';	
				document.getElementById('picture4P').className = 'hidden';	
		break;
		case 'picture4': 
				document.getElementById('picture1P').className = 'hidden';	
				document.getElementById('picture2P').className = 'hidden';	
				document.getElementById('picture3P').className = 'hidden';	
				document.getElementById('picture4P').className = 'viewer';	
		break;
		case 'picture5': 
				document.getElementById('picture5P').className = 'viewer';	
				document.getElementById('picture6P').className = 'hidden';	
				document.getElementById('picture7P').className = 'hidden';	
				document.getElementById('picture8P').className = 'hidden';	
		break;
		case 'picture6': 
				document.getElementById('picture5P').className = 'hidden';	
				document.getElementById('picture6P').className = 'viewer';	
				document.getElementById('picture7P').className = 'hidden';	
				document.getElementById('picture8P').className = 'hidden';	
		break;
		case 'picture7': 
				document.getElementById('picture5P').className = 'hidden';	
				document.getElementById('picture6P').className = 'hidden';	
				document.getElementById('picture7P').className = 'viewer';	
				document.getElementById('picture8P').className = 'hidden';	
		break;
		case 'picture8': 
				document.getElementById('picture5P').className = 'hidden';	
				document.getElementById('picture6P').className = 'hidden';	
				document.getElementById('picture7P').className = 'hidden';	
				document.getElementById('picture8P').className = 'viewer';	
		break;
	}
}
	function getserverresponse(strURL,type,param) {
					var inst = '';
					inst = 'var xmlHttpReq'+type+'=false;';
					eval(inst) ;
					var self = this;
					// Mozilla/Safari
					if (window.XMLHttpRequest) 
					{
						self.eval('xmlHttpReq'+type+'= new XMLHttpRequest()');
					}
					// IE
					else if (window.ActiveXObject) {
						self.eval('xmlHttpReq'+type+'= new ActiveXObject("Microsoft.XMLHTTP")') ;
					}
					self.eval('xmlHttpReq'+type).open('POST', strURL, true);
					//alert(strURL);
					self.eval('xmlHttpReq'+type).setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					self.eval('xmlHttpReq'+type).onreadystatechange = function()
					{
						if (self.eval('xmlHttpReq'+type).readyState == 4) 
						{
							var gridcontent;
									if(type==1){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('affiche1').innerHTML = retour;
										document.getElementById('articleGd1-1').className = 'affiche-gd1';	
												}
									if(type==2){
									retour = self.eval('xmlHttpReq'+type).responseText;
									document.getElementById('tab_Sondage2').innerHTML = document.getElementById('tab_Sondage').innerHTML;
									document.getElementById('tab_Sondage').innerHTML = retour;
									setCookie("Sondage_"+param, 'Le sondage ' + param + ' a été déjà voté', 1);
												}
									if(type==3){
										
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('news').innerHTML = retour;
										document.getElementById('articleGd1-3').className = 'actu-gd1';	
												}
									if(type==4){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('picture').innerHTML = retour;
										document.getElementById('picture1P').className = 'viewer';	
												}
									if(type==5){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('blogs').innerHTML = retour;
												}
									if(type==6){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('tag').innerHTML = retour;
												}
									if(type==7){
										retour = self.eval('xmlHttpReq'+type).responseText;
										
										if(param=='comments'){
										document.getElementById('comments').innerHTML = retour;
										}else
										if(param=='minutes'){
										document.getElementById('minutes').innerHTML = retour;
										}		
										}
									if(type==8){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('calender').innerHTML = retour;
												}
									if(type==9){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('picture').innerHTML = retour;
										document.getElementById('picture5P').className = 'viewer';	
												}
									if(type==10){
										retour = self.eval('xmlHttpReq'+type).responseText;
										document.getElementById('content-club').innerHTML = retour;
												}
												
									if(type==11){
									retour = self.eval('xmlHttpReq'+type).responseText;
									document.getElementById('picture'+param).innerHTML = retour;
									//document.getElementById('picture1P'+param).className = 'viewer';	
									}
								if(type==12){
								retour = self.eval('xmlHttpReq'+type).responseText;
								if (retour == "ok"){
								}
								}		
								
								if(type==13){
									retour = self.eval('xmlHttpReq'+type).responseText;
									document.getElementById('tab_Sondage2').innerHTML = document.getElementById('tab_Sondage').innerHTML;
									document.getElementById('tab_Sondage').innerHTML = retour;
									//setCookie("Sondage_"+param, 'Le sondage ' + param + ' a été déjà voté', 1);
												}
								if(type==14){
									retour = self.eval('xmlHttpReq'+type).responseText;
									//document.getElementById('tab_Sondage2').innerHTML = document.getElementById('tab_Sondage').innerHTML;
									alert(retour);
									//setCookie("Sondage_"+param, 'Le sondage ' + param + ' a été déjà voté', 1);
												}
								if(type==15){
									retour = self.eval('xmlHttpReq'+type).responseText;
									//document.getElementById('tab_Sondage2').innerHTML = document.getElementById('tab_Sondage').innerHTML;
									alert(retour);
							
								 // document.getElementById('interne2').innerHTML = retour +  document.getElementById('interne2').innerHTML;
								  
												}
								if(type==16){
									retour = self.eval('xmlHttpReq'+type).responseText;
									//document.getElementById('tab_Sondage2').innerHTML = document.getElementById('tab_Sondage').innerHTML;
									//alert(retour);
							
								document.getElementById('comment333').innerHTML = retour ;
								  
												}


										
						}
					 }
					self.eval('xmlHttpReq'+type).send(strURL);
	}
	
	   function Timer() {
       		url = "Channels/bewtunisie/templates/Koora/ASP/timer.asp?";
			getserverresponse(url,14);
       setTimeout("Timer()",100000);
   }
  
  
  function comment222(id) {
	//alert(id);
		var A;
	var B;
	A=document.getElementById('idnom').innerHTML ;
	B=document.getElementById('idmail').innerHTML ;

	if(document.comment.nom.value == "") {
		alert("Remplir le champs du pseudo!");
		
	}else{
		
					if((document.comment.mail.value == "")){
				alert("Remplir le champs du commentaire!");
			}else{	
				url = "../Channels/bewtunisie/templates/Koora/ASP/comment.asp?";
				url = url + "id="+id;
				url = url + "&A="+A;
				url = url + "&B="+B;
				getserverresponse(url,15);
			}

		
	}}
  function comment333(id) {
	
			url = "../Channels/bewtunisie/templates/Koora/ASP/comment-title.asp?";
			url = url + "id="+id;
			getserverresponse(url,16);
	
	}

function Nbvisit(IDRecord){
	//alert(IDRecord);
			url = "../Channels/bewtunisie/templates/Koora/ASP/insert_visit.asp?";
			url = url + "Action=Nbvisit&"
			url = url + "idarticle="+IDRecord
			getserverresponse(url,12,IDRecord);
}
function infoclub(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/infoclub.asp?=";
				url = url + "&theme="+id
				affichebloc2('hideclub');
				setTimeout('getserverresponse(url,10)',500);

					}
function afficheindex(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/afficheindex.asp?=";
				url = url + "&theme="+id
				param=id
				getserverresponse(url,1,param);
					}
function affichethemeparent(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/affichethemeparent.asp?=";
				url = url + "&theme="+id
				getserverresponse(url,1);
					}
function actthemeparent(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/actthemeparent.asp?=";
				url = url + "&theme="+id
				getserverresponse(url,3);
					}
function affichetheme(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/affichetheme.asp?=";
				url = url + "&theme="+id
				param=id
				getserverresponse(url,1,param);
				//setCookie("affiche"+id, id, 1);
}
function actindex(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/acttheme.asp?=";
				url = url + "&theme="+id
				param=id
				getserverresponse(url,3,param);
}
function calender(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/calender.asp?=";
				url = url + "&theme="+id
				param=id
				getserverresponse(url,8,param);
}
function blogs(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/blogs.asp?=";
				url = url + "&theme="+id
				param=id
				getserverresponse(url,5,param);
}
function picture(){
				url = "Channels/bewtunisie/templates/Koora/ASP/picture.asp?=";
				getserverresponse(url,4);
}
function picture222(){
				url = "Channels/bewtunisie/templates/Koora/ASP/picture2.asp?=";
				getserverresponse(url,9);
}
function picturethemeparent(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/picturethemeparent.asp?=";
				url = url + "&theme="+id
				getserverresponse(url,4);
}
function picturecat(id,div){
				url = "Channels/bewtunisie/templates/Koora/ASP/picturethemeparentcat.asp?=";
				url = url + "&theme="+id;
				param=div;
				getserverresponse(url,11,param);
}
function picturethemeparent222(id){
				url = "Channels/bewtunisie/templates/Koora/ASP/picturethemeparent2.asp?=";
				url = url + "&theme="+id
				getserverresponse(url,9);
}

function tag(){
				url = "Channels/bewtunisie/templates/Koora/ASP/tag.asp?=";
				url = url + "&Action=t"
				getserverresponse(url,6)
				//setTimeout('getserverresponse(url,6,lab)',1000);
}

function widgetAccordion(Action, label, id){
				url = "../Channels/bewtunisie/templates/Koora/ASP/accordion.asp?=";
				url = url + "&Action="+Action
				url = url + "&theme="+id
				lab=label;
				getserverresponse(url,7,lab);
}
function Close_sondage()
{
					var retour = "";
					retour = document.getElementById('tab_Sondage2').innerHTML
					document.getElementById('tab_Sondage2').innerHTML = '';
					document.getElementById('tab_Sondage').innerHTML = retour;
	
}
function Close_ligue()
{
					document.getElementById('ligue1').className = 'liste-result hidden';	
					document.getElementById('ligue2').className = 'liste-result viewer';	
	
}
function Close_ligue2()
{
					document.getElementById('ligue1').className = 'liste-result viewer';	
					document.getElementById('ligue2').className = 'liste-result hidden';	
	
}
function classement2()
{
					document.getElementById('classement1').className = 'liste-result viewer';	
					document.getElementById('classement2').className = 'liste-result hidden';	
	
}
function classement1()
{
					document.getElementById('classement2').className = 'liste-result viewer';	
					document.getElementById('classement1').className = 'liste-result hidden';	
	
}
function sondage(Question_ID,radiobutton,div){
					var returnValue = "";
					for(i = 0; i < document.forms["FormSondage"].elements.length ; i++) {
					if (document.forms["FormSondage"].elements[i].type == "radio" ) {
					if (document.forms["FormSondage"].elements[i].checked == true)
					returnValue = document.forms["FormSondage"].elements[i].value;
					}
					} 
					Answer_ID = returnValue;
					//alert(Answer_ID);
					var cookieEnabled=(navigator.cookieEnabled)? true : false
					if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
					document.cookie="testcookie"
					cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
					}
					if (cookieEnabled) {
					CookieSondage=getCookie("Sondage_"+Question_ID);
					if (CookieSondage == ""){
					url = "Channels/bewtunisie/templates/Koora/ASP/Sondage.asp?";
					url = url + "Action="+div+"&"
					url = url + "question="+Question_ID+"&"
					url = url + "answer="+Answer_ID+"&"
					getserverresponse(url,2,Question_ID)
					}
					else{
					alert('Vous avez déjà voté pour ce sondage');
					}
					}
					else{
					alert('Pour pouvoir voter, vous devez activer le support des cookies!');
					}
}
function sondage2(Question_ID,radiobutton,div){
					url = "../Channels/bewtunisie/templates/Koora/ASP/Sondage.asp?";
					url = url + "Action="+div+"&"
					url = url + "question="+Question_ID+"&"
					getserverresponse(url,13,Question_ID)
}
function getCookie(c_name)
{
					if (document.cookie.length>0)
					{
					c_start=document.cookie.indexOf(c_name + "=")
					if (c_start!=-1)
					{ 
					c_start=c_start + c_name.length+1 
					c_end=document.cookie.indexOf(";",c_start)
					if (c_end==-1) c_end=document.cookie.length
					return unescape(document.cookie.substring(c_start,c_end))
					} 
					}
					return ""
}
function setCookie(c_name,value,expiredays)
{
					var exdate=new Date();
					exdate.setDate(exdate.getDate()+expiredays);
					document.cookie=c_name+ "=" + escape(value)+	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
function TrancateBody()
{
chaine=document.getElementById("hidden_div").innerHTML;
var reg=new RegExp("[ ]+", "g");
//var reg2=new RegExp("[ ]+", "g");
var reg2=new RegExp("<br>", "g");
chaine=chaine.replace(reg2, "<br/>");
//alert(chaine);
var tableau=chaine.split(reg);
Nre_Words=tableau.length;
Words_Sup=(Nre_Words/2);
Words_min=(Nre_Words/3);
Content="";
	if (Nre_Words < 120){
	
			for (var i=0; i<Math.round(Words_Sup); i++) {
					Content=Content+tableau[i]+ " ";
			}
	}else{
	
			for (var i=0; i<120; i++) {
					Content=Content+tableau[i]+ " ";
			}
	}
	Content=Content + "...";
	document.getElementById("Show_div").innerHTML=Content;
	document.getElementById("hidden_div").innerHTML=Content;
}

function getrechmono(url){
				var sourcesearch=document.forms['rech'].sourcesearch.value;
				var datesearch=document.forms['rech'].datesearch.value;
				var datesearch2=document.forms['rech'].date2search.value;
				var motscles=document.forms['rech'].motscles.value;
				//alert(compare(getDate(datesearch),getDate(datesearch2)));
				if((datesearch2!="") || ((datesearch!="") && (datesearch2!=""))){
					if((datesearch!=datesearch2))
					{
							if(compare(getDate(datesearch),getDate(datesearch2))==-1)
							{
								//alert("mono1");
							window.location.href="../home/Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
							}
							else
							{
								alert("Vérifer les données inserés");
							}
					}else{
					window.location.href="../home/Koora-all-article?=&s="+sourcesearch+"&d="+datesearch+"&mot="+motscles+"&P="+url;
					}
				}else{
					window.location.href="../home/Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
					}
}

function getrech(url){
				var sourcesearch=document.forms['rech'].sourcesearch.value;
				var datesearch=document.forms['rech'].datesearch.value;
				var datesearch2=document.forms['rech'].date2search.value;
				var motscles=document.forms['rech'].motscles.value;
				//alert(compare(getDate(datesearch),getDate(datesearch2)));
				if((datesearch2!="") || ((datesearch!="") && (datesearch2!=""))){
					if((datesearch!=datesearch2))
					{
							if(compare(getDate(datesearch),getDate(datesearch2))==-1)
							{
								//alert("mono1");
							window.location.href="Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
							}
							else
							{
								alert("Vérifer les données inserés");
							}
					}else{
					window.location.href="Koora-all-article?=&s="+sourcesearch+"&d="+datesearch+"&mot="+motscles+"&P="+url;
					}
				}else{
					window.location.href="Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
					}
}
function getrech2(url){
				var sourcesearch=document.forms['rech'].sourcesearch.value;
				var datesearch=document.forms['rech'].datesearch.value;
				var datesearch2=document.forms['rech'].date2search.value;
				var motscles=document.forms['rech'].motscles.value;
				//alert(compare(getDate(datesearch),getDate(datesearch2)));
				if((datesearch2!="") || ((datesearch!="") && (datesearch2!=""))){
					if((datesearch!=datesearch2))
					{
							if(compare(getDate(datesearch),getDate(datesearch2))==-1)
							{
								//alert("mono1");
							window.location.href="home/Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
							}
							else
							{
								alert("Vérifer les données inserés");
							}
					}else{
					window.location.href="home/Koora-all-article?=&s="+sourcesearch+"&d="+datesearch+"&mot="+motscles+"&P="+url;
					}
				}else{
					window.location.href="home/Koora-all-article?=&s="+sourcesearch+"&d1="+datesearch+"&d2="+datesearch2+"&mot="+motscles+"&P="+url;
					}
}
function getDate(strDate){	  
day = strDate.substring(0,2);
month = strDate.substring(3,5);
year = strDate.substring(6,10);
d = new Date();
d.setDate(day);
d.setMonth(month);
d.setFullYear(year); 
return d;  
}

function compare(date_1, date_2){
diff = date_1.getTime()-date_2.getTime();
return (diff==0?diff:diff/Math.abs(diff));
}

function fermecontact(){
document.getElementById('hidestatic').style.display='none';
}
function affichselect222(texte) {
		switch (texte){
		case 'f1': 
				window.location.href="home/Koora-Liste-Article?=&t=183&P=171";	
		break;
		case 'f2': 
				window.location.href="home/Koora-Liste-Article?=&t=184&P=171";	
		break;
		case 'f3': 
				window.location.href="home/Koora-info-club?=&t=286&P=171";	
		break;
		case 'f4': 
				window.location.href="home/koora-liste-calender?=&P=171";	
		break;
		case 'f5': 
				window.location.href="home/koora-liste-resultat?=&P=171";	
		break;
		case 'f6': 
				window.location.href="home/koora-liste-classement?=&P=171";	
		break;
		case 'f7': 
				window.location.href="home/Koora-liste-images?=&P=171";	
		break;
		case 'h1': 
				window.location.href="home/Koora-Liste-Article?=&t=188&P=172";	
		break;
		case 'h2': 
				window.location.href="home/Koora-Liste-Article?=&t=189&P=172";	
		break;
		case 'h3': 
				window.location.href="home/Koora-info-club?=&t=287&P=172";	
		break;
		case 'h4': 
				window.location.href="home/koora-liste-calender?=&P=172";	
		break;
		case 'h5': 
				window.location.href="home/koora-liste-resultat?=&P=172";	
		break;
		case 'h6': 
				window.location.href="home/koora-liste-classement?=&P=172";	
		break;
		case 'h7': 
				window.location.href="home/Koora-liste-images?=&P=172";	
		break;
		case 'a1': 
				window.location.href="home/Koora-Liste-Article?=&t=203&P=175";	
		break;
		case 'a2': 
				window.location.href="home/Koora-Liste-Article?=&t=204&P=175";	
		break;
		case 'a3': 
				window.location.href="koora-liste-calender?=&P=175";	
		break;
		case 'a4': 
				window.location.href="home/koora-liste-resultat?=&P=175";	
		break;
		case 'a5': 
				window.location.href="home/koora-liste-classement?=&P=175";	
		break;
		case 'a6': 
				window.location.href="home/Koora-liste-images?=&P=175";	
		break;
		case 'e1': 
				window.location.href="home/Koora-Liste-Article?=&t=193&P=173";	
		break;
		case 'e2': 
				window.location.href="home/koora-liste-calender?=&P=173";	
		break;
		case 'e3': 
				window.location.href="home/koora-liste-resultat?=&P=173";	
		break;
		case 'e4': 
				window.location.href="home/koora-liste-classement?=&P=173";	
		break;
		case 'e5': 
				window.location.href="home/Koora-liste-images?=&P=173";	
		break;
		case 'g1': 
				window.location.href="home/Koora-Liste-Article?=&t=198&P=174";	
		break;
		case 'g2': 
				window.location.href="home/koora-liste-calender?=&P=174";	
		break;
		case 'g3': 
				window.location.href="home/koora-liste-resultat?=&P=174";	
		break;
		case 'g4': 
				window.location.href="home/koora-liste-classement?=&P=174";	
		break;
		case 'g5': 
				window.location.href="home/Koora-liste-images?=&P=174";	
		break;
			}
}
function affichselect2222(texte) {
		switch (texte){
		case 'f1': 
				window.location.href="Koora-Liste-Article?=&t=183&P=171";	
		break;
		case 'f2': 
				window.location.href="Koora-Liste-Article?=&t=184&P=171";	
		break;
		case 'f3': 
				window.location.href="Koora-info-club?=&t=286&P=171";	
		break;
		case 'f4': 
				window.location.href="koora-liste-calender?=&P=171";	
		break;
		case 'f5': 
				window.location.href="koora-liste-resultat?=&P=171";	
		break;
		case 'f6': 
				window.location.href="koora-liste-classement?=&P=171";	
		break;
		case 'f7': 
				window.location.href="Koora-liste-images?=&P=171";	
		break;
		case 'h1': 
				window.location.href="Koora-Liste-Article?=&t=188&P=172";	
		break;
		case 'h2': 
				window.location.href="Koora-Liste-Article?=&t=189&P=172";	
		break;
		case 'h3': 
				window.location.href="Koora-info-club?=&t=287&P=172";	
		break;
		case 'h4': 
				window.location.href="koora-liste-calender?=&P=172";	
		break;
		case 'h5': 
				window.location.href="koora-liste-resultat?=&P=172";	
		break;
		case 'h6': 
				window.location.href="koora-liste-classement?=&P=172";	
		break;
		case 'h7': 
				window.location.href="Koora-liste-images?=&P=172";	
		break;
		case 'a1': 
				window.location.href="Koora-Liste-Article?=&t=203&P=175";	
		break;
		case 'a2': 
				window.location.href="Koora-Liste-Article?=&t=204&P=175";	
		break;
		case 'a3': 
				window.location.href="koora-liste-calender?=&P=175";	
		break;
		case 'a4': 
				window.location.href="koora-liste-resultat?=&P=175";	
		break;
		case 'a5': 
				window.location.href="koora-liste-classement?=&P=175";	
		break;
		case 'a6': 
				window.location.href="Koora-liste-images?=&P=175";	
		break;
		case 'e1': 
				window.location.href="Koora-Liste-Article?=&t=193&P=173";	
		break;
		case 'e2': 
				window.location.href="koora-liste-calender?=&P=173";	
		break;
		case 'e3': 
				window.location.href="koora-liste-resultat?=&P=173";	
		break;
		case 'e4': 
				window.location.href="koora-liste-classement?=&P=173";	
		break;
		case 'e5': 
				window.location.href="Koora-liste-images?=&P=173";	
		break;
		case 'g1': 
				window.location.href="Koora-Liste-Article?=&t=198&P=174";	
		break;
		case 'g2': 
				window.location.href="koora-liste-calender?=&P=174";	
		break;
		case 'g3': 
				window.location.href="koora-liste-resultat?=&P=174";	
		break;
		case 'g4': 
				window.location.href="koora-liste-classement?=&P=174";	
		break;
		case 'g5': 
				window.location.href="Koora-liste-images?=&P=174";	
		break;
			}
}








function affichselect5555(texte) {
		switch (texte){
		case 'f1': 
				window.location.href="../home/Koora-Liste-Article?=&t=183&P=171";	
		break;
		case 'f2': 
				window.location.href="../home/Koora-Liste-Article?=&t=184&P=171";	
		break;
		case 'f3': 
				window.location.href="../home/Koora-info-club?=&t=286&P=171";	
		break;
		case 'f4': 
				window.location.href="../home/koora-liste-calender?=&P=171";	
		break;
		case 'f5': 
				window.location.href="../home/koora-liste-resultat?=&P=171";	
		break;
		case 'f6': 
				window.location.href="../home/koora-liste-classement?=&P=171";	
		break;
		case 'f7': 
				window.location.href="../home/Koora-liste-images?=&P=171";	
		break;
		case 'h1': 
				window.location.href="../home/Koora-Liste-Article?=&t=188&P=172";	
		break;
		case 'h2': 
				window.location.href="../home/Koora-Liste-Article?=&t=189&P=172";	
		break;
		case 'h3': 
				window.location.href="../home/Koora-info-club?=&t=287&P=172";	
		break;
		case 'h4': 
				window.location.href="../home/koora-liste-calender?=&P=172";	
		break;
		case 'h5': 
				window.location.href="../home/koora-liste-resultat?=&P=172";	
		break;
		case 'h6': 
				window.location.href="../home/koora-liste-classement?=&P=172";	
		break;
		case 'h7': 
				window.location.href="../home/Koora-liste-images?=&P=172";	
		break;
		case 'a1': 
				window.location.href="../home/Koora-Liste-Article?=&t=203&P=175";	
		break;
		case 'a2': 
				window.location.href="../home/Koora-Liste-Article?=&t=204&P=175";	
		break;
		case 'a3': 
				window.location.href="../home/koora-liste-calender?=&P=175";	
		break;
		case 'a4': 
				window.location.href="../home/koora-liste-resultat?=&P=175";	
		break;
		case 'a5': 
				window.location.href="../home/koora-liste-classement?=&P=175";	
		break;
		case 'a6': 
				window.location.href="../home/Koora-liste-images?=&P=175";	
		break;
		case 'e1': 
				window.location.href="../home/Koora-Liste-Article?=&t=193&P=173";	
		break;
		case 'e2': 
				window.location.href="../home/koora-liste-calender?=&P=173";	
		break;
		case 'e3': 
				window.location.href="../home/koora-liste-resultat?=&P=173";	
		break;
		case 'e4': 
				window.location.href="../home/koora-liste-classement?=&P=173";	
		break;
		case 'e5': 
				window.location.href="../home/Koora-liste-images?=&P=173";	
		break;
		case 'g1': 
				window.location.href="../home/Koora-Liste-Article?=&t=198&P=174";	
		break;
		case 'g2': 
				window.location.href="../home/koora-liste-calender?=&P=174";	
		break;
		case 'g3': 
				window.location.href="../home/koora-liste-resultat?=&P=174";	
		break;
		case 'g4': 
				window.location.href="../home/koora-liste-classement?=&P=174";	
		break;
		case 'g5': 
				window.location.href="../home/Koora-liste-images?=&P=174";	
		break;
			}
}
var MONTH_LIST = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
var DAY_LIST = new Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim");

/**
 * Activation du changement d'affichage des jours passés et du jour d'aujourd'hui.
 */ 
var PAST_ENABLED = true;
var TODAY_ENABLED = true;

/**
 * Instance du calendrier (unique puisqu'un seul affiché à la fois).
 */
var calendar2 = new Calendar();

/**
 * Constructeur.
 */
function Calendar() {
    this.elementId = "";
    this.element = null;

    this.weekday = 0;
    this.day = 0;
    this.month = 0;
    this.year = 0;

    this.cday = 0;
    this.cmonth = 0;
    this.cyear = 0;
    this.cyear2 = 0;

    this.mappingArray = new Array();

    this.cal = document.getElementById("cal");
    this.cald = document.getElementById("cald");
    this.calm = document.getElementById("calm");
    this.caly = document.getElementById("caly");
}

/**
 * Insère, dans le div d'id 'calendar', les éléments DOM du calendrier.
 */
function insertCalendar() {
    var calendarDiv = document.getElementById("calendar2");
    var calendarInserted = (calendarDiv != null);
    if (calendarInserted) {
        // Le calendrier est inséré dans le div d'id "calendar".
        if (document.getElementById("cal") == null) {
            addMainDiv(calendarDiv);
            addMonthDiv(calendarDiv);
            addYearDiv(calendarDiv);
        }
    }
    return calendarInserted;
}

/**
 * Insère, dans le div d'id 'calendar', les éléments DOM relatifs à la partie principale du
 * calendrier.
 */ 
function addMainDiv(calendarDiv) {
    var calDiv = document.createElement("DIV");
    calDiv.id = "cal";
    calDiv.className = "ctx";
    calDiv.style.width = "310px";
    
    var table = document.createElement("TABLE");
    table.id = "calh";
    //table.border = "1";
   //table.vAlign = "center";
   // table.width = "300";
    table.className = "calh";
    
    var row = table.insertRow(0);
    
    var cell = row.insertCell(0);
    cell.id = "cal_m_00";
    cell.onclick = decrementMonth;
    cell.appendChild(getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_left.gif"));
    
    cell = row.insertCell(1);
    cell.id = "cal_m_01";
    cell.onclick = incrementMonth;
    cell.appendChild(getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_right.gif"));
    
    cell = row.insertCell(2);
    cell.id = "cal_m_02";
    cell.onclick = updateMonthChoiceVisibility;
    cell.width = "140";
    
    cell = row.insertCell(3);
    cell.id = "cal_m_03";
    cell.onclick = updateMonthChoiceVisibility;
   // cell.appendChild(getImg("../Channels/bewtunisie/Templates/bew/images/calender/arrow_down.gif"));    
    
    cell = row.insertCell(4);
    cell.width = "10";
    
    cell = row.insertCell(5);
    cell.id = "cal_y_00";
    cell.onclick = decrementYear;
    cell.appendChild(getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_left.gif"));
    
    cell = row.insertCell(6);
    cell.id = "cal_y_01";
    cell.onclick = incrementYear;
    cell.appendChild(getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_right.gif"));
    
    cell = row.insertCell(7);
    cell.id = "cal_y_02";
    cell.onclick = updateYearChoiceVisibility;
    cell.width = "60";
    
    cell = row.insertCell(8);
    cell.id = "cal_y_03";
    cell.onclick = updateYearChoiceVisibility;
    //cell.appendChild(getImg("../Channels/bewtunisie/Templates/bew/images/calender/arrow_down.gif"));
    
    cell = row.insertCell(9);
    cell.width = "10";
    
    cell = row.insertCell(10);
    cell.id = "cal_c";
    cell.onclick = hideCalendar;
    var img = getImg("../Channels/bewtunisie/Templates/Koora/images/calender/l_cancel.gif");
    img.width = "15";
    img.height = "13";
    cell.appendChild(img);
    
    row = table.insertRow(1);
    
    cell = row.insertCell(0);
    cell.colSpan = 11;
    
    var subTable = document.createElement("TABLE");
  //  subTable.width = "300";
   // subTable.border = "1";
    subTable.className = "cal";
    subTable.id = "cald";
    
    var subRow = subTable.insertRow(0);
   // subRow.align = "center";
    subRow.height = "18";
    
    var subCell;
    var i;
    for (i = 0; i < 7; i++) {
        subCell = subRow.insertCell(i);
        subCell.width = (i < 5 ? "46" : "35");
        subCell.innerHTML = DAY_LIST[i];
    }
    
    var j;
    for (i = 0; i < 6; i++) {
        subRow = subTable.insertRow(i + 1);
      //  subRow.align = "center";
        subRow.style.height = "18";
        for (j = 0; j < 7; j++) {
            subCell = subRow.insertCell(j);
            subCell.id = "cal_d_" + i + j;
            subCell.style.border = "1px solid #fff";
        }
    }
    
    cell.appendChild(subTable);
    calDiv.appendChild(table);
    calendarDiv.appendChild(calDiv);
}

/**
 * Insère, dans le div d'id 'calendar', les éléments DOM relatifs au choix du mois du calendrier.
 */
function addMonthDiv(calendarDiv) {
    var calmDiv = document.createElement("DIV");
    calmDiv.id = "calm";
    calmDiv.className = "ctx";
    calmDiv.style.width = "300px";
    calmDiv.style.height = "120px";
    
    var table = document.createElement("TABLE");
    table.className = "calm";
    table.style.width = "300px";
    table.style.height = "120px";
    var row;
    var cell;
    for (i = 0; i < 3; i++) {
        row = table.insertRow(i);
        row.style.height = "18";
        for (j = 0; j < 4; j++) {
            cell = row.insertCell(j);
            cell.id = "calm_" + (3 * j + i + 1);
            cell.width = (j < 2 ? "23%" : "26%");
        }
    }
    calmDiv.appendChild(table);
    calendarDiv.appendChild(calmDiv);
}

/**
 * Insère, dans le div d'id 'calendar', les éléments DOM relatifs au choix de l'année du
 * calendrier.
 */
function addYearDiv(calendarDiv) {
    var calyDiv = document.createElement("DIV");
    calyDiv.id = "caly";
    calyDiv.className = "ctx";
    
    var table = document.createElement("TABLE");
    var row = table.insertRow(0);
    
    var cell = row.insertCell(0);
    var img = getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_left.gif");
    img.onclick = decreaseYear;
    cell.appendChild(img);
    
    cell = row.insertCell(1);
    var subTable = document.createElement("TABLE");
    subTable.className = "caly";
  //  subTable.border = "1";
    subTable.width = "240";
    var subRow;
    var subCell;
    for (i = 0; i < 5; i++) {
        subRow = subTable.insertRow(i);
        subRow.style.height = "18";
        for (j = 0; j < 5; j++) {
            subCell = subRow.insertCell(j);
            subCell.id = "caly_" + (5 * j + i + 1);
            subCell.width = "20%";
        }
    }
    cell.appendChild(subTable);
    
    cell = row.insertCell(2);
    img = getImg("../Channels/bewtunisie/Templates/Koora/images/calender/arrow_right.gif");
    img.onclick = increaseYear;
    cell.appendChild(img);
    
    calyDiv.appendChild(table);
    calendarDiv.appendChild(calyDiv);
}

/**
 * Retourne un élément image à insérer dans le calendrier.
 */
function getImg(src) {
    var img = document.createElement("IMG");
    img.src = src;
    img.className = "but";
    img.width = "16";
    img.height = "16";
    return img;
}

function initCalendar(date) {
    calendar2.weekday = date.getDay();
    calendar2.day = date.getDate();
    calendar2.month = date.getMonth() + 1;
    calendar2.year = date.getFullYear();

    calendar2.cmonth = calendar2.month;
    calendar2.cyear = calendar2.year;

    fillMonthChoice();
    fillYearChoice();
}

function initElement(id, evt) {
    if (!evt) {
        evt = window.event;
    }
    calendar2.elementId = "";
    calendar2.element = document.getElementById(id);

    var hGap = -92;
    var vGap = 12;
    var elementStyle = calendar2.cal.style;
    var clientX = evt.clientX;
    var clientY = evt.clientY;
    var rightedge = document.body.clientWidth - clientX - hGap;
    var bottomedge = document.body.clientHeight - clientY - vGap;
    if (rightedge < calendar2.cal.offsetWidth) {
        elementStyle.left = document.body.scrollLeft + clientX - hGap - calendar2.cal.offsetWidth;
    } else {
        elementStyle.left = document.body.scrollLeft + clientX + hGap;
    }
    if (bottomedge < calendar2.cal.offsetHeight) {
        elementStyle.top = document.body.scrollTop + clientY - vGap - calendar2.cal.offsetHeight;
    } else {
        elementStyle.top = document.body.scrollTop + clientY + vGap;
    }

    calendar2.calm.style.left = parseInt(elementStyle.left) + 5;
    calendar2.calm.style.top = parseInt(elementStyle.top) + 28;
    calendar2.caly.style.left = parseInt(elementStyle.left) + 12;
    calendar2.caly.style.top = parseInt(elementStyle.top) + 33;
}

function displayCalendar(id, ev) {
    if (insertCalendar()) {
        calendar2 = new Calendar();
    
        var i;
        var element;
        for (i = 0; i < 4; i++) {
            element = document.getElementById("cal_m_0" + i);
            element.onmouseover = highlightHead;
            element.onmouseout = unhighlightHead;
        }
        for (i = 0; i < 4; i++) {
            element = document.getElementById("cal_y_0" + i);
            element.onmouseover = highlightHead;
            element.onmouseout = unhighlightHead;
        }
        element = document.getElementById("cal_c");
        element.onmouseover = highlightHead;
        element.onmouseout = unhighlightHead;
        
        initElement(id, ev);
        var dateValue = calendar2.element.value;
        var validDate = false;
        if (dateValue != "") {
            var s = dateValue.split("/");
            var d;
            var m;
            var y;
            if (s.length == 3) {
                d = s[0];
                m = s[1];
                y = s[2];
                if (!isNaN(d) && !isNaN(m) && !isNaN(y)) {
                    var m2 = parseNumber(m);
                    if (m2 >= 1 && m2 <= 12) {
                        validDate = true;
                        var y2 = parseNumber(y);
                        if (y2 < 100) {
                            y2 += 2000;
                        }
                        var d2 = parseNumber(d);
                        var testDate = new Date(y2, m2 - 1, 1);
                        if (d2 >= 1 && d2 <= getMaxMonthLastDay(testDate)) {
                            initCalendar(new Date(y2, m2 - 1, d2));
                        } else {
                            initCalendar(new Date(y2, m2 - 1, 1));
                        }
                    }
                }
            }
        }
        if (!validDate) {
            initCalendar(new Date());
        }
        fillCalendar();
        showCalendar();
    } else {
        window.status = "Div 'calendar' inexistant : aucun calendrier ajouté.";
    }
}

function showCalendar() {
    calendar2.cal.style.display = "block";
    showDayChoice();
    hideMonthChoice();
    hideYearChoice();
}

function hideCalendar() {
    calendar2.cal.style.display = "none";
    hideDayChoice();
    hideMonthChoice();
    hideYearChoice();
}

function showDayChoice() {
    calendar2.cald.style.display = "block";
}

function hideDayChoice() {
    calendar2.cald.style.display = "none";
}

function showMonthChoice() {
    calendar2.calm.style.display = "block";
}

function hideMonthChoice() {
    calendar2.calm.style.display = "none";
}

function showYearChoice() {
    calendar2.caly.style.display = "block";
}

function hideYearChoice() {
    calendar2.caly.style.display = "none";
}

function updateMonthChoiceVisibility() {
    if (calendar2.calm.style.display == "block") {
        showDayChoice();
        hideMonthChoice();
    } else {
       // hideDayChoice();
        hideYearChoice();
       // showMonthChoice();
    }
}

function updateYearChoiceVisibility() {
    if (calendar2.caly.style.display == "block") {
        showDayChoice();
        hideYearChoice();
    } else {
        calendar2.cyear2 = calendar2.cyear;
       // hideDayChoice();
        hideMonthChoice();
        fillYearChoice();
        //showYearChoice();
    }
}

function fillCalendar() {
    document.getElementById("cal_m_02").innerHTML = getStringMonth(calendar2.cmonth);
    document.getElementById("cal_y_02").innerHTML = calendar2.cyear;
    var element;

    var i = 0;
    var j = 0;
    for (i = 0; i < 6; i++) {
        for (j = 0; j < 7; j++) {
            element = document.getElementById("cal_d_" + i + j);
            element.innerHTML = "";
            element.onclick = "";
            element.onmouseover = "";
            element.onmouseout = "";
            element.className = "";
        }
    }

    i = 0;
    j = (new Date(calendar2.cyear, calendar2.cmonth-1, 1)).getDay();
    j = (j + 6) % 7;
    var count = 1;
    var days = getMonthLastDay();
    while (count <= days) {
        element = document.getElementById("cal_d_" + i + j);
        element.innerHTML = count;
        element.onclick = selectDay;
        element.onmouseover = highlightDay;
        element.onmouseout = unhighlightDay;
        element.className = getCellClassNameSuffix(count);
        
        calendar2.mappingArray[10 * i + j] = count;
        j++;
        if (j == 7) {
            i++;
            j = 0;
        }
        count++;
    }
}

function fillMonthChoice() {
    var i;
    var element;
    for (i = 1; i <= 12; i++) {
        element = document.getElementById("calm_" + i);
        element.innerHTML = getStringMonth(i);
        element.onclick = selectMonth;
        element.onmouseover = highlightHead;
        element.onmouseout = unhighlightHead;
    }
}

function fillYearChoice() {
    var i;
    var element;
    var gap = calendar2.cyear2 - 11;
    for (i = 1; i <= 25; i++) {
        element = document.getElementById("caly_" + i);
        element.innerHTML = gap + i;
        element.onclick = selectYear;
        element.onmouseover = highlightHead;
        element.onmouseout = unhighlightHead;
    }
}

function highlightDay(evt) {
    var element = getEventElement(evt);
    element.className = "sel" + getCellClassNameSuffix(element.innerHTML);
}

function unhighlightDay(evt) {
    //getEventElement(evt).className = "";
    var element = getEventElement(evt);
    element.className = getCellClassNameSuffix(element.innerHTML);
}

function highlightHead(evt) {
    var element = getEventElement(evt);
    if (element.tagName == "IMG") {
        element = element.parentNode;
    }
    element.className = "sel";
    if (element.id == "cal_m_02") {
        document.getElementById("cal_m_03").className = "sel";
    } else if (element.id == "cal_m_03") {
        document.getElementById("cal_m_02").className = "sel";
    } else if (element.id == "cal_y_02") {
        document.getElementById("cal_y_03").className = "sel";
    } else if (element.id == "cal_y_03") {
        document.getElementById("cal_y_02").className = "sel";
    }
}

function unhighlightHead(evt) {
    var element = getEventElement(evt);
    if (element.tagName == "IMG") {
        element = element.parentNode;
    }
    element.className = "";
    if (element.id == "cal_m_02") {
        document.getElementById("cal_m_03").className = "";
    } else if (element.id == "cal_m_03") {
        document.getElementById("cal_m_02").className = "";
    } else if (element.id == "cal_y_02") {
        document.getElementById("cal_y_03").className = "";
    } else if (element.id == "cal_y_03") {
        document.getElementById("cal_y_02").className = "";
    } 
}

function selectDay(evt) {
    var id = getEventElement(evt).id;
    calendar2.cday = calendar2.mappingArray[parseInt(id.substr(id.length - 2))];
    hideCalendar();
    var d = calendar2.cday;
    var m = calendar2.cmonth;
    var y = calendar2.cyear;
    window.status = d + " - " + m + " - " + y;
    calendar2.element.value = (d < 10 ? "0" : "") + d + "/" + (m < 10 ? "0" : "") + m + "/" + y;
}

function selectMonth(evt) {
    var id = getEventElement(evt).id;
    var s = id.split("_");
    calendar2.cmonth = parseInt(s[s.length - 1]);
    hideMonthChoice();
    showDayChoice();
    fillCalendar();
}

function selectYear(evt) {
    var id = getEventElement(evt).id;
    var s = id.split("_");
    calendar2.cyear = parseInt(s[s.length - 1]) + calendar2.cyear2 - 11;
    hideYearChoice();
    showDayChoice();
    fillCalendar();
}

function incrementMonth() {
    if (calendar2.cmonth == 12) {
        calendar2.cmonth = 1;
        calendar2.cyear = calendar2.cyear + 1;
    } else {
        calendar2.cmonth = calendar2.cmonth + 1;
    }
    fillCalendar();
}

function decrementMonth() {
    if (calendar2.cmonth == 1) {
        calendar2.cmonth = 12;
        calendar2.cyear = calendar2.cyear - 1;
    } else {
        calendar2.cmonth = calendar2.cmonth - 1;
    }
    fillCalendar();
}

function incrementYear() {
    calendar2.cyear = calendar2.cyear + 1;
    fillCalendar();
}

function decrementYear() {
    calendar2.cyear = calendar2.cyear - 1;
    fillCalendar();
}

function increaseYear() {
    calendar2.cyear2 = calendar2.cyear2 + 20;
    fillYearChoice();
}

function decreaseYear() {
    calendar2.cyear2 = calendar2.cyear2 - 20;
    fillYearChoice();
}

function getMonthLastDay() {
    var testDate = new Date(calendar2.cyear, calendar2.cmonth - 1, 29);
    return getMaxMonthLastDay(testDate);
}

function getMaxMonthLastDay(date) {
    if (date.getDate() == 29) {
        date.setDate(30);
        if (date.getDate() == 30) {
            date.setDate(31);
            if (date.getDate() == 31) {
                return 31
            } else {
                return 30;
            }
        } else {
            return 29;
        }
    } else {
        return 28;
    }
}

function getStringMonth(index) {
    return MONTH_LIST[index - 1];
}

var checkClickEnabled = true;
var clickedElement = null;

function checkClick(evt) {
    if ((checkClickEnabled)
            && (calendar2.cal != null)
            && (calendar2.cal.style.display == "block")) {
        checkClickEnabled = false;
        if (evt.target != null) {
            clickedElement = evt.target;
        } else {
            clickedElement = window.event.srcElement;
        }
        setTimeout("checkClickAnalysis()", 200);
    }
}

function checkClickAnalysis() {
    var element = clickedElement;
    var calendarElement = false;
    var id;
    var tagName = element.tagName;
    // Vérification que le clic courant n'est pas relatif à une image dont le rôle est justement
    // d'afficher le calendrier.
    if (tagName == "IMG") {
        var imgOnClickFunction = "" + element.onclick;
        calendarElement = (imgOnClickFunction.indexOf("displayCalendar") != -1);
    }
    // Vérification de l'appartenance ou non de l'élément ayant déclenché l'événement 'onclick' au
    // calendrier.
    if (!calendarElement) {
        while (element != null && tagName != "FORM") {
            id = element.id;
            if (id != null && (id == "cal" || id == "calm" || id == "caly") && tagName == "DIV") {
                // L'élément ayant déclenché l'événement 'onclick' appartient au calendrier : on ne
                // doit donc pas masquer ce dernier.
                calendarElement = true;
            }
            element = element.parentNode;
            if (element != null) {
                tagName = element.tagName;
            }
        }
        if (!calendarElement) {
            hideCalendar();
        }
    }
    checkClickEnabled = true;
}

function getEventElement(evt) {
    if (!evt) {
        return window.event.srcElement;
    } else {
        return evt.target;
    }
}

function parseNumber(n) {
    while (n != "" && n.substring(0, 1) == "0") {
        n = n.substring(1);
    }
    return parseInt(n);
}

function getCellClassNameSuffix(day) {
    if (PAST_ENABLED || TODAY_ENABLED) {
        var today = new Date();
        var selectedDate = new Date(calendar2.cyear, calendar2.cmonth - 1, day);
        if (selectedDate.getYear() < today.getYear()) {
            return (PAST_ENABLED ? "pas" : "");
        } else if (selectedDate.getYear() > today.getYear()) {
            return "";
        } else {
            if (selectedDate.getMonth() < today.getMonth()) {
                return (PAST_ENABLED ? "pas" : "");
            } else if (selectedDate.getMonth() < today.getMonth()) {
                return "";
            } else {
                if (selectedDate.getDate() < today.getDate()) {
                    return (PAST_ENABLED ? "pas" : "");
                } else if (selectedDate.getDate() > today.getDate()) {
                    return "";
                } else {
                    return (TODAY_ENABLED ? "tod" : "");
                }
            }
        }
    } else {
        return "";
    }
}
