﻿// JScript File

function AlertMessage(CtrlValue, ErrNo, MinValue, MaxValue)
{
	var ErrStrg=new Array();
	ErrStrg[0]=CtrlValue;
	ErrStrg[1]=CtrlValue + ' ' + "should not be blank";
	ErrStrg[2]=CtrlValue + ' ' + "already exist, Duplicate not allowed";
	ErrStrg[3]=CtrlValue + ' ' + "should be between " + MinValue + " and " + MaxValue + "";
	ErrStrg[4]=CtrlValue + ' ' + "should be less than " + MinValue + "";
	ErrStrg[5]=CtrlValue + ' ' + "should be greater than " + MaxValue + "";
	ErrStrg[6]=CtrlValue + ' ' + "should be selected";	
	ErrStrg[7]="Invalid" + ' ' + CtrlValue;
	ErrStrg[8]=CtrlValue + ' ' + "record not found";
	ErrStrg[9]=CtrlValue + ' ' + ", Delete not allowed";
	ErrStrg[10]=CtrlValue + ' ' + ", Edit not allowed";
	ErrStrg[11]="Delete not allowed"; // Grid
	ErrStrg[12]="Edit not allowed"; //Grid
	ErrStrg[13]="Selected record does not exist, it may be already deleted"; // Grid
	ErrStrg[14]="Selected record does not exist, it may be already deleted, can not edit "; //Grid
	
	ErrStrg[15]=CtrlValue + ' ' + "should be less or equal to " + MinValue + "";
	ErrStrg[16]=CtrlValue + ' ' + "should be greater or equal to " + MaxValue + "";
	alert(ErrStrg[ErrNo]);
}

function SetFocus(c){
	document.getElementById(c).focus();
    return true;
}

 


function CheckNull(str)
{
	var s1=new String();
	var i,NoOfChars=0;
	s1=str;		    
	for(i=0;i<s1.length;i++)
	{
		if(s1.charAt(i)!=' ') 
			NoOfChars=NoOfChars+1;	
	}
	if(NoOfChars>0) 
		return true;
	return false;		
}

function OpenPopup(Path,FormName,Height,Width){
           var strURL;
           var strFeatures;
           strURL = Path + "?formname=" + FormName;
           strFeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=' + Height + ',width=' + Width + ',top=200px,left=300px';
           //window.showModalDialog(strURL,"","dialogHeight: "+Height+"px; dialogWidth: "+Width+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
           window.open(strURL,'Settings',strFeatures);
           return false;
           }
function OpenHelpPopup(Path,FormName){
            var strURL;
           var strFeatures;
           strURL = Path + "?formname=" + FormName;
           strFeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,height=400,width=600,top=100px,left=200px';
           window.open(strURL,'Settings',strFeatures);
           return false;
           }


function PressNumberInput(CurValue,Precision,Scale){
  var key;
  var mozilla=document.getElementById && !document.all
 var ie=document.all
   if (ie){
   
   key = event.keyCode;

       
	if(!(key >= 48 && key <= 57) && (key!=46))
    	{
		event.keyCode = 0;
		return true;
		}
     var a = new String();
	a = CurValue.value;
    if (a.length == parseInt(Precision))
	{
		event.keyCode = 0;
	}
	
	if (a.indexOf('.') >= 0 && key==46)
	{
		event.keyCode = 0;
	}
	
    if (a.indexOf('.')>=0)
    {
    var a=a.split(".");
    
    if (a[1].length>parseInt(Scale)-1 )
        {
        	event.keyCode = 0;
			return false;
        }
     }

   
   }
	     	return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


