
function doNavigate(pstrWhere, pintTot)
{
  var strTmp;
  var intPg; 
  strTmp = document.frmMain.txtCurr.value;
  intPg = parseInt(strTmp);
  if (isNaN(intPg)) intPg = 1; 
  if ((pstrWhere == 'F' || pstrWhere == 'P') && intPg == 1)
  {
    alert("You are already viewing first page!");
    return;
  }
  else if ((pstrWhere == 'N' || pstrWhere == 'L') && intPg == pintTot)
  {
    alert("You are already viewing last page!");
    return;
  }
  if (pstrWhere == 'F')
    intPg = 1;
  else if (pstrWhere == 'P')
    intPg = intPg - 1;
  else if (pstrWhere == 'N')
    intPg = intPg + 1;
  else if (pstrWhere == 'L')
    intPg = pintTot; 
  if (intPg < 1) intPg = 1;
  if (intPg > pintTot) intPg = pintTot;
  document.frmMain.txtCurr.value = intPg;
  document.frmMain.submit();
}



function doSort(pstrFld, pstrOrd)
{
  document.frmMain.txtSortCol.value = pstrFld;
  document.frmMain.txtSortAsc.value = pstrOrd;
  document.frmMain.submit();
}



function CheckAll( checkAllBox )
	{
			var frm = document.frmMain;
			var actVar = checkAllBox.checked ;
			for(i=0;i< frm.length;i++)
			{
				e=frm.elements[i];
				if ( e.type=='checkbox' && e.name.indexOf("chkmsg") != -1 )
				e.checked= actVar ;
			}
	}
	
	
function HandleKeyDown(obj) {
	var validKey ="1234567890" + String.fromCharCode(8)+String.fromCharCode(9)+String.fromCharCode(13)+String.fromCharCode(33)+String.fromCharCode(34)+String.fromCharCode(35)+String.fromCharCode(36)+String.fromCharCode(37)+String.fromCharCode(38)+String.fromCharCode(39)+String.fromCharCode(40)+String.fromCharCode(46)+String.fromCharCode(27);
	var lilKey=event.keyCode; 


	if(validKey.indexOf(String.fromCharCode(lilKey)) > -1)
	{
		event.returnValue=true;
	} else 
	{
	    alert("Number Only!");
		event.returnValue=false;
	}
	
	
}
	
function FormatMobileNumber(Obj) {
	var MobileString=Obj.value;
	var flag=false;
	var i=0;
		for(i=0 ; i< MobileString.length; ++i){
		   if(MobileString.charAt(i)=='0'){
		   }else{
			break;			
		   }
		}
		Obj.value=MobileString.substring(i,MobileString.length);
	 return true;
}




function DeleteFromItemList(ObjS) {

var len = ObjS.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((ObjS.options[i] != null) && (ObjS.options[i].selected == true)) {
ObjS.options[i] = null;
      }
   }
}


function AddItemToList(ObjS,ObjV) {

var len = ObjS.length;

if ((ObjV != null) && (ObjV!='')) {
//Check if this value already exist in the destList or not
//if not then add it otherwise do not add it.
var found = false;
for(var count = 0; count < len; count++) {
if (ObjS.options[count] != null) {
if (ObjS.options[count].text == ObjV) {
found = true;
break;
      }
   }
}
if (found != true) {
ObjS.options[len] = new Option(ObjV,ObjV); 
len++;
         }
      }
   
}

