

function RefreshParentWindow(){

	// Make sure that the parent window was not closed or something.
	if(typeof window.opener == 'undefined' && window.opener == null)
		return;

	var current_window_url = window.opener.location.toString();
	var new_window_url = "";

	dateObj = new Date();
	var NoCache = dateObj.getTime();

	if (current_window_url.match(/nocache=\d+/i)){
		new_window_url = current_window_url.replace(/nocache=\d+/i, ("nocache=" + NoCache));
	}
	else{
		if (!current_window_url.match(/\?/i))
			new_window_url = current_window_url + "?nocache=" + NoCache;
		else
			new_window_url = current_window_url + "&nocache=" + NoCache;
	}

	window.opener.location = new_window_url;

}


// Will encdoe a string to use with regular expression search terms.
// A lot of time the stuff you are searching FOR may be dynamic.
function encodeRE(s) 
{ 
	return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
} 

function htmlize(str)
{
        str = str.replace(/\&/g,"&amp;");
        str = str.replace(/\</g,"&lt;");
        str = str.replace(/\>/g,"&gt;");
        str = str.replace(/\"/g,"&quot;");
        return str;
}


function addslashes(str)
{
        str = str.replace(/\"/g,'\\\"');
        str = str.replace(/\'/g,"\\\'");
        return str;
}


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;
}

// This can be used like Add Commas, but with more functionality
// nStr: The number to be formatted, as a string or number. No validation is done, so don't input a formatted number. If inD is something other than a period, then nStr must be passed in as a string. 
// inD: The decimal character for the input, such as '.' for the number 100.2 
// outD: The decimal character for the output, such as ',' for the number 100,2 
// sep: The separator character for the output, such as ',' for the number 1,000.2 
// Examples
// addSeparatorsNF(43211234.56, '.', '.', ',')
// 43,211,234.56
// addSeparatorsNF('52093423.003', '.', ',', '.')
// 52.093.423,003
// addSeparatorsNF('584,567890', ',', '.', ',')
// 584.567890 
// addSeparatorsNF(-1.23e8, '.', '.', ',')
// -123,000,000

function addSeparatorsNF(nStr, inD, outD, sep)
{
	nStr += '';
	var dpos = nStr.indexOf(inD);
	var nStrEnd = '';
	if (dpos != -1) {
		nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
		nStr = nStr.substring(0, dpos);
	}
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, '$1' + sep + '$2');
	}
	return nStr + nStrEnd;
}
