Replace working as PHP str_replace //JavaScript Function
//+ Jonas Raoni Soares Silva //@ http://jsfromhell.com function replace(f, r, s){ var ra = r instanceof Array, sa = s instanceof Array, l = (f = [].concat(f)).length, r = [].concat(r), i = (s = [].concat(s)).length; while(j = 0, i--) while(s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j < l); return sa ? s : s[0]; }