//13-Oct-2004	V1.8			Selvakumar		SE131004 : Added condition to handle hidden controls(checkbox)
//14-Oct-2004	V1.8			Dhanaraja		DHAN141004 : Added the title for ftconfirm message box
//14-Oct-2004	V1.8			Vimal			Vimal14Oct2004: Bug ID 118 fixed. Allowed negation symbol in numeric text box 
//15-Oct-2004	V1.8			Dhanaraja		DHAN15OCT04: Usability - written function for date,time,datetime,lookup for poping up on press of F2
//22-Nov-2004	V1.8			Dhanaraja		DHAN22NOV04: Usability - delete button is not allowed for date related controls
//17-Dec-2004	V1.8			Sundar			YSK17NOV2004: new date format handled 
//17-Dec-2004	V1.8			Dhanasekar		FTMESSAGEBOXRPT function added  for crystal report tool
//28-Dec-2004	V1.8			Sundar			YSK24DEC2004: multi date format functions added - vMultiLookupShortKey,vMultiDateShortKey,vMultiDateTimeShortKey
//05-Jan-2005	V1.8			S.Sathish		SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes, so delete validations are commented in the following functions (VDateShortKey,VMultiDateShortKey,VTimeShortKey,VDateTimeShortKey,VMultiDateTimeShortKey)
//06-Jan-2005	V1.8			S.Sathish		SSK06JAN2005: focus should not take place for controls of type checkbox: so the following condition added : "&& (document.all[i].type != "checkbox")" to the below IF condition.
//07-Jan-2005	V1.8			S.Sathish		SSK07JAN2005: Added Special character replacing functions: Delimiters declaration, sEscape
//03-Feb-2005	V1.8			Sakthi		GS03FEB2005 : vAttach() and vViewAttachOne() function included
//03-Feb-2005	V1.8			Sakthi		GS03FEB2005_02 : "locallhost" changet to "window.location.hostname "
//10-Feb-2005       V1.8			Sakthi 		GS10022005 - If the sReturn is null assgin null to hidden field
//17-Feb-2005	V1.8			Sakthi		GS17022005 - In vAttachment - showModalDialog higth and width incresed (150,470)
//17-Feb-2005	V1.8			Sundar		YSK17FEB2005: vCalculateDate function handled for hidden attributes
//18-Mar-2005	V1.8			S.Sathish		SSK17MAR2005: Handled Lookup Validation, Added a function vCheckOnKeyPress(): to check whether the F2 key is pressed or not
//28-Mar-2005   V2.0			J.Ilango		JI28MAR2005: The keycode is now set to zero previously, thereby eradicating the run time error(BUGID: 120) when user presses "." for the second time.
//07-Apr-2005   V2.0			V.Balakrishnan	BALA07082005: if F2 is pressed load the lookup window or if lookup is pressed load the lookup window.
//08-Apr-2005	V2.0			Sakthi		GS08APR2005: FTMessageBoxRPT20 newly added for OpsSmart 2.0 Crystal report Rols/permission implement. This function used in OpsSmart root foledr CRPT_Descview.asp
//11-APR-2005	V2.0			Babu		NB110405: On selecting / De-selecting the Checkboxes in the Body, The Header Check box is Checked / UnChecked.
//19-Apr-2005	V2.0			Shankar.S	SS19Apr05 Commented as Attached file  will have Actual File name  Hence SFldName is enough nAttrId and nDOID is not required Begin
								//function vViewAttachOne(sFldName,nAttrId,nDOID) modified to accept only one argument function vViewAttachOne(sFldName)		
//27-APR-2005	V2.0			S.Sathish		SSK27APRIL2005: BugID: 160: Added New delimiter 'sMultiValueLookupDelimiter(+)' for Multi Value Lookup
//																BugId: 170: In the function vMultiSetlookupval(): Added the following condition '&& (stemp.value).indexOf('+')== -1' in the function; Reason: To skip lookupvalidation if lookup attribtue value has '+' delimiter
//03-May-2005	V2.0			Vimal			Vimal03May2005 - Added code to handle the issue of not allowing quotes and pipe symbols, and ampersand
//04-May-2005	V2.0			Ilango			JI04MAY2005: Added the keycodes for #,%,\,/ keys to the disallowed strings list.
//05-May-2005	V2.0			Vimal			Vimal05May2005: Released "/" for keying
//07-Jun-2005	V2.0			Vijayaraghavan	VJ070605: Commented the line in FTMEssageBox and modified it by removing "&message="+sMessage in the next line. Fix for Bug Id 178.
//30-Aug-2005	V2.0			A.Shankar		SHAH300805;The function vCalculateDate() will be not called if its called from EDE Application.A param is included
//04-NOV-2005	V2.0			Hema			HK04NOV2005 :- ATTACHMENT FUNCTION
//04-NOV-2005	V2.0			Hema			HK04NOV2005 :- Dont delete the attachment physically from the DB when clicked on delete
//14-Nov-2005	V2.0			A.Shankar		SHAH141105;Extra parameter added to handle the issue in Session while viewing the Attachments
//25-Nov-2005	V2.1			Hema			HK25NOV2005 :- Commented the function vAttach because the function is no more used . The page scattach.asp does not have any dependency according to dependency matrix
//09-DEC-2005	V2.1			Sundar			YSK08DEC2005 :- outfill attribute list paramters added
//06-Jan-2006	V2.1			Vimal			Vimal06Jan2006: Restricted ^ and ~ symbol for keying 
//11-Apr-2006	V2.1			Balakrishnan	BALA11042006 opened up "/" and "%"
//20-Apr-2006	V2.1			N BABU			NB20042006 : BUG ID 289 fixed. The message Box made scrollable in case of the message length is more
//24-Apr-2006	V2.1			N BABU			NB24042006 : if the confirm box is closed then NO is returned as default to avoid deletion
//02-May-2006	V2.1			Balakrishnan	BALA02052006 : opened up & in practivity.asp
//16-Oct-2006	V2.1			Vishal			VISH161006: Updates made for lookups in trace search.
//11-May-2007	V2.1			A.Shankar		SHAH110507:The issue  "Double click on the eyeicon for viewing Lookup" fixed with comments "VISH161006" was commented and a new solution has to be found for fixing that issue.

//var AttrId = nAttrid;
//SSK07JAN2005: Delimiters declaration
var sRowDelimit = '' //Chr(4) ~
var sColDelimit = '' //Chr(5) |
var sItemDelimit = '' //Chr(6) ^
var sDelimit1 = '' //Chr(3) '
var sDelimit2 = '' //Chr(7) #
var sMultiValueLookupDelimiter = "+" //SSK27APRIL2005: BugID 160 Added New delimiter for Multi Value Lookup
var msonKeydown //SSK17MAR2005


//Vimal03May2005 - Added code to handle the issue of not allowing quotes and pipe symbols, and ampersand
document.onkeypress = vCheckKeycode

// 34 - double quotes
// 39 - single quotes
// 124 - pipe
// 38 - Ampersand
// 35 - Hash
// 37 - Percentage
// 92 - Forward Slash(\)
// 47 - Backward Slash (/)
// 94 - Cap (^)
// 126 - Tilde (~)

function vCheckKeycode(e) 
{
   var keycode;
    keycode = window.event.keyCode;
    //JI04MAY2005: Added the keycodes for #,%,\,/ keys to the disallowed strings list.
    //Vimal05May2005: Released "/" for keying
    //Vimal06Jan2006: Restricted ^, ~ as they are used for Multi value section string
    //if(keycode == 34 || keycode == 39 || keycode == 124 || keycode == 38|| keycode == 35|| keycode == 37|| keycode == 92|| keycode == 94|| keycode == 126)
    //BALA11042006 opened up "/" and "%"
    //if(keycode == 34 || keycode == 39 || keycode == 124 || keycode == 38|| keycode == 35|| keycode == 94|| keycode == 126|| keycode == 92)
    //BALA02052006 : opened up & in practivity.asp
    if(keycode == 34 || keycode == 39 || keycode == 124 || keycode == 35|| keycode == 94|| keycode == 126|| keycode == 92)
    {
      window.event.keyCode = 0;
      return;
    } 
}

//SSK07JAN2005
function sEscape(sData)
{
return escape(sData)
}


function dtModalCalendar(sPath,oTxt,hTxt,sTxt)
{
	var oWinModCal=showModalDialog(sPath+"/library/calendar.asp",document.all(oTxt).value,"dialogHeight: 276px; dialogWidth: 200px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: no; title : no");
	
	if (oWinModCal!=undefined)
	{
		//start date should be greater than or equal to stage start date if exists
		/*if (oWinModCal!="" && document.frmStage.txtStartDate.value!="")
			if (bcmpDate(document.frmStage.txtStartDate.value,oWinModCal))
			{
				FTMessageBox('','','INFO','<BR><%=moDictTL("Date should be greater than or equal to activity start date")%>');
				return;
			}*/
		//if (document.all('hf'+oTxt))
		//	if (document.all('hf'+oTxt).value == 'Sowing date' && oWinModCal[0] == '')
		//		return;
		if ((oTxt == 'htxtEndDate') && (oWinModCal[0] == ''))
			return;
		if ((oTxt == 'htxtEHDate') && (oWinModCal[0] == ''))
			return;

		if (hTxt=="")
		{	
			
			if (oWinModCal[0] != "" && oWinModCal[1]!="")
			{
				
				document.all[sTxt].value=oWinModCal[1];
				document.all['ht'+sTxt].value=oWinModCal[0];
				
			}
			else
			{
				
				document.all[oTxt].value="";
				document.all['ht'+sTxt].value="";
			
			}
		}
		else
		{			
			document.all[oTxt].value=oWinModCal[0];
			document.all[hTxt].value=oWinModCal[1];
			
		}
		
	}
}
function GetWindowLocation(nWidth, nHeight)
{
	var nLeft;
	var nTop;
	var sWinLocation = "";
	
	nLeft = parseInt((screen.width - nWidth) / 2);
	nTop = parseInt((screen.height - nHeight) / 2);
	sWinLocation = "width=" + nWidth + ",height=" + nHeight + ",left=" + nLeft + ",top=" + nTop
	return sWinLocation;
}
function trim(sStr)
{
	 //return sStr.replace(/^\s+|\s+$/g, "") ;
	var nCount;
	var newText;
	newText="";
	//HK16SEP04
	if(sStr == undefined)
	{
		sStr = "";
		return sStr;
	}
	for(nCount=sStr.length;nCount>0;nCount--)
		if(sStr.charAt(nCount-1)==" ")	newText= "";
		else {
			newText=sStr.substring(0,nCount);
			break;
		}
	sStr=newText;
	newText=""
	for(nCount=0;nCount<=sStr.length-1;nCount++)
		if(sStr.charAt(nCount)==" ") newText= "";
		else {
			newText=sStr.substring(nCount,sStr.length);
			break;
		}
	return newText;
}
function MM_swapImgRestore() 
{ //v3.0
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
	x.src=x.oSrc;
}

function MM_preloadImages() 
{ 
//v3.0
  var d=document; 
  if(d.images)
  { 
	if(!d.MM_p) 
		d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
  for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0)
    {
		 d.MM_p[j]=new Image; 
		 d.MM_p[j++].src=a[i];
	}
  }
}
function MM_findObj(n, d) 
{ //v4.0
  var p,i,x;  
  if(!d) 
	d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
	    d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
    if(!(x=d[n])&&d.all) x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
    if(!x && document.getElementById) 
        x=document.getElementById(n); 
  return x;
}
function MM_swapImage() 
{ //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; 
   document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
   {
	 document.MM_sr[j++]=x; 
	 if(!x.oSrc) 
	    x.oSrc=x.src; 
	 x.src=a[i+2];
   }
}
function lkpImage(sImgPath, sImgStatus)
{
var oImage;
var nInt;
oImage = event.srcElement; 

nInt = (sImgPath.length) -1

if (sImgPath.substr(nInt,1) != "/")
	sImgPath = sImgPath + "/";

if (sImgStatus == "O")
	sImgPath = sImgPath + "eye_open.gif";
else
	sImgPath = sImgPath + "eye_close.gif";

oImage.src = sImgPath;
}
function vDelete(frm,txt,sLkup,div)
{
var iLength = 0;
var j = 0;
var sObjname = "";
var sRowName = "";
var sVal = "";
var sTemp = "";
var sTempVal = "";
var asTemp;
var nInt = 0;
var nX = 0;
var sValStr = "";
var nChkNo = 0;
var asSelVal;
var sObjIdentity = "";
var sTblId = "";
var nRowIndex = 0;
var nCount = 0;
var naRow = new Array();
var sValueDelimit = "" ;			//chr(6)
var sTempRow = "";

sTempRow = "tr" +  sLkup;
sTblId = "tbl" + sLkup ;
iLength = document.all(frm).elements.length;

	for (var j = 0; j<iLength;j++)
	{
		sObjname=document.all(frm).elements[j].name;
		
		//alert((sObjname.substring(0,9)).toUpperCase());
		//alert(sLkup);
		if (((sObjname.substring(0,9)).toUpperCase() == "CHKDELBOX")  && (sObjname.indexOf(sLkup) >= 0))
		{
			
			sVal = document.all(sObjname).value;
			sVal = sVal.toString();
			sRowName = "row" + sLkup.toUpperCase() + sVal;
			
			if (window.document.all(sRowName).style.display == "")
			{
				nChkNo = nChkNo + 1;
			}
			if (document.all(sObjname).checked == true)
			{
				window.document.all(sObjname).checked = false;
				//window.document.all(sRowName).style.display = "none";
				nRowIndex = window.document.all(sRowName).sectionRowIndex;
				naRow.length = nCount;
				naRow[nCount] = sRowName;
				nCount = nCount + 1;
				
				if (sValStr != "") sValStr = sValStr + sValueDelimit;
				sValStr = sValStr + nChkNo.toString() ;
			}
		}
		
	}
	
	nCount = 0;
	for(nCount=0;nCount<naRow.length;nCount++)
	{
		var nRowIndex = 0;
		var sRowName = "";
		//alert(naRow[nCount]);
		sRowName = naRow[nCount];
		nRowIndex = window.document.all(sRowName).sectionRowIndex;
		window.document.all(sTblId).deleteRow(nRowIndex);
		
	}
	if (sValStr != "")
	{
		sTemp = window.document.all(txt).value;
		if ((sTemp.indexOf(sValueDelimit)) >= 0)
			{
						asTemp = sTemp.split(sValueDelimit);
						//alert(asTemp.length);
			}
		else
			{
				var asTemp = new Array(1);
				asTemp[0] = sTemp;
			}
		if ((sValStr.indexOf(sValueDelimit)) >= 0)
			{
				asSelVal = sValStr.split(sValueDelimit);
				for(nInt=0;nInt<asSelVal.length;nInt++)
				{
					nX = eval(asSelVal[nInt]) - 1;
					asTemp[nX] = ""
				}
			}
		else
			{
				var asSelVal = new Array(1);
				asSelVal[0] = sValStr ;
				for(nInt=0;nInt<asSelVal.length;nInt++)
				{
					nX = eval(asSelVal[nInt]) - 1;
					asTemp[nX] = ""
				}
			}
	}
	else
	{
		//alert("Atlease one item should be selected");
		FTMessageBox('','','INFO','<BR>Atlease one item should be selected')
		return;
	}	
	nInt = 0;
	for(nInt=0;nInt<asTemp.length;nInt++)
	{
		if ((sTempVal != "") && (asTemp[nInt] != "")) sTempVal = sTempVal + sValueDelimit;
		sTempVal = sTempVal + asTemp[nInt];
	}
	
	window.document.all(txt).value = sTempVal;
	
	//alert(window.document.all(sTempRow));
	//alert(sTempRow);
	if (sTempVal == "")
	{
		//alert(sTempRow);
		//alert(div);
		sTempVal = "<table class=tableformmulti cellspacing=0 cellpadding=0 width=100%  border=0>";
		sTempVal = sTempVal + "<tbody>";
		sTempVal = sTempVal + "<tr class='cellformheader'>" + window.document.all(sTempRow).innerHTML + "</tr>";
		sTempVal = sTempVal + "<tr><td class='cellformwhite' width='5%'><td class=cellformwhite width='40%' >&nbsp;</td>";
		sTempVal = sTempVal + "<td class=cellformwhite></td>" ;
		sTempVal = sTempVal + "</tr></tbody></table>";
		window.document.all(div).innerHTML = sTempVal ;
	}
}

function ModalCalendar(oTxt)
{
	oWinModCal=showModalDialog("../library/datetimecal.asp?time=N",document.all(oTxt).value,"dialogHeight: 276px; dialogWidth: 200px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: no; title : no");
	if (oWinModCal!=undefined)
	{
		document.all[oTxt].value=oWinModCal[0];
		if (document.all['ht'+oTxt])
			document.all['ht'+oTxt].value=oWinModCal[1];
	}	
}
function FTDateTimeCalendar(oTxt,sTime,hTxt,sTxt,bCalculate)
{

	oWinModCal=showModalDialog("../library/datetimecal.asp?time="+sTime,document.all(sTxt).value,"dialogHeight: 276px; dialogWidth: 200px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: no; title : no");
	if (oWinModCal!=undefined)
	{
		if (hTxt=="")
		{
			if ((oWinModCal[0] != "" && oWinModCal[0]!=undefined) && (oWinModCal[1]!="" && oWinModCal[1]!= undefined))
			{
				document.all[oTxt].value=oWinModCal[1]  + ' ' + oWinModCal[2];
				document.all[sTxt].value=oWinModCal[0]+ ' ' + oWinModCal[2];
//********************************************************************************************************************************
// Date				Name			Reason
//02-Jul-2004		A.Shankar		Modifications made for calculating time Range and filling the value in the result Attribute 
//********************************************************************************************************************************
				//SHAH300805;The function vCalculateDate() will be not called if its called from EDE Application
				if ((bCalculate) || (bCalculate == undefined))
				{
					vCalculateDate();
				}
				//vCalculateDate();
			}
			else
			{
				document.all[oTxt].value="";
				document.all[sTxt].value="";			
				//SHAH300805;The function vCalculateDate() will be not called if its called from EDE Application
				if ((bCalculate) || (bCalculate == undefined))
				{
					vCalculateDate();
				}			
			//	vCalculateDate();				
			}
		}
		else
		{			
			document.all[oTxt].value=oWinModCal[0];
			document.all[hTxt].value=oWinModCal[1];
//********************************************************************************************************************************
// Date				Name			Reason
//02-Jul-2004		A.Shankar		Modifications made for calculating time Range and filling the value in the result Attribute 
//********************************************************************************************************************************
			vCalculateDate();
		}
		
	}	
}

function FTMessageBox(sToken,sPosition,sType,sMessage,sTitle)
{

	var iCount;
	var iInt;
	var iWinHeight;
	var iWinWidth;
	var sLength;
	var nCount;
	var nLines;
	var sBR;
	var sURL;
	if (sMessage==undefined)
		return;
	sLength=sMessage.length;
	iCount=sMessage.split("<BR>");

	//iWinHeight=Math.ceil(parseFloat(sLength / 36));
	//iWinHeight=parseInt(15 * iCount.length + 70);
	iWinHeight=parseInt(13.4 * iCount.length + 61);
	if (iWinHeight<=134)
	{
		iWinHeight=135;
		sURL="../library/ftalert.asp?tokenno="+sToken+"&position="+sPosition+"&type="+sType+"&title="+sTitle
		oWinModalAlert=showModalDialog(sURL,sMessage,"dialogHeight: "+ iWinHeight + "px; dialogWidth: 360px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: No;");
	}
	else
	{
		sURL="../library/ftalert.asp?tokenno="+sToken+"&position="+sPosition+"&type="+sType+"&title="+sTitle
		oWinModalAlert=showModalDialog(sURL,sMessage,"dialogHeight: "+ iWinHeight + "px; dialogWidth: 360px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: YES;");
	}

	
	
	
}

function FTMessageBoxRPT(sToken,sPosition,sType,sMessage)
{
	var iCount;
	var iInt;
	var iWinHeight;
	var iWinWidth;
	var sLength;
	var nCount;
	var nLines;
	var sBR;
	var sURL;
	if (sMessage==undefined)
		return;
	sLength=sMessage.length;
	iCount=sMessage.split("<BR>");
	//iWinHeight=Math.ceil(parseFloat(sLength / 36));
	//iWinHeight=parseInt(15 * iCount.length + 70);
	iWinHeight=parseInt(13.4 * iCount.length + 61);
	if (iWinHeight<=134)
		iWinHeight=135;
	sURL="../CRPT_DESCVIEW/CRPT_ftalert.asp?tokenno="+sToken+"&position="+sPosition+"&type="+sType+"&message="+sMessage
	oWinModalAlert=showModalDialog(sURL,sMessage,"dialogHeight: "+ iWinHeight + "px ; dialogWidth: 360px; edge: Raised; 			center: Yes; help: no; resizable: no; status: no; scroll: no;");
}

function FTMessageBoxRPT20(sToken,sPosition,sType,sMessage)
{
	var iCount;
	var iInt;
	var iWinHeight;
	var iWinWidth;
	var sLength;
	var nCount;
	var nLines;
	var sBR;
	var sURL;
	if (sMessage==undefined)
		return;
	sLength=sMessage.length;
	iCount=sMessage.split("<BR>");
	//iWinHeight=Math.ceil(parseFloat(sLength / 36));
	//iWinHeight=parseInt(15 * iCount.length + 70);
	iWinHeight=parseInt(13.4 * iCount.length + 61);
	if (iWinHeight<=134)
		iWinHeight=135;
	sURL="../CrystalReport/CRPT_DESCVIEW/CRPT_ftalert.asp?tokenno="+sToken+"&position="+sPosition+"&type="+sType+"&message="+sMessage
	oWinModalAlert=showModalDialog(sURL,sMessage,"dialogHeight: "+ iWinHeight + "px ; dialogWidth: 360px; edge: Raised; 			center: Yes; help: no; resizable: no; status: no; scroll: no;");
}

function FTConfirmBox(sToken,sPosition,sMessage,sButtonType,sTitle)
{
	//DHAN141004 : Added the title sTitle - for ftconfirm message box
	var iCount;
	var iWinHeight;
	var iWinWidth;
	var sLength;
	var nCount;
	var sBR;
	var sURL;
	if (sMessage==undefined)
		return;
	sLength=sMessage.length;
	iCount=sMessage.split("<BR>");
	//iWinHeight=Math.ceil(parseFloat(sLength / 36));
	iWinHeight=parseInt(15 * iCount.length + 70);
	if (iWinHeight<=124)
		iWinHeight=125;
	//DHAN141004 : Added the title for ftconfirm message box - added to the querystring
	sURL="../library/ftconfirm.asp?tokenno="+sToken+"&position="+sPosition+"&message="+sMessage+"&buttontype="+sButtonType+"&title="+sTitle
	var oWinModalConfirm=showModalDialog(sURL,sMessage,"dialogHeight: "+ iWinHeight + "px ; dialogWidth: 360px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: no;");
	// NB24042006 : if the confirm box is closed then NO is returned as default to avoid deletion
	if (oWinModalConfirm == undefined) oWinModalConfirm="NO";
	return oWinModalConfirm;
}
function vQLPopulate(sStr,bFlag)
{
	var sDelimit1 = "";  // chr(5)
	var sDelimit2 = "";  // chr(7)
	var sDelimit3 = "";   // chr(6)
	
	var nIndex = 0;
	var astemp = new Array();
	sStr = trim(sStr);
	//alert(sStr);
	if ((sStr == "undefined") || (sStr == "") || (sStr.indexOf(sDelimit1) < 0))
	{
		return;
	}
	
	
	if (sStr.indexOf(sDelimit2) > 0)
	{
		var asVal = new Array();
		asVal = sStr.split(sDelimit2);	
	}
	else
	{
		var asVal = new Array(1);
		asVal[0] = sStr;
	}
	
	for (nIndex=0;nIndex<asVal.length;nIndex++)
	{
		//alert((asVal[nIndex].indexOf(sDelimit1)));
		if ((asVal[nIndex].indexOf(sDelimit1)) >= 0)
		{ 
			asTemp = asVal[nIndex].split(sDelimit1);
			if ((bFlag == "M") && (trim(window.document.all(asTemp[0]).value) != ""))
			{
				window.document.all(asTemp[0]).value = trim(window.document.all(asTemp[0]).value) + sDelimit3 + asTemp[1] ;
			}
			else
			{	
				window.document.all(asTemp[0]).value = asTemp[1];
			}	
		}
	}
	
}
function vSingleLookup(sUrl, sTitle, sFunction)
{
	var asReturn = window.showModalDialog(sUrl + "&title=" + escape(sTitle),"","dialogHeight: 350px; dialogWidth: 620px; edge: Raised; center: Yes; help: no; resizable: yes; status: no; scroll: no; title : " + sTitle);
	if (asReturn == null)
	{
		return;
	}
	if ((asReturn.length > 0))
	{
		//alert(asReturn[0]);
		vQLPopulate(asReturn[0],"S");
	}
	else
	{
		return;
	}
	if (trim(sFunction) != "")
	{
		eval(sFunction)();
	}
}
function vMultiLookup(sUrl, sLkup, sIdFld, sDivName, sTitle, sFunction)
{
	var sTblName = "";
	var sTemp = "";
	var sHTML = "";
	
	sTblName = "tbl" + sLkup ;
	
	//Using the table id find out the last row id, which will be useful to form the next row
	if (window.document.all(sTblName))
	{
		sTemp = window.document.all(sTblName).rows(window.document.all(sTblName).rows.length-1).id ;
		sUrl = sUrl + "&row=" + sTemp;
	}
	//Take the already existing HTML for the selected rows
	if (trim(window.document.all(sIdFld).value) != "")
	{
		//Remove the closing tags of the table tag and tr tag, to attach the selected rows.
		sHTML = window.document.all(sDivName).innerHTML;
		sHTML = sHTML.substr(0,sHTML.length-16);
	}
	
	var asReturn = window.showModalDialog(sUrl+ "&title=" + sTitle,sHTML,"dialogHeight: 355px; dialogWidth: 640px; edge: Raised; center: Yes; help: no; resizable: no; status: no; scroll: yes; title : " + sTitle);
	if (asReturn == null)
	{
		return;
	}
	if ((asReturn.length > 0))
	{
		vQLPopulate(asReturn[0],"M");
		sHTML = sHTML + asReturn[1];
		//alert(sHTML);	
		window.document.all(sDivName).innerHTML = sHTML;
		
	}
	else
	{
		return;
	}
	if (trim(sFunction) != "")
	{
		eval(sFunction)();
	}
}
function CheckTime(stime)
{
	if (stime.length==0) return;
	var sMsg="Invalid time.\nTime should be in HH:MM:SS AM/PM Format.";
	var arrTimeColon=new Array();
	var arrTimeSpace=new Array();
	if (stime.length<8	|| stime.length>11)
		return sMsg;	
	arrTimeColon=stime.split(":");
	arrTimeSpace=stime.split(" ");
	if (arrTimeColon.length!=3 || arrTimeSpace.length!=2)
		return sMsg;	
	if (parseInt(arrTimeColon[0])<=0 || parseInt(arrTimeColon[0])>12 || parseInt(arrTimeColon[1])<=0 || parseInt(arrTimeColon[1])>59 || parseInt(arrTimeColon[2])<0 || parseInt(arrTimeColon[2])>59)
		return sMsg;	
	if (arrTimeSpace[1].toUpperCase()!='AM' && arrTimeSpace[1].toUpperCase()!='PM')
		return sMsg;	
	return '';
}

function vAlphabetKeyPress()
{
	if (msGlobal != msEnglishId)
		return;
	if (window.event.keyCode < 65 || window.event.keyCode > 122)  
	{
		//to allow space
		if (window.event.keyCode == 32)
		{
			return ;
		}
		//To avoid flashing alert for non impression keys
		if (window.event.keyCode < 32)
		{
			window.event.keyCode = 0 ;
			return ;
		}
		//alert("Only alphabets should be entered");
		FTMessageBox('','','INFO','<BR>Only alphabets should be entered')
		window.event.keyCode = 0  ; 
		return ;
		
	}	
}

function vNumericKeypress(sDecAllowed)
{
	//if (msGlobal != msEnglishId)
	//	return;
	
	if (window.event.keyCode == 46)
	{
		if (sDecAllowed == "Y")
		{
			var sValue = event.srcElement.value ;
			if (sValue.indexOf(".") > -1 )
			{
				FTMessageBox('','','INFO','<BR>Decimal point already exists in this value','Edit Activity')
				window.event.keyCode = 0; // JI28MAR2005: The keycode was not set to zero previously, resulting in a run time error.
				return ;
			}
			else
			{
				return ;
			}
		}
	}
	//Vimal14Oct2004: Negative symbol allowed in numeric text box
	else if (window.event.keyCode == 45)
	{
			var oText = event.srcElement;
			var sText = oText.value;
			//alert(sText.length);
			if (sText.length != 0)
			{
				window.event.keyCode = 0  ; 
				return ;
			}
			else
			{
				return;
			}
	}		
	else
	{
		if (window.event.keyCode < 48 || window.event.keyCode > 57)  
		{
				window.event.keyCode = 0 ;
				return ;
		}
	}
	/*
	if (window.event.keyCode < 48 || window.event.keyCode > 57)  
	{
		//To avoid flashing alert for non impression keys
		if (window.event.keyCode < 32)
		{
			window.event.keyCode = 0 ;
			return ;
		}
		if (window.event.keyCode == 45)
		{
			var oText = event.srcElement;
			var sText = oText.value;
			//alert(sText.length);
			if (sText.length != 0)
			{
				//alert(sText.length);
				FTMessageBox('','','INFO','<BR>Only Numbers should be entered')
				window.event.keyCode = 0  ; 
				return ;
			}
			else
			{
				return;
			}
			
		}
		if (window.event.keyCode == 46)
		{
			if (sDecAllowed == "Y")
			{
				
				var sValue = event.srcElement.value ;
				if (sValue.indexOf(".") > -1 )
				{
					//alert("Decimal point already exists in this value")
					FTMessageBox('','','INFO','<BR>Decimal point already exists in this value')
					window.event.keyCode = 0 ;
					return ;
				}
				else
				{
					return ;
				}
			}
			else
			{
				//alert("Decimal place is not allowed")
				FTMessageBox('','','INFO','<BR>Decimal place is not allowed')
				window.event.keyCode = 0 ;
				return ;
			}
		}
		//alert("Only Numbers should be entered");
		FTMessageBox('','','INFO','<BR>Only Numbers should be entered')
		window.event.keyCode = 0  ; 
		return ;
		
	}	
	*/
}
function vNumericCheck(sDecAllowed,bNegAllowed)
{
	//if (msGlobal != msEnglishId)
	//	return;
	
	//alert(window.event.keyCode);
	if (window.event.keyCode < 48 || window.event.keyCode > 57)  
	{
		//To avoid flashing alert for non impression keys
		if (window.event.keyCode < 32)
		{
			window.event.keyCode = 0 ;
			return ;
		}
		if ((window.event.keyCode == 45) && (bNegAllowed))
		{
			var oText = event.srcElement;
			var sText = oText.value;
			//alert(sText.length);
			if (sText.length != 0)
			{
				//alert(sText.length);
				FTMessageBox('','','INFO','<BR>Only Numbers should be entered')
				window.event.keyCode = 0  ; 
				return ;
			}
			else
			{
				return;
			}
		}
		else
		{
			if (!(bNegAllowed))
			{
				FTMessageBox('','','INFO','<BR>Only Numbers should be entered')
				window.event.keyCode = 0  ; 
				return ;
			}
		}
		if (window.event.keyCode == 46)
		{
			if (sDecAllowed == "Y")
			{
				
				var sValue = event.srcElement.value ;
				if (sValue.indexOf(".") > -1 )
				{
					//alert("Decimal point already exists in this value")
					FTMessageBox('','','INFO','<BR>Decimal point already exists in this value')
					window.event.keyCode = 0 ;
					return ;
				}
				else
				{
					return ;
				}
			}
			else
			{
				//alert("Decimal place is not allowed")
				FTMessageBox('','','INFO','<BR>Decimal place is not allowed')
				window.event.keyCode = 0 ;
				return ;
			}
		}
		//alert("Only Numbers should be entered");
		FTMessageBox('','','INFO','<BR>Only Numbers should be entered')
		window.event.keyCode = 0  ; 
		return ;
		
	}	
}
function vPreventSpcChars(sDot)
{
	if (msGlobal != msEnglishId)
		return;
	//alert(window.event.keyCode);
	if ((window.event.keyCode < 65 || window.event.keyCode > 122) &&  (window.event.keyCode < 48 || window.event.keyCode > 57) && (window.event.keyCode != 32))
	{
		//To avoid flashing alert for non impression keys
		if (window.event.keyCode < 32)
		{
			window.event.keyCode = 0 ;
			return ;
		}
		if (window.event.keyCode == 64) 
		{
			if (sDot == "E" )
			{
				return;
			}
			else
			{
				//alert("No special characters are allowed");
				FTMessageBox('','','INFO','<BR>No special characters are allowed')
				window.event.keyCode = 0  ; 
				return ;
			}
		}
		if (window.event.keyCode == 46)
		{
			if (sDot == "Y" || sDot == "E" )
			{
				return;
			}
			else
			{
				//alert("No special characters are allowed");
				FTMessageBox('','','INFO','<BR>No special characters are allowed')
				window.event.keyCode = 0  ; 
				return ;
			}
		}
		//alert("No special characters are allowed");
		FTMessageBox('','','INFO','<BR>No special characters are allowed')
		window.event.keyCode = 0  ; 
		return ;
	}	
}
function vNumAndAlphabetKeyPress()
{
	if (msGlobal != msEnglishId)
		return;
	//alert(window.event.keyCode);
	if ((window.event.keyCode == 96) || (window.event.keyCode == 94))
		{
			//alert("Only Numbers and Alphabets should be entered");
			window.event.keyCode = 0  ; 
			return ;
		}
	if ((window.event.keyCode < 65 || window.event.keyCode > 122) && (window.event.keyCode < 48 || window.event.keyCode > 57))  
	{
		//To avoid flashing alert for non impression keys
		if (window.event.keyCode < 32)
		{
			window.event.keyCode = 0 ;
			return ;
		}
		if (window.event.keyCode == 32)
		{
			return ;
		}
		//alert("Only Numbers and Alphabets should be entered");
		FTMessageBox('','','INFO',"Only Numbers and Alphabets should be entered")
		window.event.keyCode = 0  ; 
		return ;
		
	}	
}

/*
Function include by Vimal - 31-May-2004
To popup roles based on the Management group selection
07-Jun-2004	- Vimal - JavaScript Error fixed
*/

function vLookupRoleNames(iFieldCount)
{

	iMgtValue = "";
	if (document.all("hlertid").length+'' != 'undefined')
	{
		var iLertValue = document.all("hlertid").item(iFieldCount).value  
		var iMgtValue = document.all("cboMgtGroup").item(iFieldCount).value
	
		if (iMgtValue == 0)
		{
			for(var iCount=1;iCount< document.all("cboMgtGroup").item(iFieldCount).length;iCount++)
			{
				if (iMgtValue == 0)
				{
					iMgtValue = document.all("cboMgtGroup").item(iFieldCount).options[iCount].value;
				}
				else
				{
					iMgtValue = iMgtValue + "," + document.all("cboMgtGroup").item(iFieldCount).options[iCount].value;
				}
			}
		}
		strUrl = "../production/rolelookup.asp?mgtid="+iMgtValue+"&lntyid="+iLertValue+"&titlename="+document.all("hlertname").item(iFieldCount).value+"&sRType="+document.all("hrtype").item(iFieldCount).value;
		var hWndLookUp = window.showModalDialog(strUrl,"", "dialogHeight: 280px; dialogWidth: 470px; edge: Raised; center: Yes; help: no; resizable: yes; status: no; scroll: no; title : no");
		if(hWndLookUp != undefined )
		{
			document.all("txtLERT").item(iFieldCount).value =  hWndLookUp[0];
			document.all("hroleid").item(iFieldCount).value =  hWndLookUp[1];
		}
	}
	else
	{
		var iLertValue = document.all("hlertid").value  
		var iMgtValue = document.all("cboMgtGroup").value
	
		if (iMgtValue == 0)
		{
			for(var iCount=1;iCount< document.all("cboMgtGroup").length;iCount++)
			{
				if (iMgtValue == 0)
				{
					iMgtValue = document.all("cboMgtGroup").options[iCount].value;
				}
				else
				{
					iMgtValue = iMgtValue + "," + document.all("cboMgtGroup").options[iCount].value;
				}
			}
		}
		
		strUrl = "../production/rolelookup.asp?mgtid="+iMgtValue+"&lntyid="+iLertValue+"&titlename="+document.all("hlertname").value+"&sRType="+document.all("hrtype").value;
		var hWndLookUp = window.showModalDialog(strUrl,"", "dialogHeight: 280px; dialogWidth: 470px; edge: Raised; center: Yes; help: no; resizable: yes; status: no; scroll: no; title : no");
		if(hWndLookUp != undefined )
		{
			document.all("txtLERT").value =  hWndLookUp[0];
			document.all("hroleid").value =  hWndLookUp[1];
		}
	}
}


//************************************************************************
//function to call for Date calculation
//************************************************************************
function vCalculateDate()
{
	var icount;
	var jcount=0;
	var ifldcount;
	var stempFormula='';
	var sActualFormula='';
	var aAttrType;
	//  Following line commented by Vijayaraghavan on 19th July 2004, the next line added changing the form name to document.all
	//ifldcount=document.frmStage.htxtAttCount.value;
	ifldcount=document.all['htxtAttCount'].value;
	for (icount=0;icount<=ifldcount;icount++)
	{
		//if (document.all['hetxt'+icount] && document.all['hatxt'+icount]) //YSK17FEB2005: Commented to handle formula in hidden fields
		if (document.all['hetxt'+icount])   //YSK17FEB2005: ADDED to handle formula in hidden fields
		{
			aAttrType = trim(document.all['hatxt'+icount].value).split('~');
			
			// if (trim(document.all['hetxt'+icount].value) !='' && aAttrType[1].toUpperCase() == '') //YSK17FEB2005: Commented code - since allows date formulas only attribute type is empty
			if (1==1) //YSK17FEB2005: To allow all types to avail date functions - to handle date formulas on hidden attributes
			{
			    stempFormula =  document.all['hetxt'+icount].value;
			    sActualFormula=trim(stempFormula.toUpperCase())
			    
			   
			    if (sActualFormula.indexOf("DATEADD")!=-1)
			    {
					for (jcount=0;jcount<ifldcount;jcount++)
					{
						if (document.all["httxt"+jcount] && document.all["hftxt"+jcount])
						{
							if (trim(document.all["httxt"+jcount].value)!= '')
							{
								stempFormula = ReplaceMe(stempFormula.toUpperCase(),'<#'+trim(document.all['hftxt'+jcount].value).toUpperCase()+'#>', document.all['httxt'+jcount].value);
							}	
						}	
					}
					
					try
					{
						/* YSK17DEC2004: commented and code added below
						document.all['httxt'+icount].value = sConvertDTTM(dDateAdd(stempFormula),"");
						document.all['txt'+icount].value = sConvertDTTM(dDateAdd(stempFormula),"Y");
						*/
						//YSK17DEC2004: code added to handle date format 
						document.all['httxt'+icount].value = sConvertDTTMNumber(dDateAdd(stempFormula));
						document.all['txt'+icount].value = sConvertDTTMNumber(dDateAdd(stempFormula));
					}
					catch(e)
					{
						document.all['httxt'+icount].value = '';
						document.all['txt'+icount].value = '';
					}
				}
				
				else if (sActualFormula.indexOf("DATEDIFF") != -1)
			    {
					for (jcount=0;jcount<ifldcount;jcount++)
					{
						if (document.all["httxt"+jcount] && document.all["hftxt"+jcount])
						{
							if (trim(document.all["httxt"+jcount].value)!= '')
							{
								stempFormula = ReplaceMe(stempFormula.toUpperCase(),'<#'+trim(document.all['hftxt'+jcount].value).toUpperCase()+'#>', document.all['httxt'+jcount].value);
								
							}	
						}	
					}
					
					try
					{
						document.all['httxt'+icount].value = dDateDiff(stempFormula,0);
						document.all['txt'+icount].value = dDateDiff(stempFormula,0);
					}
					catch(e)
					{
						document.all['httxt'+icount].value = '';
						document.all['txt'+icount].value = '';
					}
				
				}
//********************************************************************************************************************************
// Date				Name			Reason
//02-Jul-2004		A.Shankar		Modifications made for calculating time Range and filling the value in the result Attribute 
//********************************************************************************************************************************
				else if (sActualFormula.indexOf("TIMEDIFF") != -1)
			    {
			     
					for (jcount=0;jcount<ifldcount;jcount++)
					{
						if (document.all["httxt"+jcount] && document.all["hftxt"+jcount])
						{
							if (trim(document.all["httxt"+jcount].value)!= '')
							{
								stempFormula = ReplaceMe(stempFormula.toUpperCase(),'<#'+trim(document.all['hftxt'+jcount].value).toUpperCase()+'#>', document.all['httxt'+jcount].value);
							}	
						}	
					}
					
					try
					{
						document.all['httxt'+icount].value = dDateDiff(stempFormula,1);
						document.all['txt'+icount].value = dDateDiff(stempFormula,1);
					}
					catch(e)
					{
						document.all['httxt'+icount].value = '';
						document.all['txt'+icount].value = '';
					}
				
				}
				
			}
			else if (trim(document.all['hetxt'+icount].value) !='' && aAttrType[1].toUpperCase() == 'GROUP')
			{
			    stempFormula =  document.all['hetxt'+icount].value;
			    sActualFormula = trim(stempFormula.toUpperCase())
			    if (sActualFormula.indexOf("DATEDIFF") != -1)
			    {
					for (jcount=0;jcount<ifldcount;jcount++)
					{
						if (document.all["httxt"+jcount] && document.all["hftxt"+jcount])
						{
							if (trim(document.all["httxt"+jcount].value)!= '')
							{
								stempFormula = ReplaceMe(stempFormula.toUpperCase(),'<#'+trim(document.all['hftxt'+jcount].value).toUpperCase()+'#>', document.all['httxt'+jcount].value);
							}	
						}	
					}
					
					try
					{
						document.all['httxt'+icount].value = dDateDiff(stempFormula,0);
						document.all['txt'+icount].value = dDateDiff(stempFormula,0);
					}
					catch(e)
					{
						document.all['httxt'+icount].value = '';
						document.all['txt'+icount].value = '';
					}
					
					
					
				}
				
				if (sActualFormula.indexOf("DATEADD")!=-1)
			    {
					for (jcount=0;jcount<ifldcount;jcount++)
					{
						if (document.all["httxt"+jcount] && document.all["hftxt"+jcount])
						{
							if (trim(document.all["httxt"+jcount].value)!= '')
							{
								stempFormula = ReplaceMe(stempFormula.toUpperCase(),'<#'+trim(document.all['hftxt'+jcount].value).toUpperCase()+'#>', document.all['httxt'+jcount].value);
							}	
						}	
					}
					
					try
					{
						/* YSK17DEC2004: Code commented and added below
						document.all['httxt'+icount].value = sConvertDTTM(dDateAdd(stempFormula),"");
						document.all['txt'+icount].value = sConvertDTTM(dDateAdd(stempFormula),"Y");
						*/
						//YSK17DEC2004:
						document.all['httxt'+icount].value = sConvertDTTMNumber(dDateAdd(stempFormula));
						document.all['txt'+icount].value = sConvertDTTMNumber(dDateAdd(stempFormula));
						
					}
					catch(e)
					{
						document.all['httxt'+icount].value = '';
						document.all['txt'+icount].value = '';
					}
				
				}
			}
		}
	}
}


//********************************************************************************************************************************
// Date				Name			Reason
//23-Jul-2004		S.Sathish		To Validate single quotes in the text box.
//********************************************************************************************************************************
function vSingleQuoteKeypress()
{
	
	if (window.event.keyCode == 39)
	{
		window.event.keyCode = 0 ;
		return ;
	}
	//alert(window.event.keyCode);
}





//********************************************************************************************************************************
// Date				Name			Reason
//`0-Sep-2004		A.Shankar		To set focus on the first control
//********************************************************************************************************************************



function vSetfocus()
	{

		//var nLength = document.forms[0].elements.length;
		var nLength = document.all.length;
		var i;
		for (i=0;i<nLength;i++)
		{
		
			if (document.all[i].tagName == "INPUT")
			{
			   // SE131004 : Added && (document.all[i].style.display != "none") with following if condition
			   // SSK06JAN2005: focus should not take place for controls of type checkbox: so the following condition added : "&& (document.all[i].type != "checkbox")" to the below IF condition.
				if((document.all[i].type != "hidden") && (document.all[i].style.display != "none") && (document.all[i].type != "checkbox"))
				{
					if((!(document.all[i].readOnly)) && (!(document.all[i].disabled)))
					{
						document.all[i].focus();
						return;
					}
				}
			}
			
			if (document.all[i].tagName=="IMG")
			{
				var sSource = document.all[i].src;
				var nSrcLength = sSource.length;
				var nStartPos = sSource.lastIndexOf("/")+ 1;
				
				var sGifName = trim(document.all[i].src.substr(nStartPos,nSrcLength));
				
				if((sGifName == "calender.gif")) 
				{
					if((!(document.all[i].readOnly)) && (!(document.all[i].disabled)))
						document.all[i].focus();
					return;
				}
				else if(sGifName == "clock.gif")
				{
					if((!(document.all[i-1].readOnly)) && (!(document.all[i-1].disabled)))
						document.all[i-1].focus();
					return;
				}
				else if(sGifName == "eye_close.gif")
				{
					// HK04NOV2005 :- If hidden even then dont keep a focus
					if((!(document.all[i-1].readOnly)) && (!(document.all[i-1].disabled)) && document.all[i-1].type != 'hidden' )
						document.all[i-1].focus();
					return;
				}
			
			}
			if (document.all[i].tagName=="SELECT")
			{	
				if(!(document.all[i].readOnly) && !(document.all[i].disabled)&&(document.all[i].name != "cboFTReports")&&(document.all[i].name != "cboFTExports")&&(document.all[i].name != "cboFTCharts"))
				{
				
					document.all[i].focus();
					return;
				}
			}
			if (document.all[i].tagName=="TEXTAREA")
			{
				if(!(document.all[i].readOnly) && !(document.all[i].disabled))
				{
					document.all[i].focus();
					return;
					//alert('sel' + document.forms[0].elements[i].tagName)
					
				}
			}
			
		}	
	}

//DH:8-Apr-2005: Lookup Validation: Added a function vMouseClick(): 
//to check whether Mouse click
//********************************************************************************************************************************
// Date				Name			Reason
//8-Apr-2005		Balakrishnan	
//********************************************************************************************************************************
function vMouseClick()
{
	msonKeydown = "MClick" ;
}

//SSK17MAR2005: Lookup Validation: Added a function vCheckOnKeyPress(): to check whether the F2 key is pressed or not
//BALA08042005 if F2 is pressed load the lookup window. Changed the Key down from Y and N to TAB and F2
//VISH161006: keycode changed to keyCode. If keys other than F2 or TAB is pressed msonKeydown is emtied.
function vCheckOnKeyPress()
{
	if (event.keyCode == 113)
		msonKeydown = "F2" ; //BALA08042005 msonKeydown = "Y" ;
	else if(event.keyCode == 9)
	{
		msonKeydown = "TAB"; //BALAO8042005 
	}
	else
	{
		//***SHAH110507
		 msonKeydown = "TAB" //BALAO8042005  msonKeydown = "N"
		//msonKeydown = ""
		//event.srcElement.focus();
	}
}
//YSK24DEC2004 - Function which is used to concatenate string values to do lookup tab validation
//BALA08042005 - if F2 is pressed load the lookup window  Function Moved from dtmultivalue.asp and practivityclientfunctions
function vMultiSetlookupval(nFormAttrId,sInputFlds,sOutputFlds,sDateFormat)
{
var stemp
stemp = event.srcElement
msRetval  = stemp.id + "~"+stemp.value+"#"

//alert('In vMultiSetlookupval: '+ (stemp.value).indexOf('+'));
//if (stemp.value != '') alert('In vMultiSetlookupval: '+ (stemp.value).indexOf('+'));

//SSK27APRIL2005: bugid: 170: Added the following condition '&& (stemp.value).indexOf('+')== -1' in the below IF statement; Reason: To skip lookupvalidation if lookup attribtue value has '+' delimiter
//SSK19MAR2005: Checked for F2 key press
//VISH161006: Added F2 in the "OR condition" as vLookup should be called even when F2 is is clicked.
// alert(msonKeydown + ' 000000000000 ')
//SHAH110507
if(msonKeydown=='TAB' && (stemp.value).indexOf(sMultiValueLookupDelimiter)== -1) //BALA08042005 Changed the key  down check to TAB (msonKeydown=='N')
	vLookup(nFormAttrId,sInputFlds,sOutputFlds,sDateFormat)
}

//YSK24DEC2004: Function to pop up the lookup on hit of F2 - For MultiDate format
//BALA08042005 if F2 is pressed load the lookup window 
function vMultiLookupShortKey(sAttrId,sInputFlds,sOutputFlds,sValue,sAttrName,sAttr,sDateFormat)
{
		var sItemValue=document.all(sValue).value;
		var sAttrName=sAttrName;
		
		if(msonKeydown=='F2') //BALA08042005 Changed (msonKeydown=='Y') to F2
			vLookup(sAttrId,sInputFlds,sOutputFlds,sItemValue,sAttrName,sDateFormat)
}

//DHAN15OCT04: Function to pop up the DATE LOOKUP on hit of F2
function vDateShortKey(sFldName,sFld,sFldVal)
{
		if (event.keyCode == 113)
		{
		    dtModalCalendar(sFldName,'',sFldVal)
		    return false;
		}
		//SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes: so below lines are commented
		/*
		//DHAN22NOV04: Usability - delete button is not allowed for date related controls
		else if (event.keyCode == 46)
		{
			event.keyCode = 0
		}
		*/
}

//YSK24DEC2004: Function to pop up the DATE LOOKUP on hit of F2 - For multidate format
function vMultiDateShortKey(sFldName,sFld,sFldVal,sDateFormat)
{
		if (event.keyCode == 113)
		{
		    dtMultiModalCalendar(sFldName,'',sFldVal,sDateFormat)
		    return false;
		}
		//SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes: so below lines are commented
		/*
		else if (event.keyCode == 46)
		{
			event.keyCode = 0
		}
		*/
}


//DHAN15OCT04: Function to pop up the TIME LOOKUP on hit of F2
function vTimeShortKey(sFldName)
{
		if (event.keyCode == 113)
		{
		    dtModalTime(sFldName)
		    return false;
		}
		//SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes: so below lines are commented
		//DHAN22NOV04: Usability - delete button is not allowed for date related controls
		/*
		else if (event.keyCode == 46)
		{
			event.keyCode = 0
		}
		*/
}

//DHAN15OCT04: Function to pop up the DATETIME LOOKUP on hit of F2
function vDateTimeShortKey(sFldName,sFldValInfo,sFld,sFldVal)
{
		
		if (event.keyCode == 113)
		{
		    FTDateTimeCalendar(sFldName,'Y','',sFldVal)
		    return false;
		}
		//SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes: so below lines are commented
		//DHAN22NOV04: Usability - delete button is not allowed for date related controls
		/*
		else if (event.keyCode == 46)
		{
			event.keyCode = 0
		}
		*/
}

//YSK24DEC2004: Function to pop up the DATETIME LOOKUP on hit of F2
function vMultiDateTimeShortKey(sFldName,sFldValInfo,sFld,sFldVal,sDateFormat)
{
		if (event.keyCode == 113)
		{
		    FTMultiModelDateTimeCalendar(sFldName,'Y','',sFldVal,sDateFormat)
		    return false;
		}
		//SSK05JAN2005: Bug Id: 254: Delete button action should take place for the date attributes: so below lines are commented
		//DHAN22NOV04: Usability - delete button is not allowed for date related controls
		/*
		else if (event.keyCode == 46)
		{
			event.keyCode = 0
		}
		*/
}

//DHAN15OCT04: Function to allow only F2 key for date, time and datetime controls
function vAllowPressKey()
{
		if (event.keyCode != 113)
		{
		    event.keyCode = 0
		}
}


//GS03FEB2005 : vATTACH() function included.

//************************************************************************
//Attachment Facility - functions start
//************************************************************************
//****************************************************************************************************
// vAttach Function is used to do attaching file. 
// Arguments : sFldName is text box name,sAttrName 
//nDOTID - value set in dtmultivalue.asp and practivity.asp
// 10-02-2005	Sakthi	V1.8	GS10022005 - If the sReturn is null assgin null to hidden field
//********************************************************************************************************
// HK25NOV2005 :- Commented the function vAttach because the function is no more used . The page scattach.asp does not have any dependency according to dependency matrix
/*function vAttach(sFldName, sAttrName,nAttrid)
//
{
	
	//GS02FEB2005
	//Commented as Attached file  will have Actual File name SS19Apr05 Hence SFldName is enough nAttrId and nDOID is not required Begin
	//var AttrId = nAttrid;
	var AttrId;
	//SS19Apr05 End
	//var sFlag="http://localhost/FTAttachments\LocnMaps";
	var sFlag="http://"+ window.location.hostname + "/" + nuploadsDirVar;

		if(sFlag=="NULL"|| sFlag == "")
	{
			var sFld = 'No file upload configuration specified';
			FTMessageBox('','','INFO',sFld,'<%=msTitle%>');
			return;
	}

	var sLcnMap=window.document.all(sFldName).value;
	
	if (trim(window.document.all(sFldName).value) != "")
	{
		if ((FTConfirmBox("","","<BR>If you are attaching a new file, the current attachment will be lost. Do you wish to continue?","FTYESNO") != 'YES'))
		//FTConfirmBox("","","<BR>Do you want to submit the report?","FTYESNO");
		return;	
	}
	window.document.all(sFldName).value="";
	if (window.document.all(sAttrName)) window.document.all(sAttrName).style.display ="none";
	//Commented as Attached file  will have Actual File name SS19Apr05 Hence SFldName is enough nAttrId and nDOID is not required
	//var sUrl = "../supplychain/scattachcall.asp?id=" + "2&scr=farm&doid=" + escape(nDOTID) + "&attrid=" + escape(AttrId) ;
	 var sUrl = "../supplychain/scattachcall.asp?id=" + "2&scr=farm" ;
	//Commented as Attached file  will have Actual File name SS19Apr05 End
	//GS17022005 - Hight and width changer from(120,460) to (150,470)
	var sReturn = window.showModalDialog(sUrl,"","dialogHeight: 150px; dialogWidth: 470px; edge: Raised; center: Yes; help: no; resizable: yes; status: no; scroll: no; ");	
	
	if ((sReturn == null) || (sReturn == ""))
	{
		//GS10022005 - If the sReturn is null assgin null to hidden field
		window.document.all(sFldName).value = "";
		window.document.all('ht'+sFldName).value = "";
		return;
	}
	else
	{
		window.document.all(sFldName).value = sReturn;
		window.document.all('ht'+sFldName).value = sReturn;
		if(sReturn!="")
		{
			document.all(sAttrName).style.display = "inline";
			document.all(sAttrName).style.visibility="visible"; 
		}
	}
}
*/
//END of Attachment function

//HK04NOV2005 :- ATTACHMENT FUNCTION - to upload to the DB

function vAttachFile(sFldName, sAttrName,nAttrid)
//
{
	
	//GS02FEB2005
	//Commented as Attached file  will have Actual File name SS19Apr05 Hence SFldName is enough nAttrId and nDOID is not required Begin
	//var AttrId = nAttrid;
	var AttrId;

	
	if (trim(window.document.all(sFldName).value) != "")
	{
		if ((FTConfirmBox("","","<BR>If you are attaching a new file, the current attachment will be lost. Do you wish to continue?","FTYESNO") != 'YES'))
		//FTConfirmBox("","","<BR>Do you want to submit the report?","FTYESNO");
		return;	
	}
	
	
	window.document.all(sFldName).value="";
	if (window.document.all(sAttrName)) window.document.all(sAttrName).style.display ="none";
	var sUrl = "../production/attachcall.asp" ;
	var sReturn = window.showModalDialog(sUrl,"","dialogHeight: 150px; dialogWidth: 470px; edge: Raised; center: Yes; help: no; resizable: yes; status: no; scroll: no; ");	
	
	if ((sReturn == null) || (sReturn == ""))
	{
		window.document.all(sFldName).value = "";
		window.document.all('ht'+sFldName).value = "";
		return;
	}
	else
	{
		window.document.all(sFldName).value = sReturn;
		window.document.all('ht'+sFldName).value = sReturn;
		if(sReturn!="")
		{
			document.all(sAttrName).style.display = "inline";
			document.all(sAttrName).style.visibility="visible"; 
		}
	}
	
}

function vDeleteAttachCall(sFldName,sAttrName,nDataDOTId,sDataAttrName)
{
	var nDoId;
	//HK04NOV2005 :- Dont delete the attachment from the DB
	if (trim(window.document.all(sFldName).value) != "")
	{
		if ((FTConfirmBox("","","<BR>Do you want to delete the attachment?","FTYESNO") != 'YES'))
		return;	
	}

	window.document.all(sFldName).value="";
	window.document.all('ht'+sFldName).value = "";
	if (window.document.all(sAttrName)) window.document.all(sAttrName).style.display ="none";
	

}





// END ATTACHMENT FUNCTION
// TO VIEW ATTACHMENT
function vViewAttachment(sFldName)
//Commented as Attached file  will have Actual File name SS19Apr05  End
//*** SHAH141105;Extra parameter added to handle the issue in Session while viewing the Attachments
{	

	var sFile = "";
	sFile = trim(window.document.all(sFldName).value);	
	if (sFile == "") 
	{
		//FTAlert("A file should be attached","INFO");
		var sFld6 = '<BR>' + '<%=moDictTL("Select a file to attach")%>';
		FTMessageBox('','','INFO',sFld6);
		return;
	}
	sFile = escape(sFile);
	//*** SHAH141105
	//sUrl = "viewattachments.asp?id=" + sFile;
	//*** SHAH141105;Extra parameter added to handle the issue in Session while viewing the Attachments
	sUrl = "viewattachments.asp?SESSIONCHK=NO&id=" + sFile;
	//Commented as Attached file  will have Actual File name SS19Apr05 End
	var sWinLcn = GetWindowLocation(750,700);
	
	var hWnd = window.open(sUrl,"Attachment","menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
	if	((window.document != null) && (!hWnd.opener))
	{
		hWnd.opener = window.document;		
	}
}
//END VIEW ATTACHMENT

//GS03FEB2005 : vViewAttachOne() function included.
//Commented as Attached file  will have Actual File name SS19Apr05 Hence SFldName is enough nAttrId and nDOID is not required
//function vViewAttachOne(sFldName,nAttrId,nDOID)
function vViewAttachOne(sFldName)
//Commented as Attached file  will have Actual File name SS19Apr05  End
{	
	
	var sFile = "";
	sFile = trim(window.document.all(sFldName).value);	
	if (sFile == "") 
	{
		//FTAlert("A file should be attached","INFO");
		var sFld6 = '<BR>' + '<%=moDictTL("Select a file to attach")%>';
		FTMessageBox('','','INFO',sFld6);
		return;
	}
	sFile = escape(sFile);
	//sUrl ="http://localhost/FTAttachments/locnmaps/" + nAttrId + '_' + nDOID + '_' + sFile;  
	//GS03FEB2005_02 - Hard code location changed
	//Commented as Attached file  will have Actual File name SS19Apr05 Hence SFldName is enough nAttrId and nDOID is not required
	//var sUrl="http://"+ window.location.hostname + "/" + nuploadsDirVar + "/" + nAttrId + '_' + nDOID + '_' + sFile;
	var sUrl="http://"+ window.location.hostname + "/" + nuploadsDirVar + "/" + sFile;   
	//Commented as Attached file  will have Actual File name SS19Apr05 End
	var sWinLcn = GetWindowLocation(750,700);
	var hWnd = window.open(sUrl,"Lookup",sWinLcn +",scrollbars=yes,resizable=yes");
	if	((window.document != null) && (!hWnd.opener))
	{
		hWnd.opener = window.document;		
	}
}
// NB110405	Included vCheckUnCheckMainChkBox function
// Accepts 2 parameters. Header Check box Name, Body Checkbox Name
// Checks / Unchecks the header check box while selcecting the Body Check boxes
function vCheckUnCheckMainChkBox(HeadChkBoxName,BodyChkBoxName)
{
	var nCnt;
	var nRowCount;
	var bAllChecked
	bAllChecked=true
	var CMainCheckBox = eval('document.all("' + HeadChkBoxName + '")')

	//eval('document.all("' + BodyChkBoxName + '")')
	if(eval('document.all("' + BodyChkBoxName + '")') !=null)
	{
		if(eval('document.all("' + BodyChkBoxName + '").length') !=undefined)
		{
				nRowCount= eval('document.all("' + BodyChkBoxName + '").length-1')
				for(nCnt=0;nCnt<=nRowCount;nCnt++)
				{
					if (eval('document.all("' + BodyChkBoxName + '").item(nCnt).checked') == false) bAllChecked = false

				}

		}
		else

		{
			if (eval('document.all("' + BodyChkBoxName + '").checked') == false) bAllChecked = false

		}
		if (bAllChecked == false) 
			CMainCheckBox.checked = false
		else
			CMainCheckBox.checked = true

	}
}
	
//END of ViewAttacOne()  function




