// This script is intended for use with a minimum of Netscape 4 or IE 4.

var ns4=false;
var ie4=false;
if(window.document.layers)
{
 	ns4 = true;
}

if(window.document.all) 
{   
	ie4 = true;
}

//to handle the trivial case in netscape

if(ie4 == false)
{
	ns4 = true;
}

function MM_openBrWindow(theURL,winName,features) 
{ 
	window.open(theURL,winName,features);
}

 function mSetFocus(aControl)
 {
	try
	{
		aControl.focus();
	}
	catch (e)
	{
	}
}

// Function Name	:	OpenScreen
// Purpose			:	This function is used to navigate from page to page.
function OpenScreen(aUrl)
{				
	if (aUrl!='')
	{
		window.document.location.href = aUrl;
		return false;
	}
}

function DisableAfterClick(Obj)
{
	Obj.style.disable = true;
	return false;
}

// Function Name	:	Trim
// Purpose			:	This function is helpful for trimming the value.
function Trim(aStrValue)
{
	// this loop will get rid of leading spaces
	while (aStrValue.substring(0,1) == ' ')
		aStrValue = aStrValue.substring(1, aStrValue.length);
	// this loop will get rid of trailing spaces
	while (aStrValue.substring(aStrValue.length-1,aStrValue.length) == ' ')
		aStrValue = aStrValue.substring(0, aStrValue.length-1);
		return aStrValue;

}
//  Trim ends
//===============================================================================


//Function to check for mandatory fields, Checks text box,combo box fields
//usage:Field1~Lable1,Field2~Lable2...
function CheckMandatoryFields(aStrManFields , aBlnFocus)
{
	
	if(Trim(aStrManFields)=='')
	{
		return true;
	}
	var pArrManFields,pObjField,pArrField,pStrVal,pStrFieldList='';
	pArrManFields=aStrManFields.split(",")
	var pFocusField;
	for (var pIntIndex=0;pIntIndex<pArrManFields.length;pIntIndex++)
	{
		pArrField=(pArrManFields[pIntIndex]).split("~");
		if (pArrField[0].indexOf('repEmployeeCensus:_ctl') == -1)
		{			
			pObjField=eval('window.document.forms[0].' + pArrField[0]);
		}
		else
		{			
			pObjField = document.getElementById(pArrField[0]);
		}				
		if ((pObjField.type=='text') || (pObjField.type=='textarea'))//text box
		{
			pStrVal=pObjField.value;
		}
		else if (pObjField.type=='select-one')//combo box
		{
			if (pObjField.selectedIndex == -1)
				pStrVal = ''
			else
				pStrVal=pObjField.options[pObjField.selectedIndex].value;
		}
		else if (pObjField.type=='password')//Passwords.
		{
			pStrVal=pObjField.value;
		}
		else if ((pObjField.length > 1)  || (pObjField.type=='radio'))//Radio buttons
		{
			var chkFlag = false;			
			for (var loopIndex= 0; loopIndex < pObjField.length; loopIndex++)
			{			
				if (pObjField[loopIndex].type == 'radio')
				{					
					if (pObjField[loopIndex].checked == true)
					{
						chkFlag = true;
						pStrVal = pObjField[loopIndex].name;						
						break;
					}
				}
			}			
			if (chkFlag == false)
			{
				pStrVal = ''
			}
		}
		if (Trim(pStrVal)=='')
		{	
			if ((pStrFieldList.length==0) && (pObjField.length==undefined))
			{
				pFocusField = pObjField;				
			}
			pStrFieldList=pStrFieldList + '* ' + pArrField[1] + '\n';
		}
	}
	if (pStrFieldList.length>0)
	{
	
		alert('Please enter the following field(s)\n\n' + pStrFieldList);		
		if ((arguments.length == 1) && (pFocusField == '[object]' ))
		{
			pFocusField.focus()
		}
		return false;
	}
	return true;
}
// End Of Function to Check Manadatory Files...


//Checking whether field value is empty or not
function isEmpty(s)
{
	return ((s == null) || (s.length == 0));
}
//End Of Checking whether field is empty or not


//Checking whether field value is Integer or not
function isInteger (s)
{
	var pIntIndex;
	if (isEmpty(s))
	if (isInteger.arguments.length == 1)
		return false;
	else
		return (isInteger.arguments[1] == true);

	for (pIntIndex = 0; pIntIndex < s.length; pIntIndex++)
	{
		// Check that current character is number.
		var c = s.charAt(pIntIndex);

		if (!((c >= "0") && (c <= "9")))
			return false;
	}

	// All characters are numbers.
	return true;
}
//End Of Checking whether field value is Integer or not

//Checking whether field value is positive Integer or not
function isPositiveInteger (s)
{
	if (isInteger(s) == true)
	{
		if ( s == 0 )
			return false;
		else
			return true;
	}
	else 
		return false;
}
//End Of Checking whether field value is Integer or not


//	Function Name	: isZIPCode
//	Purpose			: To Check the entered zip code is valid or not.
function isZIPCode (theField)
{ 
	var pStrValue = theField.value;	
	var i;
	var normalizedZIP = "";
	var ZIPCodeDelimiters = "-";
    for (i = 0; i < pStrValue.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = pStrValue.charAt(i);
        if (ZIPCodeDelimiters.indexOf(c) == -1) normalizedZIP += c;
    }		
    pStrValue = normalizedZIP;
	var digitsInZIPCode1 = 5;
	var digitsInZIPCode2 = 9;
	if (isEmpty(pStrValue)) 
		if (isZIPCode.arguments.length == 1) return false;
		else return (isZIPCode.arguments[1] == true);
	if(isInteger(pStrValue) && ((pStrValue.length == digitsInZIPCode1) ||(pStrValue.length == digitsInZIPCode2)))
	{		
		if (pStrValue.length == 5) return true;
		else theField.value = (reformat (pStrValue, "", 5, "-", 4));
		return true;
		
	}
	else
	{
		alert('Please enter a valid Zip Code')
		theField.select();
		theField.focus();		
		return false;
	}
}
//isZipCode function ends
//=========================================================================================

function reformat (s)
{   
	var arg;
    var sPos = 0;
    var resultString = "";
    
    for (var pIntIndex = 1; pIntIndex < reformat.arguments.length; pIntIndex++) {
       arg = reformat.arguments[pIntIndex];
       if (pIntIndex % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}


function isUSPhoneNumber (s)
{   var digitsInUSPhoneNumber = 10;
	if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return false;
       else return (isUSPhoneNumber.arguments[1] == true);       
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}

function CheckUSPhone (theField)
{   
	pStrValue= Trim(theField.value);
    if (pStrValue!='')
    {  
		var phoneNumberDelimiters = "()-. ";
		var normalizedPhone = '';
		var i;
		for (i = 0; i < pStrValue.length; i++)
		{   
			// Check that current character isn't whitespace.
			var c = pStrValue.charAt(i);
      		if (phoneNumberDelimiters.indexOf(c) == -1) normalizedPhone += c;
		}						
		if (isUSPhoneNumber(normalizedPhone)) 
		{
			// if you don't want to reformat as (123) 456-789, comment next line out
			theField.value = reformatUSPhone(normalizedPhone);
			return true;
		}
		else 
		{  
			  theField.focus();
			  theField.select();
			  alert('Please enter valid Phone/Fax');
			  return false;					
		}
	}
}


// Funcation Name	:	CheckDate
// Purpose			:	Checking For Date

function CheckDate(theField,MsgFlag)
{

	FormatDate(theField);
	//*****************//
	if (theField.value!='')
	{	
		var strVal,strDt;
		var dateDelimiter = "";
		
		strVal= Trim(theField.value);
		
		if (CheckDate.arguments.length == 1)
			MsgFlag = true;
		
		strDt=new Date();
		
		if (strVal.indexOf('-') != -1)
			dateDelimiter = '-';
		else
			dateDelimiter = '/';
			
		var fI=strVal.indexOf(dateDelimiter);
		var fL=strVal.lastIndexOf(dateDelimiter);
		var yr=(strVal.substring(fL+1));
		var mont=(strVal.substring(0,strVal.indexOf(dateDelimiter)));
		var dt=(strVal.substring(strVal.indexOf(dateDelimiter)+1,strVal.lastIndexOf(dateDelimiter)));

		if(isNaN(dt)||isNaN(mont)||isNaN(yr))
		{
			if (MsgFlag==true)
			{
				alert("Please enter a valid Date.");
				theField.focus();
			}
			theField.value = '';
			return false;
		}
		if (strVal.indexOf(".")!= -1)
		{
			if (MsgFlag==true)
			{
				alert("Please enter a valid Date.");
				theField.focus();
			}
			theField.value = '';
			return false;
		}

		if ((strVal.length>=6))
		{
			if ((mont>0) && (mont<=12))
			{
				if ((dt>0) && (dt<=31))
				{
					if(yr.length==4)
					{
						var now = new Date();
						var thisyear;
						var thisdate;
						var thismonth;
						thisyear = now.getYear();
						thisdate=now.getDate();
						thismonth=now.getMonth();
						var entereddate = new Date(parseInt(yr), parseInt(mont)-1, parseInt(dt), 0, 0, 0);
						var entereddate2 = new Date(parseInt(thisyear), parseInt(thismonth), parseInt(thisdate));
						if(mont==1 || mont==3 || mont==5 || mont==7 || mont==8 || mont==10 || mont==12)
						{
							if(dt<0 || dt>31)
								{
									if (MsgFlag==true)
									{
										alert("Please enter a valid Date.");
										theField.focus();
									}
									theField.value = '';
									return false;
								}
						}
						if(mont==4 || mont==6 || mont==9 || mont==11)
						{
							if(dt<0 || dt>30)
								{
									if (MsgFlag==true)
									{
										alert("Please enter a valid Date.");
										theField.focus();
									}
									theField.value = '';
									return false;
								}

						}
						//leap year
						if (CheckLeapYear(yr)==true)
						{
							if(mont==2)
							{
									if(dt<0 || dt>29)
									{
										if (MsgFlag==true)
										{
											alert("Please enter a valid Date.");
											theField.focus();
										}
										theField.value = '';
										return false;
									}
							}
						}
						if (CheckLeapYear(yr)==false)
						{
							if(mont==2)
							{
									if(dt<0 || dt>28)
									{
										if (MsgFlag==true)
										{
											alert("Please enter a valid Date.");
											theField.focus();
										}
										theField.value = '';
										return false;
									}
							}

						}
					}
					else
					{
						if (MsgFlag==true)
						{
							alert("Please enter a valid Date.");
							theField.focus();
						}
						theField.value = '';
						return false;
					}
				}
				else
				{
					if (MsgFlag==true)
					{
						alert("Please enter a valid Date.");
						theField.focus();
					}
					theField.value = '';
					return false;
				}
			}
			else
			{
				if (MsgFlag==true)
				{
					alert("Please enter a valid Date.");
					theField.focus();
				}
				theField.value = '';
				return false;
			}
		}
		else
		{
			if (MsgFlag==true)
			{
				alert("Please enter a valid Date.");
				theField.focus();
			}
			theField.value = '';
			return false;
		}
	}
	if ( eval(yr) <= '1752')
	{
		if (MsgFlag==true)
		{
			alert("Please enter a valid Date.");
			theField.focus();
		}
		theField.value = '';
		return false;
	}

	if (Trim(theField.value) != '')
	{
		//For auto formating the day and month i.e day 1--01, Month 1--01 in the date
		var pMonthtemp,pDaytemp
		pMonthtemp=Trim(mont);
		pDaytemp=Trim(dt);
		if (pMonthtemp.length==1)
		{
			mont="0"+Trim(mont);
		}
		if (pDaytemp.length==1)
		{
			dt="0"+Trim(dt);
		}

		theField.value = Trim(mont) + "/" + Trim(dt) + "/" + Trim(yr);
	}
	return true;

}
//	CheckDate Ends
//	=======================================================================================


function FormatDate(aField)
{
	// author : HYD1003049
	// date   : 18/03/2004
	// desc    : pass the field to auto format the value to mm/dd/yyyy
	//           if the field value is not correct it won't format...
	var pStrDate = Trim(aField.value);
	var pNewDate;
	
	if ((Trim(pStrDate)!='') && (pStrDate.length == 8))
	{
		if (pStrDate.indexOf('/')==(-1))
		{
			if (isNaN(pStrDate)==false)
			{
				pNewDate=pStrDate;
				if (pStrDate.length==8)
				{
					pNewDate = pStrDate.substring(0,2) + '/' + pStrDate.substring(2,4) + '/' + pStrDate.substring(4,8)
				}
				else if (pStrDate.length==6)
				{
					pNewDate = '0' + pStrDate.substring(0,1) + '/' + '0' + pStrDate.substring(1,2) + '/' + pStrDate.substring(2,6)
				}
				else if (pStrDate.length==7)
				{
					if (parseInt(pStrDate.substring(0,2))>12)
					{
						pNewDate = '0' + pStrDate.substring(0,1) + '/' + pStrDate.substring(1,3) + '/' + pStrDate.substring(3,7)
					}
					else
					{
						if (parseInt(pStrDate.substring(0,2))>9)
						{
							pNewDate = pStrDate.substring(0,2) + '/' + '0' + pStrDate.substring(2,3) + '/' + pStrDate.substring(3,7)
						}
						else
						{
							pNewDate = '0' + pStrDate.substring(0,1) + '/' + '0' + pStrDate.substring(1,3) + '/' + pStrDate.substring(3,7)
						}
					}
				}
				aField.value = pNewDate;
			}
		}
	}
}

//	 Function Name		:	CheckLeapYear
//   Purpose			:	To check the entered year is leap year or not.
function CheckLeapYear(aLngYear)
{
	var pLngYear=aLngYear; //stores the year value
	if ( (pLngYear%4==0) && ( (pLngYear%100!==0) || (pLngYear%400==0)) )
	{
		return true
	}
	else
	{
		return false;
	}
}
//	CheckLeapYear ends
//================================================================================

/*function HandleEnterKey(aControlName)
{
	//Pass the control name to this function to which the enter key has to bindede
	//Also call this funciton on onkeydown event of Body tag
	
	var pShow;
	
	if (ie4)
	{
		if (event.keyCode == 13)
		{
			pShow=true;
		}
	}
	
	if (ns4)
	{
		if (e.which == 13)
		{
			pShow=false;
		}
	}
	if (pShow==true )
	{	
		var ControlObj = window.document.getElementById(aControlName);
		
		if (ControlObj == '[object]')
		{
			window.document.getElementById(aControlName).click();
			return false;
		}
		else
		{
			return false;
		}
	}
}
//end of handling the enter key*/

// Function Name	:	DefaultFocus
// Purpose			:	This function is used to focus the control on the first text box control

function DefaultFocus(aParField)
{
	var txtFieldObj;
	
	txtFieldObj=document.getElementById(aParField);
		
	if((txtFieldObj!=null) && (txtFieldObj.disabled == false))
	{	
		txtFieldObj.select();	
		txtFieldObj.focus();
	}
}


/*// Function Name	:	Traversing
// Purpose			:	This function is capturing the active element in the page and navigate accordingly 
		
function Traversing(aParDefaultActiveElement)
{

	// Help buttons are not taken care.
	// Need to take care when coding for help "?" Buttons
	
	var strActiveElement;
	strActiveElement='';

	if (aParDefaultActiveElement!='')
		strActiveElement=aParDefaultActiveElement;
		
	//Handling for other Controls on the Screen
	
	if(ie4)
	{
		var pActiveElementID = window.document.activeElement.id;
	
		//If Repeater Controls Remove button is pressed Return true
		if ( pActiveElementID.indexOf('repDependent__ctl') > -1 
					&& pActiveElementID.indexOf('imgRemove') > -1 )
		{
			return true;
		}
	}
	
	// If return key is pressed within Multline textbox then return True
	
	pReasonFld = window.document.getElementById('txtReasonForRequest');
	if(pReasonFld != null)
	{
		if(ie4)
		{
			if  (window.document.activeElement.id=='txtReasonForRequest')
				return true;
		}
	}

	pCommentFld = window.document.getElementById('ucContactMe_txtComments');
	if(pCommentFld != null)
	{
		if(ie4)
		{
			if  (window.document.activeElement.id=='ucContactMe_txtComments')
				return true;
		}
	}
	
	//Handle the Return key for some other button
		
	pEditFld = window.document.getElementById('ImgEditEmployee');
	if(pEditFld != null)
	{
		if  (pActiveElementID=='ImgEditEmployee')
			strActiveElement='ImgEditEmployee';
	}
			
	pViewAllPaymentsFld = window.document.getElementById('imgViewAllPayments');
	if(pViewAllPaymentsFld != null)
	{
		if  (pActiveElementID=='imgViewAllPayments')
			strActiveElement='imgViewAllPayments';
	}
	
	pViewAllEmployeeFld = window.document.getElementById('imgViewAllEmployee');
	if(pViewAllEmployeeFld != null)
	{
		if  (pActiveElementID=='imgViewAllEmployee')
			strActiveElement='imgViewAllEmployee';
	}

	pViewAllActivitiesFld = window.document.getElementById('imgViewAllActivities');
	if(pViewAllActivitiesFld != null)
	{
		if  (pActiveElementID=='imgViewAllActivities')
			strActiveElement='imgViewAllActivities';
	}

	pFindEmployeeHelpFld = window.document.getElementById('imgFindEmployeeHelp');
	if(pFindEmployeeHelpFld != null)
	{
		if  (pActiveElementID == 'imgFindEmployeeHelp')
			strActiveElement = 'imgFindEmployeeHelp';
	}
	
	pManageCompanyFld = window.document.getElementById('imgManageCompany');
	if(pManageCompanyFld != null)
	{
		if  (pActiveElementID=='imgManageCompany')
			strActiveElement='imgManageCompany';
	}
	
	pAssurantContactMeFld = window.document.getElementById('ContactMe_imgContactMe');
	if(pAssurantContactMeFld != null)
	{
		if  (pActiveElementID=='ContactMe_imgContactMe')
			strActiveElement='ContactMe_imgContactMe';
	}
	
	pContactMeFld = window.document.getElementById('ContactMe_ImageContact');
	if(pContactMeFld != null)
	{
		if  (pActiveElementID=='ContactMe_ImageContact')
			strActiveElement='ContactMe_ImageContact';
	}

	pOrderIDCardFld = window.document.getElementById('imgOrderIDCard');
	if(pOrderIDCardFld != null)
	{
		if  (pActiveElementID=='imgOrderIDCard')
			strActiveElement='imgOrderIDCard';
	}
	
	pRemoveFromPolicyFld = window.document.getElementById('imgRemoveFromPolicy');
	if(pRemoveFromPolicyFld != null)
	{
		if  (pActiveElementID=='imgRemoveFromPolicy')
			strActiveElement='imgRemoveFromPolicy';
	}
	
	pAddEmployeeFld = window.document.getElementById('imgAddEmployee');
	if(pAddEmployeeFld != null)
	{
		if  (pActiveElementID=='imgAddEmployee')
			strActiveElement='imgAddEmployee';
	}
	
	pRegisterFld = window.document.getElementById('imgRegister');
	if(pRegisterFld != null)
	{
		if  (pActiveElementID=='imgRegister')
			strActiveElement='imgRegister';
	}
	
	pLogoutFld = window.document.getElementById('Logout_imgLogOut');
	if(pLogoutFld != null)
	{
		if  (pActiveElementID=='Logout_imgLogOut')
			strActiveElement='Logout_imgLogOut';
	}
	
	pAddDepFld = window.document.getElementById('imgAddDependent');
	if(pAddDepFld != null)
	{
		if  (pActiveElementID=='imgAddDependent')
			strActiveElement='imgAddDependent';
	}
	
	pAddFld = window.document.getElementById('imgAdd');
	if(pAddDepFld != null)
	{
		if  (pActiveElementID=='imgAdd')
			strActiveElement='imgAdd';
	}
	
	pRemoveEmpFld = window.document.getElementById('imgRemoveEmp');
	if(pRemoveEmpFld != null)
	{
		if  (pActiveElementID=='imgRemoveEmp')
			strActiveElement='imgRemoveEmp';
	}
	
	pContinueFld = window.document.getElementById('imgContinue');
	if(pContinueFld != null)
	{
		if  (pActiveElementID=='imgContinue')
			strActiveElement='imgContinue';
	}
	
	return HandleEnterKey(strActiveElement);
}*/


// Function Name	:	SetDateDigit
// Purpose			:	Set month and year to 2 digit on lost focus if user specified 1 digit

function SetDateDigit(obj)
{
	obj.value = Trim(obj.value);
	if (obj.value.length == 1)
		obj.value = "0" + obj.value;
}

// Function Name	:	ConvertToDate
// Purpose			:	Converts string to date value

function ConvertToDate(astrDate)
{
	if (Trim(astrDate)!='')
	{
			var strDateValue,strDt;
			strDateValue=new String(astrDate);		
			var fI=strDateValue.indexOf('/');
			var fL=strDateValue.lastIndexOf('/');
			var yr=strDateValue.substring(fL+1);
			//Converting into 4 digit year if 2 digits entered.Ramana on 07/10/2001
			if (yr.length==2)
			{		
				yr = 20 + yr;
			}
			var mont=strDateValue.substring(0,strDateValue.indexOf('/'));
			var dt=strDateValue.substring(strDateValue.indexOf('/')+1,strDateValue.lastIndexOf('/'));
			date=new Date(yr,mont-1,dt);	
			return date         
	}		
}	

//Author : HYD0600012
//Date : 08/10/2005
//Function to check only ALPHA chars.
function CheckALPHAOnly(aObj, aFor)
{
	var txtStateObj=aObj;
	
	if (txtStateObj != null)
	{
		var pIndex;
		var alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var stateVal = txtStateObj.value;
	
		stateVal = stateVal.toUpperCase();
			
		for (pIndex=0; pIndex<stateVal.length; pIndex++)
		{

			if (alphabets.indexOf(stateVal.charAt(pIndex)) == -1)
			{
				alert("Please enter a valid " + aFor + ".");
				txtStateObj.select();
				txtStateObj.focus();
				return false;
			}
		
		}
	
	}

	return true;
}

//Author : HYD0600012
//Date : 08/10/2005
//Function to check only ALPHA and Numeric chars.
function CheckALPHANum(aObj, aFor)
{
	var txtStateObj=aObj;
	
	if (txtStateObj != null)
	{
		var pIndex;
		var alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
		var stateVal = txtStateObj.value;
	
		stateVal = stateVal.toUpperCase();
			
		for (pIndex=0; pIndex<stateVal.length; pIndex++)
		{

			if (alphabets.indexOf(stateVal.charAt(pIndex)) == -1)
			{
				alert("Please enter valid " + aFor + ".");
				txtStateObj.select();
				txtStateObj.focus();
				return false;
			}
		
		}
	
	}

	return true;
}
//Opening the model dislogue starts
var dialogWin = new Object();
var vbNULL = "CSSI_DEFINED_NULL" ;//This is used to track if cancel is pressed in modal dialog or modal dialog is closed by user.

function mfpOpenPopupWindow(pStrTitle, pIntHeight, pIntWidth, pBlnShowScrollbar, pStrDestination) 
{
    /*Parameters
     pStrTitle          = Title of the modal screen
     pIntHeight         = Height
     pIntWidth          = Width
     pBlnShowScrollbar  = If you wish to show the scrollbar in the modal form.
     pStrDestination    = Destination with complete querystring etc..
    */
    var pOutput;
    var strOptions = '';
    
    //Get the unique dialog name; so as to avoid overwriting existing dialog box.
    var strDlgName = (new Date()).getSeconds().toString();

    dialogWin.width = pIntWidth;
    dialogWin.height = pIntHeight;
	if(navigator.appName == 'Netscape')
    {
			pBlnShowScrollbar = 1;
	}
    if (pBlnShowScrollbar == 1)
        pStrShowScrollbar ="Yes";
    else
        pStrShowScrollbar ="No";

    //Decode the destination string
    pStrDestination = pStrDestination.replace(/&/g , '~');
    //Build the complete URL
    pStrURL = 'popup_main.aspx?Title=' + pStrTitle + '&Scrollbar=' + pStrShowScrollbar + '&Destination=' + pStrDestination 

    //Check for the browser type.
    if(navigator.appName == 'Netscape')
    {
        //Center form in Netscape
        dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width)/2);
        dialogWin.top =  window.screenY + ((window.outerHeight - dialogWin.height)/2);

        strOptions = strOptions + ' height='  + pIntHeight;
        strOptions = strOptions + ',width='   + pIntWidth;
        strOptions = strOptions + ',modal='   + 'yes';
        strOptions = strOptions + ',screenX=' + dialogWin.left;
        strOptions = strOptions + ',screenY=' + dialogWin.top;
        strOptions = strOptions + ',';

        dialogWin.returnedValue = '';
        dialogWin.win=window.open(pStrURL, strDlgName, strOptions);
        pOutput = dialogWin.returnedValue;
    }
    else
    {
        //Center form in IE
        //pIntHeight =  pIntHeight + pIntHeight * 0.1;
        //pIntWidth =  pIntWidth + pIntWidth * 0.005;
        
        dialogWin.left = (screen.width - dialogWin.width)/2;
        dialogWin.top = (screen.height - dialogWin.height)/2;

        strOptions = strOptions + 'dialogHeight: ' + pIntHeight + 'px;';
        strOptions = strOptions + 'dialogWidth: ' + pIntWidth +'px';
        strOptions = strOptions + 'center: no; ';
        strOptions = strOptions + 'help: No; ';
        strOptions = strOptions + 'resizable: No; ';
        strOptions = strOptions + 'status: No; ';
        strOptions = strOptions + 'left:' + dialogWin.left + '; ';
        strOptions = strOptions + 'top:' + dialogWin.top + '; ';
       // alert(pStrURL)
        pOutput = window.showModalDialog(pStrURL, strDlgName, strOptions);
    }    
    if (!pOutput) 
    {
        pOutput = vbNULL;
    }
    return pOutput;
}

//Set the return value for child window.
function mfpReturnToparent(pStrValue)
{
    
    if(navigator.appName == 'Netscape')
    {
        top.opener.dialogWin.returnedValue = pStrValue;        
    }
    else
    {
        window.returnValue = pStrValue;
    }
}
//opening model dailogue ends

function FormatGivenDate(aobjControl)
{
	var val = eval(aobjControl);
	var CurrentControl;
	CurrentControl = aobjControl; //document.getElementById(val.controltovalidate) ;
	var op=CurrentControl.value;
	//trim the value automatically
	CurrentControl.value = Trim(op);
	//incase data type is DATE - change the format automatically

	//if ((val.operator == "DataTypeCheck") && (val.type == "Date"))
	//{
		//incase 6 - format yeat first
		if (op.length==6)
		{
				var strVal = CurrentControl.value;
				var fL=strVal.lastIndexOf('/');
				if (fL == -1)
				{
					op = strVal.substring(0,2) + '/' + strVal.substring(2,4) + '/' + strVal.substring(4,6);
				}
				else
				{

					var yr=(strVal.substring(fL+1));
					yr = (parseInt(yr) + parseInt(2000)) - ((parseInt(yr) < 29) ? 0 : 100);
					op = strVal.substring(0,fL+1) + yr ;

				}
		}
		
		//Do autoformat only incase length is 8 chars
		if (op.length == 8)
		{
			if (isNaN(op)==false)
			{
				CurrentControl.value = op.substring(0,2) + '/' + op.substring(2,4) + '/' + op.substring(4,8);
			}
			else
			{	
				var strVal = op;
				var fL=strVal.lastIndexOf('/');
				var yr=(strVal.substring(fL+1));
				if (yr.length==2)
				{
					yr = (parseInt(yr) + parseInt(2000)) - ((parseInt(yr) < 29) ? 0 : 100);
				}

				var month=(strVal.substring(0,strVal.indexOf('/')));
				var dt=(strVal.substring(strVal.indexOf('/')+1,strVal.lastIndexOf('/')));

				if (month.length==1)
				{
					month="0"+month;
				}
				if (dt.length==1)
				{
					dt="0"+dt;
				}

				CurrentControl.value = month + "/" + dt + "/" + yr;
			}
		}
	//}
}

// function to handle enter key on all the forms
function Traversing(aParDefaultActiveElement)
{
	var strActiveElement='';
	
	// Help buttons are not taken care.
	// Need to take care when coding for help "?" Buttons
	
	if (aParDefaultActiveElement!='')
		strActiveElement=aParDefaultActiveElement;
	
	pLogoutFld = window.document.getElementById('Logout_imgLogOut');
	if(pLogoutFld != null)
	{
		if (ie4)
		{
			if  (window.document.activeElement.id=='Logout_imgLogOut')
				strActiveElement='Logout_imgLogOut';
		}
	}
	return HandleEnterKey(strActiveElement);				
}


function HandleEnterKey(aControlName)
{
	//Pass the control name to this function to which the enter key has to bindede
	//Also call this funciton on onkeydown event of Body tag
	
	var pShow;
	
	if (ie4)
	{
		if (event.keyCode == 13)
		{
			pShow=true;
		}
	}
	
	if (ns4)
	{
		if (e.which == 13)
		{
			pShow=false;
		}
	}
	if (pShow==true )
	{	
		var ControlObj = window.document.getElementById(aControlName);
		
		if (ControlObj == '[object]')
		{
			window.document.getElementById(aControlName).click();
			return false;
		}
		else
		{
			return false;
		}
	}
}
//end of handling the enter key