function checkIt(evt, decimal, negative) {
	evt = (evt) ? evt : window.event;
	decimal = (decimal) ? true : false;
	negative = (negative) ? true : false;
	var charCode = (evt.which) ? evt.which : evt.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 35 || charCode > 40)) {
		if((decimal && charCode == 46) || (negative && charCode == 45)) {
			if(charCode == 46 && evt.originalTarget.value.test(/\./)) {
				return false;
			}
			if(charCode == 45 && evt.originalTarget.value.test(/-/)) {
				return false;
			}
			return true;
		}
		return false;
	}

	return true;
}

function createCSSButtons() {
	$$('.css_button').each(function(el) {
		el.addEvents({
			'mouseenter': function() {
				if (Browser.Engine.trident) {
					this.setStyle('background-position-y', 'bottom');
				} else {
					this.setStyle('background-position', this.getStyle('background-position').split(' ')[0] + ' bottom');
				}
			},
			'mouseleave': function() {
				if (Browser.Engine.trident) {
					this.setStyle('background-position-y', 'top');
				} else {
					this.setStyle('background-position', this.getStyle('background-position').split(' ')[0] + ' top');
				}
			}
		});
		el.set('class', el.get('class').split(' ').erase('css_button').join(' '));
	});
}

function createHoverButtons() {
	$$('.hover').each(function(el) {
		el.addEvents({
			'mouseenter': function() {
				this.set('class', this.get('class') + '_hover');
			},
			'mouseleave': function() {
				this.set('class', this.get('class').split('_').erase('hover').join('_'));
			}
		});
		el.set('class', el.get('class').split(' ').erase('hover').join(' '));
	});
}
function setAutoRemove(id, val) {
	if (!$(id)) return false;
	$(id).addEvent('focus', function() {
		if (this.get('value') == val) {
			this.set('value', '');
		}
	});
	$(id).addEvent('blur', function() {
		if (this.get('value') == '') {
			this.set('value', val);
		}
	});
	if ($(id).get('value') == '') $(id).set('value',val);

	return $(id);
}
function clone(obj){
    if(obj == null || typeof(obj) != 'object') return obj;

    if(obj.constructor == Array) {
        var temp = [];
        for(var i = 0; i < obj.length; i++) {
                if(typeof(obj[i]) == 'object')   temp.push(clone(obj[i]));
                else temp.push(obj[i]);
        }
        return temp;
    }

    var temp = {};
    for(var key in obj) temp[key] = clone(obj[key]);
    return temp;
}
