// 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.
// This forms the javascript functions used for the Explain pane of 
// PowerPlay Studio.
// The functions handle any minor browser differences.

function init(){

	topparent.openActionPane();

    ContextMenu.initialize(true,false);

	var rowSelections = topparent.getXtabFrame().getSelected("r");
	var colSelections = topparent.getXtabFrame().getSelected("c");

	//update "EXPL" parameter
	var updateNotification = '1';

	if (rowSelections.length == 1){
		if (colSelections.length == 1 || !colSelections.length)
		{
			updateNotification += '\tr' + rowSelections[0].getAttribute("nodeId");
		}
	}

	if (colSelections.length == 1)  
		updateNotification += '\tc' + colSelections[0].getAttribute("nodeId");

	//update hidden form entry
	var explFormEntry = topparent.getXtabFrame().document.fhidden.EXPL;
	explFormEntry.value = updateNotification;
}

function refresh() {
	resetExplainDialog()
}

function resetExplainDialog() {   
	var ACT_PANE_EXPLAIN = 4;

	var rowSelections = topparent.getXtabFrame().getSelected("r");
	var colSelections = topparent.getXtabFrame().getSelected("c");

	var action = "ME";

	var hiddenForm = topparent.getXtabFrame().fh;

	hiddenForm.EXPL.value = '1';

	if (rowSelections.length == 1){
		if (colSelections.length == 1 || !colSelections.length)
			action += ":" + "r" + + rowSelections[0].getAttribute("nodeId");
	}

	if (colSelections.length == 1){
		if (!rowSelections.length)
			action += ":" + "c" + colSelections[0].getAttribute("nodeId"); 
							
		if(rowSelections.length == 1)
			hiddenForm.EXPL.value = '1\tc' + colSelections[0].getAttribute("nodeId");
	} 


	hiddenForm.CO.value=action;
	hiddenForm.ACTPANE.value = ACT_PANE_EXPLAIN;
	hiddenForm.CNCT.value = 19;
	hiddenForm.target = "ActionPane";
	topparent.getXtabFrame().FTok=false;
	hiddenForm.RA.value = 999;

	topparent.getXtabFrame().parseAndSubmit(hiddenForm);
}