<!--


/////////////////////////////////////////////////////////////////////////////////////
// Copyright © WebOperator ® 2003-2006 Tous droits réservés
// Ce programme informatique est protégé par les droits d'auteur et des brevets
// TOUTE REPRODUCTION OU CONTREFACON EST INTERDITE
//
// Copyright © WebOperator ® 2003-2006 All rights reserved
// This data-processing program is protected by author's right and patents
// ANY REPRODUCTION OR COUNTERFEIT PROHIBITED
//
// WebOperator 
// 85, bd Auguste Blanqui
// 75013 Paris
// France
// http://www.weboperator.net
/////////////////////////////////////////////////////////////////////////////////////


function WO_FormatLien(chaine){

	var chr, chr2, expreg, intitule, lien, pos;
	var sch = new Array();
	
	if(type_affi != 'form'){
		
		//expreg = /((http:\/\/|https:\/\/|www\.)[^,:; <>]+[^\.,:; <>]|[a-z0-9\.\-_]+@[a-z0-9\.\-_]+\.[a-z]{2,})/i;
		expreg = /((http:\/\/|https:\/\/|www\.)[^ <>\n\r\t]+[^\.,:; <>\n\r\t]|[a-z0-9\.\-_]+@[a-z0-9\.\-_]+\.[a-z]{2,})/i;
		
		chr = chaine;
		chaine = '';
		
		while(chr){
			
			chr2 = '';
			pos = chr.search('<');
			if(pos >= 0){
				chr2 = chr.substr(pos);
				chr = chr.substr(0, pos);
			}
			
			while(chr){
				pos = chr.search(expreg);
				if(pos >= 0){
					sch = chr.match(expreg);
					lien = sch[0];
					intitule = lien;
					if(sch = intitule.match(/^(http:\/\/|https:\/\/|www\.)[^\/]*($|\/)/i)){
						intitule = sch[0];
						if(intitule != lien) intitule += '...';
					}
					chaine += chr.substring(0, pos) + '<a href="';
					if(lien.match(/^[a-z0-9\.\-_]+@[a-z0-9\.\-_]+\.[a-z]{2,}$/i)) chaine += 'mailto:';
					else if(!lien.match(/^https{0,1}:\/\//i)) chaine += 'http://';
					//chaine += lien + '" class="wo_cont_lien" target="blank">' + intitule + '</a>';
					chaine += lien + '" target="blank">' + intitule + '</a>';
					chr = chr.substring(pos + lien.length);
				}
				else {
					chaine += chr;
					chr = '';
				}
			}
			
			pos = chr2.search('>');
			if(pos >= 0){
				chaine += chr2.substr(0, pos+1);
				chr = chr2.substr(pos+1);
			}
			else {
				chaine += chr2;
			}
		}	
	}
	
	return chaine;
}


//-->
