var FDUtil = new Object;
/******************************************************/
FDUtil.getImage = function(imageid, imagepath, imagetype) {
	aWindow = window.open("UploadLogo.aspx?imageid=" + imageid + "&imagepath=" + imagepath + "&imagetype=" + imagetype, "blah", "width=500,height=225");
	aWindow.opener.name = "opener";
	if (aWindow.opener == null) aWindow.opener = window;
}
/******************************************************/
FDUtil.getAttachment = function(imageid, imagepath, imagetitle, imagesize) {
	aWindow = window.open("UploadAttachment.aspx?imageid=" + imageid + "&imagepath=" + imagepath + "&imagetitle=" + imagetitle + "&imagesize=" + imagesize, "blah", "width=500,height=225");
	aWindow.opener.name = "opener";
	if (aWindow.opener == null) aWindow.opener = window;
}
/******************************************************/
FDUtil.getPassword = function() {
    aWindow = window.open("../ForgotPassword.aspx", "ForgotPassword", "width=450,height=200");
	aWindow.opener.name = "opener";
	if (aWindow.opener == null) aWindow.opener = window;
}
/******************************************************/
FDUtil.getAuthPage = function(authPage) {
    aWindow = window.open(authPage, "AuthPage", "height=" + screen.height/2.3 + ",width=" + screen.width/2.8 + "");
    aWindow.opener.name = "opener";
    if (aWindow.opener == null) aWindow.opener = window;
}
/******************************************************/
FDUtil.y2k = function(number) {
	return (number < 1000) ? number + 1900 : number;
}
/******************************************************/
FDUtil.daysElapsed = function(date1,date2) {
    var difference = Date.UTC(FDUtil.y2k(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0) - Date.UTC(FDUtil.y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0);
    return difference/1000/60/60/24;
}
/******************************************************/
FDUtil.findDateDiff = function(dat1,dat2) {
	var d1 = new Date(dat1);
	var d2 = new Date(dat2);

	return FDUtil.daysElapsed(d1,d2);
}
/******************************************************/
FDUtil.findInterest = function(dt1, dt2, val, prcnt) {
	if (dt1 == null || dt2 == null || val == null || prcnt == null) { return 0; }
	if (dt1 >= dt2) return 0;
	var days = FDUtil.findDateDiff(dt1, dt2);
	return (val * Math.pow(((prcnt/36500) + 1 ), days));
}
/******************************************************/
FDUtil.formatCurrency = function(num) {
	if (num == null) return 0;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) 	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num % 100;
	num = Math.floor(num/100).toString();
	if(cents < 10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}
/******************************************************/
FDUtil.getCookie = function(c_name)
{
if (document.cookie.length > 0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start != -1)
    {
    c_start = c_start + c_name.length + 1;
    c_end = document.cookie.indexOf(";", c_start);
    if (c_end==-1) c_end = document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
/******************************************************/
FDUtil.setCookie = function(c_name,value,expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie= c_name + "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
/******************************************************/
var Cursor = new Object();
Cursor.setAtEnd = function(sTextboxID) { var oTextbox = $(sTextboxID); if (oTextbox .createTextRange) { var r = (oTextbox.createTextRange()); r.moveStart('character', (oTextbox.value.length)); r.collapse(); r.select(); }}
/******************************************************/
Array.prototype.insert = function(i, v) { if (i >= 0) { this.splice(i, 0, v); } }
/******************************************************/
String.prototype.parseQty = function()
{
	var result = this.replace(/[^0-9\.]/g,"");
	return (result == "") ? 1 : parseFloat(result);
}
String.prototype.parseFloat = function()
{
	var result = this.replace(/[^0-9\.-]/g,"");
	return (result == "") ? 0 : parseFloat(result);

	return this;
}
String.prototype.parseDays = function()
{
	var result = this.replace(/[^0-9\.]/g,"");
	var days = (result == "") ? 1 : parseInt(result);
	if (days == 0) { return 1; }
	return (days > 365) ? 365 : days;
}
/******************************************************/
var NumberUtil = new Object;

NumberUtil.isNumeric = function(sText)
{
   var ValidChars = '0123456789.';
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++)
   {
	  Char = sText.charAt(i);
	  if (ValidChars.indexOf(Char) == -1)
	  {
		 IsNumber = false;
	  }
   }
   return IsNumber;
}

NumberUtil.isInt = function(myNum)
{
	if ((myNum == null) || (myNum == '')) { return false; }
	return ((myNum % 1) == 0);
}

NumberUtil.roundDecimals = function(original_number, decimals) {
    var result = Math.round(original_number * Math.pow(10, decimals));
    return result / Math.pow(10, decimals)
}
/******************************************************/

