Array.prototype.inArray = function ( search_phrase ) {
  for( var i = 0; i < this.length; i++ ) {
    if( search_phrase == this[i] ) {
      return i;
    }
  }
  return false;
}

function makeFlash(url,width,height,alt) {
	return('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + width + '" height="' + height + '">'
			+ '<param name="movie" value="' + url + '" />'
			+ '<param name="wmode" value="opaque" />'
			+ '<!--[if !IE]>-->'
			+ '<object type="application/x-shockwave-flash" data="' + url + '" width="' + width + '" height="' + height + '">'
			+ '<param name="wmode" value="opaque" />'
			+ '<!--<![endif]-->'
			+ alt
			+ '<!--[if !IE]>-->'
			+ '</object>'
			+ '<!--<![endif]-->'
			+ '</object>');
}

function roundNumber(rnum, rlength) { 
  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	return newnumber;
}

function zeroPad(number, width) {
	var ret = "" + number;
	while( ret.length < width )
		ret = "0" + ret;
	return ret;
}

function truncate(text, len) {
	return text.substring(0, len) + "...";
}

window.ify = function() {
	var entities = {
			'"' : '&quot;',
			'&' : '&amp;',
			'<' : '&lt;',
			'>' : '&gt;'
	};

	return {
		"link": function(t) {
			return t.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?\/.=]+[^:\.,\)\s*$]/ig, function(m) {
				return '<a href="' + m + '">' + ((m.length > 25) ? m.substr(0, 24) + '...' : m) + '</a>';
			});
		},
		"at": function(t) {
			return t.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15})/g, function(m, m1, m2) {
				return m1 + '@<a href="http://twitter.com/' + m2 + '">' + m2 + '</a>';
			});
		},
		"hash": function(t) {
			return t.replace(/(^|[^\w'"]+)\#([a-zA-Z0-9_]+)/g, function(m, m1, m2) {
				return m1 + '#<a href="http://search.twitter.com/search?q=%23' + m2 + '">' + m2 + '</a>';
			});
		},
		"clean": function(tweet) {
			return this.hash(this.at(this.link(tweet)));
		}
	};
}();

function filterText(text) {

		var badwordssource = "\x2F\x66\x75\x63\x6B\x7C\x66\x75\x6B\x7C\x73\x68\x69\x74\x7C\x62\x61\x73\x74\x61\x72\x64\x7C\x61\x72\x73\x65\x7C\x6D\x69\x6E\x67\x65\x7C\x66\x61\x6E\x6E\x79\x7C\x74\x77\x61\x74\x7C\x63\x6C\x69\x74\x7C\x63\x75\x6E\x74\x7C\x6E\x69\x67\x67\x65\x72\x7C\x70\x61\x6B\x69\x7C\x77\x61\x6E\x6B\x7C\x63\x72\x61\x70\x2F\x67\x69";
		var badwords= new RegExp(badwordssource);
		if (text.search(badwords) < 1) {
			return text;
		}
}