﻿if(!Array.indexOf){
    Array.prototype.indexOf = function(obj, start){
        for(var i=(start||0); i<this.length; i++){
            if(this[i]==obj){
                return i;
            }
        }
    }
}
var isNull = function(value)
{
	if (!value || value == null || (typeof(value)=='string' && value.length <= 0))
		return true;
	else
		return false;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
Object.prototype.urlEncode = function(replacement)
{
	if (this == null) 
		return '';
	else
	{
		var value = this.toString();
		return value.urlEncode(replacement);
	}
}
String.prototype.urlEncode = function(replacement) 
{ 
	if (!replacement) replacement = '';
	var value = (this == null || this.length <= 0) ? replacement : this;
	return escape(value);
}


String.prototype.formatCurrency = function() 
{
	nStr = this;
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return '$' + (x1 + x2);
}

Number.prototype.formatCurrency = function() 
{
	nStr = this;
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return '$' + (x1 + x2);
}

var BrowserAgent = 
{
	UserAgent: window.navigator.userAgent,
	IsIE: (window.navigator.userAgent.indexOf('MSIE') >= 0),
	IsFF: (window.navigator.userAgent.indexOf('Firefox') >= 0),
	Version: function () {
		if (this.IsIE)
			return window.navigator.appVersion.substr(window.navigator.appVersion.indexOf('MSIE')+5, 1);
	}
}
