// Title: Tigra Calendar PRO
// Description: Tigra Calendar PRO is flexible JavaScript Calendar offering
//	 high reliability and wide browsers support.
// URL: http://www.softcomplex.com/products/tigra_calendar_pro/
// Version: 4.2
// Date: 05-24-2002 (mm-dd-yyyy)
// Technical Support: support@softcomplex.com (specify product title and order ID)
// Notes: This Script is shareware. Please visit url above for registration details.

// MODIFICATIONS
// Date modified: 06-13-2002
// Author: Tai Nguyen, tnguyen@edocs.com
// Notes: Moved some object references into a separate calendar method "cal_finish".
//   Form field can now be placed after the constructor method but before the
//   cal_finish() method.  Removed input field generation from cal_get_html(). 
//   Field must now be manually created in the HTML.
//
//   Added routine to cal_validate() to disable dates on the 29, 30, and 31st if
//   reoccur_payment flag is set to true in the HTML file.
//
// Date modified: 06-25-2002
// Author: Tai Nguyen, tnguyen@edocs.com
// Notes: Changed cal_get_html() to not show past years in drop-down.
//   Changed cal_get_body() to set today's date to class="calDayToday".
//   Changed cal_finish() to update the current date to be within the
//   date range if minimum or maximum date is specified.
//
// Date modified: 06-28-2002
// Author: Tai Nguyen, tnguyen@edocs.com
// Notes: Changed calendar() to create a this.min_valid_date property which
//   is used to update the date when date is not valid.
//
// Date modified: 07-05-2002
// Author: Tai Nguyen, tnguyen@edocs.com
// Notes: Added a payment date parameter to constructor - sets selected date to 
//   payment date if specified.  Also updated cal_finish() to set date form field  
//   to current date on initialization.
//
// Date modified: 07-18-2002
// Author: Tai Nguyen
// Notes: Moved date validation code to calendar() and changed them so they would
//   only set dt_current, not call this.update().
//
// Date modified: 07-18-2002
// Author: Tai Nguyen
// Notes: Added a use_dt_original parameter to cal_get_body().  When set to true,
//   the calendar is rendered based on the original date, not the current date.
//   The constructor function now calls cal_get_html() with this set to true.
//
// Date modified: 07-24-2002
// Author: Tai Nguyen
// Notes: Fixed cal_get_body() logic for determining which months to show.
//
// Date modified: 07-24-2002
// Author: Tai Nguyen
// Notes: Fixed cal_rel_update() logic so that use_dt_original is only true
//    on first load.
//
// Date modified: 08-20-2002
// Author: Charlie Ouellette
// Notes: Added 8th parameter which is a comma separated list of text form fields
//         that must have their values persisted on calendar actions. The calendar
//         gets their values in cal_rel_update and writes them back to the request 
//         specifically for Netscape 4.7 issues.
//
// Date modified: 04-04-2003
// Author: Tai Nguyen
// Notes: Fixed min_valid_date validation logic.
//
// --------------------------------------------------------------------------------
// --- user configuration block ---

// months as they appear in the selection list
var ARR_MONTHS = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
// week day titles as they appear on the calendar
var ARR_WEEKDAYS = ["S", "M", "T", "W", "T", "F", "S"];
// day week starts from (normally 0-Su or 1-Mo)
var NUM_WEEKSTART = 0;

// --------------------------------------------------------------------------------
var calendars = [];
var formArray = [];
var dt_original;
var max_date;
var min_date;
var dt_current;
// Constructor
function calendar (str_date, str_form_name, str_ctrl_name, str_min_date, str_max_date, str_pay_date, reoccur_pay,act_pay_date, form_array) {

	// assign methods
	this.get_html  = cal_get_html;
	this.get_body  = cal_get_body;
	this.set_year  = cal_set_year;
	this.set_month = cal_set_month;
	this.set_day   = cal_set_day;
	//this.validate  = cal_validate;
	this.finish    = cal_finish;
	this.alt_header = cal_alt_header; 
    expected_posting = act_pay_date;
    var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");

        // split the form_array by ',' 8-20-02
        formArray = (form_array ? form_array.split(',') : null);

	this.update = (document.body && document.body.innerHTML
		? cal_css_update : cal_rel_update);

	// register in global collections
	this.id = calendars.length;
	calendars[this.id] = this;
    //alert(this.id);
	// process input parameters
	var re_url = new RegExp('cal' + this.id + '_val=(\\d+)');
	var dt_params = (str_date ? cal_parse_date(str_date) : cal_date_only());
	
	var has_url = re_url.exec(String(window.location));    
	dt_current = ( has_url ? new Date(new Number(RegExp.$1)) : dt_params);
	dt_original = dt_params; 
	this.dt_pay = (str_pay_date ? cal_parse_date(str_pay_date) : null);
	
    this.reoccur_pay =  true;
	//alert(this.reoccur_pay );
	if (!str_form_name)
		return alert('Form name is required parameter of draw method.');
	if (!document.forms[str_form_name])
		return alert ("Form with name '" + this.form_name + "' can't be found in the document.");
	this.form_name = str_form_name;
	this.control_name = (str_ctrl_name ? str_ctrl_name : 'datetime_' + this.id);
	
	// set date limits
	var re_num = /^-?\d+$/;
	if (str_min_date != null)
        // if str_min_date is a number, calculate it relative to the original date, else parse it as a date
		min_date = (re_num.exec(str_min_date)
			? new Date (dt_params.valueOf() - new Number(str_min_date * 864e5))
			: cal_parse_date(str_min_date)
		);
	if (str_max_date != null)
        // if str_max_date is a number, calculate it relative to the original date, else parse it as a date
		max_date = (re_num.exec(str_max_date)
			? new Date (dt_params.valueOf() + new Number(str_max_date * 864e5))
			: cal_parse_date(str_max_date)
		);
	
	if (this.reoccur_pay) {
		this.min_valid_date = min_date ? min_date : dt_original;
        // if the date falls between the 29th and 31st, bump it 3 days into
        // the next month, then set it to the first day of that month
		if (this.min_valid_date.getDate() >= 29 && this.min_valid_date.getDate() <= 31 ) {
            if(frequency != null || frequency != undefined){
                if(frequency.value == 'RECURRING'){
                    this.min_valid_date = new Date(this.min_valid_date.valueOf() + new Number(3 * 864e5));
                    this.min_valid_date.setDate(1);
                }
            }
            if(freqLabel != null || freqLabel != undefined){
                if(freqLabel.innerHTML == 'RECURRING'){
                    this.min_valid_date = new Date(this.min_valid_date.valueOf() + new Number(3 * 864e5));
                    this.min_valid_date.setDate(1);
                }
            }
		}
	}
	
	// if a payment date was specified, set selected date to payment date
	//if (this.dt_pay) dt_current = this.dt_pay;

	// set current date to within date limits
	if (max_date && dt_current > max_date) dt_current = max_date;
	if (min_date && dt_current < min_date) dt_current = min_date;

	var curr_date = dt_current.getDate();
	if (this.reoccur_pay && curr_date >= 29 && curr_date <= 31) dt_current = this.min_valid_date;
	
	// write input control
	var use_dt_original = !has_url;
    var discard = document.getElementById("payOnlineForm:isDuplicatePayment");   
    var hiddenPayDate = document.getElementById("payOnlineForm:hiddenPayDate");      
    //alert("In calendar() hiddenPayDate... "+hiddenPayDate.value);
    var hDate = hiddenPayDate.value.indexOf("/");   
    var month = hiddenPayDate.value.substring(0,hDate);
    var hDateEnd = hiddenPayDate.value.lastIndexOf("/");
    var day = hiddenPayDate.value.substring(hDate+1,hDateEnd); 
    //alert("day.."+day);
    //alert("dt_original in calendar..."+dt_original);
    
    var paymentAmount= document.getElementById("payOnlineForm:txtPaymentAmount");
    var userSSN = document.getElementById("userSSN");
    var payAmount = document.getElementById("payAmount");
    //alert("userSSN "+userSSN);
    //Change for Late payment indicator: Start date: 6 June 2008
    var one_day = 24*60*60*1000;
    
    var diff = 0;
    if(expected_posting != null && expected_posting != '')
        diff = (cal_parse_date(expected_posting)).getTime() - 60*one_day;
        
    var LPD = document.getElementById("payOnlineForm:lastPayDate").value;
    if(LPD != null && LPD != '')
        LPD = cal_parse_date(LPD);    
    if((frequency != null && frequency.value == 'ONE-TIME' )
        || (freqLabel != null && freqLabel.innerHTML == 'ONE-TIME')){        
       if(LPD != null && LPD != '' && cal_parse_date(LPD).getTime() < diff ){
            var lateMsg = document.getElementById("showLateMsg");
            lateMsg.style.visibility = 'visible';
       } 
    }
    //Change for Late payment indicator: End date: 11 June 2008  
    
    if(discard != null){  
        //alert("day..."+day); 
        var hDate1 = cal_parse_date(hiddenPayDate.value); 
              
        hDate1 = new Date(hDate1.valueOf()); 
        //alert("hDate1.."+hDate1); 
        
        //alert("month..."+month);
        //hDate1.setMonth(month-1); 
        //alert("hDate2.."+hDate1); 
        
        if(month > dt_original.getMonth()+1)
            hDate1.setMonth(month-1);
    
    	// change for same payment error :start date: 5 sep '07
    	hDate1.setDate(day);   
    	// change for same payment error :end date: 5 sep '07
        //alert("hDate1.3.."+hDate1);
        document.write (this.get_html(hDate1, false));
        var mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_0'];
        var year_ctrl = document.forms['payOnlineForm'].elements['dt_year_0'];
        //alert("year_ctrl ..."+year_ctrl);
        mon_ctrl.selectedIndex = hDate1.getMonth(); 
        mon_ctrl.disabled = true;
        year_ctrl.disabled = true;
        var calendar_body = document.getElementById("cal_body_0");
        calendar_body.readOnly = true;
        //if(frequency != null || frequency != undefined){
            //frequency.disabled = true;
        //} 
    }
    else if(freqLabel != null || freqLabel != undefined){
        var hDate1 = cal_parse_date(hiddenPayDate.value); 
        //alert("hDate1.."+hDate1);        
        hDate1 = new Date(hDate1.valueOf()); 
        hDate1.setDate(day);        
        if(month > dt_original.getMonth()+1)
            hDate1.setMonth(month-1);            
        //alert("hDate1..."+hDate1);
        document.write (this.get_html(hDate1, false));   
        var mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_0'];
        mon_ctrl.selectedIndex = hDate1.getMonth();              
    }
    else if(payAmount != null && payAmount.innerHTML != ''){
        var hDate1 = cal_parse_date(hiddenPayDate.value); 
        //alert("hiddenPayDate in calendar.."+hiddenPayDate.value);        
        hDate1 = new Date(hDate1.valueOf()); 
        //alert("hDate1 in calendar().."+hDate1); 
        document.write (this.get_html(hDate1, false));  
        var mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_0'];
        mon_ctrl.selectedIndex = hDate1.getMonth();              
    }    
    else if(paymentAmount.value == null || paymentAmount.value ==''){
        document.write (this.get_html(dt_current, use_dt_original));
    }
    else if(userSSN != null && userSSN.innerHTML != ''){
        var hDate1 = cal_parse_date(hiddenPayDate.value); 
        //alert("hDate1.."+hDate1);        
        hDate1 = new Date(hDate1.valueOf()); 
        //alert("hDate1.."+hDate1); 
        document.write (this.get_html(hDate1, false));  
        var mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_0'];
        mon_ctrl.selectedIndex = hDate1.getMonth();              
    }
    else if((day > dt_original.getDate())||(month > dt_original.getMonth()+1)){
        var hDate1 = cal_parse_date(hiddenPayDate.value); 
        //alert("hDate1.."+hDate1);        
        hDate1 = new Date(hDate1.valueOf()); 
        hDate1.setDate(day);
        
        if(month > dt_original.getMonth()+1)
            hDate1.setMonth(month-1);
            
        //alert("hDate1..."+hDate1);
        document.write (this.get_html(hDate1, use_dt_original));     
    }
    else{
        document.write (this.get_html(dt_current, use_dt_original));
    }
}
// --------------------------------------------------------------------------------
function cal_finish() {
	this.control_obj = document.forms[this.form_name].elements[this.control_name];
    //alert("dt_original..."+dt_original);
    this.mon_ctrl    = document.forms[this.form_name].elements['dt_mon_'  + this.id];
    //alert("mon_ctrl...."+this.mon_ctrl.value);
	this.year_ctrl   = document.forms[this.form_name].elements['dt_year_' + this.id];
	var userSSN = document.getElementById("userSSN");
    var payAmount = document.getElementById("payAmount");
    var hiddenPayDate = document.getElementById("payOnlineForm:hiddenPayDate"); 
    //alert("hiddenPayDate.in cal_finish."+hiddenPayDate.value);       
    var hDate = hiddenPayDate.value.indexOf("/");   
    var month = hiddenPayDate.value.substring(0,hDate);
    var hDateEnd = hiddenPayDate.value.lastIndexOf("/");
    var day = hiddenPayDate.value.substring(hDate+1,hDateEnd); 
    var hDate1;  
    var hDate2 = cal_parse_date(hiddenPayDate.value);         
    hDate2 = new Date(hDate2.valueOf()); 
           
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
    var paymentAmount= document.getElementById("payOnlineForm:txtPaymentAmount");
	var discard = document.getElementById("payOnlineForm:isDuplicatePayment"); 
    // write current date to date form
    //alert("dt_original.getDate()..."+dt_original.getDate());
    if (dt_original.getDate() >= 29 && dt_original.getDate() <= 31)	{
        if(dt_original.getDate() == 29)
            var control_obj_date = new Date(dt_original.valueOf() + new Number(3 * 864e5));
        else
            var control_obj_date = new Date(dt_original.valueOf() + new Number(2 * 864e5));
       
        //alert(control_obj_date);       
        this.control_obj.value = cal_generate_date(control_obj_date);
        //alert("this.control_obj.value.."+this.control_obj.value);
        //fnShowMessage(control_obj_date);
    }   
     if(freqLabel != null || freqLabel != undefined){     
        hDate1 = cal_parse_date(hiddenPayDate.value);         
        hDate1 = new Date(hDate1.valueOf()); 
           
        //alert("hDate1..."+hDate1); 
        if(month > dt_original.getMonth()+1)
            hDate1.setMonth(month-1);        
        
        // change for same payment error :start date: 5 sep '07
        hDate1.setDate(day);
        // change for same payment error :end date: 5 sep '07
        this.control_obj.value = cal_generate_date(hDate1);
        fnShowMessage(hDate1);
    }
    else if (userSSN != null && userSSN.innerHTML != ''){
    //alert(hiddenPayDate.value);        
        this.control_obj.value = cal_generate_date(hDate2);
        fnShowMessage(hDate2);       
    }
    else if (payAmount != null && payAmount.innerHTML != ''){
        this.control_obj.value = cal_generate_date(hDate2);
        fnShowMessage(hDate2);       
    }    
    else if(paymentAmount.value == null || paymentAmount.value ==''){
        this.control_obj.value = cal_generate_date(dt_current);   
        fnShowMessage(dt_current);  
    }
    else if(discard != null){
        var hDate1 = cal_parse_date(hiddenPayDate.value);
        hDate1 = new Date(hDate1.valueOf());
        this.control_obj.value = cal_generate_date(hDate1);
        fnShowMessage(hDate1);
    }
    else if((day > dt_original.getDate())||(month > dt_original.getMonth()+1)){
        hDate1 = cal_parse_date(hiddenPayDate.value);         
        //alert("hDate1 in finish..."+hDate1); 
        hDate1 = new Date(hDate1.valueOf());         
               
        if(month > dt_original.getMonth()+1)
            hDate1.setMonth(month-1);        
        
        // change for same payment error :start date: 5 sep '07
        hDate1.setDate(day);   
        // change for same payment error :end date: 5 sep '07
        this.control_obj.value = cal_generate_date(hDate1);         
        fnShowMessage(hDate1);   
    }
    else{
        this.control_obj.value = cal_generate_date(dt_current);
        //alert("dt_current in else..."+dt_current);
        fnShowMessage(dt_current);
    } 
    //alert(dt_original);
    //alert("hDate1..."+hDate1); 
    //alert("dt_current "+dt_current);
    
	
    /*if(freqLabel != null || freqLabel != undefined)
        fnShowMessage(hDate1);
    else
        fnShowMessage(dt_current);*/
}
// --------------------------------------------------------------------------------
/*function cal_css_update (dt_datetime, use_dt_original) {
    var selectDate = dt_datetime;
	use_dt_original = use_dt_original ? true : false;
	// #################################################### Added by Bala ######################################
	//alert('dt_datetime : ' + dt_datetime);
	if(selectDate.getDate() >= 29 && selectDate.getDate() <= 31) {
		selectDate = new Date(selectDate.valueOf() + new Number(3 * 864e5));
		selectDate.setDate(1);
	}
	//alert('dt_datetime : ' + dt_datetime);
	// #################################################### END Added by Bala ######################################
	dt_current = selectDate;
	this.control_obj.value = cal_generate_date(selectDate);
	
	var obj_container = (document.all ?
		document.all['cal_body_' + this.id] :
		document.getElementById('cal_body_' + this.id)
	);
	obj_container.innerHTML = this.get_body(dt_datetime, use_dt_original);
	this.mon_ctrl.selectedIndex = selectDate.getMonth(); 
    
	this.year_ctrl.selectedIndex =
		dt_datetime.getFullYear() - Number(this.year_ctrl.options[1].text) + 1;
	this.control_obj.value = cal_generate_date(selectDate);
    fnShowMessage(dt_datetime);
}*/

function cal_css_update (dt_datetime, use_dt_original) {
    //alert(calendars.length);
    this.id = calendars.length - 1;
    var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");               
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
	use_dt_original = use_dt_original ? true : false;
	// #################################################### Added by Bala ######################################
	//alert('dt_datetime : ' + dt_datetime);
    //alert("frequency.value  "+frequency.value);
    if (dt_datetime.getDate() >= 29 && dt_datetime.getDate() <= 31)	{
		if(frequency != null || frequency != undefined){
            if(frequency.value == 'RECURRING'){
                dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
                dt_datetime.setDate(1);
            }
        }
        if(freqLabel != null || freqLabel != undefined)
        {
            if(freqLabel.innerHTML == 'RECURRING'){
                dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
                dt_datetime.setDate(1);
            }
        }
	}      
	//alert('dt_datetime : in update ' + dt_datetime);
	// #################################################### END Added by Bala ######################################
	dt_current = dt_datetime;
    this.control_obj = document.getElementById("payOnlineForm:txtSubmitDate");
	this.control_obj.value = cal_generate_date(dt_datetime);
	
	var obj_container = (document.all ?
		document.all['cal_body_0'] :
		document.getElementById('cal_body_0')
	);
	obj_container.innerHTML = cal_get_body(dt_datetime, use_dt_original);
    this.mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_0'];
    this.year_ctrl = document.forms['payOnlineForm'].elements['dt_year_0'];
    
	this.mon_ctrl.selectedIndex = dt_datetime.getMonth(); 
	this.year_ctrl.selectedIndex =
		dt_datetime.getFullYear() - Number(this.year_ctrl.options[1].text) + 1;
	this.control_obj.value = cal_generate_date(dt_datetime);
    fnShowMessage(dt_datetime);
}

function cal_update_recurring (dt_datetime, use_dt_original) {
    this.id = calendars.length;
	use_dt_original = use_dt_original ? true : false;
	// #################################################### Added by Bala ######################################
	//alert('cal_update_recurring : ' + dt_datetime);
	if(dt_datetime.getDate() >= 29 && dt_datetime.getDate() <= 31) {
		dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
		dt_datetime.setDate(1);
	}
	//alert('dt_datetime : ' + dt_datetime);
	// #################################################### END Added by Bala ######################################
	dt_current = dt_datetime;
    this.control_obj = document.getElementById("payOnlineForm:txtSubmitDate");
	this.control_obj.value = cal_generate_date(dt_datetime);
	
	var obj_container = (document.all ?
		document.all['cal_body_' + this.id] :
		document.getElementById('cal_body_' + this.id)
	);
	obj_container.innerHTML = cal_get_body(dt_datetime, use_dt_original);
    this.mon_ctrl = document.forms['payOnlineForm'].elements['dt_mon_'  + this.id];
    this.year_ctrl = document.forms['payOnlineForm'].elements['dt_year_' + this.id];
    
	this.mon_ctrl.selectedIndex = dt_datetime.getMonth(); 
	this.year_ctrl.selectedIndex =
		dt_datetime.getFullYear() - Number(this.year_ctrl.options[1].text) + 1;
	this.control_obj.value = cal_generate_date(dt_datetime);
    fnShowMessage(dt_datetime);
}



// --------------------------------------------------------------------------------
function cal_rel_update (dt_datetime, use_dt_original) {

        // begin 8-20-02
        var strAppend = String();
        if (formArray != null)
        {
            for (var i=0; i < formArray.length; i++) 
            {
                strAppend = strAppend + '&' + formArray[i] + '=' + document.forms[this.form_name].elements[formArray[i]].value;
            }
        //alert("Append: " + strAppend);
        }
        // end 8-20-02


	use_dt_original = use_dt_original ? true : false;
	var arr_location = String(window.location).split('?');
//alert("arr_location: " + arr_location);
	var arr_params = String(arr_location[1]).split('&');
//alert("arr_params: " + arr_params);

	var num_found = -1;
	for (var i = 0; i < arr_params.length; i++)
		if((arr_params[i].split('='))[0] == 'cal' + this.id + '_val') {
			num_found = i;
			break;
		}
	arr_params[(num_found == -1 ? (arr_location[1] ? arr_params.length : 0) : num_found)]
		= 'cal' + this.id + '_val=' + dt_datetime.valueOf();

        // begin 8-20-02
        var fa_found = 0;
	for (var i = 0; i < arr_params.length; i++)
        {
            for (var ii = 0; ii < formArray.length; ii++)
            {
		if((arr_params[i].split('='))[0] == formArray[ii]) 
		{
			fa_found++;
			arr_params[i] = '';
			break;
		}
            }
        }
//alert("arr_params after cleanup: " + arr_params);
        // end 8-20-02
    
    if (dt_datetime.getDate() >= 29 && dt_datetime.getDate() <= 31)	{
        dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
        dt_datetime.setDate(1);
    }
	//alert(dt_datetime+" in rel update");
    this.control_obj.value = cal_generate_date(dt_datetime);    
	window.location = arr_location[0] + '?' + arr_params.join('&') + strAppend;
    fnShowMessage(dt_datetime);
}
// --------------------------------------------------------------------------------
function cal_set_day (num_datetime) {
	var dt_newdate = new Date(num_datetime);
    //alert(dt_newdate);

    disableButton(false);
    var discard = document.getElementById("payOnlineForm:isDuplicatePayment"); 
    if(discard == null)
	this.update(cal_validate(dt_newdate) ? dt_newdate : dt_current, false);
    else 
    return;
}
// --------------------------------------------------------------------------------
function cal_set_month () {
    var userSSN = document.getElementById("userSSN");
    var payAmount = document.getElementById("payAmount"); 
    var hiddenPayDate = document.getElementById("payOnlineForm:hiddenPayDate");    
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
    if((userSSN != null && userSSN.innerHTML != '') || (payAmount != null &&  payAmount.innerHTML != '')){
        var dt_newdate = cal_parse_date(hiddenPayDate.value); 
        dt_newdate = new Date(dt_newdate.valueOf());
        //alert("dt_newdate in else "+dt_newdate);     
        }
    else if(freqLabel != null || freqLabel != undefined){
        var dt_newdate = cal_parse_date(hiddenPayDate.value); 
        dt_newdate = new Date(dt_newdate.valueOf()); 
        //alert("dt_newdate.."+dt_newdate);       
    }
    else {
        var dt_newdate = new Date(dt_current);  
        //alert("dt_newdate in if "+dt_newdate);
    }   

	//var dt_newdate = new Date(dt_current);
	var num_month = this.mon_ctrl.options[this.mon_ctrl.selectedIndex].value;
	//alert("nummonth "+num_month);
	dt_newdate.setMonth(num_month);
	if (num_month != dt_newdate.getMonth())
		dt_newdate.setDate(0);
	
	if (cal_validate(dt_newdate))
		this.update(dt_newdate, false);
	else
		this.mon_ctrl.selectedIndex = dt_current.getMonth();
        
        //alert("this.mon_ctrl.selectedIndex "+this.mon_ctrl.selectedIndex);
}
// --------------------------------------------------------------------------------
function cal_set_year () {
    var userSSN = document.getElementById("userSSN");
    var payAmount = document.getElementById("payAmount"); 
    var hiddenPayDate = document.getElementById("payOnlineForm:hiddenPayDate");    
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
    if((userSSN != null && userSSN.innerHTML != '') || (payAmount != null &&  payAmount.innerHTML != '')){
        var dt_newdate = cal_parse_date(hiddenPayDate.value); 
        dt_newdate = new Date(dt_newdate.valueOf());
        //alert("dt_newdate in else "+dt_newdate);     
        }
    else if(freqLabel != null || freqLabel != undefined){
        var dt_newdate = cal_parse_date(hiddenPayDate.value); 
        dt_newdate = new Date(dt_newdate.valueOf()); 
        //alert("dt_newdate.."+dt_newdate);       
    }
    else {
        var dt_newdate = new Date(dt_current);  
        //alert("dt_newdate in if "+dt_newdate);
    }    
	var str_year = this.year_ctrl.options[this.year_ctrl.selectedIndex].text;
    var str_scroll = this.year_ctrl.options[this.year_ctrl.selectedIndex].value;
	var num_year = new Number(str_year);
	if (str_scroll) {
        if(str_scroll == '+')
            num_year = dt_current.getFullYear() + 4;
        else if(str_scroll == '-')
            num_year = dt_current.getFullYear() - 4;	
	}
	//else 
		//num_year = new Number(str_year);
	dt_newdate.setFullYear(num_year);
	var num_month = this.mon_ctrl.options[this.mon_ctrl.selectedIndex].value;
	//alert("num_month .."+num_month);
    //alert("dt_newdate.getMonth().."+dt_newdate.getMonth());
    if (num_month != dt_newdate.getMonth()){        
		dt_newdate.setDate(0);
        }
	if (!cal_validate(dt_newdate)) {
		this.year_ctrl.selectedIndex =
			dt_current.getFullYear() - Number(this.year_ctrl.options[1].text) + 1;
        return;
	}
	if (str_scroll) {
		var j = 0;
		this.year_ctrl.length = 0;
		// show paging only if year is greater than original date year
		if ( num_year - 4 > dt_original.getFullYear() ) {
			this.year_ctrl.options[0] = new Option('<< ' + (num_year - 4), '-');
			j++;
		}
		
		for (var i = j; i < 8; i++) {
			// do not show years before original date year
			if (num_year + (i-4) >= dt_original.getFullYear()) {
				this.year_ctrl.options[j] = new Option(num_year + i - 4);
				this.year_ctrl.options[j].selected = !(i-4);
                //alert("year "+this.year_ctrl.options[j].text);
                //alert("j.."+j);
                j++;
			}
		}
		this.year_ctrl.options[i] = new Option((num_year + 4) + ' >>', '+');
	}
    //alert("dt_newdate.."+dt_newdate);
	this.update(dt_newdate, false);
}
// --------------------------------------------------------------------------------
function cal_get_html (dt_datetime, use_dt_original) { 
//alert("cal get html "+new Date(dt_datetime)); 
    var oneMinute = 60 * 1000;  // milliseconds in a minute
    var oneHour = oneMinute * 60;
    var oneDay = oneHour * 24;
  	use_dt_original = use_dt_original ? true : false;
	
    var dt_actual = new Date(dt_original.getTime() + 2*oneDay);
    //alert("dt_actual.."+dt_actual);
    
	// print calendar header
	var i, str_buffer = new String (
		'<table cellspacing="0" id="calOutTable" class="calOuterTable" border="0"><tr>' +
		'<td>' + 
		'<table cellspacing="0" class="calSelectTable"><tr><td>' +
		'<select name="dt_mon_0" class="calMonCtrl" onchange="return calendars[0].set_month();">');
	for (i = 0; i < 12; i++)
			str_buffer += '<option value="' + i + '"' + (i == dt_actual.getMonth() ? ' selected' : '') + '>' + ARR_MONTHS[i] + "</option>\n";
	str_buffer += '</select></td>' +
		'<td align="right"><select name="dt_year_' + this.id + '" class="calYearCtrl" onchange="return calendars[' + this.id + '].set_year();">'

	// page to past years
	if (dt_datetime.getFullYear() - 4 > dt_original.getFullYear()) {
		str_buffer += '<option value="-">&lt;&lt; ' + (dt_datetime.getFullYear() - 4) + "</option>\n";
	}
	
	for (i = 0; i < 4; i++) {
		if (dt_datetime.getFullYear() + i >= dt_original.getFullYear()) {
			str_buffer += '<option' + (i == 0 ? ' selected' : '') + '>' + (dt_datetime.getFullYear() + i) + "</option>\n";
		}
	}
	
	// page to future years
	str_buffer += '<option value="+">' + (dt_datetime.getFullYear() + 4) +  " &gt;&gt;</option>\n"
	str_buffer += 
		'</select></td></tr></table></td></tr>' +
		'<tr><td><div id="cal_body_' + this.id + '">' + this.get_body(dt_datetime, use_dt_original) +'</div>'
		+ '</td>'
		+ '</tr></table>';

	return (str_buffer);
} 
// --------------------------------------------------------------------------------

function cal_alt_header(dt_datetime){ 

//alert("updated date.."+updated_date); 

//alert(calendars.length);
//var curr_date = this.control_obj.value; 
//alert("offset..."+this.control_obj.value); 

var reference_date = dt_datetime; 
//alert("reference date.."+reference_date) 

// get same date in the previous year 
        var dt_prev_year = new Date(reference_date); 
        dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1); 
        if (dt_prev_year.getDate() != dt_datetime.getDate()) 
                dt_prev_year.setDate(0); 
                
// get same date in the next year 
        var dt_next_year = new Date(reference_date); 
        dt_next_year.setFullYear(dt_next_year.getFullYear() + 1); 
        if (dt_next_year.getDate() != dt_datetime.getDate()) 
                dt_next_year.setDate(0); 
                
                
// get same date in the previous month 
var cal_prev_month = new Date(reference_date); 
cal_prev_month.setMonth(cal_prev_month.getMonth() - 1); 
if (cal_prev_month.getDate() != dt_datetime.getDate()) 
        cal_prev_month.setDate(0); 

// get same date in the next month 
var dt_next_month = new Date(reference_date); 
dt_next_month.setMonth(dt_next_month.getMonth() + 1); 
if (dt_next_month.getDate() != dt_datetime.getDate()) 
        dt_next_month.setDate(0); 


var STR_ICONPATH = 'resources/images/tfs/'; 

/* 
var buff = new String( 
'<tr>'+ 
'<td>'+ 
'<a href="this.set_day('+dt_prev_year.valueOf()+')">'+ 
'<img src="'+STR_ICONPATH+'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a>&nbsp;'+ 
'<a href="this.set_day('+cal_prev_month.valueOf()+')">'+ 
'<img src="'+STR_ICONPATH+'prev.gif" width="16" height="16" border="0" alt="previous month"></a></td>'+ 
'<td align="center" width="100%"> 
<font color="#ffffff">'+ARR_MONTHS[dt_datetime.getMonth()]+' '+dt_datetime.getFullYear() + '</font></td>'+ 
'<td><a href="this.set_day('+cal_next_month.valueOf()+')"> 
<img src="'+STR_ICONPATH+'next.gif" width="16" height="16" border="0" alt="next month"></a>'+ 
'&nbsp;<a href="this.set_day('+dt_next_year.valueOf()+')"> 
<img src="'+STR_ICONPATH+'next_year.gif" width="16" height="16" border="0" alt="next year"></a>'+'</td>'+'</tr>' 
); 
*/ 
var buff = new String( 
'<tr><td colspan="7">'+'<table><tr>'+ 
'<td>'+'<a href="javascript:calendars[' + this.id + '].set_day('+dt_prev_year.valueOf()+');">'+ 
//'<img src="'+STR_ICONPATH+'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a>&nbsp;'+ 
'<a href="javascript:calendars[' + this.id + '].set_day('+cal_prev_month.valueOf()+');">'+ 
'<img src="'+STR_ICONPATH+'prev_arrow.gif" border="0" alt="previous month"></a></td>'+ 
'<td align="center" width="100%">'+ 
'<font size="1" color="#333333" font style="Verdana">'+ARR_MONTHS[dt_datetime.getMonth()]+' '+dt_datetime.getFullYear() + '</font></td>'+ 
'<td>'+'<a href="javascript:calendars[' + this.id + '].set_day('+dt_next_month.valueOf()+');">'+ 
'<img src="'+STR_ICONPATH+'arrow.gif" border="0" alt="next month">'+'</a>'+ 
'&nbsp;'+'<a href="javascript:calendars[' + this.id + '].set_day('+dt_next_year.valueOf()+');">'+ 
//'<img src="'+STR_ICONPATH+'next_year.gif" width="16" height="16" border="0" alt="next year">'+'</a>'+ 
'</td>'+'</tr></table></td></tr>' 
); 

return (buff); 

} 

function cal_get_body (dt_datetime, use_dt_original) {
    //alert("cal get body "+dt_datetime);
	use_dt_original = use_dt_original ? true : false;
	this.id = calendars.length -1 ;
    //alert(calendars.length);
    var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");  
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
    // get same date in the previous year
	var dt_prev_year = new Date(dt_datetime);
	dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
	if (dt_prev_year.getDate() != dt_datetime.getDate())
		dt_prev_year.setDate(0);
	
	// get same date in the next year
	var dt_next_year = new Date(dt_datetime);
	dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
	if (dt_next_year.getDate() != dt_datetime.getDate())
		dt_next_year.setDate(0);
	
	var dt_firstday = new Date(use_dt_original ? dt_datetime : dt_datetime);
	
	// set the month the date is in
	var cal_main_month = dt_firstday.getMonth();
	
	// get first day to display in the grid for current month
	dt_firstday.setDate(1);
	dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);
	
	// set the month the first day to display is in
	var cal_prev_month = dt_firstday.getMonth();
	
	var dt_current_day = new Date(dt_firstday);
	
	// print calendar body
	var str_buffer = new String (
	'<table cellspacing="1" cellpadding="2" class="calDaysTable" width="100%">');
	
	//str_buffer +=this.alt_header(dt_datetime); 
	// print weekdays titles
	str_buffer += '<tr>';
	for (var n = 0; n < 7; n++)
		str_buffer += '<td class="calWTitle">' + ARR_WEEKDAYS[(NUM_WEEKSTART + n) % 7] + '</td>';
	// print calendar table
	str_buffer += "</tr>\n";

	while (	dt_current_day.getMonth() == cal_prev_month || dt_current_day.getMonth() == cal_main_month ) {
		// print row header
		str_buffer += '<tr>';
// #################################################### Added by Bala ######################################
	//alert("current day  "+dt_current_day.getDate());
    //alert("original day  "+dt_datetime.getDate());
    
    if (dt_datetime.getDate() >= 29 && dt_datetime.getDate() <= 31)	{
		if(frequency != null || frequency != undefined){
            if(frequency.value == 'RECURRING'){
                dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
                dt_datetime.setDate(1);
            }
        }
        if(freqLabel != null || freqLabel != undefined)
        {
            if(freqLabel.innerHTML == 'RECURRING'){
                dt_datetime = new Date(dt_datetime.valueOf() + new Number(3 * 864e5));
                dt_datetime.setDate(1);
            }
        }
	} 
         
// #################################################################################
		for (var n_current_wday = 0; n_current_wday < 7; n_current_wday++) {
			// is the current day today's date
			var bool_istoday = (dt_original.getDate() == dt_current_day.getDate() &&
								dt_original.getMonth() == dt_current_day.getMonth() &&
								dt_original.getFullYear() == dt_current_day.getFullYear());
			
			// --- set background style ---
            //alert(cal_validate(dt_current_day, true));
			if (dt_current_day.getDate() == dt_datetime.getDate() &&
				dt_current_day.getMonth() == dt_datetime.getMonth()) {
				// print current date
				if (this.dt_pay != null &&
                    dt_current_day.getDate() == this.dt_pay.getDate() && 
					dt_current_day.getDay() == this.dt_pay.getDay() && 
					dt_current_day.getMonth() == this.dt_pay.getMonth() && 
					dt_current_day.getYear() == this.dt_pay.getYear()){					
                    str_buffer += '<td class="calDuePostDate" align="center" valign="middle">';
				} else {
                    str_buffer += '<td class="calDayCurrent" align="center" valign="middle">';
				}
			}
			// #################################################### Added by Bala ######################################
			else if ( this.dt_pay != null &&
                dt_current_day.getDate() == this.dt_pay.getDate() && 
				dt_current_day.getDay() == this.dt_pay.getDay() && 
				dt_current_day.getMonth() == this.dt_pay.getMonth() && 
				dt_current_day.getYear() == this.dt_pay.getYear()){
				str_buffer += '<td class="calDueDate" align="center" valign="middle">';
			}
			//else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
				// weekend days
				//str_buffer += '<td class="calDayWeekend" align="center" valign="middle">';
                
			else if(!cal_validate(dt_current_day, true) )
				str_buffer += '<td class="calForbDate" align="center" valign="middle">';
			else
				// print working days of current month
				str_buffer += '<td class="calDayWorking" align="center" valign="middle">';

			// --- set foreground style ---
			// #################################################### Added by Bala ######################################
			// dates for saturday and sunday...
			//if (n_current_wday == 0 || n_current_wday == 6) {
				//str_buffer += 
					// (bool_istoday ? '<span class="calDayToday">' : '')
					//+ dt_current_day.getDate()
					//+ (bool_istoday ? '</span>' : '')
					//+'</td>';
				//alert('Weekend date is : ' + dt_current_day.getDate());
				//alert(str_buffer);
				//str_buffer +=str_buffer1;
			//}
			// ################################################### Added by Bala #######################################

                        // --- set foreground style --- 
                        // forbidden dates 
                         if (!cal_validate(dt_current_day, true)) {                         
                                str_buffer +=  
                                         (bool_istoday ? '<SPAN CLASS="calDayToday">' : '') 
                                        + dt_current_day.getDate() 
                                        + (bool_istoday ? '</SPAN>' : '') 
                                        + '</td>'; 
                                        
                                        
                                        }
                        // dates of current month 
                        else if (dt_current_day.getMonth() == dt_datetime.getMonth()) {
                                str_buffer += '<a href="javascript:calendars[' + this.id + 
                                        '].set_day(' + dt_current_day.valueOf() + ');" class="calThisMonth">' 
                                        + (bool_istoday ? '<SPAN CLASS="calDayToday">' : '') 
                                        + dt_current_day.getDate() 
                                        + (bool_istoday ? '</SPAN>' : '') 
                                        + '</a></td>'; 
                                        //alert("hi");
                                        }
                        // dates of other months 
                        else {
                                str_buffer += '<a href="javascript:calendars[' + this.id + 
                                        '].set_day(' + dt_current_day.valueOf() + ');" class="calOtherMonth">' 
                                        + (bool_istoday ? '<SPAN CLASS="calDayToday">' : '') 
                                        + dt_current_day.getDate() 
                                        + (bool_istoday ? '</SPAN>' : '') 
                                        + '</a></td>'; 
                                        
                                        //alert("other");
                                        
                             }

                        dt_current_day.setDate(dt_current_day.getDate() + 1); 
                        
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
//alert("dt_datetime in get_html "+dt_current_day); 
	str_buffer +=
		'</table>';

	return (str_buffer);
}

// --------------------------------------------------------------------------------
// Discard time fields of date object
function cal_date_only (dt_datetime) {
	if (!dt_datetime)
		dt_datetime = new Date();
	dt_datetime.setHours(0);
	dt_datetime.setMinutes(0);
	dt_datetime.setSeconds(0);
	dt_datetime.setMilliseconds(0);
	return dt_datetime;
}

function cal_validate (dt_datetime, b_silent) {
    //alert("min_date "+min_date);
    var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");               
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
	if (max_date && dt_datetime >max_date) {
		if (!b_silent)
			cal_css_update(max_date, false);
			// alert ('Sorry, dates after ' + cal_generate_date(this.max_date) + ' are not allowed.');
		return false;
	}
	if (min_date && dt_datetime < min_date) {
		if (!b_silent)
			cal_css_update(min_date, false);
			// alert ('Sorry, dates before ' + cal_generate_date() + ' are not allowed.');
		return false;
	}
	// more validation can be added here
	var curr_date = dt_datetime.getDate();
    //if(frequency.value == 'RECURRING')
    //alert(b_silent);
	if (curr_date >= 29 && curr_date <= 31 ) {
        if(frequency != null || frequency != undefined){
            if(frequency.value == 'RECURRING'){
                if (!b_silent){
                //alert("hi"+this.min_valid_date);
                cal_css_update(this.min_valid_date, false);
                //alert ('Sorry, reoccurring payments are not allowed on the 29th, 30th, or 31st.');
                }
                //alert("recurring");
                return false;
            }
        }
        if(freqLabel != null || freqLabel != undefined){
            //alert(freqLabel);
            if(freqLabel.innerHTML == 'RECURRING'){
                if (!b_silent){
                //alert("hi"+this.min_valid_date);
                cal_css_update(this.min_valid_date, false);
                //alert ('Sorry, reoccurring payments are not allowed on the 29th, 30th, or 31st.');
                }
                //alert("recurring");
                return false;
            }
        }        
	}

	return true;
}
// --------------------------------------------------------------------------------
function fnShowMessage(ob){
    
    //alert("fnShowMessage  "+ob);
    var postDate = ob;
    var pDate = ob;
    //alert("pDate is.."+pDate);
    var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");                   
    var freqLabel = document.getElementById("payOnlineForm:labelPaymentFrequency");
    
    //cal_update_recurring(cal_validate(pDate) ? pDate : dt_current, false);
    // #################################################### Added by Bala ######################################
    //alert(' dt_datetime : ' + dt_datetime);
    //if (postDate.getDate() >= 29 && postDate.getDate() <= 31 && frequency.value == 'RECURRING')	{
      //  postDate = new Date(postDate.valueOf() + new Number(3 * 864e5));
        //postDate.setDate(1);
   // }
    if (postDate.getDate() >= 29 && postDate.getDate() <= 31)	{
		if(frequency != null || frequency != undefined){
            if(frequency.value == 'RECURRING'){
                postDate = new Date(postDate.valueOf() + new Number(3 * 864e5));
                postDate.setDate(1);
            }
        }
        if(freqLabel != null || freqLabel != undefined)
        {
            if(freqLabel.innerHTML == 'RECURRING'){
                postDate = new Date(postDate.valueOf() + new Number(3 * 864e5));
                postDate.setDate(1);
            }
        }
	}      
    
    var yyyy = postDate.getFullYear();
    var mm = postDate.getMonth() + 1;
    var dd = postDate.getDate();
    
    postDate=+ mm + "/" + dd + "/" + yyyy;
    
    var hiddenPayDate = document.getElementById("payOnlineForm:hiddenPayDate");
    //alert("hiddenPayDate.value in fnMessage  "+hiddenPayDate.value);
    //var hdate = Date.parse(hiddenPayDate);

    var discard = document.getElementById("payOnlineForm:isDuplicatePayment");
    //alert("discard "+discard);
    
    //Change for Late payment indicator: Start date: 6 June 2008
    var one_day = 24*60*60*1000;
    var LDD = 0;
    var LLDD = 0;
    var DD = 0;
    var LPD = document.getElementById("payOnlineForm:lastPayDate").value;    
 
    if(LPD != null && LPD != '')
        LPD = cal_parse_date(LPD).getTime();    
    
    if(expected_posting != null && expected_posting != ''){
        LDD = (cal_parse_date(expected_posting)).getTime() - 30*one_day;
        LLDD = (cal_parse_date(expected_posting)).getTime() - 60*one_day;
        DD = (cal_parse_date(expected_posting)).getTime();
    }   
    var lateMsg = document.getElementById("showLateMsg");
    
    if((frequency != null && frequency.value == 'ONE-TIME' )
        || (freqLabel != null && freqLabel.innerHTML == 'ONE-TIME')){
          
          if(expected_posting == null || expected_posting == ''){
                lateMsg.style.visibility = 'hidden';
          }
          else if(cal_parse_date(postDate).getTime() < LDD){
                lateMsg.style.visibility = 'hidden'; 
          }
          else if(LPD==null || LPD=='' || (LLDD < LPD && LPD < LDD)){                
                if(cal_parse_date(postDate).getTime() > DD){                    
                    lateMsg.style.visibility = 'visible';
                }else{                    
                    lateMsg.style.visibility = 'hidden';
                }            
          }
          else if(LPD < LLDD ){ 
                lateMsg.style.visibility = 'visible';
          } 
    }  else {                
                lateMsg.style.visibility = 'hidden';        
    }
    //Change for Late payment indicator: End date: 11 June 2008  
    if(discard != null && discard != '')
    {
        var postingDate = document.getElementById("payOnlineForm:txtSubmitDate");
        var hDate = hiddenPayDate.value.indexOf("/");
        //var month = hiddenPayDate.value.substring(0,hDate);
        var hDateEnd = hiddenPayDate.value.lastIndexOf("/");
        var day = hiddenPayDate.value.substring(hDate+1,hDateEnd); 
        //alert("pDate in discard 0 "+pDate);  
        //pDate = new Date(pDate.valueOf());
        //alert("pDate in discard 1 "+pDate); 
        //pDate.setDate(day);
        //alert("pDate in discard 2 "+pDate); 
        //alert("pDate in discard "+pDate);
        //if(month > dt_original.getMonth()+1)
          //  pDate.setMonth(month-1);
        
        //this.get_html(pDate, use_dt_original);
        var yyyy = pDate.getFullYear();
        var mm = pDate.getMonth()+1 ;
        var dd = pDate.getDate();
        //alert("dd is..."+dd);
        pDate=+ mm + "/" + dd + "/" + yyyy;
        postDate = pDate;
        //alert("pDate in discard1 "+pDate);
        //pDate.value = hiddenPayDate.value;
        //alert("pDate after "+pDate.value);
        postingDate.value = postDate;
    }
    //alert("postDate is "+postDate);
    hiddenPayDate.value = postDate;        
    var postDiv =  document.getElementById('postMessage');
   
    var isShow = document.getElementById("paymentFreqency");
    //alert(isShow.value);     
    
    //alert("freqLabel "+freqLabel);
    //alert("isShow "+isShow);
    
        if(frequency != null && frequency !='')
        {
            if(isShow != null)
                isShow.value = frequency.value;    
        }
         if(freqLabel != null && freqLabel.innerHTML != '')
           {
            //alert("expected_posting "+expected_posting);
            //if(expected_posting!='' && expected_posting!= null && cal_parse_date(expected_posting)<cal_parse_date(postDate))
            //{
               // if(freqLabel.innerHTML == 'ONE-TIME')
               // {            
                   // var text="Your payment will be posted LATE on "+postDate;
                   // postDiv.innerHTML='<P CLASS="yellowbox_late">' + text + '</P>';
                //}
                //if(freqLabel.innerHTML == 'RECURRING')
                //{
                   // var text="Your Recurring payment will be posted on "+fn_getDate(dd)+" of each month";           
                   // postDiv.innerHTML='<P CLASS="yellowbox">' + text + '</P>'; 
                //}                            
            //}
           // else{                
                if(freqLabel.innerHTML == 'ONE-TIME')
                {   
                    //alert("expected_posting "+expected_posting);
                    var text="Your One Time payment will be posted on "+postDate;                
                }
                if(freqLabel.innerHTML == 'RECURRING')
                {
                    var text="Your Recurring payment will be posted on "+fn_getDate(dd)+" of each month";           
                }
                 postDiv.innerHTML='<P CLASS="yellowbox">' + text + '</P>';
            //}                        
           }

        
    if(isShow != null && isShow.value != ''){      
        //if(expected_posting!='' && expected_posting!= null && cal_parse_date(expected_posting)<cal_parse_date(postDate))
        //{
            //if(isShow.value == 'ONE-TIME' ){
               // var text="Your payment will be posted LATE on "+postDate;
                //postDiv.innerHTML='<P CLASS="yellowbox_late">' + text + '</P>';
            //}
           //if(isShow.value == 'RECURRING')
            //{
                //var text="Your Recurring payment will be posted on "+fn_getDate(dd)+" of each month";            
                //postDiv.innerHTML='<P CLASS="yellowbox">' + text + '</P>';
            //}            
        //}
        //else{
            
            if(isShow.value == 'ONE-TIME')
            {
                var text="Your One Time payment will be posted on "+postDate;                
            }
            if(isShow.value == 'RECURRING')
            {
                var text="Your Recurring payment will be posted on "+fn_getDate(dd)+" of each month";            
            }
             postDiv.innerHTML='<P CLASS="yellowbox">' + text + '</P>';
        //} 
    }           

    //postDiv.innerHTML='<P CLASS="yellowbox_late">' + text + '</P>';
}

function fn_getDate(ob){
    var date = ob;
    var str;
    if((date ==1) || (date == 21) || (date == 31))
        str = date+"st";
    else if((date == 2) || (date == 22))
        str = date+"nd";
    else if((date == 3)||(date == 23))
        str = date+"rd";
    else
        str = date+"th";
        
    return str;
}

    function setHidden(){
        var frequency  = document.getElementById("payOnlineForm:cboPaymentFrequency");
        var val = frequency.value;
        var hiddenFreq = document.getElementById("paymentFreqency");           
        hiddenFreq.value = val;
        var hiddenPDate = document.getElementById("payOnlineForm:hiddenPayDate");
        //alert("after "+hiddenPDate.value);
        //var cal = new calendar(null, 'payOnlineForm', 'payOnlineForm:txtSubmitDate',-2, null, dueDate.trim(), true, dueDate.trim());              
        //cal.finish();
        if(hiddenPDate != null){
            var hDate = hiddenPDate.value;
            //alert(hDate.valueOf());
            var pDate = new Date(hDate.valueOf());
            //alert(pDate);
            //cal_update_recurring(cal_validate(pDate) ? pDate : dt_current, false);
            //alert(dt_current);
            fnShowMessage(pDate);
                //if(frequency.value == 'RECURRING' )
        cal_css_update(cal_validate(pDate,true) ? pDate : dt_current, false);
        }
    }