function importDirect(){
			
var arrayPageSize = getPageSize();
var arrayPageScroll = getPageScroll();
var Top = arrayPageScroll[1] + (arrayPageSize[3] / 3);
var result_findPos = findPos(document.getElementById('conteneur'));
var Left = result_findPos[0];

					var objBody = document.getElementsByTagName("body").item(0);
					
					var objOverlay = document.createElement("div");
					objOverlay.setAttribute('id','overlay');
					objOverlay.style.display = 'none';
					objOverlay.style.width = arrayPageSize[0]+'px';
					objOverlay.style.height =  arrayPageSize[1]+'px';
					objBody.appendChild(objOverlay);

					var objSuperBloc = document.createElement("div");
					objSuperBloc.setAttribute('id','block');
					objSuperBloc.style.display = 'none';
					objSuperBloc.style.width = '800px';
					objSuperBloc.style.height = '280px';
					objSuperBloc.style.marginTop = Top+'px';
					objSuperBloc.style.marginLeft = Left+55+'px';
					objSuperBloc.innerHTML='<div class="close" onclick="closeWin();">X</div><div class="log">Veuillez entrer les adresses email séparées d\'une virgule ou d\'un point virgule, ou coller le contenu d\'un fichier csv.</div><textarea name="impcsv" id="impcsv" style="border:1px solid #CCCCCC; height:140px; width:600px; margin-left:100px; margin-top:20px;"></textarea><input type="button" value="Valider" class="button" style="margin-left:340px; margin-top:20px;" onclick="getMailCsv()" />';
					objBody.appendChild(objSuperBloc);
					
					var objSuperChe = document.createElement("div");
					objSuperChe.setAttribute('id','blockChe');
					objSuperChe.style.display = 'none';
					objSuperChe.style.width = '800px';
					objSuperChe.style.height = '280px';
					objSuperChe.style.marginTop = Top+'px';
					objSuperChe.style.marginLeft = Left+55+'px';
					objSuperChe.innerHTML='<img src="../page/image/site/ajax.gif"/>';
					objBody.appendChild(objSuperChe);

					new Effect.Appear('overlay', { duration: 0.5, from: 0.0, to: 0.6, afterFinish: 
						function(){ Element.show('block'); }
						});

					return false;
}

function getMailCsv(){
	
	Element.hide('block');
	Element.show('blockChe');
	
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
		http = new XMLHttpRequest();
		}

		var impcsv = encodeURI(document.getElementById('impcsv').value);
		var data = 'impcsv='+impcsv;			

		http.open('post', '../page/script/getMailCsv.php');
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      
		http.send(data);
		http.onreadystatechange = getMailCsvReply;			

	return false;
}
function getMailCsvReply() {
	if(http.readyState == 4){
	var response = http.responseText;
		if(response == 0){
			alert('Error');
		} else {
			location.reload() ; 
		}
	}
}


function importCarnet(){

var arrayPageSize = getPageSize();
var arrayPageScroll = getPageScroll();
var Top = arrayPageScroll[1] + (arrayPageSize[3] / 3);
var result_findPos = findPos(document.getElementById('conteneur'));
var Left = result_findPos[0];
		
					//on créer le body
					var objBody = document.getElementsByTagName("body").item(0);
					
					var objOverlay = document.createElement("div");
					objOverlay.setAttribute('id','overlay');
					objOverlay.style.display = 'none';
					objOverlay.style.width = arrayPageSize[0]+'px';
					objOverlay.style.height =  arrayPageSize[1]+'px';
					objBody.appendChild(objOverlay);
						
					var objSuperBloc = document.createElement("div");
					objSuperBloc.setAttribute('id','block');
					objSuperBloc.style.display = 'none';
					objSuperBloc.style.width = '800px';
					objSuperBloc.style.height = '280px';
					objSuperBloc.style.marginTop = Top+'px';
					objSuperBloc.style.marginLeft = Left+55+'px';
					objSuperBloc.innerHTML='<div class="close" onclick="closeWin();">X</div><div class="log">Veuillez entrer l\'adresse email et le mot de passe de votre compte de messagerie Yahoo mail, Hotmail, Gmail, Msn ou AOL Mail.</div><div  class="left" style="float:none; margin-left:220px;" ><div class="box"><div class="form">Adresse e-mail<input type="text" value="" id="user" style="margin-left:40px;"/></div><div class="form">Password<input type="password" value="" style="margin-left:67px;" id="password"  /></div><input type="button" class="button" value="Valider"  style="margin-top:20px; margin-left:115px;"  onClick="getMailCarnet()" /></div></div>';
					objBody.appendChild(objSuperBloc);

					var objSuperChe = document.createElement("div");
					objSuperChe.setAttribute('id','blockChe');
					objSuperChe.style.display = 'none';
					objSuperChe.style.width = '800px';
					objSuperChe.style.height = '280px';
					objSuperChe.style.marginTop = Top+'px';
					objSuperChe.style.marginLeft = Left+55+'px';
					objSuperChe.innerHTML='<img src="../page/image/site/ajax.gif"/>';
					objBody.appendChild(objSuperChe);

					var objSuperVal = document.createElement("div");
					objSuperVal.setAttribute('id','blockVali');
					objSuperVal.style.display = 'none';
					objSuperVal.style.width = '96%';
					objSuperVal.style.marginTop = '10%';
					objSuperVal.style.marginLeft = '2%';
					objBody.appendChild(objSuperVal);

					var objSuperErr = document.createElement("div");
					objSuperErr.setAttribute('id','blockErr');
					objSuperErr.style.display = 'none';
					objSuperErr.style.width = '800px';
					objSuperErr.style.height = '280px';
					objSuperErr.style.marginTop = Top+'px';
					objSuperErr.style.marginLeft = Left+55+'px';
					objSuperErr.onclick = function() { 
						location.reload() ; 
					};
					objSuperErr.innerHTML='<div>Login ou mot de passe incorrecte, veuillez cliquer sur cette fenetre pour etre redirigé.</div>';
					objBody.appendChild(objSuperErr);	

					new Effect.Appear('overlay', { duration: 0.5, from: 0.0, to: 0.6, afterFinish: 
						function(){ Element.show('block'); }
						});
								
					
					return false;


}

function getMailCarnet(){
	
	Element.hide('block');
	Element.show('blockChe');
	
		// on créer l'objet ajax
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
		http = new XMLHttpRequest();
		}
		
		nocache = Math.random()
		var user = encodeURI(document.getElementById('user').value);
		var password = encodeURI(document.getElementById('password').value);	

		var data = 'user='+user;
		data += '&password='+password;	

		http.open('post', '../page/script/getMailCarnet.php');
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      
		http.send(data);
		http.onreadystatechange = getMailCarnetReply;	

	return false;
}
function getMailCarnetReply() {
	if(http.readyState == 4){
	var response = http.responseText;
		if(response == 0){
			Element.hide('blockVali');
			Element.show('blockErr');
		} else {
			Element.hide('block');
			Element.hide('blockChe');
			Element.show('blockVali');

            var text;
			text='<div class="close" onclick="closeWin();" style="margin-top:0px;">X</div><div class="log" style="margin-top:15px;">Veuillez selectionner les adresses.</div>';
			text=text+response;
			text=text+'<div class="autoclear"></div><input type="button" class="button" value="Valider"  style=" clear:both; margin-top:20px; margin-bottom:30px; margin-left:650px;"  onClick="setMailCarnet()" />';
            document.getElementById('blockVali').innerHTML=text;
		}
	}
}


function setMailCarnet(){
	
	Element.hide('blockVali');
	Element.show('blockChe');
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
		http = new XMLHttpRequest();
		}

		var param="";
		var i = 0;
		while(document.getElementById('checkMail'+i)){
			if(document.getElementById('checkMail'+i).checked){
				param=param+document.getElementById('checkMail'+i).value+";";
  			}
			i++;
		} 	

		var data = 'param='+param;

		http.open('post', '../page/script/setMailCarnet.php');
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      
		http.send(data);
		http.onreadystatechange = setMailCarnetReply;	

		return false;
}

function setMailCarnetReply() {
	if(http.readyState == 4){
	var response = http.responseText;
		if(response == 0){
			Element.hide('blockChe');
			Element.show('blockErr');
		} else {
			location.reload() ; 
		}
	}
}

function getPageScroll(){
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}



function getPageSize(){
	
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}





function sendMail(title, link, headerMail, idProjet){
	


		Effect.SlideUp('hideAll', { duration: 1.0 , afterFinish: 
						function(){	
						Effect.Appear('MailWait', { duration: 1.0 });					

		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
		http = new XMLHttpRequest();
		}

		title = encodeURI(title);
		link = encodeURI(link);
		headerMail = encodeURI(headerMail);
		idProjet = encodeURI(idProjet);

		updateTextArea('bodytextarea');
		
		message=document.getElementById('bodytextarea').value;
		message=str_replace('&', 'replaceampforpostajax', message);
		message = encodeURI(message);

		var data = 'title='+title;
		data += '&link='+link;
		data += '&headerMail='+headerMail;
		data += '&message='+message;
		data += '&idProjet='+idProjet;
		
		http.open('post', '../page/script/sendMail.php');
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      
		http.send(data);
		http.onreadystatechange = sendMailReply;
	return false;
		}
	});
}
function sendMailReply() {
	if(http.readyState == 4){
	var response = http.responseText;	
		if(response == 0){
				Effect.Fade('MailWait', { duration: 1.0 , afterFinish: 
					function(){	
						Effect.Appear('MailErr', { duration: 1.0 });					
					}
			});	
		} else {
				Effect.Fade('MailWait', { duration: 1.0 , afterFinish: 
					function(){	
						Effect.Appear('MailOk', { duration: 1.0 });					
					}
			});	
		}
	}
}

function findPos(obj) {
	
	var curleft = curtop = 0;
	if (obj.offsetParent) {

		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
	
		}while (obj = obj.offsetParent);

		return [curleft,curtop];
	}
}

function str_replace(search, replace, subject) {
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
    return sa ? s : s[0];
}

function closeWin(){
	location.reload();
}