Element.addMethods({
	getText: function(element){
		element = $(element);
		return (element.firstChild && element.firstChild.nodeValue) ? element.firstChild.nodeValue : '';
	}
});

function popUpMap(URL, width, height) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height="+ height +"');");
}
function tryAndEncode(value)
{
	try{
		var encoded = "";
		for(var i = 0; i < value.length;i++){
			if(value.charCodeAt(i) == 8364){
				encoded += "&euro;";
			}else{
				encoded += value.charAt(i);
			}
		}
		encoded = encodeURIComponent(encoded);
		return encoded;
	}
	catch(e){
		return value;
	}
}
function count_words_in(value)
{

	if(value.blank()){ return 0;}
	var len = 0;
	a = value.replace(/\s\s+|;|\.|,|:|\/|-|\n|\'/g, ' ');
	a = a.replace(/\s\s+/g,'');
	return a.split(' ').size();
}