// Licensed Materials - Property of IBM
//
// IBM Cognos Products: pps
//
// (C) Copyright IBM Corp. 2005, 2017
//
// US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
/**
 * @type Object
 */
D_ppesAdminPDFPaginationDialog.F_GetValue = function()
{
	return this.m_sCurrentValue;	
};

/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.F_Dialog_OnInit = function()
{
	/**
	 * @private
	 */	 
	this.m_oTab = new C_Tab( this.F_GetDlgItem( "ppesAdminPDFPaginationTabs" ).id );
};

D_ppesAdminPDFPaginationDialog.f_setRadioButtonVal = function( v_sName, v_iVal ) {
	//All radio buttons in 3s
	for (var i = 0; i < 3; i++) {
		this.F_GetDlgItem( v_sName + i).checked = (i == v_iVal);
	}
}

D_ppesAdminPDFPaginationDialog.f_getRadioButtonVal = function( v_sName ) {
	//All radio buttons in 3s
	for (var i = 0; i < 3; i++) {
		if (this.F_GetDlgItem( v_sName + i).checked)
			return i;
	}
}

/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.f_SetDialogControls = function()
{
	//Set the values of the various controls
	var props = null;
	if (this.m_sCurrentValue != "") {
		props = this.m_sCurrentValue.split(";");
	} else {
		props = this.m_sDefaultValue.split(";");
	}

	for (var i = 0; i < props.length; i++) {
		if (props[i].indexOf("=") != -1) {
			var com = props[i].substr(0,props[i].indexOf("="));
			var val = props[i].substr(props[i].indexOf("=") + 1);
			
			if (com.length && val.length) {
			
				switch(com) {
					case "CT_RPT":
					case "CT_CPT": 
					case "CH_PT": 
					case "NC_RPT": 
					case "NC_CPT":  this.f_setRadioButtonVal(com,val); break;
									 
					case "CT_ENR": 
					case "CT_RONG": 
					case "CT_ENC": 
					case "CT_CONG": 
					case "SV_ROP": 
									this.F_GetDlgItem(com).checked = (val == "1"); break;
					
					case "CT_NOR": 
					case "CT_NOC": 
					case "CH_NCA": 
					case "NC_NBR": 
					case "NC_NBC": 
									this.F_GetDlgItem(com).value = val; break;
					
				}
			}
		}
	}
}

/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.f_GetValueString = function()
{
	var valuesStr  = "CT_RPT=" + this.f_getRadioButtonVal("CT_RPT") + ";";
	    valuesStr += "CT_ENR=" + ((this.F_GetDlgItem("CT_ENR").checked)? "1" : "0") + ";";
	    valuesStr += "CT_NOR=" + this.F_GetDlgItem("CT_NOR").value + ";"; 
	    valuesStr += "CT_RONG=" + ((this.F_GetDlgItem("CT_RONG").checked)? "1" : "0") + ";";
	    valuesStr += "CT_CPT=" + this.f_getRadioButtonVal("CT_CPT") + ";";
	    valuesStr += "CT_ENC=" + ((this.F_GetDlgItem("CT_ENC").checked)? "1" : "0") + ";";
	    valuesStr += "CT_NOC=" + this.F_GetDlgItem("CT_NOC").value + ";"; 
	    valuesStr += "CT_CONG=" + ((this.F_GetDlgItem("CT_CONG").checked)? "1" : "0") + ";";
	    valuesStr += "CH_PT=" + this.f_getRadioButtonVal("CH_PT") + ";";
	    valuesStr += "CH_NCA=" + this.F_GetDlgItem("CH_NCA").value + ";"; 
	    valuesStr += "NC_RPT=" + this.f_getRadioButtonVal("NC_RPT") + ";";
	    valuesStr += "NC_NBR=" + this.F_GetDlgItem("NC_NBR").value + ";"; 
	    valuesStr += "NC_CPT=" + this.f_getRadioButtonVal("NC_CPT") + ";";
	    valuesStr += "NC_NBC=" + this.F_GetDlgItem("NC_NBC").value + ";"; 
	    valuesStr += "SV_ROP=" + ((this.F_GetDlgItem("SV_ROP").checked)? "1" : "0") + ";";    			
	
	return valuesStr;
}
/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.F_Dialog_OnBeforeVisible = function()
{	
	this.f_SetDialogControls();
}

/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.F_OnOk = function() 
{	
	this.m_sCurrentValue = this.f_GetValueString(); 
	this.M_fnSuper_OnOK();
};

/**
 * @private
 */
D_ppesAdminPDFPaginationDialog.F_OnReset = function() 
{
	this.m_sCurrentValue = this.m_sDefaultValue;
	this.f_SetDialogControls();
};