function SaveScrollPositions() {   
	document.forms[0].StaticPostBackScrollVerticalPosition.value = (navigator.appName == 'Netscape') ? document.pageYOffset : document.body.scrollTop;
	document.forms[0].StaticPostBackScrollHorizontalPosition.value = (navigator.appName == 'Netscape') ? document.pageXOffset : document.body.scrollLeft;
	setTimeout('SaveScrollPositions()', 10);
}

function SwapDivs(HideDiv, ShowDiv) {
	document.body.style.cursor = 'wait'
	var oHideDiv = document.getElementById(HideDiv);
	oHideDiv.style.cssText = 'display:none';
	var oShowDiv = document.getElementById(ShowDiv);
	oShowDiv.style.cssText = 'display:inline';
}

function Capitalize(txtVar) {
  MyText = trim(txtVar.value);
  txtVar.value = MyText.substr(0, 1).toUpperCase() + MyText.substr(1);
}

function CapitalizeAll(txtVar) {
  MyText = trim(txtVar.value);
  txtVar.value = MyText.substr(0).toUpperCase();
}

function CapitalizeEveryWord(txtVar) {
  MyText = trim(txtVar.value);
  var pattern = /(\w)(\w*)/; // a letter, and then one, none or more letters 
  var a = MyText.split(/\s+/g); // split the sentence into an array of words

    for (i = 0 ; i < a.length ; i ++ ) {
        var parts = a[i].match(pattern); // just a temp variable to store the fragments in.

        var firstLetter = parts[1].toUpperCase();
        var restOfWord = parts[2];

        a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on
    }
    
    txtVar.value = a.join(' '); // join it back together
}

function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 

// Added by ARRK - Geeta - 30-08-2004
function pagenum(tname, pagenum) {
	document.getElementById(tname + "_PageNum").value = pagenum;
	stdData.submit();
	return true;
}

// Added by ARRK - Geeta - 01-09-2004
function goDirect(fname, maxname) {
	var ele = document.getElementById(fname).value.toString();
	var max = document.getElementById(maxname).value.toString();
	if (ele > 0 ) {
		if (ele > max) {
			return showerror("Page number too large");
		} else {
			pagenum("ab", ele);
		}
	} else {
		if (ele=="")
			return showerror('Please enter a page number.');
		else
			return showerror('Invalid page number.');
	}
	return true;
}
function showerror(msg) {
	alert(msg);
	return false;
}
//Added by ARRK - Geeta - on 17 Nov 2004
function changeFocus(fname, nextval)
{
	var str;
	str = eval("document.forms[0]." + fname + "_" + nextval);
	
	
		if(event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 16 && event.keyCode != 37 && event.keyCode != 38 && event.keyCode != 39 && event.keyCode != 40 && event.keyCode != 46)
		{
			
			if (fname == "tAccountNumber" )	
			{
				nextval = nextval + 1;
				str = eval("document.forms[0]." + fname + "_" + nextval);
				str.focus();
				str.select();
			}
			 if (fname == "tSortCode" )
			{

				if(str.value.length == 2)
				{
					nextval = nextval + 1;
					str = eval("document.forms[0]." + fname + "_" + nextval);
					str.focus();
					str.select();
				}

			}
			 // Added by Amit for Cr 1868 on 5-Aug-05
			  if (fname == "iBRefrno" ) 
			{
			
				nextval = nextval + 1;
				str = eval("document.forms[0]." + fname + "_" + nextval);
				str.focus();
				str.select();
			}
			// till here
			//Added by Amit Arrk For Cr 10489 on 15-Sep-05

			if (fname == "tAccountNumberCR" )	
			{
				nextval = nextval + 1;
				str = eval("document.forms[0]." + fname + "_" + nextval);
				str.focus();
				str.select();
			}
			 if (fname == "tSortCodeCR" )
			{

				if(str.value.length == 2)
				{
					nextval = nextval + 1;
					str = eval("document.forms[0]." + fname + "_" + nextval);
					str.focus();
					str.select();
				}

			}
			// Added for CR 20999 by Amit on 2-May-06
			if (fname == "tAccountNumberDW" )	
			{
				nextval = nextval + 1;
				str = eval("document.forms[0]." + fname + "_" + nextval);
				str.focus();
				str.select();
			}
			//Till here for cr 20999
			//Till Here
		}
	
}
// till here
