function EP_divtrans_sub(tx,transtype) {
	if ( tx.indexOf('\n') == -1 ) {
		tx = tx.replace(/\r/g,'\n');
	}
	tx = tx.replace(/</g,'&lt;');
	tx = tx.replace(/>/g,'&gt;');
	tx = tx.replace(/&/g,'&amp;');
	var smileys = [ [':-*[)]+', 'smiley.gif', ':-)'], [':-*[(]+', 'sad.gif', ':-('], [':-*[*]', 'kiss.gif', ':-*'],
		[':-*D+', 'grin.gif', ':-D'], [':-*[Oo]', 'shocked.gif', ':-O'], [':-*[pP]', 'tongue.gif', ':-P'],
		[';-*[)]+', 'wink.gif', ';-)'], [':-*/', 'undecided.gif', ':-/'] ];
	var i;
	var r;
	var rep;
	for(i=0;i<smileys.length;i++) {
		rep = '<img src="http://images.eropolis.hu/imgs/smile/'+smileys[i][1]+'" width="15" height="15" alt="'+smileys[i][2]+'">';
		/*
		r = new RegExp('^'+smileys[i][0]+'(\\s)','g');
		tx = tx.replace(r,rep+'$1');
		r = new RegExp('(\\s)'+smileys[i][0]+'(\\s)','g');
		tx = tx.replace(r,'$1'+rep+'$2');
		r = new RegExp('(\\s)'+smileys[i][0]+'$','g');
		tx = tx.replace(r,'$1'+rep);
		r = new RegExp('^'+smileys[i][0]+'$','g');
		tx = tx.replace(r,rep);
		*/
		r = new RegExp('^'+smileys[i][0],'g');
		tx = tx.replace(r,rep);
		r = new RegExp('(\\s)'+smileys[i][0],'g');
		tx = tx.replace(r,'$1'+rep);
		r = new RegExp(smileys[i][0]+'$','g');
		tx = tx.replace(r,rep);
	}
	if ( ( transtype == 'relaxed' ) || ( transtype == 'relaxed-nomail' ) ) {
		tx = tx.replace(/(\s)(https?[:]\S+)/g,'$1<a href="$2" target="_blank">$2</a>');
		tx = tx.replace(/(\s)[!]link[:](https?[:]\S+)/g,'$1<a href="$2" target="_blank">$2</a>');
		tx = tx.replace(/^(https?[:]\S+)/g,'<a href="$1" target="_blank">$1</a>');
		tx = tx.replace(/^[!]link[:](https?[:]\S+)/g,'<a href="$1" target="_blank">$1</a>');
		tx = tx.replace(/[!]kep[:](\S+)/g, '<a href="$1" target="_blank"><img src="$1" width="200" border="0" alt="kattints az eredeti m&eacute;retben val&oacute; megtekint&eacute;shez!"></a>');
		if ( transtype == 'relaxed' )
			tx = tx.replace(/([a-zA-Z0-9_%.!=:-]+@[a-zA-Z0-9-]+[.][a-zA-Z0-9.-]+)/g,'<a href="mailto:$1">$1</a>');
		else
			tx = tx.replace(/[a-zA-Z0-9_%.!=:-]+@[a-zA-Z0-9-]+[.][a-zA-Z0-9.-]+/g,'<i>(t&ouml;r&ouml;lt email c&iacute;m)</i>');
	}
	else {
		tx = tx.replace(/(\s)(https?[:]\S+)/g,'$1<i>(t&ouml;r&ouml;lt link)</i>');
		tx = tx.replace(/(\s)[!]link[:](https?[:]\S+)/g,'$1<i>(t&ouml;r&ouml;lt link)</i>');
		tx = tx.replace(/^(https?[:]\S+)/g,'<i>(t&ouml;r&ouml;lt link)</i>');
		tx = tx.replace(/^[!]link[:](https?[:]\S+)/g,'<i>(t&ouml;r&ouml;lt link)</i>');
		tx = tx.replace(/[a-zA-Z0-9_%.!=:-]+@[a-zA-Z0-9-]+[.][a-zA-Z0-9.-]+/g,'<i>(t&ouml;r&ouml;lt email c&iacute;m)</i>');
		tx = tx.replace(/[!]kep[:](\S+)/g, '<i>(t&ouml;r&ouml;lt k&eacute;p)</i>');
	}
	tx = tx.replace(/EROPOLIS[:](\S+)/g, '<a href="http://www.eropolis.hu/$1" target="_blank">EROPOLIS:$1</a>');
	tx = tx.replace(/ettp:(\S+)/g, '<a href="http://www.eropolis.hu/$1" target="_blank">EROPOLIS:$1</a>');
	tx = tx.replace(/[*]([^*]+)[*]/g,'<b>$1</b>');
	tx = tx.replace(/\b_([^_]+)_\b/g,'<u>$1</u>');
	tx = tx.replace(/\n/g,'<br/>\n');
	return(tx);
}
function EP_divtrans_sizesub(mat) {
	x = mat.split('=',2);
	x[1] = x[1].replace(/[^0-9%]+/g,'');
	if ( x[1].substr(x[1].length-1,1) == '%' ) {
		x[1] = x[1].substr(0,x[1].length-1);
		if ( parseInt(x[1]) > 100 ) x[1] = '100';
		x[1] += '%';
	} else {
		if ( parseInt(x[1]) > 450 ) x[1] = '450';
	}
	mat = x[0]+'="'+x[1]+'"';
	return(mat);
}
function EP_divtrans() {
 $$('[eptrans]').each(function (el) {
 	var ine = el.down();
	var isrelax = el.getAttribute('eptrans');
	var te = ine.innerHTML;
	var t1,t2,tp,tn;
	if ( ( el.hasAttribute('eptransallowhtml') === true ) && ( el.getAttribute('eptransallowhtml') == 'yes' ) ) {
		t2 = '';
		while(te!='') {
			tn = '';
			tp = te.indexOf('[html]');
			if ( tp != -1 ) {
				t2 += EP_divtrans_sub(te.substr(0,tp),isrelax);
				te = te.substr(tp+6);
				tp = te.indexOf('[/html]');
				if ( tp == -1 ) {
					tn = te;
					te = '';
				} else {
					tn = te.substr(0,tp);
					te = te.substr(tp+7);
				}
				if ( tn != '' ) {
					tn = tn.replace(/width=['"]?[0-9%]+['"]?/gi,EP_divtrans_sizesub);
					t2 += tn;
				}
			} else {
				t2 += EP_divtrans_sub(te,isrelax);
				te = '';
			}
		}
		el.innerHTML = t2;
	} else {
		el.innerHTML = EP_divtrans_sub(te,isrelax);
	}
 });
}
