//-----------------------------------------------------------------//
//	THIS FUNCTION IS FOR SWITCHING FOCUS	
//-----------------------------------------------------------------//

/*
To focus on the next element considering the maximum length/enter key press /tab key press event of the form element starts here
thisForm=Name of the form containing the concerned element
thisElement=this i.e. the form element using this function
thisEvent=event, here it's onkeypress event
MaxLngth=max length set for the form element
*/

function nextFocusWithMaxLength(thisForm,thisElement,thisEvent,MaxLngth)
{
var kCode = (navigator.appName == "Netscape") ? thisEvent.which : thisEvent.keyCode
txtVal=thisElement.value;
txtName=thisElement.name;
frmName=thisForm.name;
tLength=parseInt(thisElement.value.length)
frmLength=parseInt(document.forms.length);
for(p=0;p < frmLength;p++)
{
if(document.forms[p].name==frmName)
{
elemntLength=parseInt(document.forms[p].elements.length)
	for(i=0;i<elemntLength;i++)
	{
		if(document.forms[p].elements[i].name == txtName)
		{
			for(k=0;k < tLength;k++)
			{
			j=i+1;
				if( (kCode !=8) && (kCode !=46))
				{
						nxtElmnt=document.forms[p].elements[j].name;
						if( (thisElement.value.length == MaxLngth) || (kCode ==9) || (kCode ==13))
						{
							document.forms[p][nxtElmnt].focus();
							break;
						}
				}
			}
		}
	}
}
}
}
//To focus on the next element considering the maximum length/enter key press /tab key press event of the form element ends



//-->

