function debug(s) {
	if (typeof console != "undefined" && typeof console.log != "undefined") {
		console.log(s);
	} else {
		alert(s);
	}
}


String.prototype.niceTruncate = function(len){
				if(this.length>len){
					var retStr = "";
					var arrStr = this.split(' ');
					var count_chars = 0;
					for(var wordIdx in arrStr){
						count_chars += arrStr[wordIdx].length;
						if(count_chars<len || retStr==''){
							retStr += arrStr[wordIdx]+ ' ';
						}
					}
					retStr = (retStr.length>len)?retStr.substring(0,len):retStr;
					retStr= "<span title=\""+this+"\">" + retStr + "...</span>";
					return retStr;
				}else{
					return this;	
				}
		}
		

String.prototype.URICompatible = function(){
	
}


Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

Array.prototype.remove = function (subject) {
	var r = new Array();
	for(var i = 0, n = this.length; i < n; i++){
		if(!(this[i]==subject)){
			r[r.length] = this[i];
		}
	}
	return r;
}
