
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) +String.fromCharCode(96)+String.fromCharCode(97)+String.fromCharCode(98)+String.fromCharCode(99)+String.fromCharCode(100)+String.fromCharCode(101)+String.fromCharCode(102)+String.fromCharCode(103)+String.fromCharCode(104)+String.fromCharCode(105);
	var lilKey=event.keyCode; 


	if(validKey.indexOf(String.fromCharCode(lilKey)) > -1)
	{
		event.returnValue=true;
	} else 
	{
	    alert("Number Only!");
		event.returnValue=false;
	}
	
	
}

///----------------------------------------------------------------

function HandleDecimalKeyDown(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) +String.fromCharCode(190) + String.fromCharCode(96)+String.fromCharCode(97)+String.fromCharCode(98)+String.fromCharCode(99)+String.fromCharCode(100)+String.fromCharCode(101)+String.fromCharCode(102)+String.fromCharCode(103)+String.fromCharCode(104)+String.fromCharCode(105)+String.fromCharCode(110);
	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++;
         }
      }
   
}


//---------------------------------------------------


function MoveListItem(ObjL,ObjR,MoveOper) {
var hObjS;
var hObjD;

if (MoveOper=="<"){
hObjS=ObjR;
hObjD=ObjL;

}else if (MoveOper==">"){

hObjS=ObjL;
hObjD=ObjR;

}

var lenD=hObjD.length;
var lenS = hObjS.length;



		for(var count = 0; count < lenS; count++) {
				if (hObjS.options[count] != null && hObjS.options[count].selected==true ) {
					hObjD.options[lenD] = new Option(hObjS.options[count].text,hObjS.options[count].value); 
					ObjS.options[count] = null;
					lenD++;
  				 }
		}


       
   
   
}

//--------------------------------------------------------------
function MoveSelected(hlstObj1,hlstObj2,opt)
{

	var lstObj1,lstObj2;
	if(opt=='L')
	{
		lstObj1 = hlstObj1;
		lstObj2 =hlstObj2;
	}
	else
	{
		lstObj2 = hlstObj1;
		lstObj1 =hlstObj2;
	}
	var i;
	var lobj = new Option();
	
	
	if(lstObj1!=null && lstObj2!=null)
	{
	
		if(lstObj1.length > 0)
		{					
			if(lstObj1.selectedIndex == -1)
			{
				alert("Please select atleast one Item");
				return;
			}
			else
			{					
					i = lstObj1.length;
					while(i!=0 )
					{	
						i = i -1;						
						lObj = new Option();
						if( (lstObj1.options[i]!=null) && (lstObj1.options[i].selected) )
						{
								lObj.text = lstObj1.options[i].text;
								lObj.value = lstObj1.options[i].value;
								lstObj1.remove(i);
								lstObj2.options.add(lObj);		
						}						
					}				
			}		
		}
	}
		
}
//--------------------------------------------
function CompareValues(Val1 , Val2){
if(Val1==Val2){
return true;
}else{
return false;
}
}
//-------------------------------------------
function IsEmpty(Val1){
if (Val1!=null && Val1!=""){
return true;
}else{
return false;
}
}

//------------------------------------------
function IsValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 


}
//-----------------------------------------------


	function CheckSelected( )
			{
			var frm = document.frmMain;
			
			for(i=0;i< frm.length;i++)
			{
				e=frm.elements[i];
				if (  e.type=='checkbox' && e.checked== true ){
					return true
					}
			}
			return false;
			}
			
///-----------------------------------------			

function SendRequest(reqType,msg){
	if (CheckSelected()==true){
		if(confirm(msg)){
			document.frmMain.TRAN.value = reqType;
			document.frmMain.submit();
		}
	}
}
