//==============================================================================
// File Name:
//    REALTransFormat.js
//
// Purpose:
//    Formatting functions.
//        FormatCurrency()
//        FormatDate()
//        FormatFloat()
//        FormatPhoneNumber()
//        FormatPostalCodeUS()
//        FormatSocialSecurityNumberUS()
//        FormatCurrencyUS()
//        StripFloat()
//        StripInteger()
//        StripLeadingSpaces()
//        StripLeadingZeros()
//        StripTrailingSpaces()
//		  isValidContactOrder2()
//		  isValidContactOrder4()
//		  onlyOne()
//        AlignMoney()
//        outputComma(number)
//        FormatEIN(number)
//- Maintenance ----------------------------------------------------------------
// 29 june 2001 Alexander Makarov <amakarov@ocwen.com>
//    Added   outputComma(number)
// 03 October Nellie Izmaylova <nizmaylo@ocwen.com>
//   Added AlignMoney
//29 September 2000 Alexander Makarov <amakarov@ocwen.com>
//  altered StripFloat()
// 28 July 2000		  Peter Rinehart <prinehart@ocwen.com> / <per3@cornell.edu>
//	  corrected FormatPostalCodeUS()
// 07 February 2000	  Craig Newman	added onlyOne()
// 19 Janurary 2000   Thomas W Stetler <tstetler@realtrans.com>
//    Altered FormatDate().
// 18 Janurary 2000   Thomas W Stetler <tstetler@realtrans.com>
//    Added isValidContactOrder2() and isValidContactOrder4().  
// 20 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Added functions FormatDate(), FormatPhoneNumber(), FormatPostalCodeUS()
//    and FormatSocialSecurityNumberUS().
// 17 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Added functions StripLeadingZeros(), StripLeadingSpaces(),
//    StripTrailingSpaces(), and FormatCurrencyUS(). Modified FormatCurrency()
//    work with any currency.
// 16 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Moved stripping of invalid characters from integers and floats to
//    StripInteger() and StripFloat() respectively.
// 15 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Fixed problem in FormatCurrency() with leading zeros ending up in the
//    output string.
// 14 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Original version of FormatCurrency().
// 08 December 1999   Charles J. Coker <chuckc@realtrans.com>
//    Added FormatFloat().
// 20 October 2000.  Teodoro Viteri <tviteri@ocwen.com>
//    Added FormatTaxIDNumberUS().
// 09 October 2003 Lakshmi M S <maralurl@ocewn.co.in>
//    Added FormatEIN()
//==============================================================================
//==============================================================================
// Function Name:
//   outputComma(number)
//
// Purpose:
//    Formats the input string into comma delimited number 
//    1,123,456,789 format.
//
// 
//
// Parameters:
//    number     The string to be formatted.
//
// Returns:
//    A string formatted to display a   number in
//    1,123,456,789 format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function outputComma(number) {
 var regex = /[^0-9]/g;
 var expressionA=/[a-z]/i;
 if (number.match(expressionA)!=null) {
     alert('This is not a valid number.');
     }
 for (i=0 ; i < number.length  ; i++){
   number=number.replace(regex,'');
  }
   
number ='' + number ;
if (number.length > 3)  {
var mod = number.length%3; var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length/3) ; i++) {
if ((mod ==0) && (i ==0))
output+= number.substring(mod+3*i,mod+3*i+3);else
output+= ',' + number.substring(mod+3*i,mod+3*i+3);}
return (output);
}
else 
return number;
}



//==============================================================================
// Function Name:
//    FormatSocialSecurityNumberUS()
//
// Purpose:
//    Formats the input string into the United States Social Security number
//    123-45-6789 format.
//
// Known Limitations:
//
// Parameters:
//    number_in     The string to be formatted.
//
// Returns:
//    A string formatted to display a United States Social Security number in
//    123-45-6789 format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

//================================================================================

function FormatSocialSecurityNumberUS(number_in)
{
    if (!(IsValidSocialSecurityNumberUS(number_in)))
        return "";
    var number_out = StripInteger(number_in);
    return (number_out.substr(0, 3) + "-" + number_out.substr(3, 2) + "-"
        + number_out.substr(5, 4));
}

//==============================================================================
// Function Name:
//    FormatTaxIDNumberUS()
//
// Purpose:
//    Formats the input string into the United States Tax ID number
//    12-3456789 format.
//
// Known Limitations:
//
// Parameters:
//    number_in     The string to be formatted.
//
// Returns:
//    A string formatted to display a United States Tax ID number in
//    12-3456789 format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatTaxIDNumberUS(number_in)
{
    if (!(IsValidTaxIDNumberUS(number_in)))
        return "";
    var number_out = StripInteger(number_in);
    return (number_out.substr(0, 2) + "-" + number_out.substr(2, 7));
}

//==============================================================================
// Function Name:
//    FormatPostalCodeUS()
//
// Purpose:
//    Formats the input string into the United States postal code in Zip Code
//    12345 format or a Zip+4 Code in 12345-6789 format.
//
// Known Limitations:
//    None.
//
// Parameters:
//    code_in     The string to be formatted.
//
// Returns:
//    A string formatted to display a United States postal code (Zip Code) in
//    12345 format or a Zip+4 Code in 12345-6789 format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatPostalCodeUS(code_in)
{
    var code_out = "";
    if (!(IsValidPostalCodeUS(code_in)))
        return "";
    code_out = StripInteger(code_in);
    if (9 == code_out.length)
        code_out = code_out.substr(0, 5) + "-" + code_out.substr(5);
    else
        code_out = code_out;
    return code_out;
}

//==============================================================================
// Function Name:
//    FormatPhoneNumber()
//
// Purpose:
//    Formats the input string into the '(123) 456-7890' or
//    '(123) 456-7890 ext 1234' format.
//
// Known Limitations:
//
// Parameters:
//    number_in     The string to be formatted.
//
// Returns:
//    A string formatted to display phone number in '(123) 456-7890' or
//    '(123) 456-7890 ext 1234' format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatPhoneNumber(number_in)
{
    if (!(IsValidPhoneNumber(number_in)))
        return "";
    var number_out = StripInteger(number_in);
    if (10 == number_out.length)
    {
        return ("(" + number_out.substr(0, 3) + ") " + number_out.substr(3, 3)
            + "-" + number_out.substr(6, 4));
    }
    else
    {
        return ("(" + number_out.substr(0, 3) + ") " + number_out.substr(3, 3)
        + "-" + number_out.substr(6, 4) + " ext " + number_out.substr(10));
    }
}

//==============================================================================
// Function Name:
//    FormatDate()
//
// Purpose:
//    Formats the input string into the MM-DD-YYYY date format.
//
// Known Limitations:
//
// Parameters:
//    date_in     The string to be formatted.
//
// Returns:
//    A string formatted to display date in MM-DD-YYYY format.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatDate(date_in)
{
    var month_in;        // valid range: 01 through 31
    var day_in;          // valid range: 01 through 12
    var year_in;         // valid range: min_year through max_year

    if (!(IsValidDate(date_in)))
        return "";

	//find delimiter
	var delimiter;
	var i; //index
	i = 0;
	while ((i < date_in.length) && IsDigit(date_in.charAt(i))) {
		i++;
	}
	// found a delimiter?
	if (i < date_in.length) {				
		delimiter = date_in.charAt(i);
	
		//split into month/day/year strings	
		var TempArray = date_in.split(delimiter);
		month_in = TempArray[0];
		if (month_in.length == 1)
			month_in = '0' + month_in; //to change '1' into '01' for Janurary, '2' into '02' for Feburary....
		day_in = TempArray[1];
		if (day_in.length == 1)
			day_in = '0' + day_in; // to change '1' into '01' for 1st day of month....
		year_in = TempArray[2];
	} else if (i == 8) { //8 is the magic number for a valid date
		month_in = date_in.substr(0, 2);
		day_in = date_in.substr(2, 2);
		year_in = date_in.substr(4, 4);
	} else
		return false;

    return (month_in + "-" + day_in + "-" + year_in);
}

//==============================================================================
// Function Name:
//    FormatCurrencyUS()
//
// Purpose:
//    Formats a string of digits into standard United States currency format.
//
// Known Limitations:
//    None.
//
// Parameters:
//    string_in     The string to be formatted.
//
// Returns:
//    A string formatted to display currency.
//
// Errors/Exceptions:
//    None.
//- Examples -------------------------------------------------------------------
//        string_in    returns
//        12345678     $12,345,678.00
//        123456.78    $123,456.78
//        012345678    $12,345,678.00   removed leading zero
//        123456..00   $123456.00       removed invalid extra decimal point
//         123456X.95  $123,456.95      removed leading space and invalid
//                                      character 'X'
//        1234.5678    $1,234.57        rounded to nearest cent
//==============================================================================

function FormatCurrencyUS(string_in)
{
    return FormatCurrency(string_in, 2, "$", ".", ",");
}

//==============================================================================
// Function Name:
//    FormatCurrency()
//
// Purpose:
//    Formats the input string into the proper currency format.
//
// Known Limitations:
//  1 A negative number will always have the negative sign in front of the
//    currency symbol.
//  2 Numbers are always grouped into three-digit segments.
//
// Parameters:
//    string_in               The string to be formatted.
//    decimal_places          The number of digits to the right of the decimal
//                            point.
//    currency_symbol         The symbol used to designate currency, e.g., in
//                            the United States a dollar sign ('$') is used.
//    decimal_symbol          The symbol used to make the decimal point, e.g.,
//                            in the United States a period ('.') is used.
//    thousands_separator     The symbol used to separate thousands, e.g., in
//                            the United States a comma (',') is used.
//
// Returns:
//    A string formatted to display currency.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatCurrency(string_in, decimal_places, currency_symbol,
    decimal_symbol, thousands_separator)
{
    var string_out = "";
    var temp_string = "";
    var temp_decimal_symbol = ".";
    var negative = 0;
    var num_decimal_points = 0;
    var temp_int = 0;
    var temp_float = 0.0;

    // Determine if our number is negative.
    if (-1 != string_in.indexOf('-'))
        negative++;

    // Determine if we already have a decimal point.
    if (-1 != string_in.indexOf(temp_decimal_symbol))
    {
        num_decimal_points++;
        // Take out everything except characters '0' through '9' and one
        // decimal point.
        temp_string = StripFloat(string_in);
        //Added by Venkobachar.T.G. on 15th Jan 2010  for HD477870
        if(temp_string == '0')
			num_decimal_points=0;
		//End HD477870 Changes		
    }
    else
    {
        // Take out everything except characters '0' through '9'.
        temp_string = StripInteger(string_in);
    }
    
    // Remove any leading zeros.
    //Added length checking by Venkobachar.T.G. on 15th Jan 2010  for HD477870
    if(temp_string.length > 1)//End HD477870 Changes
		temp_string = StripLeadingZeros(temp_string)

    // If we don't have any decimal points, put one in and pad the right with
    // zeros.
    if (0 == num_decimal_points)
    {
        temp_string += temp_decimal_symbol;
        for (j = 0; j < decimal_places; j++)
            temp_string += "0";
    }

    // We need to round off the "cents" to the nearest "cent".
    temp_float = eval(temp_string);
    temp_string = ""
        + (Math.round(temp_float * Math.pow(10, decimal_places))
        / Math.pow(10, decimal_places));

    // Make sure that we have a decimal point.
    if (-1 == temp_string.indexOf(temp_decimal_symbol))
        temp_string += temp_decimal_symbol;

    // Make sure we have enough zeros after the decimal point.
    for (j = 0; j < decimal_places; j++)
        temp_string += "0";
    temp_string = temp_string.substr(0,
        (temp_string.indexOf(temp_decimal_symbol) + (decimal_places + 1)));

    // Add thousands separators.
    string_out = temp_string.substr(temp_string.indexOf(temp_decimal_symbol));
    temp_int = 0;
    for (i = (temp_string.indexOf(temp_decimal_symbol) - 1); i >= 0; i--)
    {
        string_out = temp_string.charAt(i) + string_out;
        temp_int++;
        if (((decimal_places + 1) == temp_int) && (0 != i))
        {
            string_out = thousands_separator + string_out;
            temp_int = 0;
        }
    }

    // Add currency symbol and negative sign.
    string_out = currency_symbol + string_out;
    if (0 < negative)
        string_out = "-" + string_out;
    
    // Put in the correct decimal symbol.
    temp_int = string_out.indexOf(temp_decimal_symbol);
    string_out = string_out.substr(0, temp_int) +
        decimal_symbol +
        string_out.substring((temp_int + 1), string_out.length);
    return string_out;
}

//==============================================================================
// Function Name:
//    FormatFloat()
//
// Purpose:
//    FormatFloat() formats a decimal (base-10) floating-point number.
//
// Known Limitations:
//  1 Currently this function will only format positive numbers. Any other
//    characters such as negative (minus) signs, parentheses, dollar signs,
//    etc., must be added (or re-added) by the calling function.
//  2 Assumes a number in 12345.67 format, i.e., a period as the decimal point
//    character. This function will not work with numbers that use, for example,
//    a comma as a decimal point.
//
// Parameters:
//    float_value        A string containg the float value to format.
//    decimal_places     How many decimal places to show.
//
// Returns:
//    A string formatted to display a float value.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatFloat(float_value, decimal_places)
{
    // Strip all non-digit and non-decimal-point characters from number_in.
    float_value = StripFloat(float_value);
 
    // Multiply the incoming value by 10 to the power of the number of decimal
    // places. Round the result to the nearest integer. Convert the result to a
    // string.
    var str = "" + Math.round(Math.abs(eval(float_value))
        * Math.pow(10, decimal_places));
    
    // Pad a small value with zeros to the left of the rounded number.
    while (str.length <= decimal_places)
        str = "0" + str;
    
    // Find the location of the decimal point.
    var decimal_point_pos = str.length - decimal_places;
    
    // Build the formatted string.
    var return_value = str.substring(0, decimal_point_pos) + "."
        + str.substring(decimal_point_pos, str.length);

    return return_value;
}

//==============================================================================
// Function Name:
//    StripTrailingSpaces()
//
// Purpose:
//    Strips all trailing space characters (' ') from the input string.
//
// Known Limitations:
//    None.
//
// Parameters:
//    temp_string     The string that needs to be stripped.
//
// Returns:
//    A string with no trailing space characters (' ').
//
// Errors/Exceptions:
//    None.
//==============================================================================

function StripTrailingSpaces(temp_string)
{
    while (' ' == temp_string.charAt(temp_string.length - 1))
        temp_string = temp_string.substr(0, (temp_string.length - 1));

    return temp_string;
}

//==============================================================================
// Function Name:
//    StripLeadingSpaces()
//
// Purpose:
//    Strips all leading space characters (' ') from the input string.
//
// Known Limitations:
//    None.
//
// Parameters:
//    temp_string     The string that needs to be stripped.
//
// Returns:
//    A string with no leading space characters (' ').
//
// Errors/Exceptions:
//    None.
//==============================================================================

function StripLeadingSpaces(temp_string)
{
    while (' ' == temp_string.charAt(0))
        temp_string = temp_string.substr(1);

    return temp_string;
}

//==============================================================================
// Function Name:
//    StripLeadingZeros()
//
// Purpose:
//    Strips all leading zeros ('0') from the input string.
//
// Known Limitations:
//    None.
//
// Parameters:
//    temp_string     The string that needs to be stripped.
//
// Returns:
//    A string with no leading zeros ('0').
//
// Errors/Exceptions:
//    None.
//==============================================================================

function StripLeadingZeros(temp_string)
{
    while ('0' == temp_string.charAt(0))
        temp_string = temp_string.substr(1);

    return temp_string;
}

//==============================================================================
// Function Name:
//    StripFloat()
//
// Purpose:
//    Strips all characters from the input string that do not fall into the
//    range '0' through '9' and '.'. Any characters that fall outside this
//    range are removed.
//
// Known Limitations:
//    None.
//
// Parameters:
//    string_in     The string that needs to be stripped.
//
// Returns:
//    A string containing only characters '0' through '9', and '.'.
//
// Errors/Exceptions:
//    None.
//==============================================================================
/** before altering 29/09/2000
function StripFloat(string_in)
{
    var string_out = "";
    var len = string_in.length;
    var num_decimal_points = 0;
    
    for (i = 0; i < len; i++)
    {
        var character = string_in.charAt(i);
        if ((character >= '0') && (character <= '9'))
        {
            string_out += character;
        }
        else if ('.' == character)
        {
            num_decimal_points++;
            if (1 == num_decimal_points)
            {
                string_out += ".";
            }
        }
    }
    return string_out;
}
**/
// after 29/09/2000
function StripFloat(string_in)
{
   
    var string_out = "";
    var len = string_in.length;
    var num_decimal_points = 0;
       
           // alert(string_in)
    
    
    for (i = 0; i < len; i++)
    {
        var character = string_in.charAt(i);
      
    
       
        if ((character >= '0') && (character <= '9'))
        {
            string_out += character;
        }
        else if ('.' == character)
        {
            num_decimal_points++;
            if (1 == num_decimal_points)
            {
                string_out += ".";
            }
        }
    }
    
    for (i = 0; i < len; i++) {
      
         if (string_out.charAt(0)== '.') break;
        
            if  (string_out.charAt(0)== '0') 
         
              {  string_out=string_out.substr(1,string_out.length-1);          }
           
   }
          if ((string_out=='.')||(string_out=='' )){string_out='0';}
          
    return string_out;
}


//==============================================================================
// Function Name:
//    StripInteger()
//
// Purpose:
//    Strips all characters from the input string that do not fall into the
//    range '0' through '9'. Any characters that fall outside this range are
//    removed.
//
// Known Limitations:
//    None.
//
// Parameters:
//    string_in     The string that needs to be stripped.
//
// Returns:
//    A string containing only characters '0' through '9'.
//
// Errors/Exceptions:
//    None.
//==============================================================================

function StripInteger(string_in)
{
    var string_out = "";
    var len = string_in.length;

    for (i = 0; i < len; i++)
    {
        var character = string_in.charAt(i);
        if ((character >= '0') && (character <= '9'))
            string_out += character;
    }
    return string_out;
}

//==============================================================================
//
// Function FixFormat(inp_object, fieldtype)
//
// purpose:
//			change the value field of the input object (given
//			by the first parameter, into a format whose type is
//			indicated by the second parameter, ie
//				FixFormat(this, 'Phone');
//			will be used for objects which the web users enter a
//			phone number and this function will put the entered phone
//			number into approriate format.  This function calls the 
//			functions above to accomplish this task.
//
//==============================================================================

	function FixFormat(inp_object, fieldtype)
	{
		var val_string = inp_object.value;
		if (fieldtype == 'Phone') 
			results = FormatPhoneNumber(val_string);
		else if (fieldtype == 'SSN')
			results = FormatSocialSecurityNumberUS(val_string);
		else if (fieldtype == 'USZip')
			results = FormatPostalCodeUS(val_string);
		else if (fieldtype == 'Date')
			results = FormatDate(val_string);
		else if (fieldtype == 'St') {
			if(IsValidState(val_string))
				results = val_string.toUpperCase();
			else
				results = '';
			}
		//inp_object.value = results;
		eval("inp_object.value = \"" + results + "\"");
	}
	
//==============================================================================
//
//	function isValidContactOrder2(PhoneSeq, FaxSeq)
//
//  purpose:
//		Most of this code has been copied from isValidContactOrder
//		from the last release, This function will check for duplicate
//		priorities.  Duplicate priorities aren't allowed and the user will
//		be warned if one is passed in.   
//==============================================================================
	
function isValidContactOrder2(PhoneSeq, FaxSeq){
	phn   = PhoneSeq.value;
	fax   = FaxSeq.value;

	if(phn == fax){
		window.alert("The order of contact for the phone and fax cannnot be the same. Please check these values and re-submit.");
		PhoneSeq.focus();
		return false;
	}
}

//==============================================================================
//
//	function isValidContactOrder4(PhoneSeq, FaxSeq, CellSeq, EmailSeq)
//
//  purpose:
//		Most of this code has been copied from isValidContactOrder
//		from the last release, this function check for duplicate priories
//		which aren't allowed.  Each of the parameters are the select objects
//		for the following items: Phone, Fax, Cellular, and Email
//==============================================================================
	
function isValidContactOrder4(PhoneSeq, FaxSeq, CellSeq, EmailSeq){
	phn   = document.frmNewUser.cmbPhoneSeq.value;
	fax   = document.frmNewUser.cmbFaxSeq.value;
	cell  = document.frmNewUser.cmbCellSeq.value;
	email = document.frmNewUser.cmbEmailSeq.value;
	
	
	if(phn != fax && phn != cell && phn != email){
		 //do nothing
	}
	else{
		window.alert("Please check the order of contact for the phone and re-submit.");
		PhoneSeq.focus();
		return false;
	}
	if(fax != cell && fax != email){
		//do nothing
	}
	else{
		window.alert("Please check the order of contact for the fax number and re-submit.");
		FaxSeq.focus();
		return false;
	}
	if(cell != email){
		//do nothing
	}
	else{
		window.alert("Please check the order of contact for the cell phone and re-submit.");
		CellSeq.focus();
		return false;
	}
}

//  mutually exclusive checkboxes
//  numX format is formName.dataName
//  note: the maximum numer of parameters..
//        num1 is always the box just-clicked
//  ex: onclick="onlyOne(this,clem.ORD_CnfrmByOthrDate_CHK);"

function onlyOne(num1, num2, num3, num4, num5, num6, num7, num8)
{
	//Num1 must always be the checkbox being checked and/or unchecked.
	//First, prevent num1 of being unchecked.
	if (num1.checked == false) { return false; }
//alert('num2 = ' + num2.value);
//alert('num1 = ' + num1.name + '\n' + 'num2 = ' + num2.name +'\n'  + 'num3 = ' + num3 +'\n'  + 'num4 = ' + num4 +'\n'  + 'num5 = ' + num5 +'\n'  + 'num6 = ' + num6 +'\n'  + 'num7 = ' + num7 +'\n'  + 'num8 = ' + num8 );
  if (num2)
    if (num2.checked){ num2.checked = false; num2.value=0;}
  if (num3)
    if (num3.checked){ num3.checked = false; num3.value=0;}
  if (num4)
    if (num4.checked){ num4.checked = false; num4.value=0;}
  if (num5)
    if (num5.checked){ num5.checked = false; num5.value=0;}
  if (num6)
    if (num6.checked){ num6.checked = false; num6.value=0;}
  if (num7)
    if (num7.checked){ num7.checked = false; num7.value=0;}
  if (num8)
    if (num8.checked){ num8.checked = false; num8.value=0;}
  if (num1.checked){ num1.checked = true; num1.value=1;}
  else{ num1.checked = false; }
}
// ==================================================================

// function (sub)name:  AlignMoney(strTag, strSearch)
// Parameters: strTag - tag, which contains a money field
//             example: on order or fulfillment form - 'INPUT'
//						on a view form 'TD'
//             strSearch - string in outerHTML to search for
//             example: on order or fulfillment form - '_$TWC'
//                      on a view form '$'
// Purpose: format fields containing money values to the right
// Example: as the last call in the body of function onLoad() if
//          present or simply a call in the BODY 
//          onload="rightAlignMoney('INPUT', '_$TWC');"             
function AlignMoney(strTag, strSearch) {
	if (!document.all){document.all = document.order;}
	if (IE) {
		var allTWC = document.all.tags(strTag);
		for (var i=0; i < allTWC.length; i++)
		{
			if (allTWC[i].outerHTML.indexOf(strSearch) != -1) {
			allTWC[i].style.textAlign = "right";}
		}
	}
}

//==============================================================================
// Function Name:
//    FormatEIN()
//
// Purpose:
//    FormatEIN() formats a input number in to the EIN format.
//
// Known Limitations:
//    None.
//
// Parameters:
//    number     The string that needs to be converted to EIN format(Eg:- 12-3456789).
//
// Returns:
//    A string in EIN format (Eg:- 12-3456789).
//
// Errors/Exceptions:
//    None.
//==============================================================================

function FormatEIN(number)
{
   number = StripInteger(number); 
   if(number.length==9)
    return (number.substr(0,2) + "-" + number.substr(2, number.length));
  else  
    return number;  
        
}

//==============================================================================
//======== End of REALTransFormat.js ===========================================
//==============================================================================
