function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
function replaceCommas(str){
	str = str.replace(/,/g, '');
	return parseInt(str);
}
function roundNumber(num, dec){
	return Math.round(num * Math.pow(10,dec))/Math.pow(10,dec);
}
function ucFirst(str){
	return str.substr(0,1).toUpperCase()+str.substr(1).toLowerCase();
}
function shortPrice(long_price){
	long_price = parseInt(long_price);
	/* 1,200,000 => 1.2mil */
	if(long_price > 1000000){
		
	}
	
}
function arrayIn(array, value){
	for(var i=0; i<array.length; i++){
		if(array[i] == value){
			return true;
		}
	}
	return false;
}
function allNumbers(){
for(var i=0; i<arguments.length; i++){
	if(isNaN(arguments[i])){ return false;}
}
return true;
}
function Event(e){
	var e = (typeof(e) == 'undefined') ? window.event : e;
	return e;
}
function Key(e){
	e = Event(e);
	return (typeof(e.which) == 'undefined') ? e.keyCode : e.which;
}
function lvlToExp(level){
	points = 0;
	for(lvl = 1; lvl < level; lvl++){
		points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.));
	}
	return Math.floor(points/4);
}
function expToLevel(experience){
	
	for(var i=0; i<200; i++){
		if(experience(i) > experience){
			return (i-1);
		}
	}
	return -1;
}
String.prototype.reverse = function(){
	splitext = this.split("");
	revertext = splitext.reverse();
	reversed = revertext.join("");
	return reversed;
}
function Timer(){
	this.start_time = 0;
	this.end_time = 0;
	this.duration = 0;
	
	this.start = function(){
		this.start_time = new Date().getTime();
	}
	this.end = function(){
		this.end_time = new Date().getTime();
	}
	this.clear = function(){
		this.duration = 0;
	}
	this.getValue = function(){
		this.duration = (this.end_time - this.start_time);
		return this.duration;
	}
}
function getElementsByClassName(className, parentElement) {
  if (typeof parentElement == 'string'){
    parentElement = document.getElementById(parentElement);
  } else if (typeof parentElement != 'object' || typeof parentElement.tagName != 'string') {
    parentElement = document.body;
  }
  
  var children = parentElement.getElementsByTagName('*');
  var re = new RegExp('\\b' + className + '\\b');
  var element, elements = [];
  var i = 0;
  while ( (element = children[i++]) ){
    if ( element.className && re.test(element.className)){
      elements.push(element);
    }
  }
  return elements;
}