
var selectedEntity = null;
var idFromNode = null;
var objCalWindow;

function expand( hierarchy )
{
	var stateImage;
	var oImage

	stateImage = document.all["stateImage" + hierarchy.name];

	if(stateImage)
	 stateImage.src = stateImage._open;

	for( i = 0; i < hierarchy.childNodes.length; i++ )
	{
		hierarchy.childNodes(i).style.display = "block"
	}
	hierarchy.open = "true"
}


function collapse(hierarchy)
{
	var i
	var oImage
	var stateImage;

	stateImage = document.all["stateImage" + hierarchy.name];
	oImage = hierarchy.childNodes(0).all["image"]
	oImage.src = hierarchy.image

	if(stateImage)
		stateImage.src = stateImage._closed;

	for( i = 0; i  < hierarchy.childNodes.length; i++ )
	{
		if(hierarchy.childNodes(i).tagName == "TABLE")
		{
			if(hierarchy.name != "results")
				hierarchy.childNodes(i).style.display = "none"
			collapse(hierarchy.childNodes(i))
		}
	}
	hierarchy.open = "false"
}

function sendIdField( id )
{
	idFromNode = id;
	parent.treeframe.document.forms["treefinaljsp"].idNode.value = idFromNode;
	//Charset: Added by Atsushi 01-29-2009
	parent.treeframe.document.forms["treefinaljsp"].charset = "UTF-8";
	parent.treeframe.document.forms["treefinaljsp"].submit();
}

function setParentSelectBox(total_pages,curpage)
{

	var objlstSel ;

	objlstSel = parent.document.getElementById("Total_Pages");
	objlstSel.options.length = total_pages;

	var selectvalue="";
	var i;
	for(i=1; i <=total_pages;i++)
	{
		objlstSel.options[i-1].value =i ;
		objlstSel.options[i-1].text =i ;
		if(i == curpage)
		{
		objlstSel.options[i-1].selected = true;

		}
	}
}

function getNonLeafMembers(dimid,hierarchyname,treestate,ctxpath)
{
	
	dimid = parent.document.getElementById('hSelectedDimensionId').value;
	parent.document.frames["frmTree"].location.href = "../html-jsp/tree.jsp?dimID=" + dimid + "&TreeState=" + treestate + "&HierarchyName=" +hierarchyname+"&getMembers=CallMember";
	
}

function getHierarchy( id, name )
{
	idFromNode=id;
	parent.treeframe.document.forms["treefinaljsp"].dimensionidselected.value=idFromNode;
	parent.treeframe.document.forms["treefinaljsp"].dimensionnameselected.value=name;
	parent.treeframe.document.forms["treefinaljsp"].ResultsClicked.value = "false";
	//Charset: Added by Atsushi 01-29-2009
	parent.treeframe.document.forms["treefinaljsp"].charset = "UTF-8";
	parent.treeframe.document.forms["treefinaljsp"].submit();
}


function MoveUP(lstName)
{
	var intI;
	var strText,strValue;
	var objlst = document.getElementById(lstName);
	if(objlst.selectedIndex > 0)
	{
		strText = objlst.options[objlst.selectedIndex].text;
		strValue = objlst.options[objlst.selectedIndex].value;
		objlst.options[objlst.selectedIndex].text = objlst.options[objlst.selectedIndex-1].text;
		objlst.options[objlst.selectedIndex].value= objlst.options[objlst.selectedIndex-1].value;
		objlst.options[objlst.selectedIndex-1].text  = strText;
		objlst.options[objlst.selectedIndex-1].value  = strValue;
		objlst.options[objlst.selectedIndex-1].selected = true;
		objlst.selectedIndex = objlst.selectedIndex;
	}
}

function MoveDown(lstName)
{
	var intI;
	var strText, strValue;
	var objlst = document.getElementById(lstName);
	if(objlst.selectedIndex < objlst.options.length-1)
	{
		strText = objlst.options[objlst.selectedIndex].text;
		strValue = objlst.options[objlst.selectedIndex].value;
		objlst.options[objlst.selectedIndex].text = objlst.options[objlst.selectedIndex+1].text;
		objlst.options[objlst.selectedIndex].value= objlst.options[objlst.selectedIndex+1].value;
		objlst.options[objlst.selectedIndex+1].text  = strText;
		objlst.options[objlst.selectedIndex+1].value  = strValue;
		objlst.options[objlst.selectedIndex+1].selected = true;
		objlst.selectedIndex = objlst.selectedIndex+1;
	}
}


function parseSpecialChar( pValue )
{
	var specialString = pValue;
	specialString = replace(specialString, "&", "~");
	specialString = replace(specialString, "%", "^");
	return specialString;
}

function showEditChart( ctxpath )
{
	show( ctxpath );
}

function showEditMap( ctxpath )
{
	show( ctxpath );
}

// Added by Ganesh 08/07/2003
function setCheckBox( chkObj )
{
	if(chkObj.checked)
		document.forms[0].chkHchy.value = "true";
	else
		document.forms[0].chkHchy.value = "false";
}

function setStylesData( stepval, id )
{
	var URL;
	var pos;
    	URL = "home.do?Step=" + stepval + "&menuid=" + id;
	document.forms["ddponline"].action = URL;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["ddponline"].charset = "UTF-8";
	document.forms["ddponline"].submit();
}
function  setCubeData( stepval, dimension, id,ctxpath)
{
	if(parent.document.getElementById("hdnCheckSelection") && stepval==1)
	{
		var check = parent.document.getElementById("hdnCheckSelection").value;
		if((check!="null") && (check=="Yes"))
		{
			var blnReturn = confirm("Your selection will be lost do you want to continue");
			if(!blnReturn)
			{
				return;
			}else
				parent.document.getElementById("hdnCheckSelection").value =""
		}
	
	}
	if(typeof(objCalWindow) != 'undefined')
	{
		objCalWindow.close()
	}
	
	var obj =  document.frames["frmTree1"] 
	if(typeof(obj) != 'undefined')
	{
		if(typeof(document.frames["frmTree1"].objCalWindow) != 'undefined')
		{
			document.frames["frmTree1"].objCalWindow.close()
		}
	}
	if(document.getElementById("countrylstselected"))

	{
		if(parent.document.getElementById("hdnSelectedMemberCount"))
		{
			parent.document.getElementById("hdnSelectedMemberCount").value =document.getElementById("countrylstselected").options.length;
		}
	}
	else
	{
		var obj =  document.frames["frmTree1"] ;
		if(typeof(obj) != 'undefined')
		{
			document.getElementById("hdnSelectedMemberCount").value= document.frames["frmTree1"].document.getElementById("countrylstselected").options.length;
		}
	}
	var URL;
	var objCube		= document.getElementById("lstCubes");
	var objType		= document.getElementById("lstDBCategory");
	var objSource	= document.getElementById("lstDBSubCategory");
	var aggregation = "";
	//retaining the header and footer values
	if(document.getElementById("txtHeader"))
	{
		document.getElementById("hReportHeader").value=document.getElementById("txtHeader").value
		document.getElementById("hReportFooter").value=document.getElementById("txtFooter").value
	}
	//alert(document.all['lstXAxis']);
	if(document.all['lstXAxis']){
		document.getElementById("rowAxisCaption").value=getDimensionsName(document.all['theRowtable']);
		document.getElementById("columnAxisCaption").value=getDimensionsName(document.all['thecoltable']);
		document.getElementById("pageAxisCaption").value=getDimensionsName(document.all['thetable']);

		document.getElementById("rowAxis").value=getDimensionsId(document.all['theRowtable']);
		document.getElementById("columnAxis").value=getDimensionsId(document.all['thecoltable']);
		document.getElementById("pageAxis").value=getDimensionsId(document.all['thetable']);
		parent.document.getElementById("RESET_AXIS_SESSION").value="true";
		
	}
	//alert(parent.document.getElementById("RESET_AXIS_SESSION").value);
	
	if(objCube && objType && objSource )
	{
		if (objSource.selectedIndex == -1 )
		{
			alert("Please select a database type.");
			return;

		} else{
			branding = customBrandingArray[objSource.options[objSource.selectedIndex].text];
		}

		if(objCube.selectedIndex == -1)
		{
			alert("Please select a database.");
			return;
		} else {
			aggregation = aggregationArray[objCube.options[objCube.options.selectedIndex].text];
		}
		if(stepval != 2)
		{
			alert("Please select variables from at least two dimensions.");
			return;
		}
		//--------------------- added for Branding ---

		if (typeof(branding) != 'undefined') {
			var imgXML =  branding.split("~");
			parent.document.forms["ddponline"].BrandImage.value = imgXML[0];
			parent.document.forms["ddponline"].BrandXmlName.value = imgXML[1];
		}
	}
	

	if(dimension != "" || dimension != null  )
	{
		if(parent.document.getElementById("hActiveDimensionId"))
		{
			parent.document.getElementById("hActiveDimensionId").value = dimension;
		}

		else
		{
			if(document.getElementById("hActiveDimensionId"))
			{
				document.getElementById("hActiveDimensionId").value = dimension;
			}
		}
	}
	
	// work  around to  set the dimension id    for the successive dimensions after the 
	//members for the first dimension are selected as selectDimennsions jsp 
	//requires the  current selected dimension as a param
	
	if(dimension != "" && dimension != "null" &&  dimension != "-1"){
		var selMember = document.getElementById("hdnSelMember");
		//alert(dimension);
		if(selMember == undefined){
			URL = "home.do?Step=" + stepval + "&id=" + id+"&hActiveDimensionId="+dimension ;
		}else{
				selMember = document.getElementById("hdnSelMember").value;
			//alert("value="+dimension);
			URL = "home.do?Step=" + stepval + "&id=" + id+"&hActiveDimensionId="+dimension+"&hdnSelMember="+selMember ;
		}
	}else{
		var selMember = document.getElementById("hdnSelMember");
		//alert(selMember);
		if(selMember == undefined){
			URL = "home.do?Step=" + stepval + "&id=" + id ;
		}else{
			selMember = document.getElementById("hdnSelMember").value;
			//alert(selMember);
			URL = "home.do?Step=" + stepval + "&id=" + id+"&hdnSelMember="+selMember ;
		}
	}
	if (aggregation != ""){
		URL = URL+"&DisplayAggregation="+aggregation;
	}

	setSelectedMembers1()
	//alert(URL);
	parent.document.forms["ddponline"].target="_self";
	parent.document.forms["ddponline"].action = URL;
	parent.document.forms['ddponline'].method =  "POST";
	//Charset: Added by Atsushi 01-29-2009
	parent.document.forms["ddponline"].charset = "UTF-8";
	parent.document.forms["ddponline"].submit();

}

function changeCustomBranding() {

	var objSource = document.getElementById("lstDBSubCategory");
	var objType = document.getElementById("lstDBCategory");
	var setBrandRequired = false;
	var setNewBrand = false;
	var URL = "home.do?Step=1&id=4";
	var	branding = customBrandingArray[objSource.options[objSource.selectedIndex].text];
	
	var presentImage = parent.document.forms["ddponline"].PreviousBrandImage.value;
	if (typeof(branding) != 'undefined' && branding != null && 
		branding != "" && branding != '~' ) {
		setNewBrand = true;
	} else{
		setNewBrand = false;
	}
	//alert("Set New Brand "+setNewBrand);
	if ( (presentImage == "null" || presentImage == "") && !setNewBrand ) {
		setBrandRequired = false;
	} else{
		setBrandRequired = true;
	}
	//alert("setBrandRequired: "+setBrandRequired);
	if (setBrandRequired) {
		parent.document.forms["ddponline"].SelectedDBIndex.value = objType.selectedIndex;
		parent.document.forms["ddponline"].SelectedDBTypeIndex.value = objSource.selectedIndex;
		//alert(parent.document.forms["ddponline"].SelectedDBIndex.value+"\t-- ");
		//alert("URL: "+URL);
		var imgXML =  branding.split("~");
		parent.document.forms["ddponline"].BrandImage.value = imgXML[0];
		parent.document.forms["ddponline"].BrandXmlName.value = imgXML[1];
		URL = URL+"&SET_BRANDING=YES"
		parent.document.forms["ddponline"].target="_self";
		parent.document.forms["ddponline"].action = URL;
		parent.document.forms['ddponline'].method =  "POST";
		//Charset: Added by Atsushi 01-29-2009
		parent.document.forms["ddponline"].charset = "UTF-8";
		parent.document.forms["ddponline"].submit();
	} else {
		PopulateCubes();
	}
	return;
}


function setOrientation()
{
	var intC;
	var strRowAxis = "", strRowAxisCaption = "";
	var strColAxis = "", strColAxisCaption = "";
	var strPageAxis = "", strPageAxisCaption = "";
	var objElement;



	objElement = document.getElementById("lstXAxis");

	if (objElement != null)
	{

		strRowAxis =  getDimensions(document.all['theRowtable']);
		strRowAxisCaption =  getDimensions(document.all['theRowtable']);
		strColumnAxis = getDimensions(document.all['thecoltable']);
		strColAxisCaption = getDimensions(document.all['thecoltable']);
		strPageAxis  =  getDimensions(document.all['thetable']);
		strPageAxisCaption = getDimensionsName(document.all['thetable']);
	}
}

function setSelectedMembers1()
{

	var selectedMembersUniqueName = "";
	var selectedMembersDispName = "";

	var replacedval;
	var strTreeState;
	
	var checkSelected = parent.document.getElementById("hdnCheckSelection");
	if(document.getElementById("countrylstselected"))
	{
		var objlistSelected = document.getElementById("countrylstselected");
		var objlistSelectedFrom = document.getElementById('countrylst');
		//var checkSelected = document.getElementById("hdnCheckSelection");
	}
	else
	{
		var obj =  document.frames["frmTree1"] ;
		if(typeof(obj) != 'undefined')
		{
			var objlistSelected = document.frames["frmTree1"].document.getElementById("countrylstselected");
			var objlistSelectedFrom = document.frames["frmTree1"].document.getElementById('countrylst');
		//	var checkSelected = document.frames["frmTree1"].document.getElementById("hdnCheckSelection");
		}
	}

	if(objlistSelected != null && objlistSelectedFrom != null)
	{
		for( intK = 0; intK < objlistSelected.options.length; intK++ )
		{
			if(intK == objlistSelected.options.length-1)
			{
				optval = objlistSelected.options[intK].value;
				
				replacedval = replace(optval,'"','&quot;');
				selectedMembersUniqueName = selectedMembersUniqueName + replacedval;
				selectedMembersDispName = selectedMembersDispName + objlistSelected.options[intK].text;
			}
			else
			{
				optval = objlistSelected.options[intK].value;
				replacedval = replace(optval,'"','&quot;');

				selectedMembersUniqueName = selectedMembersUniqueName + replacedval + "~";
				selectedMembersDispName = selectedMembersDispName + objlistSelected.options[intK].text + "~";
			}
		}
		
		
		if(objlistSelected.options.length>0)
		{
			checkSelected.value = "Yes";
		}
		
		parent.document.getElementById("hSelectedMembersUniqueName").value =selectedMembersUniqueName;
		parent.document.getElementById("hSelectedMembersDispName").value =selectedMembersDispName;
	}
}

function setMemberValuesToHidden( strlistTo)
{
	var memberstext = "";
	var sessionstring = "";
	var arrTemp;
	var optval;
	var replacedval;
	var strTreeState;
	var hdnMembers = document.getElementById("listmembers");
	var hdnMembertext = document.getElementById("listmemberstext");
	var objlistSelected = document.getElementById(strlistTo);
	var hdnTreeState = document.getElementById("hdnTreeState");
	var dimension;
	var objlistSelectedFrom = document.getElementById('countrylst');
	var selMembersList ="";
	var memberList =   document.getElementById('selectedMembersList');


	if(objlistSelected != null && objlistSelectedFrom != null)
	{

		strTreeState = parent.document.frames["frmTree"].document.getElementById("hdnSelMember").value;

		//Set the selected Hierarchy
		if(hdnTreeState)
		{
			if(hdnTreeState.value == "null" || hdnTreeState.value == null || hdnTreeState.value == "")
				hdnTreeState.value = "";

			//Check if there is the dimension TreeState already there
			if(hdnTreeState.value != "")
			{
				arrHier = hdnTreeState.value.split("*");
				hdnTreeState.value = "";
				for( intI = 0; intI < arrHier.length; intI++ )
				{
					if(arrHier[intI].split("~")[0] != strTreeState.split("~")[0])
						hdnTreeState.value = hdnTreeState.value + arrHier[intI] + "*";

				}
			}

			hdnTreeState.value = hdnTreeState.value + strTreeState ;
		}


		for( intK = 0; intK < objlistSelected.options.length; intK++ )
		{


			if(intK == objlistSelected.options.length-1)
			{
				optval = objlistSelected.options[intK].value;
				replacedval = replace(optval,'"','&quot;');
				sessionstring = sessionstring + replacedval;
				memberstext = memberstext + objlistSelected.options[intK].text;
				selMembersList  =selMembersList  + objlistSelected.options[intK].text
			}
			else
			{
				optval = objlistSelected.options[intK].value;
				replacedval = replace(optval,'"','&quot;');

				sessionstring  = sessionstring + replacedval + "~";
				memberstext = memberstext + objlistSelected.options[intK].text + "~";
				selMembersList  =selMembersList  + objlistSelected.options[intK].text + "~";
			}
		}

		var arrtextTemp,strtempText;





		if(objlistSelected.options.length > 0)
		{

			dimension = objlistSelected.options[0].value.split(".")[0];

			//Remove the previous selection from the hidden variables;
			tempvar = hdnMembers.value;
			strtempText = hdnMembertext.value;

			if(tempvar != null && tempvar != "null")
			{
				arrTemp = tempvar.split("~");
				arrtextTemp = strtempText.split("~");

				for(intK = 0; intK < arrTemp.length; intK ++)
				{

					if(dimension != arrTemp[intK].split(".")[0])
					{


						sessionstring = sessionstring + "~" +arrTemp[intK];
						memberstext = memberstext + "~" + arrtextTemp[intK];
						//selMembersList  = arrtextTemp[intK];
					}
				}
			}


		}
		else
		{
	     if(objlistSelectedFrom.options.length > 0)
		  {

		   sessionstring = "";
           memberstext = "";

			dimension = objlistSelectedFrom.options[0].value.split(".")[0];

			//Remove the previous selection from the hidden variables;
			tempvar = hdnMembers.value;
			strtempText = hdnMembertext.value;

			if(tempvar != null && tempvar != "null")
			{
				arrTemp = tempvar.split("~");
				arrtextTemp = strtempText.split("~");

				for(intK = 0; intK < arrTemp.length; intK ++)
				{

					if(dimension != arrTemp[intK].split(".")[0])
					{


						sessionstring = sessionstring + "~" +arrTemp[intK];
						memberstext = memberstext + "~" + arrtextTemp[intK];
						//selMembersList  = arrtextTemp[intK];
					}
				}
			}
		  }//End check for null selection
		}


		if(sessionstring != "")
		{
			 hdnMembers.value = sessionstring;
			 hdnMembertext.value = memberstext;
			 memberList.value  = selMembersList ;
		}



	}


}

function replace( memstring, replchar, withstring )
{
	var strLength = memstring.length;
	var txtLength = replchar.length;

	if ((strLength == 0) || (txtLength == 0))
		return memstring;

	var i = memstring.indexOf(replchar);

	if ((!i) && (replchar != memstring.substring(0,txtLength)))
		return memstring;

	if (i == -1)
		return memstring;

	var newstr = memstring.substring(0,i) + withstring;

	if (i+txtLength < strLength)
		newstr += replace(memstring.substring(i+txtLength,strLength),replchar,withstring);

	return newstr;
}

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function


function SetSelectedValue(lstCntrl,value)
{
	var intX;
	var objCntrl = document.getElementById(lstCntrl);
	for( intX = 0; intX < objCntrl.options.length; intX++ )
	{
		if(objCntrl.options[intX].value == value)
		{
			objCntrl.options[intX].selected = "true";
			return;
		}
    }
}

function SetSelectedValues(lstCntrl,value)
{
	var intX,intY;
	var objCntrl = document.getElementById(lstCntrl);

	for(intY = 0; intY < value.length ; intY++)
	{
		for(intX=0;intX < objCntrl.options.length;intX++)
		{
			if(objCntrl.options[intX].value == value[intY])
			{
				objCntrl.options[intX].selected = "true";
			}
		}
	}
}

function saveReport()
{
	window.showModalDialog("SaveReport.jsp");
}

function Close()
{
	window.close();
}

function displayReport( reportID, requesttype, ctxpath ){
	var URL;
	var flag = true;
	if (requesttype == "REFRESH") {
		if(!confirm("Report will be refreshed. If your report sets the option to hide empty rows or columns, all changes you may have made in Excel will be lost."))
			flag = false;
	}
	if (flag){
		URL = ctxpath + "/viewSavedReport?REPORT_ID=" + reportID+"&REQUEST_TYPE="+requesttype;
		sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=900,height=500,left = 122,top = 134';
		window.open(URL, "Report", sFeatures);
	}
}

function displayViewChart( reportID, requesttype, ctxpath ){

	var URL;
	var flag = true;
	if (requesttype == "REFRESHCHART") {
		if(!confirm("Report will be refreshed. If your report sets the option to hide empty rows or columns, all changes you may have made in Excel will be lost."))
			flag = false;
	}
	if (flag){
		URL = ctxpath + "/viewSavedChart?REPORT_ID=" + reportID+"&REQUEST_TYPE="+requesttype;
		sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=900,height=500,left = 122,top = 134';
		window.open(URL, "Chart", sFeatures);
	}
}

function displayViewMap( reportID, requesttype, ctxpath ){

	var URL;
	var flag = true;
	if (requesttype == "REFRESHMAP") {
		if(!confirm("Report will be refreshed. If your report sets the option to hide empty rows or columns, all changes you may have made in Excel will be lost."))
			flag = false;
	}
	if (flag){
		URL = ctxpath + "/viewSavedMap?REPORT_ID=" + reportID+"&REQUEST_TYPE="+requesttype;
		sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=900,height=500,left = 122,top = 134';
		window.open(URL, "Map", sFeatures);
	}
}

function refresh( reportID, requesttype, ctxpath ) {
	var URL;
	URL = "DisplayReport.jsp?REPORT_ID=" + reportID + "&REQUEST_TYPE=" + requesttype;
	document.forms["displayrpt"].action = URL;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["displayrpt"].charset = "UTF-8";
	document.forms["displayrpt"].submit();
}

function deleteReport( reportID, requesttype )
{
	var blnValue = confirm("Are you sure you want to delete the report?")
	if(blnValue==true)
	{
		var URL;
		var elemToDel = document.getElementById("hdnrptidfordeletion");
		elemToDel.value = reportID;
		URL = "home.do?Step=1&id=3&new=1"+"&REPORT_ID_FOR_DELETION="+reportID+"&REQUEST_TYPE="+requesttype;
		document.forms["ddponline"].action = URL;
		//Charset: Added by Atsushi 01-29-2009
		document.forms["ddponline"].charset = "UTF-8";
		document.forms["ddponline"].submit();
	}
}

function updateReport( reportID, requesttype, ctxpath )
{
	var sFeatures;
	var windowName;
	windowName = "upload";
	sFeatures = "width=500,height=50,left = 122,top = 134";
	window.open(ctxpath+'/html-jsp/UpdateReport.jsp?REPORT_ID='+reportID+'&requesttype='+requesttype,windowName,sFeatures);

}

function downloadToExcel( reportID )
{
   document.getElementById("hdnreportid").value = reportID;
   document.forms.hReportId.value = reportID;
	//Charset: Added by Atsushi 01-29-2009
   document.forms["displayrpt"].charset = "UTF-8";
   document.forms["displayrpt"].submit();
}


function viewExcel(ctx,formname,reqType,dimAxis,qryString )// it shud work for the metadata page as well
{
var url = '';
	if(reqType == "META_EXCEL")
	{
		if(dimAxis == null) dimAxis = "";
		if(qryString == null)
			url = ctx+ "/viewSourceNotes?REQUEST_TYPE=8&DIMENSION_AXIS="+dimAxis;
		else{
			url = ctx+ "/viewSourceNotes?"+qryString;
		}
		//url = ctx+"/processExcel.do?REQUEST_TYPE=804";
	}
	else
	{
		url = ctx+"/processExcel.do?REQUEST_TYPE="+reqType;
	}
	if(url =='' || url == ' ' )
	{
		url = ctx+"/processExcel.do?REQUEST_TYPE="+reqType;
	}
	document.forms[formname].method = "POST"
	document.forms[formname].action= url;
	document.forms[formname].target = "_self";
	//Charset: Added by Atsushi 01-29-2009
	document.forms[formname].charset = "UTF-8";
	document.forms[formname].submit();
}

function uploadExcel( reportid, requesttype, ctxpath )
{
	var URL;
	var filetoupload = document.getElementById("fileName").value;
	if (filetoupload != "" )
	{
		var sFeatures = "height=687px;width=800px;status=yes;"
		URL = ctxpath + "/html-jsp/UpdateReport.jsp?PATH=" + filetoupload+"&REPORT_ID="+reportid+"&REQUEST_TYPE="+requesttype;
		document.forms["updateform"].action = URL;
		//Charset: Added by Atsushi 01-29-2009
		document.forms["updateform"].charset = "UTF-8";
		document.forms["updateform"].submit();
	} else{
		alert("Please select a file for uploading");
	}
}

function saveStyleSelection( id )
{

	var URL;
	var arrControls = new Array(6);
	var arrValues = new Array(4);
	arrControls[0] = document.getElementById('hdnHeader');
	arrControls[1] = document.getElementById('hdnColumn');
	arrControls[2] = document.getElementById('hdnSection');
	arrControls[3] = document.getElementById('hdnRow');
	arrControls[4] = document.getElementById('hdnContentArea');

	arrControls[5] = document.getElementById('hdnContentAlt');
	arrControls[6] = document.getElementById('hdnFooter');

	arrValues[0] = document.getElementsByName('cmbFont');
	arrValues[1] = document.getElementsByName('cmbFontType');
	arrValues[2] = document.getElementsByName('cmbFontsize');
	arrValues[3] = document.getElementsByName('tdSelFontColor');
	arrValues[4] = document.getElementsByName('tdSelBgColor');
	//Get all the hidden variables set
	for( var iY = 0; iY < arrValues.length; iY++ )
	{
		for(var iX = 0; iX < arrControls.length; iX++)
		{
			if(iY <= 2)
			{
				arrControls[iX].value = arrControls[iX].value + arrValues[iY][iX].options[arrValues[iY][iX].selectedIndex].text+ "~";
			}
			else
			{
				arrControls[iX].value = arrControls[iX].value + arrValues[iY][iX].style['backgroundColor']+ "~";
			}
		}
	}





	URL = "home.do?Step=3" + "&menuid=" + id + "&Action=1"

	var styleName = document.getElementById('txtName').value;
	if(styleName == "" || styleName == null ) {
		 alert('Give a name to your layout (max 10 characters).' );
	}else if((styleName.indexOf("<")!=-1) || (styleName.indexOf("\"")!=-1) ){
		alert("The characters \" < are special reserved characters that are not allowed in the style name. Please save the style with another name.");
		return;

	}else{
		document.forms["ddponline"].action = URL;
		//Charset: Added by Atsushi 01-29-2009
		document.forms["ddponline"].charset = "UTF-8";
		document.forms["ddponline"].submit();
	}
}

function SetSavedStyles( strStyles )
{
	var arrStyles;
	var iX,iY;
	var arrValues = new Array(4);

	arrStyles = strStyles.split("^");
	arrValues[0] = document.getElementsByName('cmbFont');
	arrValues[1] = document.getElementsByName('cmbFontsize');
	arrValues[2] = document.getElementsByName('cmbFontType');
	arrValues[3] = document.getElementsByName('tdSelBgColor');
	arrValues[4] = document.getElementsByName('tdSelFontColor');

	for( iX = 0; iX < arrStyles.length-1; iX++ )
	{
		arrStyle = arrStyles[iX].split("~");

		for(iY = 0; iY < (arrStyle.length-2); iY++)
		{
			SetSelectedText( arrValues[iY][iX], arrStyle[iY] );
		}
		for( ; iY < arrStyle.length; iY++ )
		{
			arrValues[iY][iX].style['backgroundColor'] = arrStyle[iY];
		}
	}
}

function SetSelectedText( objCntrl, value )
{
	var intX;
	for( intX = 0; intX < objCntrl.options.length; intX++ )
	{
		if(objCntrl.options[intX].text == value)
		{
			objCntrl.options[intX].selected = "true";
			return;
		}
    }
}

function SetValueinPreview( tblPart, property, cntrl )
{
	var intC;
	var arrElement;
	var style_flag;
	var style_weight;
	arrElement = document.getElementsByName(tblPart);
	for( intC = 0; intC < arrElement.length; intC++ )
	{
		style_flag = "3";

         style_weight =  cntrl.options[cntrl.selectedIndex].text;

		   if(style_weight.indexOf("Italic") == 0)
		{

		arrElement[intC].style['fontStyle'] =  'Italic';
		arrElement[intC].style['fontWeight']  = 'Normal';

		  style_flag ="-1";
        }

	   if(style_weight.indexOf("Bold") == 0)
		{

		  arrElement[intC].style['fontWeight'] = 'Bold';
		  arrElement[intC].style['fontStyle'] = 'Normal';

		  style_flag ="-2";
        }

	   if((style_weight.indexOf("Bold Italic") == 0) && (style_weight.length > 4))
        {
		  arrElement[intC].style['fontWeight'] = 'Bold';
		  arrElement[intC].style['fontStyle'] = 'Italic';
		  style_flag ="-3";
		}


	   if(style_weight.indexOf("Normal") == 0 && (style_weight.length == 6))
		{
		  arrElement[intC].style['fontStyle'] = 'Normal';
		  arrElement[intC].style['fontWeight'] = 'Normal';
		  style_flag ="-4";
		}

		if(style_flag == "3")
		{

		  arrElement[intC].style[property] = cntrl.options[cntrl.selectedIndex].text;

		}

			switch (tblPart) {

			case "tdHeader" :
					
					arrElement[intC].innerHTML = "Header - ";
					break;

			case "tdColumn" :

					arrElement[intC].innerHTML = "Column - ";
					break;

			case "tdSection" :

					arrElement[intC].innerHTML = "Section - ";
					break;

			case "tdRow" :

					arrElement[intC].innerHTML = "Row - ";
					break;

			case "tdCntArea" :

					arrElement[intC].innerHTML = "Content Area - ";
					break;

			case "tdCntAreaAlt" :

					arrElement[intC].innerHTML = "Content Area Alt - ";
					break;

			case "tdFooter" :

					arrElement[intC].innerHTML = "Footer - ";
					break;

		}
		var strFontWt = arrElement[intC].style["fontWeight"];
		var strFontSt = arrElement[intC].style["fontStyle"];
		var strFinalStyle="";

		if(strFontWt != "normal")
			strFinalStyle = strFontWt.substring(0,1).toUpperCase() + strFontWt.substring(1,strFontWt.length);
	
		if(strFontSt != "normal")		
			strFinalStyle = strFinalStyle + " " + strFontSt.substring(0,1).toUpperCase() + strFontSt.substring(1,strFontSt.length);
		if(strFontWt == "normal" && (strFontSt == "normal" || strFontSt == ""))
			strFinalStyle = strFontWt.substring(0,1).toUpperCase() + strFontWt.substring(1,strFontWt.length);

		
		arrElement[intC].innerHTML = arrElement[intC].innerHTML + " " + arrElement[intC].style["fontFamily"] + " "  + arrElement[intC].style["fontSize"].substring(0,2) + " " +strFinalStyle ;
	}
}


function RefreshToViewReports()


{
	//alert('RefreshToViewReports');
	var strURL;

	//strURL = "document.forms['ddponline'].action='home.do?Step=1&id=3&new=1&requesttype=VIEW';document.forms['ddponline'].submit();"
	//Charset: Added by Atsushi 01-29-2009
	strURL = "document.forms['ddponline'].action='home.do?Step=1&id=3&requesttype=VIEW';document.forms['ddponline'].charset='UTF-8';document.forms['ddponline'].submit();"
	//alert(strURL);
	window.opener.execScript( strURL, "javascript" );
	window.close();
}


function viewSavedReport(url)
{
	sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=900,height=500,left = 122,top = 134';
	window.open( url, "viewreport" , sFeatures );
	window.close();
}


function colorPalate(tblPart,element,elementpos,ctxpath)
{
	var intC;
	var color;
	var selColor;
	var property;
	var sFeatures;
	var arrElement
	var activeElement;

	activeElement = document.getElementsByName(element)[elementpos]
	color = activeElement.style['backgroundColor'];
	sFeatures = "dialogHeight=330px;dialogWidth=220px;help=no;status=no;"
	selColor = window.showModalDialog('..'+ctxpath+'/html-jsp/images/colorpalate.htm',color	,sFeatures);

	if(element == 'tdSelBgColor')
		property="backgroundColor";
	else
		property="color";

	//Set the Preview
	arrElement = document.getElementsByName(tblPart);
	activeElement.style['backgroundColor'] = selColor;
	for( intC = 0;intC < arrElement.length; intC++ )
	{
		arrElement[intC].style[property] = selColor;
	}

	function hidestatus(){
		window.status=''
		return true
	}

}

function SetStyleDefaults( scale, precision, empty, style, hierarchy )
{
	SetSelectedValue('cmbScale',scale);
	SetSelectedValue('cmbPrecision',precision);
	SetSelectedValue('cmbEmpty',empty);
	SetSelectedValue('lstStyle',style);
}



function SetSelectedCount( lstname, name)
{
	var checkSelected = parent.document.getElementById("hdnCheckSelection");
	
	var objlst = document.getElementById(lstname);
	var objDisplay = document.getElementById(name);

	objDisplay.innerText = "Selected - " + objlst.options.length;
	if(document.getElementById("hSelMembersCount"))
	{
		document.getElementById("hSelMembersCount").value=objlst.options.length;
	}
	
	if(objlst.options.length>0)
	{
		checkSelected.value = "Yes";
	}
	
}
function SetAvailableCount( lstname, name)
{
	var objlst = document.getElementById(lstname);
	var objDisplay = document.getElementById(name);
	objDisplay.innerText = "Available - " + objlst.options.length;
}


function swapImage( cntrl, image, newimage )
{
try{
	var objImage = cntrl.children(image);
	objImage.src = newimage;
	
	}
	catch(anonymous){
	}
}

/* needs to be checked whether this is required.*/
function getHierarchySelection(ctxpath,dimid)
{
	var strParams;
	var strDimId;


	if(dimid == "0"){
		strDimId = document.getElementById('hActiveDimensionId').value;
		}
	else
		strDimId = dimid;

	
	
	var strHierarchyName = "";
	
	strParams = "dimID=" + strDimId + "&HierarchyName=" + strHierarchyName
	var sFeatures = "toolbar=no,status=yes,menubar=no,location=no,height=600,width=800"
	window.open( ctxpath + "/html-jsp/Hierarchy.jsp?" + strParams, "Hierarchy", sFeatures );
}

function SetValues()
{
	var intI;
	var objlstDimensions = document.getElementById('countrylstselected');
	var objlstSelected = top.window.opener.document.getElementById('countrylstselected');
	var arrDelValues = new Array();
	objlstSelected.options.length = objlstDimensions.options.length;
	for( intI = 0; intI < objlstDimensions.options.length; intI++ )
	{
		objlstSelected.options[intI].text = objlstDimensions.options[intI].text;
		objlstSelected.options[intI].value = objlstDimensions.options[intI].value;
	}
	top.window.opener.execScript("SetSelectedCount('countrylstselected','tdcount');","javascript");
	top.window.close();
}

function CloseWindow()
{
	top.window.close();
}

function SetSelectedRadio(objvalue)
{
	//Alert before clearing.
	document.getElementById('hdnSelHierarchy').value = objvalue;
	document.getElementById('countrylstselected').options.length=0;
	SetSelectedCount('countrylstselected','tdcount');
}

function getSelectedDim(id)
{
	var objlst = document.getElementById('lstSel');
	var objHdn = window.opener.document.getElementById('hdnSelectedDim');
	var strDimensions = "";
	for( var iCount = 0; iCount < objlst.options.length; iCount++ )
	{
		if(iCount == objlst.options.length-1)
				strDimensions = strDimensions + objlst.options[iCount].value;
		else
			strDimensions = strDimensions + objlst.options[iCount].value + "~";
	}
	objHdn.value = strDimensions;
	URL = "home.do?Step=2&id=" + id;
	window.opener.document.forms["ddponline"].action = URL;
	//Charset: Added by Atsushi 01-29-2009
	window.opener.document.forms["ddponline"].charset = "UTF-8";
	window.opener.document.forms["ddponline"].submit();
	window.close();
}

function invokeChangedSpecialReport()
{
	var i;
	var objSelect;
	var objSelected;
	var delimeter = "~";
	var sessionString = "";
	var objlst = document.getElementById('lstPageDimensions');

	objDiv = document.getElementById("selectionlistsdiv");
	objSelect = objDiv.getElementsByTagName("select");

	if(objSelect != null)
	{
		for( i = 0; i < objSelect.length; i++ )
		{
			sessionString = sessionString+objSelect[i].options[objSelect[i].selectedIndex].value + delimeter;
		}
	}
	//Set the selected Styles
	document.forms["specialrptform"].hdnpagedim.value = sessionString;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["specialrptform"].charset = "UTF-8";
	document.forms["specialrptform"].submit();
}

function SetSelectedMembers(cntrlname,membervalues,membertext,dimension)
{
	var intI;
	var arrValues,arrText;
	
	arrValues = membervalues.split("~");
	arrText = membertext.split("~");
	var objlst = document.getElementById(cntrlname);
	

	if(dimension == "" && membervalues != "" && arrValues[0] != null)
	{
        if(arrValues[0].indexOf('`') > -1)
		{
		  dimension = arrValues[0].substring(arrValues[0].indexOf('['),arrValues[0].indexOf(']')+1);

		}
		else
		{
		 dimension = arrValues[0].split(".")[0];

		}

	}
	else
	{
		dimension = "[" + dimension + "]";

	}


	objlst.options.length =0;

	for( intI = 0; intI < arrValues.length; intI++ )
	{

		tempvar = arrValues[intI].split(".")[0];

        if(arrValues[intI].indexOf('`') > -1)
		{

		  tempvar = arrValues[intI].substring(arrValues[intI].indexOf('['),arrValues[intI].indexOf(']')+1);
		  //showCustomIndicator(arrValues[intI],arrText[intI]);

		}
		else
		{
 		 tempvar = arrValues[intI].split(".")[0];
		}


		if(tempvar == dimension)
		{
			objlst.options.length = objlst.options.length + 1;
			objlst.options[objlst.options.length-1].value = arrValues[intI];
			objlst.options[objlst.options.length-1].text = arrText[intI];
		}
	}

}

function SetSelectedHierarchy(dimension, hierarchy, chkHierarchy)
{
	var objHierarchy = document.getElementById(hierarchy);
	var objchkHierarchy = document.getElementsByName(chkHierarchy);
	var arrValues = objHierarchy.value.split("~");

	if(dimension != "")
	{
		dimension = "[" + dimension + "]";
		for(intI = 0; intI < arrValues.length; intI++)
		{
			if(arrValues[intI].split(".")[0] == dimension)
			{
				for(intJ=0;intJ < objchkHierarchy.length;intJ++)
				{
					if(objchkHierarchy[intJ].value.split("~")[0] == arrValues[intI])
					{
						objchkHierarchy[intJ].checked = true;
						document.getElementById('hdnSelHierarchy').value = objchkHierarchy[intJ].value.split("~")[1];
					}
					else
					{
						objchkHierarchy[intJ].checked = false;
					}
				}
				//Set exit condition
				intI = arrValues.length;
			 }
			 else
			{
				objchkHierarchy[0].checked = true;
				document.getElementById('hdnSelHierarchy').value = objchkHierarchy[0].value.split("~")[1];
			}
		}
		if(objchkHierarchy.length <= 0)
		{
			objchkHierarchy.checked = true;
			document.getElementById('hdnSelHierarchy').value = objchkHierarchy.value.split("~")[1];
		}
	}
}

function SetMembersFromMain( cntrlname )
{
	//get the values from the Parent window
	var intI;
	var objlstDimensions = window.top.opener.document.getElementById(cntrlname);
	if(!objlstDimensions) return;

	var objlstSelected = document.getElementById('hdnSelected');
	var objlstSelectedText =document.getElementById('hdnSelectedText')

	for( intI = 0; intI < objlstDimensions.options.length; intI++ )
	{
		if( intI == (objlstDimensions.options.length-1) )
		{
			objlstSelected.value = objlstSelected.value + objlstDimensions.options[intI].value;
			objlstSelectedText.value = objlstSelectedText.value  + objlstDimensions.options[intI].text;
		}
		else
		{
			objlstSelected.value = objlstSelected.value + objlstDimensions.options[intI].value + "~";
			objlstSelectedText.value = objlstSelectedText.value  + objlstDimensions.options[intI].text + "~";
		}
	}
}

function RemoveFromList( cntrlname, all )
{
	var intI,intLen;
	var objlstDimensions = document.getElementById(cntrlname);
	if(all !='yes'){
		if (document.getElementById("countrylstselected").selectedIndex == -1){
			alert("Please select the variable to remove for the selected list.");
			return;
		}

		var Objlist = document.getElementById("countrylstselected");
		value = Objlist.options[Objlist.selectedIndex].value;
		text= Objlist.options[Objlist.selectedIndex].text;
		text = "["+text+"]";
		
		if(value.indexOf("CUSTOM_INDICATOR")!=-1){
					
			for( i=0;i<Objlist.options.length;i++){
				if (Objlist.selectedIndex != i ) {
					displayName =Objlist.options[i].text;
					uniqueName =Objlist.options[i].value;
					if(displayName != text){
						if(uniqueName.indexOf(text) !=-1){
							alert("The custom Indicator "+
								Objlist.options[Objlist.selectedIndex].text+
								" is referenced in other indicator. You cannot delete the custom indicator "+
								Objlist.options[Objlist.selectedIndex].text+".");
							return;
						}
					}
				}
			}
		}
		from_value = parent.document.getElementById("hCIndicatorUniqueName");
		if(from_value.value.indexOf(text) != -1){
			alert("The custom Indicator "+Objlist.options[Objlist.selectedIndex].text+
				  " is referenced in other indicator. You cannot delete the custom indicator "+
				  Objlist.options[Objlist.selectedIndex].text+".");
			return;
		}
	} else if(all =='yes'){
		from_value = parent.document.getElementById("hCIndicatorUniqueName").value;
		var Objlist = document.getElementById("countrylstselected");
		for( i=0; i < Objlist.options.length; i++) {
			value = Objlist.options[i].value;
			if(from_value != null && stringTrim(from_value) != "" &&  
				value.indexOf(from_value) != -1){
				alert("The custom Indicator selected in the custom indicator area is referenced in other indicator. You cannot delete the custom indicator ");
				return;
			}
		}
	}
	
	for( intI =0; intI < objlstDimensions.options.length; intI++ )	{

		if(objlstDimensions.options[intI].selected == true || all == "yes") {
			objlstDimensions.remove( intI );
			intI = -1;
		}
	}
	if (objlstDimensions.options.length>0 ) {	
		objlstDimensions.options[0].selected =true;
	}
}

function invokeChangedSpecialReport()
{
	var i;
	var objSelect;
	var objSelected;
	var delimeter = "~";
	var sessionString = "";
	var objlst = document.getElementById('lstPageDimensions');

	objDiv = document.getElementById("selectionlistsdiv");
	objSelect = objDiv.getElementsByTagName("select");

	if(objSelect != null)
	{
		for( i = 0; i < objSelect.length; i++ )
		{
			sessionString = sessionString+objSelect[i].options[objSelect[i].selectedIndex].value+delimeter;
		}
	}
	//Set the selected Styles
	document.forms["specialrptform"].hdnpagedim.value = sessionString;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["specialrptform"].charset = "UTF-8";
	document.forms["specialrptform"].submit();
}

function displaySpecialReport( reportID, requesttype, ctxpath )
{
	var URL;
	sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=900,height=500,left = 122,top = 134';
	//URL = ctxpath + "/html-jsp/SpecialReport.jsp?reportID=" + reportID + "&requesttype=" + requesttype;
	URL = ctxpath + "/viewSavedReport?REPORT_ID=" + reportID + "&REQUEST_TYPE=" + requesttype;

	window.open(URL, "ViewReport", sFeatures);
}

function displayChart( context,xaxis, yaxis )
{
	var XAxisDims = xaxis.split("~");
	var YAxisDims = yaxis.split("~");
	if(XAxisDims.length > 2 || YAxisDims.length > 2)
	{
		alert('Please select only one dimension each for X and Y axis');
	}
	else
	{
		URL = context+"/processGraph.do?REQUEST_TYPE=CHART&NEW=Y";
		document.forms["reportform"].action = URL;
		document.forms["reportform"].target = "_self";
		//Charset: Added by Atsushi 01-29-2009
		document.forms["reportform"].charset = "UTF-8";
		document.forms["reportform"].submit();
	}
}

function displayMap( xaxis, yaxis, countryavailability )
{
	var XAxisDims = xaxis.split("~");
	var YAxisDims = yaxis.split("~");
	if( countryavailability )
	{
		if( countryavailability == true )
		{
			if(XAxisDims.length > 2 || YAxisDims.length > 2)
			{
				alert('Please select only one dimension each for X and Y axis');
			}
			else
			{
				URL = "../processMap.do";
				document.forms["reportform"].action = URL;
				//Charset: Added by Atsushi 01-29-2009
				document.forms["reportform"].charset = "UTF-8";
				document.forms["reportform"].submit();
			}
		}
	}
	else
	{
		alert('Please Select Country Dimension and try again');
	}
}

function viewMap(mapID, requesttype, ctxpath, reqtype)
{
	var URL,sFeatures;

	URL = ctxpath + "/html-jsp/DisplaySavedMap.jsp?mapID=" + mapID+"&requesttype="+reqtype;
	sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=900,height=500,left = 122,top = 134';
	window.open(URL, "viewmap", sFeatures);
}


function viewChart(chartID, type, ctxpath, requestType)
{
	var URL;
	URL = ctxpath + "/viewSavedReport?REPORT_ID=" + chartID+"&REQUEST_TYPE="+requestType;
	sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=900,height=500,left = 122,top = 134';
	window.open(URL,"viewchart",sFeatures);
}


function savechart()
{
	var URL;
	URL = "saveChart.do";
	document.forms[0].action=URL;
	//Charset: Added by Atsushi 01-29-2009
	document.forms[0].charset = "UTF-8";
	document.forms[0].submit();
}


function editReport( rptId, reqType , ctxPath, reportType )
{
	URL =ctxPath+ "/editReport?REPORT_ID="+rptId+"&REQUEST_TYPE="+reqType+"&REPORT_TYPE="+reportType;
	document.forms["ddponline"].action = URL;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["ddponline"].charset = "UTF-8";
	document.forms["ddponline"].submit();
}
function CheckEdit()
{
	alert("The datasource and the cube details cannot be changed in the Edit Mode");
	return;
}

function chooserequest(objcntrl)
{
	for( i = 0; i < document.forms[0].lstPageDimensions.options.length; i++ )
	{
		if(document.forms[0].lstPageDimensions.options[i].selected )
		{
			document.forms[0].HDNPAGEDIM.value = document.forms[0].HDNPAGEDIM.value + document.forms[0].lstPageDimensions.options[i].value+ "~";
			break;
		}
		else
		{
			//document.forms[0].HDNPAGEDIM.value =document.forms[0].HDNPAGEDIM.value +document.forms[0].lstPageDimensions.options[i].value+ "~";
		}
	}
	var URL = "../processSpecialChart.do";
}


function ViewSeriesScaling(ctxpath)
{
	var strURL  = ctxpath + "/html-jsp/SeriesScaling.jsp";
	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=300,left = 222,top = 234';
	var win = window.open( "", "SeriesScaling", sFeatures );
	win.name ="seriesScalingWin";
	document.forms["reportform"].action = strURL;
	document.forms["reportform"].method = "post";
	document.forms["reportform"].target = "seriesScalingWin";
	//Charset: Added by Atsushi 01-29-2009
	document.forms["ddponline"].charset = "UTF-8";
	document.forms["reportform"].submit();
}

//this function is being used to popup the hidecolumn functionality

function OpenHideColumn( ctxpath )
{
	var strHideColumns = document.getElementById("hdnHideColumns").value;
	//alert(strHideColumns);
	var strURL  = ctxpath + "/html-jsp/HideColumn.jsp?HIDE_COLUMN="+strHideColumns;

	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=300,left = 222,top = 234';
	window.open( strURL, "SeriesScaling", sFeatures );

}

function OpenHideColumnFromMainPage( ctxpath )
{
	var strHideColumns = document.getElementById("hdnHideColumns").value;
	var strColumnAxis	= getDimensionsId(document.all['thecoltable']);

	if (strColumnAxis == null || strColumnAxis.length <=0) {
		alert('Please select at least variable for Column');
		return ;
	}
	var strURL  = ctxpath + "/html-jsp/newHideColumn.jsp?HIDE_COLUMN="+strHideColumns + "&fromMainPage=YES&colAxis=" + strColumnAxis;
	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=300,left = 222,top = 234';
	window.open( strURL, "SeriesScaling", sFeatures );

}

function viewHierarchyList(ctxpath)
{
	var strURL  = ctxpath + "/html-jsp/hierarchyList.jsp";
	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=700,height=400,left = 122,top = 204';
	var win = window.open( strURL, "hierarchyList", sFeatures );
	win.name ="hierarchyList";
	win.focus();
}

function drilldownHierarchy(ctxPath)
{
	window.opener.refreshReport(ctxPath,"true","false" );
	window.close();
}



/* not  being used as of now***/

function showFootNotes(ctxPath,uniquesnames)
{
	var strURL  = ctxPath+"/html-jsp/Notes.jsp?uniquenames=" + uniquesnames + "&type=footnotes";
	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=700,height=330,left = 222,top = 234';
	var fNotes = window.open( '', "Notes",sFeatures);
	fNotes.name ="fNotes";
	document.reportform.method = "post";
	document.reportform.action = strURL;
	document.reportform.target = "fNotes";
	//Charset: Added by Atsushi 01-29-2009
	document.reportform.charset = "UTF-8";
	document.reportform.submit();
}

function showSourceNotes(context  ,  sourceNotesString)
{
	/*
	notesArray =sourceNotesString.split("~");
	dimension =notesArray[0];
	hierarchy = notesArray[1];
	uniquename =notesArray[2];
	URL = context +"/viewSourceNotes?DIMENSION_NAME="+dimension+"&HIERARCHY="+hierarchy;

	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=150,left = 222,top = 234';
	var sNotes = window.open('', "Notes", sFeatures);
	sNotes.name ="sNotes";
	document.reportform.UNIQUE_NAME.value = uniquename;
	document.reportform.method = "post";
	document.reportform.action = URL;
	document.reportform.target = "sNotes";
	document.reportform.submit();
	*/

	notesArray =sourceNotesString.split("~");
	dimension =notesArray[0];
	hierarchy = notesArray[1];
	uniquename =notesArray[2];
	if(typeof(cdbStatus)!='undefined' && cdbStatus=="true" || notesArray[3]!=null && typeof(notesArray[3])!='undefined' && notesArray.length >=4)
	{
		var cubeNo =notesArray[3];
		var cdbLst=sourceNotesString.substring(sourceNotesString.indexOf(cubeNo));
		cdbLst=cdbLst.substring(cdbLst.indexOf("~")+1);
		if(cdbLst==cubeNo)
			cdbLst="";
		if(typeof(cubeNo)!='undefined' && cubeNo!="")
			URL = context +"/viewSourceNotes?DIMENSION_NAME="+dimension+"&HIERARCHY="+hierarchy+"&CNO="+cubeNo+"&CDB_LST="+cdbLst;
		else
			URL = context +"/viewSourceNotes?DIMENSION_NAME="+dimension+"&HIERARCHY="+hierarchy;
	}
	else
		URL = context +"/viewSourceNotes?DIMENSION_NAME="+dimension+"&HIERARCHY="+hierarchy;

	var sFeatures = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=700,height=330,left = 222,top = 234';
	var sNotes = window.open('', "Notes", sFeatures);
	sNotes.name ="sNotes";
	//prompt("URL ",URL);
	document.reportform.UNIQUE_NAME.value = uniquename;
	document.reportform.method = "post";
	document.reportform.action = URL;
	document.reportform.target = "sNotes";
	//Charset: Added by Atsushi 01-14-2009
	document.reportform.charset = "UTF-8";
	document.reportform.submit();
}

function closemenu_CI()
{
	window.close();
}

function addExpression(ff)
{
	if(document.getElementById("custom_indicators_area"))
		funCheckCustomIndicatorEditor()
	
	if(ff == "DEL") {
		eraseLastCustomDefn()
	} else  {
		customDefn = document.getElementById("custom_indicators_area");

		eprev = customDefn.innerHTML;
		if(eprev.length > 0)
			eprev = eprev + '<font color=red size=1><b>' + ff + '</b></font>';
		else
			eprev = '<font color=red size=1><b>' + ff + '</b></font>';

		if(validate_CI(ff))
		{
			customDefn.innerHTML = eprev;
			addExpressionHidden(ff);
		}
	}
}

function validate_CI(xx)
{
	
  var number_string = "0123456789";
  var spe_string = "./*-+^";

  chk_str = document.getElementById("custom_indicators_area").innerText;

  temp_chk_str = "";

  if(spe_string.indexOf(xx) > -1)
  {
     if(chk_str.length <= 0)
 	   return false;
	 if(chk_str.length > 2 && (chk_str.substring(chk_str.length-3,chk_str.length)== "rnd" ||chk_str.substring(chk_str.length-3,chk_str.length) == "log"))
       return false;
	 if(chk_str.length > 0 && spe_string.indexOf((chk_str.substring(chk_str.length-1,chk_str.length))) > -1 )
       return false;

  }

  if(number_string.indexOf(xx) > -1)
  {
	  if(chk_str.length >2)
	  {
		  num_chk_str = chk_str.substring(chk_str.length-3,chk_str.length);
      	  }
	  else
	  {
		  num_chk_str = chk_str;

	  }

      if(num_chk_str == "rnd" || num_chk_str == "log")
	  {
		  return false;
	  }

	  if(chk_str.length >0)
	  {
		  num_chk_str = chk_str.substring(chk_str.length-1,chk_str.length);
      }


      if(num_chk_str.indexOf(']') > -1)
	  {
		  return false;
	  }

  }


  if(xx == "rnd" || xx == "log")
  {
	  valid_string = "+/*-";

	  if(chk_str.length >1)
	  {
		  temp_chk_str = chk_str.substring(chk_str.length-1,chk_str.length);
      }
	  else
	  {
		  temp_chk_str = chk_str;

	  }
	  if(valid_string.indexOf(temp_chk_str) == -1)
	  {

		return false;
	  }
  }

 return true;
}

function addExpressionHidden(ff)
{

	customUniqueName= parent.document.getElementById("hCIndicatorUniqueName");
	//customDispName= parent.document.getElementById("hCIndicatorDisplName");
	eprev = customUniqueName.value;

	if(eprev != "" && eprev != null && eprev != "null" && eprev.length > 0)
	  	eprev = eprev + '`' + ff ;
	else
      		eprev = '`' + ff ;
	customUniqueName.value = eprev;
	
}



function clearmenu_CI()
{
	e2 = document.getElementById("custom_indicators_area");
	from_value = parent.document.getElementById("hCIndicatorUniqueName")
	eprev = e2.innerHTML;

	if(eprev.indexOf("To add a custom indicator") ==-1 && e2.innerHTML !="" )
	{
		if(confirm("Are you sure you want to clear your custom indicator formula?"))
		{
			document.getElementById("custom_ind_txtbox").value="";
			e2.innerHTML = "";
			parent.document.getElementById("hCIndicatorUniqueName").value = "";
		}
	}
	else
	{
		alert("There is no custom indicator formula to clear.")
		return
	}
}


function showCustomIndicator(str1,str2)
{
	custom_area_text = document.getElementById("custom_ind_txtbox");
	custom_area_hidden = document.getElementById("custom_indicator_hidden");
	custom_area = document.getElementById("custom_indicators_area");

	custom_area_text.value = str2;
}

function eraseLastCustomDefn()
{
	
	customDispName = document.getElementById("custom_indicators_area").innerHTML;	
	customUniqueName = new String(parent.document.getElementById("hCIndicatorUniqueName").value);
	if( customDispName != null && customDispName != "" && 
		customUniqueName != null && customUniqueName != "" )  {
		//alert(document.getElementById("custom_indicators_area").innerText);
		var len = document.getElementById("custom_indicators_area").childNodes.length-1
		document.getElementById("custom_indicators_area").removeChild(document.getElementById("custom_indicators_area").childNodes.item(len))
		var lastChar = customUniqueName.lastIndexOf("`")
		parent.document.getElementById("hCIndicatorUniqueName").value=customUniqueName.substring(lastChar,customUniqueName-lastChar)
	}
	
}


function funCheckCustomIndicatorEditor()
{
	objCIEditor = document.getElementById("custom_indicators_area");
	var objValue  = objCIEditor.innerHTML;
	var posn = objValue.indexOf("add a custom indicator to your selection");
	if(posn != -1)
		objCIEditor.innerHTML="";
}

function showmenu_CI(name)
{
	var winl = (screen.width - 470) / 2;
    	var wint = (screen.height - 175) / 2;
	var URL;
	URL = "/html-jsp/ExpressionBuilder.jsp";
	objCalWindow = window.open(''+name+''+URL,"Re",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=240,height=190,left='+winl+',top='+wint+'');
	objCalWindow.window.focus();
}

function validate_CI1()
{
	var spe_string = "./*-+dg()";
	e21 = document.getElementById("custom_indicators_area");
	eprev1 = e21.innerText;
	temp_chk_str = "";

	if(eprev1.length >0)
	{
		temp_chk_str = eprev1.substring(eprev1.length-1,eprev1.length);
	}
	else
	{
		temp_chk_str = "." ;
	}


	if(spe_string.indexOf(temp_chk_str) > -1 )
	{

		return true;
	}
	else
	{

	return false;
	}

}



function checkNull(valobj)
{

   var val;
   var valid_num;

   valid_num = "0123456789*/-+.";
   val = valobj.value;


   if(val.length <=0 || val == null || val == "")
	{
	   alert("Expression cannot be null");

	   return false;
	}
   else
	{
	   return true;
   }

}

function DOMGetElement(xx)
{
 if (document.getElementById) return document.getElementById(xx);
 return nul;
}




// new function added by murugan 01/06/2003 to check for member hierarchy
 
 

    
function setActiveDimensions(dimensionID , dimensionName , dimensionType)
{
	document.getElementById('hSelectedDimensionId').value=dimensionID;
	document.getElementById('hActiveDimensionName').value=dimensionName;
	document.getElementById('hActiveDimensionType').value=dimensionType;
}
      
 
var columnAxis = "";
var pageAxis = "";
var rowAxis= "";

var columnAxisName = "";
var pageAxisName = "";
var rowAxisName= "";

function setDimensionAxis(dimensionId ,  axisValue , dimensionName)
{

   if(axisValue=="0"){
	   columnAxis = columnAxis +dimensionId +"~";
	   columnAxisName = columnAxisName +dimensionName +"~";
	   document.getElementById("NEW_REPORT_COLUMN_AXIS").value=columnAxis;
	   document.getElementById("NEW_REPORT_COLUMN_AXIS_NAME").value=columnAxisName;
   }
    if(axisValue=="1"){
	   rowAxis= rowAxis+dimensionId +"~";
	   rowAxisName = rowAxisName +dimensionName +"~";
	   document.getElementById("NEW_REPORT_ROW_AXIS").value=rowAxis;
	   document.getElementById("NEW_REPORT_ROW_AXIS_NAME").value=rowAxisName;
   }
    if(axisValue=="2"){
	   pageAxis = pageAxis+dimensionId +"~";
	   pageAxisName = pageAxisName +dimensionName +"~";
	   document.getElementById("NEW_REPORT_PAGE_AXIS").value=pageAxis;
	   document.getElementById("NEW_REPORT_PAGE_AXIS_NAME").value=pageAxisName;
   }
   

}

function loadAllMembers(controlName , index , displayName ,  uniqueName)
{
	// THIS FUNCTION LOADS ALL THE MEMBERS INTO THE DROP DOWN BOX  
	//  this is done  because  of the fact  that the   static list box is painted  as empty and then  the values gets
	// populated   into it  

       var obj = document.getElementById(controlName);

       if(index ==0)
       {
	       obj.options.length =1;
       }
       else{
	       obj.options.length =index+1;
       }
        obj.options[index].text=displayName;
        obj.options[index].value=uniqueName;
        
} 
 
 
 function chkSpecialChar(data) 
 {   // checks if all characters 
 	var invalid = "\\!@^&$()\"<>?{}[]*''";     // are invalid characters
 	var checktemp;
 	for (var i=0; i<data.length; i++) 
 	{
 		checktemp = "" + data.substring(i, i+1);
 		
 		if (invalid.indexOf(checktemp) != "-1") 
 		{
 			
 			return false; 
 		}
 	}
 		return true;
}

/*function showReportFormat( ctxpath )
{
	var intC;
	var strRowAxis = "", strColumnAxis = "", strPageAxis = "", strPageAxisCaption = "";
	var strFootNotes = "";
	var strScale, strPrecision, strEmpty, strchkHierarchy;
	var rptHeader = parseSpecialChar(document.getElementById("txtHeader").value);
	var rptFooter = parseSpecialChar(document.getElementById("txtFooter").value);
	var objElement = document.getElementById("lstStyle");
	var strStyleId = objElement.options[objElement.selectedIndex].value;

	sFeatures = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=780,height=500,left = 122,top = 134';

	strPageAxisCaption = getDimensionsName(document.all['thetable']);
	strColAxisCaption = getDimensionsName(document.all['thecoltable']);
	strRowAxisCaption = getDimensionsName(document.all['theRowtable']);

	if(!(checkMembersforXYAxis(strRowAxisCaption   , strColAxisCaption))){

	alert("PLEASE CHOOSE ATLEAST ONE  MEMBER FOR THE  X AND Y AXIS");
	return;
	}

	strRowAxis =  getDimensionsId(document.all['theRowtable']);
	strColumnAxis = getDimensionsId(document.all['thecoltable']);
	strPageAxis  =  getDimensionsId(document.all['thetable']);


   	objElement = document.getElementById("cmbScale");
   	strScale = objElement.options[objElement.selectedIndex].value;
   	objElement = document.getElementById("cmbPrecision");
	strPrecision = objElement.options[objElement.selectedIndex].value;
	objElement = document.getElementById("cmbEmpty");
	strEmpty = objElement.options[objElement.selectedIndex].value;
	strchkHierarchy = document.forms[0].chkHchy.value;
	
	
	//Format.jsp is being used in FormateReport.jsp and vewNewReport.jsp
	//When the user selects some values from FormatReport.jsp , those have to be
	//retained in viewNewReport.jsp and new button called ShowReport has to be 
	//added in Format.jsp after checking this variable
	// added by Uge on 22Jan04

	var newReport ="yes";
	window.open(ctxpath+'/html-jsp/viewNewReport.jsp?Step=3&id=4&reportHeader='+rptHeader+'&reportFooter='+rptFooter+'&NEW_REPORT_STYLE=' + strStyleId + '&RowAxis=' + strRowAxis+ '&ColAxis=' + strColumnAxis + '&PageAxis=' + strPageAxis +'&PageAxisCaption='+strPageAxisCaption+'&RowAxisCaption='+strRowAxisCaption+'&ColAxisCaption='+strColAxisCaption+ '&NEW_REPORT_SCALE='+strScale+'&NEW_REPORT_PRECISION='+strPrecision+'&NEW_REPORT_HIERARCHY='+strchkHierarchy+'&NEW_REPORT_EMPTYFORMAT=' + strEmpty+'&NEW_REPORT_FOOTNOTES='+strFootNotes+"&newReport="+newReport,"Report",sFeatures);
}*/



function scaleReport(ctxPath)
{
	var blnCheckScale	= "false"
	window.opener.refreshReport(ctxPath,blnCheckScale );
	window.close();
}
function rolloverReport(ctxPath)
{
	
	window.opener.refreshReport(ctxPath,"true");
	window.close();
}

function routeToReportPage(ctxpath , reportName,strHideColumn,seriescale)
{
	var URL = ctxpath+'/html-jsp/viewNewReport.jsp?IS_REPORT_SAVED=yes&SAVED_REPORT_NAME='+reportName+"&HIDE_COLUMN="+strHideColumn+"&SERIES_SCALING_FLAG="+seriescale;	
	window.open(URL , 'Report');
 }


function ViewSavedReports(context)
{
	var strURL;
	RefreshToViewExportReports();
}


function RefreshToViewExportReports()
{
	var strURL;
	//Charset: Added by Atsushi 01-29-2009
	strURL = "document.forms['ddponline'].action='home.do?Step=1&id=7&requesttype=VIEW';document.forms['ddponline'].charset='UTF-8';document.forms['ddponline'].submit();"
	window.opener.execScript( strURL, "javascript" );
	window.close();
}

/*function routeToQuickReportPage(ctxpath)
{

 var URL = ctxpath+'/html-jsp/QuickViewReport.jsp?newReport=yes&DATA_EXPORT=yes';	
 window.open(URL , 'Report');
 
 }
 */
function viewAdhocReport(url)
{
	self.open( url,'_self' ,  "viewSharedReport" );
}

function deleteExportData(dataId){
	var blnValue = confirm("Are you sure you want to delete the dataset?");
	if(blnValue == true) {
		URL = "home.do?Step=1&id=7&new=1";
		document.ddponline.requesttype.value		= "DELETE";
		document.ddponline.ExportDataId.value	= dataId;
		document.ddponline.method = "post";
		document.ddponline.action = URL;
		//Charset: Added by Atsushi 01-29-2009
		document.ddponline.charset = "UTF-8";
		document.ddponline.submit();
	}
}
 
function openHelp(ctx){
	temp = '/html-jsp/Help.jsp?project=DDPTimeSeries&amp;topic=Full&amp;language=1';
	win = window.open(''+ctx+''+temp,"Help",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=750,height=500');
	win.window.focus();
}

function routeToChartPage(ctxpath , reportName)
{
 var URL = ctxpath+'/html-jsp/viewNewChart.jsp?newReport=yes&IS_REPORT_SAVED=yes&SAVED_CHART_NAME='+reportName;	
 window.open(URL , 'Report');
 
}
  
 function routeToMapPage(ctxpath , reportName)
 {
 
  var URL = ctxpath+'/html-jsp/viewNewMap.jsp?newReport=yes&IS_REPORT_SAVED=yes&SAVED_MAP_NAME='+reportName;	
  window.open(URL , 'Report');
  
 }


function setSavedDatasetMessage(isDatasetSaved){

	obj = window.opener.saveDatasetMessage;
	if(isDatasetSaved =='true'){
		obj.innerHTML = "<i><b><font color='blue'>File saved to&nbsp;</font>\"<a href='javascript:mydatasetpage()'><font color='red'>My Datasets</font><a>\"</b></i>";
	}else{
		obj.innerHTML = "<font color='red'><b><i>Dataset name already exists.Please provide another name.</b></i></font>";
	}
	obj.style.display = '';
	self.close();
}
function emptyStyleErrorMsg(){
	if (document.getElementById('errorMsg') != null)
	document.getElementById('errorMsg').innerText = "";
}
function isPositiveInteger (s)
{   
	//s = parseInt(s);
	if (isNaN(s))
	{
		return false;
	} else {
		if (s <= 0)
			return false;
		else 
			return true;
	}
}
function isNotNegativeInteger (s)
{   
	s = parseInt(s);
	if (isNaN(s))
	{
		return false;
	} else {
		if (s < 0)
			return false;
		else 
			return true;
	}
}
function decToHex(dec) {
	var hexStr = "0123456789ABCDEF";
	var low = dec % 16;
	var high = (dec - low)/16;
	hex = "" + hexStr.charAt(high) + hexStr.charAt(low);
	return hex;
}
/*function colorPalette(context,tdId,objName)
{
	sFeatures = "dialogHeight=285px;dialogWidth=293px;help=no;status=no;modal=yes;"
	var colorHexValue = "";
	var colorCode = document.getElementById(objName).value;
	var rgb = colorCode.split(",");
	for( var i=1; i < rgb.length ; i++) {
		colorHexValue = colorHexValue + decToHex(rgb[i]);
	}
	colorHexValue = window.showModalDialog(context+'/html-jsp/ColorPalette.jsp',colorCode,sFeatures);
	document.getElementById(objName).value = colorHexValue;
	rgb = colorHexValue.split(",");
	colorHexValue = "#";
	for( var i=1; i < rgb.length ; i++) {
		colorHexValue = colorHexValue + decToHex(rgb[i]);
	}
	document.getElementById(tdId).setAttribute('bgColor',colorHexValue);
}*/
function colorPalette(context,colorCode,reportType)
{
	var sFeatures = "dialogHeight=282px;dialogWidth=214px;help=no;status=no;modal=yes;"
	var colorHexValue = window.showModalDialog(context+'/html-jsp/ColorPalette.jsp?ReportType='+reportType,colorCode,sFeatures);
	return colorHexValue;
}
function buildSharedReportURL(context,reportId,reqType)  {
	//alert("Context "+context+"\tID: "+reportId+"\tType "+reqType);
	var comprvalue = document.getElementById("CONSTANT_VAL").value;
	var xAxis = document.getElementById("XAXIS_VALUE").value;
	var varlength = comprvalue.length;
	comprvlaue = comprvalue.substring(varlength-1,varlength);
	var allPageAxisDimNames =  "";
	if (document.getElementById("PAGE_AXIS_UNIQUE_NAMES")) {
		allPageAxisDimNames =  document.getElementById("PAGE_AXIS_UNIQUE_NAMES").value;
	}
	var dimName = "";
	//alert(allPageAxisDimNames);
	var axisDimNameArray = allPageAxisDimNames.split("~");
	var selectedDimIndex = "";
	var selIndex;
	for ( var i= 0; i < axisDimNameArray.length ; i++ ){
		dimName =  axisDimNameArray[i];
		selIndex = 1+parseInt(document.getElementById("PAGE_AXIS_"+dimName).selectedIndex);
		if ( selectedDimIndex == "" ){
			selectedDimIndex = selIndex;
		} else {
			selectedDimIndex = selectedDimIndex+","+selIndex;
		}
	}
	sfeatures='toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=285,left=300,top=300';
	url = context+"/ShareReport?REPORT_ID="+reportId+"&REQUEST_TYPE="+reqType+"&SELECTED_DIMENSIONS="+selectedDimIndex+"&COMPARE_DIMENSION="+comprvlaue+"&X_AXIS="+xAxis;
	window.open(url , "ShareReport" ,sfeatures);
}
function editExportData(rptId,ctxPath){

	URL =ctxPath+ "/EditExportData?REPORT_ID="+rptId;
	document.forms["ddponline"].action = URL;
	//Charset: Added by Atsushi 01-29-2009
	document.forms["ddponline"].charset = "UTF-8";
	document.forms["ddponline"].submit();
}
function refreshExportData(rptId,ctxPath){
	URL = "home.do?Step=1&id=7";
	document.ddponline.requesttype.value		= "REFRESHDATASET";
	document.ddponline.ExportDataId.value	= rptId;
	document.ddponline.action = URL;
	//Charset: Added by Atsushi 01-29-2009
	document.ddponline.charset = "UTF-8";
	document.ddponline.submit();
}
function stringTrim (str) {
	return str.replace (/^\s+|\s+$/g,'');
}
var meta_data_display_win,other_meta_data_type_win;
function popupMetaData(srcPath,selId)
{
	var selVal =document.getElementById(selId).value
	var selObj=document.getElementById(selId);
    var StrSelectedVal = selObj.options[selObj.selectedIndex].value;
	var srcFile=srcPath+"/html-jsp/MetaDataDisplay.jsp?DIM_VAL="+StrSelectedVal;
	meta_data_display_win=window.open(srcFile,"meta_data_display","width=370,height=500");
}
//This is same as setMetadataMember function in viewnewReport.jsp
//This needs to be invoked from the viewNewReport page instead of having its own function
//row axis invokation also needs to be changed to invoke this method

var metadataWin;
var meta_data_flag_set;


function displayMetaDataforMembers(ctxpath,selIdx,rowVal,rowName)
{
	if( metadata_flag == false){
		showSourceNotes (ctxpath,rowVal);
	}
	else{
	
		var dimension_axis='';
		var index_ctr = 0;
		var selObj=document.getElementById(selIdx);
		if(selObj!=null){
			index_ctr = selObj.selectedIndex;
		}else{
			index_ctr = selIdx;
		}
		var reportType = null;
		
		if(document.getElementById('reportPageType') && document.getElementById('reportPageType') != 'undefined')
			reportType = document.getElementById('reportPageType').value;
		
		if(rowVal == null){
		    if(selObj!=null){
			    document.getElementById('selectedMembersUniqueName').value = selObj.options[selObj.selectedIndex].value;
			    document.getElementById('selectedMembersDispName').value = selObj.options[selObj.selectedIndex].text;
			if(reportType && reportType == 'VIEW_SAVE_REPORT'){
				document.getElementById('dimType').value = document.getElementById('pageDimType').value;
			}
			
			 }
	   }
	   else{
		   	if(reportType && reportType == 'VIEW_SAVE_REPORT')
			   document.getElementById('dimType').value = document.getElementById('rowDimType').value;
		   	document.getElementById('selectedMembersUniqueName').value = rowVal;
		 	document.getElementById('selectedMembersDispName').value = rowName;
		 	dimension_axis = 'ROW'
		 }
		 URL = ctxpath + "/viewSourceNotes?REQUEST_TYPE=7&DIMENSION_AXIS="+dimension_axis;
		//Ramvel 9thFeb_2009 ISSUE#10
		metadataWin = window.open('', "meta_data_display"+index_ctr, "width=1000,height=700,left=100px,top=100px");
		metadataWin.name = "METAdataWin"+index_ctr;
		//metadataWin.moveTo(100,0);
		document.metadataForm.method="POST";
		document.metadataForm.action = URL;
		//Ramvel 9thFeb_2009 ISSUE#10
		document.metadataForm.target = "METAdataWin"+index_ctr;
		document.metadataForm.submit();
	}
}