var gobackurl = '';
function getHTTPObject()
{
  var xmlhttp = false;

  /* Compilation conditionnelle d'IE */
  /*@cc_on
  @if (@_jscript_version >= 5)
     try
     {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     }
     catch (e)
     {
        try
        {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
           xmlhttp = false;
        }
     }
  @else
     xmlhttp = false;
  @end @*/

  /* on essaie de créer l'objet si ce n'est pas déjà fait */
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
     try
     {
        xmlhttp = new XMLHttpRequest();
     }
     catch (e)
     {
        xmlhttp = false;
     }
  }

  if (xmlhttp)
  {
     /* on définit ce qui doit se passer quand la page répondra */
     xmlhttp.onreadystatechange=function()
     {
        if (xmlhttp.readyState == 4) /* 4 : état "complete" */
        {
           if (xmlhttp.status == 200) /* 200 : code HTTP pour OK */
           {
              /*
              Traitement de la réponse.
              Ici on affiche la réponse dans une boîte de dialogue.
              */
             var htmlres = ' ' + xmlhttp.responseText + ' ';
  		     var isgo = 1;
			
			//alert(htmlres);
			if(htmlres.indexOf('err1') >=1)
			  {
			   dispdiv('err1',1);
			   isgo = 0;
			  dispdiv('err2',0);
			  dispdiv('err3',0);
			  dispdiv('err4',0);
			  dispdiv('err5',0);
			  }
			 if(htmlres.indexOf('err2')>=1)
			  {
			   dispdiv('err2',1);
   			   isgo = 0;
			   dispdiv('err1',0);
			  dispdiv('err3',0);
			  dispdiv('err4',0);
			  dispdiv('err5',0);
			  }
			 if(htmlres.indexOf('err3')>=1)
			  {
			   dispdiv('err3',1);
   			   isgo = 0;
			   dispdiv('err1',0);
			  dispdiv('err2',0);
			  dispdiv('err4',0);
			  dispdiv('err5',0);
			  }
			if(htmlres.indexOf('err4')>=1)
			  {
			   dispdiv('err4',1);
   			   isgo = 0;			
			   dispdiv('err1',0);
			  dispdiv('err2',0);
			  dispdiv('err3',0);
			  dispdiv('err5',0);
			  }
			 if(htmlres.indexOf('err5')>=1)
			  {
			   dispdiv('err5',1);
   			   isgo = 0;
			   dispdiv('err1',0);
			  dispdiv('err2',0);
			  dispdiv('err3',0);
			  dispdiv('err4',0);
			  }
			  
			  if(isgo==1)
			  {
			  dispdiv('err1',0);
			  dispdiv('err2',0);
			  dispdiv('err3',0);
			  dispdiv('err4',0);
			  dispdiv('err5',0);
			  disablebutton('cbutton',0);
			  dispdiv('mimp',0)
			  dispdiv('mimpdata',1)
			  dispdiv('mimpdatabutton',1)

			  var final_html = "<table>";
			  mlistsplit = htmlres.split("\n");
			  var tmp_data_split ="";
			  var line_htm = "";
			  for(var k=0;k<mlistsplit.length;k++)
			 {
				line_htm = "<tr><td><input type=\"checkbox\" checked=\"checked\" value=\"[EMAILV]\" name=\"mlistb\"></td><td>[NOM]</td><td>[EMAIL]</td></tr>";
				if(mlistsplit[k].indexOf('@')>=1) 
				 {
				  tmp_data_split = mlistsplit[k].split(';');
				  line_htm = line_htm.replace('[NOM]',tmp_data_split[0]);
				  line_htm = line_htm.replace('[EMAIL]',tmp_data_split[1]);
				  line_htm = line_htm.replace('[EMAILV]',tmp_data_split[1]+'|'+tmp_data_split[0]);
				  final_html = final_html +line_htm;
				 }
			 }

			  final_html = final_html + "</table>";
			  document.getElementById('mimpdata').innerHTML = final_html;
			  }
			  else
			  {
			  disablebutton('cbutton',1);
			  }			  
			  /*alert(xmlhttp.responseText);
			  /*if(gobackurl=='noaction')
			  {
			  }
			  else
			  {
  			 window.location.href = gobackurl;
			  }*/
           }
        }
     }
  }
  return xmlhttp;
}

function geturl(myurl)
{
	var xmlhttp = getHTTPObject(); 
	xmlhttp.open("GET", ""+myurl+"",true); 
	xmlhttp.send(null); 
}

function vote(myaction,myvote,myid,myredirect)
{
	var curr_nb = 0;
	geturl('ajax.asp?a='+myaction+'&v='+myvote+'&i='+myid);
	if(myvote!=0)
	{
		document.getElementById('vote_'+myvote+'_'+myid+'').style.color = '#666666';
		document.getElementById('vote_'+myvote+'_'+myid+'').href = 'javascript:';
		curr_nb = document.getElementById('votecnt_'+myvote+'_'+myid+'').innerHTML;
		document.getElementById('votecnt_'+myvote+'_'+myid+'').innerHTML = curr_nb*1+1;
		if(document.getElementById('comment_'+myid+''))
		{
		document.getElementById('comment_'+myid+'').style.display = 'block';
		}
	if(myredirect!='')
		{
		window.location.href = myredirect;
		}
	}
}

function notif(myaction,myid)
{
	geturl('ajax.asp?a='+myaction+'&i='+myid);
}


function dispdiv(mydiv,myact)
{
	// afficher
	if(myact==1)
	{
		document.getElementById(mydiv).style.display = '';
	}
	// cacher
	else
	{
		document.getElementById(mydiv).style.display = 'none';
	}
}


function disablebutton(mydiv,myact)
{
	if(myact==0)
	{
	document.getElementById(mydiv).style.backgroundColor = '#999';
	document.getElementById(mydiv).disabled = true;
	document.getElementById(mydiv).value = 'Veuillez patienter...';
}
	else
	{
	document.getElementById(mydiv).style.backgroundColor = '#000000';
	document.getElementById(mydiv).disabled = false;
	document.getElementById(mydiv).value = 'Afficher vos contacts';
	}
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

function popup(myurl,myname,mywidth,myheight,myoptions) {
    var window_top = (screen.height-myheight)/2;
    var window_left = (screen.width-mywidth)/2;
   	var mywindow = window.open(''+ myurl + '',''+ myname + '','width=' + mywidth + ',height=' + myheight + ',top=' + window_top + ',left=' + window_left + ',' + myoptions + '');
    mywindow.focus();
}

function exit()
{
document.location.href = '/?exit=1';
}

function closecomment(myid)
{
document.getElementById('comment_'+myid+'').style.display = 'none';
}

function setblank(myid,value)
{
	if(document.getElementById(''+myid+''))
	{
		if(document.getElementById(''+myid+'').value ==''+value+'')
		{
			document.getElementById(''+myid+'').value = '';
		}
	}
}

function insertinto(myfield,myval)
{
document.getElementById(''+myfield+'').value = document.getElementById(''+myfield+'').value  + myval;
}