/*--------------------------------------------------------------------------------
'    Component   : CommonFunctions.js
'    Project     : Quest
'
'    Description : Functions used for Company detail display and Article detail display
'
'    Dependencies: --None--
'
'    Author      :  104644, HCL Technologies Ltd, Gurgaon, INDIA.
'
'    Date        :  14/06/2002, 12:38 PM
'
'    Modified    :	102209, HCL Technologies Ltd, Gurgaon, INDIA.
'	 Modified    :	By 104315 on 30/04/03 to implement CR 166.Change in function jfn_CommonArticle
'	 Modified    :	By 104304 on 011/05/04 to implement CR 492
'	 Modified	 :  104304, HCL Technologies Ltd, Gurgaon, INDIA. - 17-Apr-2004
'					Reason: CR 474 	
'	 Modified	 :  120407, HCL Technologies Ltd, Gurgaon, INDIA. - 18-July-2005
'	 Reason		 :	CR 683v2 : FireFox Support
'
'	 Modified	 :  120407, HCL Technologies Ltd, Gurgaon, INDIA. - 04-Aug-2005
'	 Reason		 :	Performance improvement using 'script' tag
'	 Modified by :  102021 Cr 330 for implementing Batch report and calling batch report function and in turn 
'                   this function will call jfn_common batch report function defined in common functions.js
'				    on 20th Sep 2005.
'    Modified	 :  126881, HCL Technologies Ltd, Gurgaon, INDIA. - 22-Sep-2006
'	 Reason		 :	CR 911- Modeller Webservice Access permission error msg const added.
'	 Modified    :	120407, HCL Technologies Ltd, Gurgaon, INDIA. - 19-Jan-2007
'    Reason		 :  CR 877 - Hypertext link feature for CS articles in the Quest Website
'	 Modified    :	151351, HCL Technologies Ltd, Gurgaon, INDIA. - 12-Feb-2007
'    Reason		 :  CR 1024v3 - Cascading of articles opened via quest website
'    Modified By :  135519 for CR 892v1 Uppercase QUEST to Quest 
'	 Modified    :	148816, HCL Technologies Ltd, Gurgaon, INDIA. - 7-Jul-2008
'    Reason		 :  Qstp5706 - to get the handle of the article opened
'   
'--------------------------------------------------------------------------------*/

var SEPARATOR_PIPE         = "|"	//Constant for pipe symbol				
var SEPARATOR_COMMA        = ","	//Constant for coma symbol	
var SEPARATOR_HASH		   = "#"	//Constant for hash symbol
var SEPARATOR_CARAT		   = "^"	//Constant for carot symbol

var SEPARATOR_PIPE_NC      = "|^~"	//Constant for pipe symbol				
var SEPARATOR_COMMA_NC     = ",^~"	//Constant for coma symbol	
var SEPARATOR_HASH_NC      = "#^~"	//Constant for hash symbol
var SEPARATOR_CARAT_NC	   = "^^~"	//Constant for carot symbol
var SEPARATOR_TILDE_NC     = "~|^"  //Constant for tilde symbol 

var SEPARATOR_PIPE_LEN     = 1		//Length Constant for pipe symbol				
var SEPARATOR_COMMA_LEN    = 1		//Length Constant for coma symbol	
var SEPARATOR_HASH_LEN	   = 1		//Length Constant for hash symbol
var SEPARATOR_CARAT_LEN	   = 1		//Length Constant for carot symbol

var SEPARATOR_PIPE_NC_LEN     = 3		//Length Constant for pipe symbol				
var SEPARATOR_COMMA_NC_LEN    = 3		//Length Constant for coma symbol	
var SEPARATOR_HASH_NC_LEN	  = 3		//Length Constant for hash symbol
var SEPARATOR_CARAT_NC_LEN	  = 3		//Length Constant for carot symbol

var DIS_SHOW			   = "SHOW"		//Constant for Display mode Show
var DIS_PRINT			   = "PRINT"	//Constant for Display mode Printer friendly version
var DIS_QPCARD			   = "QPCARD"	//Constant for Display mode in Quest Card
var DIS_QPPRINT			   = "QPPRINT"
var DIS_EXCEL			   = "E2E"		//Constant for Display mode Export to Excel 
var DIS_WEB_SERVICE		   = "WS"		//Web Service
var DIS_PDF				   = "PDF"		//PDF

var PATH_DISPLAY_MESSAGE   = "../../Code/CM/DisplayMessage.asp?MessageID="	//Constant for display message file
var strNOACCESS			   = "You do not have access rights to {0}. Please contact your Quest system administrator to gain access to {0}."

var winPleaseWaitHandle		// holds the window handle for Please wait dialog.

//Added by 120407 : Declaring and initialising global variables as an impact of including 
//this file in 'script' tag at application level.These variables will be set in the control panel files
//of all the functionalities, for eg.WelcomeControlPanel.asp
var gstrLoginStateCF = "";
var gstrSysUserIdCF = "";
var gstrFunctionCF = "";
var gstrEntityCF = "";
var gstrValidateCITNAccessCF = "";
var gstrValidateTriangleAccessCF = "";

// Added By 120407 for CR 877 - Hypertext link feature for CS articles in the Quest Website
// This variable is set in function jfn_setArticleOpener of Commonfunctions.js. 
// This is done because jfn_CommonArticle function of Commonfunctions.js
// needs to know from where it is called so that it can appropriately set the relative path of ArticleDisplay.asp
var gstrIsQuestCard = "" ;


//CR 330 
var mWinBatchReport;
// CR 330 WindowHandle for Batch Report Status Screen
var mWinBatchStatusReport; 
var MSGBRACCESS = "You do not have access rights to Batch Report. Please contact the Quest™ helpline on +44 (0) 207 523 8493 for assistance";
//Cr 330
//CR-911 -ModellerWS access permission
var MSGMWSACCESS = "You do not have access rights to Modeller Webservice. Please contact the Quest™ helpline on +44 (0) 207 523 8493 for assistance";
//CR-911 -ModellerWS access permission
/*--------------------------------------------------------------------------------
' Procedure  :       jfn_OpenStatusScreenWindow
' Description:       Function which opens Batch Report status Screen 
'
' Created by :       104644, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       11/06/2002, 05:50:00 PM
'
' Parameters :       argURL - Url for window
'				     argFeatures - Features 
'--------------------------------------------------------------------------------*/
function jfn_OpenStatusScreenWindow(argURL, argFeatures)
{		
	if (!mWinBatchStatusReport) 
	{
		mWinBatchStatusReport = window.open(argURL ,"StatusWindow" ,argFeatures);
		mWinBatchStatusReport.focus();
	}		
	else 
	{
		if (!mWinBatchStatusReport.closed)
		{
			mWinBatchStatusReport.focus();
		}	
		else
		{
			mWinBatchStatusReport = window.open(argURL,"StatusWindow",argFeatures);
		}	
	}
}

/*--------------------------------------------------------------------------------
' Procedure  :       jfn_ShowCompanyDetails
' Description:       Function which shows the details of the company selected
'
' Created by :       104644, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       11/06/2002, 05:50:00 PM
'
' Parameters :       argStrCompanyID    - Company ID
'					 argStrCompanyShortName - company short name
'					 argStrFunctionName - Function Name
'--------------------------------------------------------------------------------*/
function jfn_ShowCompanyDetails(argStrCompanyID, argStrCompanyShortName, argStrFunctionName)
{
	//If the user has not logged in do not perform any action
	//Modified By 120407 : Performance improvement using 'script' tag
	//if ('<%=Request("hdnLoginState")%>' == '0' || '<%=Request("hdnLoginState")%>' == '' ){
		
	if (gstrLoginStateCF == '0' || gstrLoginStateCF == '' ){
		alert("Please login into the Quest system to access this functionality.");
	}
	else{		
		/*Call the function jfn_ShowCompanyDetails which will set the values for 
		the variables in Navigation Controller.  If the function Name is received 
		blank it will set as SUMMARY else the received function name will be used*/
				
		// we need to update the ActivePool list also..
		window.parent.frames['fraTop'].jfn_AppendCompanyInActivePool(argStrCompanyID, argStrCompanyShortName)
		
		if (argStrFunctionName == "" || String(argStrFunctionName)=='undefined'){
			argStrFunctionName = "SUMMARY";			
		}
		window.parent.frames['fraTop'].document.frmTabChanged.hdnFunctionToShow.value = "QUEST_ANALYSIS"	
		
		window.parent.frames['fraTop'].jfn_ShowCompanyDetails(argStrCompanyID, argStrFunctionName);
		
	}
}

/*--------------------------------------------------------------------------------
' Procedure  :       jfn_ShowSectorDetails
'
' Description:       Function which shows the details of the sector selected.
'
' Created by :       181154, HCL Technologies Ltd, Gurgaon, INDIA.
'
' Reason	 :		 Created for CR-1280v1 - Quest Website Sector Analysis
'
' Date-Time  :       23/04/2009, 04:20:00 PM
'
' Parameters :       argStrSectorID			- Sector ID
'					 argStrSectorName		- Sector Name
'					 argStrFunctionName		- Function Name
'--------------------------------------------------------------------------------*/
function jfn_ShowSectorDetails(argStrSectorID, argStrSectorName, argStrFunctionName)
{
	// If the user has not logged in do not perform any action
	
	if (gstrLoginStateCF == '0' || gstrLoginStateCF == '' )
	{
		alert("Please login into the Quest system to access this functionality.");
	}
	else
	{	
		//  We need to update the ActivePool list also..
		window.parent.frames['fraTop'].jfn_AppendSectorInActivePool(argStrSectorID, argStrSectorName);
		
		if (argStrFunctionName == "" || String(argStrFunctionName)=='undefined')
		{
			argStrFunctionName = "SECTOR_SUMMARY";			
		}

		window.parent.frames['fraTop'].document.frmTabChanged.hdnFunctionToShow.value = "SECTOR ANALYSIS";
		//ADDED BY 189433 FOR CR1280V3
		if((argStrFunctionName == "SECTOR_MOMENTUM") || (argStrFunctionName == "SECTOR_MODELLER") || (argStrFunctionName == "SECTOR_COMMENTARY") || (argStrFunctionName == "SECTOR_SENSITIVITY"))
		{
			window.parent.frames['fraTop'].jfn_ShowSectorDetails(argStrSectorID, argStrSectorName, "SECTOR_SUMMARY");	
		}
		else
		{
			window.parent.frames['fraTop'].jfn_ShowSectorDetails(argStrSectorID, argStrSectorName, argStrFunctionName);		
		}
	}
}

/*--------------------------------------------------------------------------------
' Procedure  :       jfn_ShowCompanyDetails_Strategy
' Description:       Function which shows the details of the company selected
'
' Created by :       120387, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       30/07/2007
'
' Parameters :       argStrCompanyID    - Company ID
'					 argStrCompanyShortName - company short name
'					 argStrFunctionName - Function Name
'					 argDisplayOptions - Variable Controlling Display of Sector Averages and Supporting Data
'--------------------------------------------------------------------------------*/
function jfn_ShowCompanyDetails_Strategy(argStrCompanyID, argStrCompanyShortName, argStrFunctionName, argDisplayOptions)
{
	//If the user has not logged in do not perform any action
	//Modified By 120407 : Performance improvement using 'script' tag
	//if ('<%=Request("hdnLoginState")%>' == '0' || '<%=Request("hdnLoginState")%>' == '' ){
	if (gstrLoginStateCF == '0' || gstrLoginStateCF == '' ){
		alert("Please login into the Quest system to access this functionality.");
	}
	else{		
		/*Call the function jfn_ShowCompanyDetails which will set the values for 
		the variables in Navigation Controller.  If the function Name is received 
		blank it will set as SUMMARY else the received function name will be used*/
				
		// we need to update the ActivePool list also..
		window.parent.frames['fraTop'].jfn_AppendCompanyInActivePool(argStrCompanyID, argStrCompanyShortName)
		
		window.parent.frames['fraTop'].document.frmTabChanged.hdnFunctionToShow.value = "QUEST_ANALYSIS"		
		window.parent.frames['fraTop'].jfn_ShowCompanyDetails_Strategy(argStrCompanyID, argStrFunctionName, argDisplayOptions);
		
	}
}

	
	/*--------------------------------------------------------------------------------
	' Procedure  :       jfn_SetUrlNavigatorCall
	' Description:       Function which reset the URL Navigator Call variable.
	'
	' Created by :       Surendra 126881, HCL Technologies Ltd, Gurgaon, INDIA.
	' Date-Time  :       13/08/2007
	'
	'---------------------------------------------------------------------------------*/
	function jfn_SetUrlNavigatorCall(strValue)
	{			
		document.frmQAControlPanel.hdnUrlNavigatorCall.value = strValue;		
	}				

	/*--------------------------------------------------------------------------------
	' Procedure  : jfn_SetSAUrlNavigatorCall()
	'
	' Description: Function which reset the URL Navigator Call variable for SA.
	'
	' Reason	 : Created for CR-1280v1 - Quest Website Sector Analysis				
	'
	' Created by : Nimisha 181154, HCL Technologies Ltd, Gurgaon, INDIA.
	'
	' Date-Time  : 23/04/2009, 11:49 AM
	'---------------------------------------------------------------------------------*/
	function jfn_SetSAUrlNavigatorCall(strValue)
	{			
		document.frmSAControlPanel.hdnUrlNavigatorCall.value = strValue;		
	}
	
/*--------------------------------------------------------------------------------
' Procedure  :       jfn_UpdateUsageLog
' Description:       Function which logs an entry into the usage_log_for_cmpny_pgs table
'
' Created by :       151351, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       30/07/2007
'
' Parameters :       argUserID			- User Id
					 argStrCompanyID    - Company ID
'					 argStrFunctionName - Function Name
'					 argCallOfHit		- WEB or PDF 
'--------------------------------------------------------------------------------*/
function jfn_UpdateUsageLog(argUserID,argStrCompanyID,argStrFunctionName,argCallOfHit)
{
	//If the user has not logged in do not perform any action
	if ('<%=Request("hdnLoginState")%>' == '0' || '<%=Request("hdnLoginState")%>' == '' )
	{
		alert("Please login into the Quest system to access this functionality.");
	}
	else
	{
		/*Calls the function in the navigation controller with the required function name
		in order to make an entry in the log table*/
		window.parent.frames['fraTop'].jfn_UpdateUsageLog(argUserID,argStrCompanyID,argStrFunctionName,argCallOfHit);
	}
}

/*--------------------------------------------------------------------------------
' Procedure  :       jfn_UpdateUsageLogforSector
' Description:       Function which logs an entry into the usage_log_for_sector_pgs table
'
' Created by :       189433, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       17/11/2009
'
' Parameters :       argUserID			- User Id
					 argStrSectorID		- Sector ID
'					 argStrFunctionName - Function Name
'					 argCallOfHit		- WEB or PDF 
'--------------------------------------------------------------------------------*/
function jfn_UpdateUsageLogforSector(argUserID,argStrSectorID,argStrFunctionName,argCallOfHit)
{
	//If the user has not logged in do not perform any action
	if ('<%=Request("hdnLoginState")%>' == '0' || '<%=Request("hdnLoginState")%>' == '' )
	{
		alert("Please login into the Quest system to access this functionality.");
	}
	else
	{
		/*Calls the function in the navigation controller with the required function name
		in order to make an entry in the log table*/
		window.parent.frames['fraTop'].jfn_UpdateUsageLogforSector(argUserID,argStrSectorID,argStrFunctionName,argCallOfHit);
	}
}

/*--------------------------------------------------------------------------------
' Procedure   :       jfn_ShowArticleDetail
' Description :       The protected articles can be viewed only when the user has 
'					 logged in. The unprotected articles can be viewed without logging in
'
' Created by  :       104644, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time   :       11/06/2002, 05:35:00 PM
'
' Parameters  :       argStrArticleID - Article ID
'				  	  argIntIsProtected - Flag which checks whether the article 
'										 is protected or not
' Dependencies:		  The handle for the ArticleDisplay.asp should be declared as
'					  "mWinArticleDisplay", which will be used in the respective page
'					  level in the window_onunload event to close the existing 
'					  popup windows opened.  This variable should be declared 
'					  page level in the respective pages
'--------------------------------------------------------------------------------*/
function jfn_ShowArticleDetail(argStrArticleID, argStrArticleType, argIntIsProtected){
	
	var strArticleType
	
	strArticleType = new String(argStrArticleType)
	strArticleType = strArticleType.toUpperCase();
	
	if (argIntIsProtected == 1){
		//Modified By 120407 : Performance improvement using 'script' tag
		if (gstrLoginStateCF != '1'){
			alert("Please login into the Quest system to access this article.");
		}
		else{
			
			if (strArticleType.search("TRIANGLE") != -1) 
				strArticleType = "TRIANGLE"
				
			switch (strArticleType)
			{
				case "CITN":
					//Modified By 120407 : Performance improvement using 'script' tag
					if (gstrValidateCITNAccessCF != '0'){
						jfn_CommonArticle(argStrArticleID,strArticleType);															
						break;
					}
					else{
						//If the Article Type is CITN and the user doesn't have access skip from the function
						alert("Current settings do not allow access to CiTN articles.");
						break;
					}
					
				case "TRIANGLE":
					//Modified By 120407 : Performance improvement using 'script' tag
					if (gstrValidateTriangleAccessCF != '0'){				
						jfn_CommonArticle(argStrArticleID,strArticleType);
						break;
					}
					else{
						//If the Article Type is TRIANGLE and the user doesn't have access skip from the function
						alert("Current settings does not allow access to triAngle articles.");
						break;
					}
					
				default:
					//Normal articles for which the security check is maintained						
					//If the Article Display window is not available open a new instance of the window
					jfn_CommonArticle(argStrArticleID,strArticleType);
			}
		}
	}
	else{
		//Not a protected article
		//If the Article Display window is not available open a new instance of the window
		jfn_CommonArticle(argStrArticleID,"");
	}										
}

/*--------------------------------------------------------------------------------
' Procedure   :       jfn_CommonArticle
' Description :       The common code for the Article Display
'
' Created by  :       104644, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time   :       07/08/2002, 12:14:00 PM
'
' Parameters  :       argStrArticleID - Article ID
' Dependencies:		  Nil
' Modified	  :		  By 104315 on 30/04/03 to implement CR 166	 
' Modified By :		  151351 , HCL Technologies Ltd. , GGN, INDIA - On 19/01/2007
' Reason	  :		  CR 877v4 - All articles must open in a new blank window         	
' Modified By :		  120407 , HCL Technologies Ltd. , GGN, INDIA - On 19/01/2007
' Reason	  :		  CR 877v4 - CR 877 - Hypertext link feature for CS articles in the Quest Website
' Modified    :		  148816, HCL Technologies Ltd, Gurgaon, INDIA. - 7-Jul-2008
' Reason		 :  Qstp5706 - to get the handle of the article opened
'--------------------------------------------------------------------------------*/
function jfn_CommonArticle(argStrArticleID, argStrArticleType){

	if (gstrIsQuestCard == '1')
	{
		//Qstp5706---148816--below line commented
		//var strWindowOpenURL = "../Code/MC/ArticleDisplay.asp?ArticleID=" + argStrArticleID  + "&hdnRandom=" + Math.random(1);
		var strWindowOpenURL = "../Code/CM/Article_FrameSet.asp?ArticleID=" + argStrArticleID  + "&hdnRandom=" + Math.random(1);
		gstrIsQuestCard = "";
	}
	else
	{
		//Qstp5706---148816--below line commented
		//var strWindowOpenURL = "../../Code/MC/ArticleDisplay.asp?ArticleID=" + argStrArticleID  + "&hdnRandom=" + Math.random(1);
		var strWindowOpenURL = "../../Code/CM/Article_FrameSet.asp?ArticleID=" + argStrArticleID  + "&hdnRandom=" + Math.random(1);
	}
	
	//Modified By 151351 for CR 1024v3 - Starts
	//var strWindowOpenFeatures = "resizable=yes,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,height=200,width=500" + jfn_getPopupSizeParameters();
	//Qstp5706---148816--below line commented
	//CR-1166v3 (181154): START
	//The status bar is set to trye for CR-1166v3.
	var strWindowOpenFeatures = "resizable=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,height=" + (window.screen.availHeight - 195 - 70) + ",width=743" // + jfn_getPopupSizeParameters();
	//CR-1166v3 (181154): END
	//var strWindowOpenFeatures = "resizable=yes,status=no,toolbar=no,menubar=no,location=no,height= 515,width=760,top=100,left=137,directories=no,scrollbars=no";
	//Modified By 151351 for CR 1024v3 - Ends
	
	//Commented by 151351 for CR 877v4 - all articles to open in different windows - Starts
	/*var mWinArticleDisplay	//handle for window Article Display..added by 104315
	
	mWinArticleDisplay = window.parent.frames['fraTop'].mWinArticleDisplay	//getting the handle of article display window from top control panel	
	*/
	//Commented by 151351 for CR 877v4 - all articles to open in different windows - Ends
	
	//Used for Usage Data	
	var strEntity
	//Modified By 120407 : Performance improvement using 'script' tag
	var strSysUserID = gstrSysUserIdCF;
	var strFunction = gstrFunctionCF;
	var strIssueNumber 
	
	//Default value assignment
	strIssueNumber = "";
	
	if(argStrArticleType =='CITN')
	{
		strIssueNumber = (window.parent.frames['fraTop'].strIssueNumber);
	}
		
	if (strFunction == "QUEST_ANALYSIS"){
		/*
		if (mBlnIE){
			objForm = document.forms['frmQAControlPanel']
		}
		else{
			objForm = document.layers['divTop'].document.frmQAControlPanel
		}
		*/
		// CR 683v2 : FireFox Support
		objForm = document.frmQAControlPanel
		// CR 683v2 : FireFox Support
		strEntity = objForm.hdnCurrentEntity.value		
	}
	else{
		//Modified By 120407 : Performance improvement using 'script' tag
		strEntity = gstrEntityCF;
	}
	
	strWindowOpenURL = strWindowOpenURL + "&CurrentEntity=" + strEntity + "&ArticleType=" + argStrArticleType + "&SysUserID=" + strSysUserID + "&IssueNumber=" + strIssueNumber
	//Qstp5706---148816---"mWinArticleDisplay=" is added in the line below
	mWinArticleDisplay=window.open(strWindowOpenURL,"_blank",strWindowOpenFeatures);
	//Qstp5744---148816--starts
	var i;
	for (i=0; i<(window.parent.frames['fraTop'].arrWinArticleOpen.length); i++)
	{	
		//alert(window.parent.frames['fraTop'].arrWinArticleOpen[i]+ " " + window.parent.frames['fraTop'].arrArticles[i] );
		if (!window.parent.frames['fraTop'].arrWinArticleOpen[i])
		{	
			window.parent.frames['fraTop'].arrWinArticleOpen[i]=mWinArticleDisplay;
			window.parent.frames['fraTop'].arrArticles[i]=argStrArticleID;
			window.parent.frames['fraTop'].mWinArticleDisplay=mWinArticleDisplay;
			break;					
		}
		else
		{
			if ((window.parent.frames['fraTop'].arrWinArticleOpen[i]).closed==true)
			{
				window.parent.frames['fraTop'].arrWinArticleOpen[i]=mWinArticleDisplay;
				window.parent.frames['fraTop'].arrArticles[i]=argStrArticleID;
				window.parent.frames['fraTop'].mWinArticleDisplay=mWinArticleDisplay;
				break;
			}
		}
	}
	
	if (i==(window.parent.frames['fraTop'].arrWinArticleOpen.length))
	{
		window.parent.frames['fraTop'].arrWinArticleOpen[i]=mWinArticleDisplay;
		window.parent.frames['fraTop'].arrArticles[i]=argStrArticleID;
		window.parent.frames['fraTop'].mWinArticleDisplay=mWinArticleDisplay;
	}
	//window.parent.frames['fraTop'].mWinArticleDisplay=mWinArticleDisplay;
	//Qstp5744---148816--ends
	//Qstp5706---148816---"mWinArticleDisplay=" is added in the line below
	//window.parent.frames['fraTop'].mWinArticleDisplay=mWinArticleDisplay
	//Added by 151351 for CR 877v4 - opens article in a new blank window - Ends
}
/*--------------------------------------------------------------------------------
' Procedure  :       jfn_Trim
' Description:       Function which trims the string
'
' Created by :       ######, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       21/06/2002, 03:32:00 PM
'
' Parameters :       argItem - String to be trimmed
'--------------------------------------------------------------------------------*/
function jfn_Trim(argStr){
	var strText
	strText = argStr
	strText = this != window? this : strText;
	return strText.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


/*--------------------------------------------------------------------------------
' Procedure  :       jfn_ValidateEmail
' Description:       Validates the email id on the basis of common characteristics,
'						such as presence of @ sign and a dot (.) after that.
'
' Created by :       102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       09/07/2002, 03:32:00 PM
'
' Parameters :       strEmail - Email address, to be validated.
'--------------------------------------------------------------------------------*/
function jfn_ValidateEmail(strEmail) {

	var intAt = String(strEmail).indexOf("@")		// check for @ symbol..
	var intDot = String(strEmail).lastIndexOf('.')	// get last index of .
	var arrEmail = strEmail.split("@")
	
	if (intAt <=0)
		return false;								// if @ is at zero pos or not found.. then exit with false
	
	if (intDot <= 0 || intDot < intAt || intDot==String(strEmail).length-1 )
		return false;								// if dot is not found, or position of dot
													// is less than that of @, then exit with false
	
	if(arrEmail.length >2) //if the user enters more than one "@" in the email address
		return false;
		
	// all passed.. return true
	return true;
						
}


/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_Round
' Description:	   Function to Round of float numbers to specified digits
'
' Created by :	   105270, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   07/07/2002, 08:00:00 PM
'
' Parameters :	   
'--------------------------------------------------------------------------------*/
function jfn_Round(dblNumber, intNoofDigits)
{
	var intFactor
	
	intFactor = Math.pow(10, intNoofDigits)
	
	return (Math.round(dblNumber * intFactor )/intFactor)
}

/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_isBrowserIE
' Description:	   Function to check the browser
'
' Created by :	   104548, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   10/07/2002, 11:58:00 AM
'
' Parameters :	   
'--------------------------------------------------------------------------------*/
// CR 683v2 : FireFox Support
/*function jfn_isBrowserIE(){	
		
	var strBrowser;		
		
	strBrowser = navigator.appName.substring(0,1);
	if(strBrowser == 'N'){
		return false;			
	}
	else{
		return true;
	}		
}
*/
// CR 683v2 : FireFox Support

/*--------------------------------------------------------------------------------
' Function   :      jfn_LTrimZero
' Description:      clears leading 0's.
' Created by :      103171, HCL Technologies Ltd, Gurgaon, INDIA.
' Machine    :       
' Date-Time  :      24/06/2002- 11:30 AM
' Parameters :      
'--------------------------------------------------------------------------------*/
function jfn_LTrimZero(pitem){

	var strFinal
    strFinal = new String(pitem);
		
    if ((strFinal.indexOf("0") != -1) &&  (strFinal.length > 1))
    {
	       
        if (strFinal.indexOf("0") == 0)
        {
            strFinal = strFinal.substring(1,strFinal.length);
	            
            strFinal = jfn_LTrimZero(strFinal);
        }
    }
    return strFinal 
}

/*--------------------------------------------------------------------------------
' Procedure  :       fn_CheckNumeric()
' Description:       Function to check Whether passed parameter is numeric or not
'	
' Created by :       105270, HCL Technologies Ltd, Gurgaon, INDIA.
' Modified   :		   
' 
' Date-Time  :       29/06/2002, 11:30:00 AM
'
' Parameters :       pobjControl - Reference to Text Control
'					 pNumIntDigits - Number of Integral Digits
'					 pNumDecimalDigits - Number of Decimal Digits
' Modified On:	  
'     RETURNS:
'   True if valid, otherwise false.
'--------------------------------------------------------------------------------*/
function  fn_CheckNumeric(pobjControl, pNumIntDigits, pNumDecimalDigits){
	
	var txtValue
	var blnValidFormat 
	var strOutputString
	var strMinusSign
	var intReturnValue
	var DISPLAY_CHAR
	
	txtValue = ""
	blnValidFormat  = true
	strOutputString = ""
	strMinusSign = ""
	intReturnValue = 0.00
	DISPLAY_CHAR = "#"
	
	txtValue = pobjControl.value
	
	if ((txtValue.toString()).length > 0)
	{
		//Remove Spaces
		pobjControl.value = jfn_Trim(pobjControl.value)

		if(isNaN(txtValue))
		{
			 blnValidFormat = false
		}
		else
		{
			//102661 - 9/10/2003 - PVCS # 204
			txtValue = jfn_Round(parseFloat(jfn_LTrimZero(txtValue)), pNumDecimalDigits)
			txtValue = txtValue.toString()
			
			//Remove MINUS sign and Store in variable
			if(txtValue.indexOf("-") != -1)
			{
				if(txtValue.indexOf("-") == 0)
				{
					strMinusSign = "-"
					txtValue = txtValue.substr(1)
				}
				else
					blnValidFormat = false
			}
			//
			if(txtValue.indexOf(".")== -1)
			{
				
				intReturnValue = parseFloat(jfn_LTrimZero(txtValue))
				
				if((intReturnValue.toString()).length > pNumIntDigits)
				{
					blnValidFormat = false	
				}
			}
			else
			{
				//Obtain the integral part and check its length
				intReturnValue = parseFloat(jfn_LTrimZero(txtValue.split(".")[0]))

				if((intReturnValue.toString()).length > pNumIntDigits)
				{
					blnValidFormat = false
				}

				intReturnValue= parseFloat(txtValue)
			}
		}

		//if format is not valid then show error
		if (blnValidFormat == false)
		{
			//Insert A Space
			strOutputString = strOutputString + " "

			for (var iCnt =0; iCnt < pNumIntDigits; iCnt++)
				strOutputString = strOutputString + DISPLAY_CHAR
			
			if (pNumDecimalDigits > 0 )
			{
				strOutputString = strOutputString + "."
			}

			for (var iCnt =0; iCnt < pNumDecimalDigits; iCnt++)
				strOutputString = strOutputString + DISPLAY_CHAR

			alert("Please enter a numerical value of the format " + strOutputString)
			pobjControl.value = "";
			pobjControl.focus();
		}
		else
		{	
			if (!(isNaN(intReturnValue)))
			{
				strOutputString = strMinusSign + intReturnValue.toString();
			}

			if (strOutputString.length > 0 )
				//102661 - 9/10/2003 - PVCS # 204
				//pobjControl.value = jfn_Round(parseFloat(strOutputString), pNumDecimalDigits)
				pobjControl.value = parseFloat(strOutputString)
		}
	}
  return blnValidFormat;
}

/*--------------------------------------------------------------------------------
' Procedure  :       jfn_CheckNumericWithoutAlert()
' Description:       This function is similar to the function fn_CheckNumeric().It checks whether 
'					 value typed in textbox is numeric or not.However,it does not give any alert if the value 
'					 in the text box is not numeric.It simply returns false.
'	
' Created by :       120407, HCL Technologies Ltd, Gurgaon, INDIA.
' Reason	 :		 CR 683v2 : FireFox Support
' Modified   :		   
' 
' Date-Time  :       07/07/2005, 04:49:00 PM
'
' Parameters :       pobjControl - Reference to Text Control
'					 pNumIntDigits - Number of Integral Digits
'					 pNumDecimalDigits - Number of Decimal Digits
' Modified On:	  
'     RETURNS:
'   True if valid, otherwise false.
'--------------------------------------------------------------------------------*/
function  jfn_CheckNumericWithoutAlert(pobjControl, pNumIntDigits, pNumDecimalDigits){
	
	var txtValue
	var blnValidFormat 
	var strOutputString
	var strMinusSign
	var intReturnValue
	var DISPLAY_CHAR
	
	txtValue = ""
	blnValidFormat  = true
	strOutputString = ""
	strMinusSign = ""
	intReturnValue = 0.00
	DISPLAY_CHAR = "#"
	
	txtValue = pobjControl.value
	
	if ((txtValue.toString()).length > 0)
	{
		//Remove Spaces
		pobjControl.value = jfn_Trim(pobjControl.value)

		if(isNaN(txtValue))
		{
			 blnValidFormat = false
		}
		else
		{
			//102661 - 9/10/2003 - PVCS # 204
			txtValue = jfn_Round(parseFloat(jfn_LTrimZero(txtValue)), pNumDecimalDigits)
			txtValue = txtValue.toString()
			
			//Remove MINUS sign and Store in variable
			if(txtValue.indexOf("-") != -1)
			{
				if(txtValue.indexOf("-") == 0)
				{
					strMinusSign = "-"
					txtValue = txtValue.substr(1)
				}
				else
					blnValidFormat = false
			}
			//
			if(txtValue.indexOf(".")== -1)
			{
				
				intReturnValue = parseFloat(jfn_LTrimZero(txtValue))
				
				if((intReturnValue.toString()).length > pNumIntDigits)
				{
					blnValidFormat = false	
				}
			}
			else
			{
				//Obtain the integral part and check its length
				intReturnValue = parseFloat(jfn_LTrimZero(txtValue.split(".")[0]))

				if((intReturnValue.toString()).length > pNumIntDigits)
				{
					blnValidFormat = false
				}

				intReturnValue= parseFloat(txtValue)
			}
		}

		//if format is not valid then show error
		if (blnValidFormat == false)
		{
			/*
			//Insert A Space
			strOutputString = strOutputString + " "

			for (var iCnt =0; iCnt < pNumIntDigits; iCnt++)
				strOutputString = strOutputString + DISPLAY_CHAR
			
			if (pNumDecimalDigits > 0 )
			{
				strOutputString = strOutputString + "."
			}

			for (var iCnt =0; iCnt < pNumDecimalDigits; iCnt++)
				strOutputString = strOutputString + DISPLAY_CHAR

			//alert("Please enter a numerical value of the format " + strOutputString)
			//pobjControl.value = "";
			//pobjControl.focus();
			*/
			return blnValidFormat;
		}
		else
		{	
			if (!(isNaN(intReturnValue)))
			{
				strOutputString = strMinusSign + intReturnValue.toString();
			}

			if (strOutputString.length > 0 )
				//102661 - 9/10/2003 - PVCS # 204
				//pobjControl.value = jfn_Round(parseFloat(strOutputString), pNumDecimalDigits)
				pobjControl.value = parseFloat(strOutputString)
		}
	}
  return blnValidFormat;
}

/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_isScreenResolutionLow
' Description:	   Function to check screen resolution, and return true, if screen
'					resolution is 800*600
'
' Created by :	   102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   13-Aug-2002, 20:30
'
' Parameters :	   
'--------------------------------------------------------------------------------*/
function jfn_isScreenResolutionLow() {
	var intWidth = parseInt(window.screen.width, 10)
	
	if (intWidth < 1000)
		return true;
	else
		return false;
		
}

/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_getPopupSizeParameters
' Description:	   Returns the best fit parameters depending upon the screen resolution
'
' Created by :	   102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   13-Aug-2002, 20:35
'
' Parameters :	   
'--------------------------------------------------------------------------------*/
function jfn_getPopupSizeParameters() {
	var strReturn
	var intTop
	var intHeight
	
	// CR683v2 FireFox Changes 
	intTop		= (window.screen.height - window.screen.availHeight)*2 + 115
	intHeight	= window.screen.availHeight - intTop - 45 // 50 for status bar.and task bar
	
	
	if (jfn_isScreenResolutionLow()) {
		strReturn = 'left=130,width=660,top=' + String(intTop) + ',height=' + String(intHeight)
	} else {
		strReturn = 'left=200,width=660,top=' + String(intTop) + ',height=' + String(intHeight)
	}
	return strReturn
	
}

/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_accessCheck
' Description:	   Checks for the authentication on the client side, to prevent
'					any un-authorised access.
'
' Created by :	   102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   13-Aug-2002, 20:40
'
' Parameters :	   strFunctionName (String)
'--------------------------------------------------------------------------------*/
function jfn_accessCheck(strFunctionName) {
	var blnReturn = false
	var arrAccessArray = String(window.parent.frames['fraTop'].document.frmTabChanged.hdnAccessPermissions.value).split(SEPARATOR_PIPE_NC)
	var intLoop
	
	for(intLoop=0; intLoop < arrAccessArray.length; intLoop=intLoop+2) {
		if (strFunctionName==arrAccessArray[intLoop]) {
			return (String(arrAccessArray[intLoop + 1])=='1')
		}
	}
}



/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_DisplayCustomAlert
' Description:       Displays a custom alert message, by replacing the placeholders 
'					 with the passed values 
' Created by :       102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       16-Aug-2002 11:34
'
' Parameters :       strMessage (String)
'					 strParam (Pipe delimited String)
'--------------------------------------------------------------------------------*/
function jfn_DisplayCustomAlert(strMessage, strParam) {
	var strAlert = strMessage
	var arrParamList 
	var intLoop
	var strPlaceHolder
	
	arrParamList = strParam.split(SEPARATOR_PIPE_NC)
	
	for(intLoop=0; intLoop<arrParamList.length; intLoop++) {
		do {		
			strPlaceHolder = '{' +  eval(intLoop) + '}'
			strAlert = strAlert.replace(strPlaceHolder, arrParamList[intLoop])
		} while(strAlert.indexOf(strPlaceHolder) >= 0)
	}
	
	alert(strAlert)
	return;	
	
}
    
/*'--------------------------------------------------------------------------------
' Function   :       jfn_setFocusToContent()
' Description:	     Sets the focus to the content frame
' Created by :       103171, HCL Technologies Ltd, Gurgaon, INDIA.
' Machine    :       Quest Development Team - <103171>
' Date-Time  :       
' Parameters :       
'--------------------------------------------------------------------------------*/
function jfn_setFocusToContent()
{
	//setting the focus to the content area    	
	window.parent.frames['fraContent'].focus()  
}


/*'--------------------------------------------------------------------------------
' Function   :       jfn_showPrintSettingsDialog()
' Description:		 Displays the print settings popup
' Created by :       102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Parameters :       blnQPCard : pass any string/boolean value if being called from Articles/QPCard.
'--------------------------------------------------------------------------------*/
function jfn_showPrintSettingsDialog(blnQPCard)
{
		return true;
		
		/*
		if (jfn_isBrowserIE()) {
			var strOptions = "resizable=no,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,width=500," + jfn_getPopupSizeParameters() + ",width=500"
			if (String(blnQPCard)=='undefined')
				window.open("../../Code/CM/PrintMessage.asp", "_blank", strOptions)
			else
				window.open("../Code/CM/PrintMessage.asp", "_blank", strOptions)
		}
		*/
		//CR 683v2 : FireFox Support		
		var strOptions = "resizable=no,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,width=500," + jfn_getPopupSizeParameters() + ",width=500"
		if (String(blnQPCard)=='undefined')
			window.open("../../Code/CM/PrintMessage.asp", "_blank", strOptions)
		else
			window.open("../Code/CM/PrintMessage.asp", "_blank", strOptions)
}

/*'--------------------------------------------------------------------------------
' Function   :       jfn_showWaitMessage()
' Description:		 Displays the Please wait popup...
' Created by :       102209, HCL Technologies Ltd, Gurgaon, INDIA.
'--------------------------------------------------------------------------------*/
function jfn_showWaitMessage()
{
	var strOptions = "resizable=no,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,width=440,height=80,left=220,top=320"
	jfn_hideWaitMessage()
	winPleaseWaitHandle = window.open('../../Code/CM/PleaseWait.asp', "_blank", strOptions)
}

/*'--------------------------------------------------------------------------------
' Function   :       jfn_hideWaitMessage()
' Description:		 Hides the please wait dialog box.
' Created by :       102209, HCL Technologies Ltd, Gurgaon, INDIA.
'--------------------------------------------------------------------------------*/
function jfn_hideWaitMessage()
{
	if (winPleaseWaitHandle) 
		if (!winPleaseWaitHandle.closed)
			winPleaseWaitHandle.close()
}
/*---------New Function for CiTN EMail functionality-------*/
/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_CreateCookie
' Description:       This function Creates the Cookie as per the passed parameters.
' Created by :       104304, HCL Technologies Ltd, Gurgaon, INDIA. 
' Parameter	 :		 name,value,days		
' Date-Time  :       05/05/04 
'--------------------------------------------------------------------------------*/		
function jfn_CreateCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else
	{
		var expires = "";
	}
	document.cookie = name+"="+value+expires+";path=/";
}

/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_EraseCookie
' Description:       This function destroys the Cookie as per the passed parameters.
' Created by :       104304, HCL Technologies Ltd, Gurgaon, INDIA. 
' Parameter	 :		 name	
' Date-Time  :       05/05/04 
'--------------------------------------------------------------------------------*/
function jfn_EraseCookie(name)
{
	jfn_CreateCookie(name,"",-1);
}

/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_ReadCookie
' Description:       This function check the presence of the Cookie as per the passed parameters.
' Created by :       104304, HCL Technologies Ltd, Gurgaon, INDIA. 
' Parameter	 :		 ckieName	
' Date-Time  :       05/05/04 
'--------------------------------------------------------------------------------*/
function jfn_ReadCookie(ckieName)
{
	var nameEQ 
	var ca 
	var i
				
	nameEQ = ckieName + "=";
	ca = (document.cookie.split(';'));
				
	for(i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if(c.indexOf(nameEQ) == 0)
			  return c.substring(nameEQ.length,c.length);
	}
	return "0";
}
/*'--------------------------------------------------------------------------------
	' Procedure  :       jfn_RemoveHeader
	' Description:       function to remove the content header
	' Created by :       104315, HCL Technologies Ltd, Gurgaon, INDIA.
	' Modified   :		  
	' Date-Time  :       28/1/2004, 02:00:00 PM
	' Parameters :       
	'--------------------------------------------------------------------------------*/	
function jfn_RemoveHeader(){
	/*
	if(jfn_isBrowserIE())
	{
		header = window.parent.document.getElementById("Header")
		header.rows = "0,*"
	}
	*/
	//CR 683v2 : FireFox Support
	header = window.parent.document.getElementById("Header")
	header.rows = "0,*"
}
	/******************************************************************************
		Function   :       jfn_CommonBatchReport()
		Description:	   Calls the Batch Report screen.  
		Created by :       102021, HCL Technologies Ltd
		Date-Time  :       19th Sep 2005
		Parameters :       strCaller
		Remarks    :	   This function is called from QA and PR control panels it passess all required variables
						   and this will construct the url and will open the small window.
	*******************************************************************************/
		function jfn_CommonBatchReport(strCaller,strSystemUserId,strQuestGroupId,strIndexProvider,strPortfolioId, strTokenString)
		{
		
			var strWinFeatures;
			var strURL;
			
			strWinFeatures = "resizable=no,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=no," + jfn_getSmallPopupSizeParameters();			
			strURL = "../../Code/CM/ViewExistingBatchReport.asp?SystemUserID=" + strSystemUserId + "&QuestGroupID=" + strQuestGroupId + "&IndexProvider=" + strIndexProvider + "&Invoker=" + strCaller + "&PortFolioId=" + strPortfolioId + "&hdnTokenString=" + strTokenString ;
			
				
			if (!mWinBatchReport)
			{
				mWinBatchReport = window.open(strURL,"BatchReport",strWinFeatures);
			}
			else
			{
				if (!mWinBatchReport.closed)
				{
					mWinBatchReport.close();
					mWinBatchReport = window.open(strURL,"BatchReport",strWinFeatures);
							
					mWinBatchReport.focus();
				}
				else
				{
					mWinBatchReport = window.open(strURL,"BatchReport",strWinFeatures);
				}
			}	
		}
/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_getPopupSizeParameters
' Description:	   Returns the best fit parameters depending upon the screen resolution
'
' Created by :	   102209, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :	   13-Aug-2002, 20:35
'
' Parameters :	   
'--------------------------------------------------------------------------------*/
function jfn_getSmallPopupSizeParameters() {
	var strReturn
	var intTop
	var intHeight
	
	// CR683v2 FireFox Changes 
	intTop		= (window.screen.height - window.screen.availHeight)*2 + 115
	intHeight	= window.screen.availHeight - intTop - 45 // 50 for status bar.and task bar
	
	
	if (jfn_isScreenResolutionLow()) {
		strReturn = 'left=130,width=500,top=' + String(intTop) + ',height=200' //+ String(intHeight)
	} else {
		strReturn = 'left=200,width=500,top=' + String(intTop) + ',height=200' //+ String(intHeight)
	}
	return strReturn
	
}

/*--------------------------------------------------------------------------------
' Procedure  :	   jfn_setArticleOpener
' Description:	   Sets the page level variable 'gstrIsQuestCard'. On the basis of 
'				   its value, relative path of ArticleDisplay.asp is built in jfn_CommonArticle function
'
' Created by :	   120407, HCL Technologies Ltd, Gurgaon, INDIA.
' Date       :	   19-Jan-2007
'
' Parameters :	   argIsOpenerQuestCard - Whether opener of the link is Quest Card or not
'				   (If article link clicked from Quest Card --> Value = 1, else 0)
'--------------------------------------------------------------------------------*/
function jfn_setArticleOpener(argIsOpenerQuestCard){
	
	gstrIsQuestCard = argIsOpenerQuestCard;
}

/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_SearchScenarioIdFromList
' Description:       Function to linearly search given Scenario Id in the Scenario Array Ref. passed
' Created by :       151282, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       16/10/2007- 03:30 PM
' Reason	 :		 CR-1049v5
' Parameters :       arrScenarioList- Scenario Array Ref. (FORMAT: scenario-id SEPARATOR_CARAT_NC ...)
'					 intScenarioId	- Scenario Id to be searched in the list given
' Returns	 :		 -1 (if scenario-id not found), otherwise index position of match
'--------------------------------------------------------------------------------*/

function jfn_searchScenarioIdFromList(arrScenarioList, intScenarioId)
{
	var result = -1;
	
	for(var intCounter=0; intCounter < arrScenarioList.length; intCounter++)
	{
		if(intScenarioId == arrScenarioList[intCounter].split(SEPARATOR_CARAT_NC)[0])
		{
			result = intCounter;
			break;
		}
	}
	return result;
}

/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_ProcessedScenarioName
' Description:       Function to get the scenario name in the text box by separating it from id (if applicable)
' Created by :       151282, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       16/10/2007- 03:30 PM
' Reason	 :		 CR-1049v5
' Parameters :       strScenarioName- Scenario name in any form "testname - myinfo" or "testname - 1423"
'					 strScenarioType- possible values: [User/Admin/Article/""(default)]
' Returns	 :		 Processed scenario name without id
'--------------------------------------------------------------------------------*/

function jfn_processedScenarioName(strScenarioName, strScenarioType)
{
	var result = strScenarioName;	//initialize with the scenario name supplied
	var posOfSeparator;				//SEPARATOR USED: " - "
	
	switch((strScenarioType.toString()).toUpperCase())
	{
		case "ARTICLE":		//currently; ONLY article account scenarios are appended with scenario ids
			{
				posOfSeparator = strScenarioName.lastIndexOf(' - ');
				if(posOfSeparator != -1)
					result = strScenarioName.substring(0,posOfSeparator);
			}
			break;
		
		case "QP":			//no processing required!
		case "USER":		//no processing required!
		case "ADMIN":		//no processing required!
		default:
			break;
	}

	return result;
}

/*'--------------------------------------------------------------------------------
' Procedure  :       jfn_BreakItUp
' Description:       Function to split big ASP form variables for proper ASP POSTing
' Created by :       151282, HCL Technologies Ltd, Gurgaon, INDIA.
' Date-Time  :       28/02/2008- 06:30 PM
' Reason	 :		 QSTP-5613 (some fields of compareform were crossing the fixed size limit
'					 of 102399 bytes for single form variable in POST method of ASP)
' Parameters :       objForm- form object to process
'					 objFormField- hidden form field to process for size overflow
' Returns	 :		 nothing
'--------------------------------------------------------------------------------*/
function jfn_BreakItUp(objForm, objFormField)
{
	//Set the limit for field size. (REF: http://support.microsoft.com/kb/273482)
	var FormLimit = 102399;

	//Get the value of the large input object.
	var TempVar = new String;
	TempVar = objFormField.value;

	//If the length of the object is greater than the limit, break it
	//into multiple objects. (CODING-NOTE: done for all cases in general. So, if condition n/a)
	//if(TempVar.length>FormLimit)
	//{
	objFormField.value = TempVar.substr(0, FormLimit);
	TempVar = TempVar.substr(FormLimit);

	while(TempVar.length > 0)
	{
		//UTC
		//alert("TempVar.length = " + TempVar.length)
		var objINPUT = document.createElement("INPUT");
		objINPUT.name = objFormField.name;
		objINPUT.type = "hidden";
		objINPUT.value = TempVar.substr(0, FormLimit)
		objForm.appendChild(objINPUT)
		
		TempVar = TempVar.substr(FormLimit)
	}
	//}
}

/********************************************************************************************************
Function   :       jfn_setValues()
Description:       sets the values on-window load and check the ControlPanel Name for BACK Functionality
Created by :       189433, HCL Technologies Ltd, Gurgaon, INDIA.
Date-Time  :       19/08/2009- 11:30 AM
Parameters :       None
Reason	   :	   QSTP 6117
*********************************************************************************************************/
function jfn_setValues()
{
	// code for implementing back functionality
	
	var strControlPageName				=  "QUESTANALYSISCONTROLPANEL.ASP"
	var strURL					=  ""
	var blnMultipleFrames;
	blnMultipleFrames = true
	if (String(window.parent.frames["fraLeft"]) == 'undefined') 
	{
			blnMultipleFrames = false		
	}
	blnControlPanelMisMatch = false
	
	if(blnMultipleFrames==true)
	{
		strURL = new String(window.parent.frames['fraLeft'].location.href);
		// check whether the search control panel is loaded in fraLeft. If not call navigation controller's tabclick function
		strURL = strURL.toUpperCase()	
		if (strURL.indexOf(strControlPageName ) == -1 ){
			blnControlPanelMisMatch = true
			
			if (strURL.indexOf('TRIANGLECONTROLPANEL.ASP') == -1 )
			{				
				window.parent.frames['fraLeft'].window.history.back();				
				
			}
			else
			{				
				window.parent.frames['fraLeft'].window.history.go(-2);				
			}
			return 
		}
	}
}

/********************************************************************************************************
Function   :       jfn_setSectorValues()
Description:       sets the values on-window load and check the ControlPanel Name for BACK Functionality
Created by :       189433, HCL Technologies Ltd, Gurgaon, INDIA.
Date-Time  :       19/08/2009- 11:30 AM
Parameters :       None
Reason	   :	   QSTP 6117
*********************************************************************************************************/
function jfn_setSectorValues()
{
	// code for implementing back functionality
	
	var ControlPageName				=  "SECTORANALYSISCONTROLPANEL.ASP"
	var URL						=  ""
	var MultipleFrames;
	MultipleFrames = true
	if (String(window.parent.frames["fraLeft"]) == 'undefined') 
	{
			MultipleFrames = false		
	}
	blnControlPanelMisMatch_SA = false
	
	if(MultipleFrames==true)
	{
		URL = new String(window.parent.frames['fraLeft'].location.href);
		// check whether the search control panel is loaded in fraLeft. If not call navigation controller's tabclick function
		URL = URL.toUpperCase()	
		if (URL.indexOf(ControlPageName ) == -1 ){
			blnControlPanelMisMatch_SA = true			
			
			if (URL.indexOf('TRIANGLECONTROLPANEL.ASP') == -1 )
			{				
				window.parent.frames['fraLeft'].window.history.back();				
				
			}
			else
			{				
				window.parent.frames['fraLeft'].window.history.go(-2);				
			}			 
			return 
		}
	}
}

		