<!--
var Error=""
var globalflag = 0; //0 if error not occured or 1 if error already occured (in list of jscript function calls) for tracking focus field


//Function for Showing Errors
function showError()
{
	globalflag = 0;
	if(Error!="")
	{
	 alert(Error);
	 Error=""
	 return false; 
	}
	Error=""
	return true;
}

function notnull(obj,msg)
{
	var value = obj.value;
	if(value=="")
	{
		Error = Error +msg+" must be entered \n";	
		if(globalflag == 0)
		{
 			obj.focus();
			globalflag=1;
		}
		return false;
	}
	return true;
}

//Function for checking whether the field is null
function notnull(form,field,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';
	var value = eval(str);
	if(value=="")
	{
		Error = Error +msg+" must be entered \n";	
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		}
		return false;
	}
	return true;
}


// function for checking whether one of the two field is null
function twonotnull(form,field1,field2,msg)
{
	var str1= 'document.'+form+ '.'+field1+'.value';
	var value1 = eval(str1);
	var str2= 'document.'+form+ '.'+field2+'.value';
	var value2 = eval(str2);

	if((value1=="" || value1=="0") && (value2 == ""||value2 == "0"))
	{
		Error = Error +msg+" must be entered \n";	
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field1 + '.focus()';
			eval(focusField);
			globalflag=1;
		}
		return false;
	}
	return true;

}

//Function for checking whether the field is null zero not allowed
function notnullnotzero(form,field,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';
	var value = eval(str);
	if(value=="" || value=="0")
	{
		Error = Error +msg+" must be entered \n";	
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		}
		return false;
	}
	return true;
}

//Function for focusing first field of form
function focus(form)
{
	var str = 'document.'+form+'.elements.length';


	var len = eval(str);
	for(var i=0; i<len; i++)
	{
		var strtype = 'document.'+form+'.elements[i].type';
		var focustype = eval(strtype);		
		var strdisable = 'document.'+form+'.elements[i].disabled';
		var focusdisable = eval(strdisable);

		if(focustype == 'hidden' || focusdisable == true) {}		
		else
		{
			var strfocus = 'document.'+form+'.elements[i].focus()';
			eval(strfocus);
			break;
		}	} 
}


//function for checking password validations
function chpass(form,field,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';
	var pass=eval(str);
	if(pass.length<8)
	{
		Error = Error +"Length of " +msg+" should be atleast 8\n";
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		}
      }
}


//function for indian pin validation 6 digits
function inpin(form,field,msg)
{
	var str= 'document.'+form+'.'+field+'.value';
	var inpin=eval(str);

	if(inpin=="")
	{
	   return;
	}

	if(inpin.length < 5 || inpin.length > 7)
	{

		Error = Error +"Length of " +msg+" should be between 5 and 7\n";
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		}
	}
	else if(!isNumber(inpin,0))
	{
		Error = Error +msg+" should be Numeric\n";
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
eval(focusField);
			globalflag=1;
		}
	}
}
//function for us pin validation 5 digits
function uspin(form,field,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';
	var uspin=eval(str);
	
	if(uspin=="")
	{
	   return;
	}

	if(uspin.length!=5)
	{
	 Error = Error +"Length of "+msg+" should be 5\n";
	 if(globalflag == 0)
	 {
 		var focusField =	'document.' +form+ '.' +field+ '.focus()';
		eval(focusField);
		globalflag=1;
	 }
      }
	else if(!isNumber(uspin,0))
	{
	 Error = Error +msg+" should be Numeric\n";
	 if(globalflag == 0)
	 {
 		var focusField =	'document.' +form+ '.' +field+ '.focus()';
		globalflag=1;
	 }
	}
}

//function for Checking number & their decimals ----i.e. number with 2 decimal plcaces,3 decimal places

function check_Number(form,field,dec,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';

	var checknumber=eval(str);
		
	var dot =checknumber.indexOf(".");
      var len =checknumber.length;
      var flag =len - dot;
	
	if(!isNumber(checknumber,dec))
	{
	 Error = Error +msg+"\n";
	 if(globalflag == 0)
	 {
 		var focusField =	'document.' +form+ '.' +field+ '.focus()';
		eval(focusField);
		globalflag=1;
	 }
       return false;
	}		

	else if(dec==1)
	{
		if(flag != 2)
		{
		 Error = Error +msg+"\n";
		 if(globalflag == 0)
		 {
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		 }
		 return false;
		}
	}
	else if(dec==2)
	{
		 if(flag != 3 && flag!=2)
		 {
		  Error = Error +msg+"\n";
		 if(globalflag == 0)
		 {
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		 }
		 return false;
		 }
	}
	else if(dec==3)
	{
		 if(flag != 4 && flag!=3 && flag!=2)
		 { 
		  Error = Error +msg+"\n";
		 if(globalflag == 0)
		 {
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		 }
		 return false;
	       }
	}
	else if(dec==4)
	{
		 if(flag != 5 && flag!=4 && flag!=3 && flag!=2)
	 {
		  Error = Error +msg+"\n";
		 if(globalflag == 0)
		 {
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		 }
		 return false;
		 }
	}
    return true;
	
}


//Email validation

function check_email(form,field,msg)
{
	var str= 'document.'+form+'.'+field+'.value';
	var email=eval(str);
	if (email=="") 
	{
		return;
	}
/*
	var at=email.indexOf("@");
	var dot=email.indexOf(".");
	var a=new Array();
	a[0]='.';
	a[1]='@';
	if(at==-1 || dot==-1)
	{
	 Error=Error+"Invalid " +msg+"\n";
	 if(globalflag == 0)
	 {
 		var focusField =	'document.' +form+ '.' +field+ '.focus()';
		eval(focusField);
		globalflag=1;
	 }
	}
	else if(!isalphanum(email,a))
	{
		Error = Error +"Invalid " +msg+"\n";
		if(globalflag == 0)
		 {
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		 }
	}
*/

}



// Date comparison, ( field is in the Grid.. or html table)...
function compDateInGrid(field1,field2,msg1,msg2)
{
	var str1= 'document.'+ field1 + '.value';
	var fdate=eval(str1);

	var str2= 'document.' + field2 + '.value';
	var todate=eval(str2);

	var fday  = fdate.substring(0,2);
	var fmonth = fdate.substring(3,5);	
	var fyear = fdate.substring(6,10);

	var today  = todate.substring(0,2);
	var tomonth = todate.substring(3,5);	
	var toyear = todate.substring(6,10);

	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date(toyear,tomonth-1,today);
  
	if(fdate != "" && todate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear()){}
		else if( (date1.getTime() < date2.getTime()) )
		{
 		   Error=Error+msg1+" should be less than " +msg2+"\n";
		   if(globalflag == 0)
		   {
 			var focusField ='document.' + field1 + '.focus()';
			eval(focusField);
			globalflag=1;
		   }
	           return false;
		}
	}
	return true;
}


//Date comparison
function compDate(form,field1,field2,msg1,msg2)
{

	var str1= 'document.' +form+ '.' +field1+ '.value';
	var fdate=eval(str1);

	var str2= 'document.' +form+ '.' +field2+ '.value';
	var todate=eval(str2);

	alert(fdate);
	alert(todate);

	var fday  = fdate.substring(0,2);
	var fmonth = fdate.substring(3,5);	
        var fyear = fdate.substring(6,10);

	var today  = todate.substring(0,2);
	var tomonth = todate.substring(3,5);	
	var toyear = todate.substring(6,10);

	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date(toyear,tomonth-1,today);

	if(fdate != "" && todate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear()){}
		else if( !(date1.getTime() < date2.getTime()) )
		{
		   // Error = Error + msg1+" should be less than " +msg2+"\n";
		   Error = Error + msg2 + " should be greater than or equals to " + msg1 + "\n";
	           return false;
		   if(globalflag == 0)
		   {
 			var focusField ='document.' +form+ '.' +field1+ '.focus()';
			eval(focusField);
			globalflag=1;
		   }
		}
	}
}

function compDateGrid(form,idx,fdate,todate,msg1,msg2,format)
{


	var fday  = fdate.substring(0,2);
	var fmonth = fdate.substring(3,5);	
              var fyear = fdate.substring(6,10);

	var today  = todate.substring(0,2);
	var tomonth = todate.substring(3,5);	
	var toyear = todate.substring(6,10);

	var fday = 0;
	var fmonth = 0;
	var fyear = 0;

	
	var format = eval('document.'+form+'.'+format+'.value');
	if(format == null){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);
		today  = todate.substring(0,2);
		tomonth = todate.substring(3,5);	
	              toyear = todate.substring(6,10);

	}
	else if(format.substring(0,1) == 'd'){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);
		today  = todate.substring(0,2);
		tomonth = todate.substring(3,5);	
	              toyear = todate.substring(6,10);

	}
	else if(format.substring(0,1) == 'M'){
		fday  = fdate.substring(3,5);
		fmonth = fdate.substring(0,2);	
	              fyear = fdate.substring(6,10);
		today  = todate.substring(3,5);
		tomonth = todate.substring(0,2);	
	              toyear = todate.substring(6,10);

	}


	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date(toyear,tomonth-1,today);

	if(fdate != "" && todate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear())
		{
		}
		else if( !(date1.getTime() < date2.getTime()) )
		{
		   Error = Error + msg2 + " should be greater than or equals to " + msg1 + " at grid line " + idx + " \n";
	           return false;
		}
	}
}


//Compare date given should  be less than current date
function compCurrentDate(form,date,msg)
{

	var str= 'document.' +form+ '.' +date+ '.value';
	var fdate=eval(str);


	var fday  = fdate.substring(0,2);
	var fmonth = fdate.substring(3,5);	
	var fyear = fdate.substring(6,10);


	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date();

	if(fdate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear()){}
		else if( !(date1.getTime() < date2.getTime()) )
		{
		Error=Error+ msg +" cannot be greater than current date\n";
	      return false;
	      if(globalflag == 0)
	      {
 			var focusField =	'document.' +form+ '.' +date+ '.focus()';
			eval(focusField);
			globalflag=1;
	      }
		}
	}
	
	return true;
}




//Null dates valid but wrong date not valid
function isNullDate(form,dateval,msg)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);
	if(date.length != 0)
	{
	  if(!checkDate(form,dateval,msg))
	  {
		alert("Invalid " +msg);
		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
		Error= msg +  " must be entered";
	  	return false;
          }
	}
	return true;
}




//Date Validation - null date invalid

function checkDate(form,dateval,msg)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);
	var len = date.length;
	
	if( len == 0)
        {
  	   Error = Error + msg + " must be entered\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	}
	

        if(len != 10)
        {
           Error=Error+"Invalid " +msg+ ". Valid format of date is dd/mm/yyyy.\n";    
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	}


	var char1 = date.charAt(2);
	var char2 = date.charAt(5);

	if((char1!="-" && char1!="/") || (char2!="-" && char2!="/"))
	{
           Error=Error+"Invalid " +msg+ ". Valid format of date is dd/mm/yyyy.\n";          
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
	}
	

	var day  = date.substring(0,2);
        var month = date.substring(3,5);	
        var year = date.substring(6,10);
	

	if(isNaN(day) || isNaN(month) || isNaN(year))
	{
           Error=Error+"Invalid " +msg+ ". Valid format of date is dd/mm/yyyy.\n";          
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+" is having invalid month.\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}

	if(day<1 || day>31)
	{
  	   Error=Error+msg+" is having invalid day.\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}

	switch(month)
	{
		case '02': 
			  //if(!(year%400==0 || (year%4==0 && year%100!=0)))
			  if(!(year%4==0))
			  {
				if(day>28)
				{
			  	   Error=Error + "Invalid " + msg + ", as entered date isn't fall in leap year.\nSo maximum days in Feb is 28.\n";
				   return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				}
			  }
			  if(day>29)
			  {
			  	 Error=Error + "Invalid " + msg+ ", as maximum days in Feb for leap year is 29.\n";
			   	 if(globalflag == 0)
				 {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				 }
				 return false;
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':
			  if(day==31)
			  {
			           Error=Error+"Invalid " +msg+"\n";
			   	   if(globalflag == 0)
				   {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				   return false;
                          }
			  break;
	}		    
	return true;
}



function checkDateGrid(form,idx,date,msg,format)
{
	var len = date.length;
	
	if( len == 0)
        {
  	   Error = Error + msg + " is must at grid line " + idx + ".\n";
	   return false;
  	}
	

        if(len != 10)
        {
           Error=Error+"Invalid " +msg+ "at grid line " + idx + ". Valid format of date is dd/mm/yyyy.\n";    
	   return false;
  	}


	var char1 = date.charAt(2);
	var char2 = date.charAt(5);

        var day  = date.substring(0,2);
        var month = date.substring(3,5);	
        var year = date.substring(6,10);
	var valchar;



	if(format == null){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = '/';
	}
	else{
	var format = eval('document.'+form+'.'+format+'.value');
              if(format == 'dd-MM-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM-dd-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
              else if(format == 'dd/MM/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM/dd/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	}

	
	if((char1 != valchar) || (char2!=valchar))
	{
           Error=Error+"Invalid " +msg+ "at grid line " + idx + ". Valid format of date is dd/mm/yyyy.\n";    
	   return false;
	}
	

	

	if(isNaN(day) || isNaN(month) || isNaN(year))
	{
           Error=Error+"Invalid " +msg+ "at grid line " + idx + ". Valid format of date is dd/mm/yyyy.\n";    
	   return false;	
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+" at grid line " + idx + " is having invalid month.\n";
	   return false;	
	}

	if(day<1 || day>31)
	{
  	   Error=Error+msg+" at grid line " + idx + " is having invalid day.\n";
	   return false;	
	}

	switch(month)
	{
		case '02': 
			  //if(!(year%400==0 || (year%4==0 && year%100!=0)))
			  if(!(year%4==0))
			  {
				if(day>28)
				{
			  	   Error=Error + "Invalid " + msg + " at grid line " + idx + ", as entered date isn't fall in leap year.\nSo maximum days in Feb is 28.\n";
				   return false;
				}
			  }
			  if(day>29)
			  {
			  	 Error=Error + "Invalid " + msg+ " at grid line " + idx + ", as maximum days in Feb for leap year is 29.\n";
				 return false;
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':
			  if(day==31)
			  {
				   Error=Error+msg+" at grid line " + idx + " is having invalid day.\n";
				   return false;
                          }
			  break;
	}		    
	return true;
}





//MM-DD >>Date Validation - null date valid || function checkDate() is suitably modified

function checkMMDD(form,dateval,msg)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);

	var len = date.length;

if (len!=0) {
        if(len != 5)
	  {
  	   Error=Error+"Invalid " +msg+"\n";
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	  }


	var char1 = date.charAt(2);
	var char2 = date.charAt(2);

	if((char1!="-" && char1!="/") || (char2!="-" && char2!="/"))
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}
	

	var day  = date.substring(0,2);
      var month = date.substring(3,5);	

	

	if(isNaN(day) || isNaN(month))
	{
   	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	if(day<1 || day>31)
	{
    	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	switch(month)
	{
		case '02': 
			  if(day>29)
			  {
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':if(day==31)
			    {
				Error=Error+"Invalid " +msg+"\n";
				return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			    }
			    break;
	}		    

 }
return true;

}



//MM-YYYY >>Date Validation - null date invalid..  function checkDate() is suitably modified
function checkMMYYYY(form,dateval,msg)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);

	var len = date.length;

        if(len != 7)
	  {
  	   Error=Error+"Invalid " +msg+"\n";
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	  }


	
	var char2 = date.charAt(2);

	if((char2!="-" && char2!="/"))
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}
	


      var month = date.substring(0,2);	
      var year = date.substring(3,7);
	

	if(isNaN(month) || isNaN(year))
	{
   	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

}


//same as isNullDate and checkDate resp.. but for detail rows
// dateval >> takes the element's value directly..
function isNullDatedetail(form,dateval,msg)
{
	var str1= dateval+ '.value';
	var date=eval(str1);
	
	if(date.length != 0)
	{
	  checkDatedetail(form,dateval,msg);
	}
	return true;
}
//same as isNullDate and checkDate resp.. but for detail rows
// dateval >> takes the element's value directly..
//Date Validation - null date invalid
function checkDatedetail(form,dateval,msg)
{
	var str1= dateval+ '.value';
	var date=eval(str1);


	var len = date.length;

        if(len != 10)
	  {
  	   Error=Error+"Invalid " +msg+"\n";
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	  }


	var char1 = date.charAt(2);
	var char2 = date.charAt(5);

	if((char1!="-" && char1!="/") || (char2!="-" && char2!="/"))
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}
	

	var day  = date.substring(0,2);
      var month = date.substring(3,5);	
      var year = date.substring(6,10);
	

	if(isNaN(day) || isNaN(month) || isNaN(year))
	{
   	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	if(day<1 || day>31)
	{
    	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	switch(month)
	{
		case '02': 
			  if(day>29)
			  {
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			  }
			  else if(!(year%400==0 || (year%4==0 && year%100!=0)))
			  {
				if(day>28)
				{
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				}
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':if(day==31)
			    {
				Error=Error+"Invalid " +msg+"\n";
				return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			    }
			    break;
	}		    

}



//same as checkMMDD().. but for detail rows
// dateval >> takes the element's value directly..
function checkMMDDdetail(form,dateval,msg)
{
	var str1= dateval+ '.value';
	var date=eval(str1);

	var len = date.length;

if (len!=0) {
        if(len != 5)
	  {
  	   Error=Error+"Invalid " +msg+"\n";
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	  }


	var char1 = date.charAt(2);
	var char2 = date.charAt(2);

	if((char1!="-" && char1!="/") || (char2!="-" && char2!="/"))
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}
	

	var day  = date.substring(0,2);
      var month = date.substring(3,5);	

	

	if(isNaN(day) || isNaN(month))
	{
   	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	if(day<1 || day>31)
	{
    	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	switch(month)
	{
		case '02': 
			  if(day>29)
			  {
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':if(day==31)
			    {
				Error=Error+"Invalid " +msg+"\n";
				return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			    }
			    break;
	}		    

 }
return true;

}





function groupOrClient(form,client,group,msgclient,msggroup)
{
 var str1= 'document.'+form+ '.'+client+'.value'; 
 var str2= 'document.'+form+ '.'+group+'.value'; 
 
 if(eval(str1)!=0 && eval(str2)!=0)
 {
  Error=Error + "Both "+msgclient+ " and "+msggroup+ " can not be queried together\n";  
 }
}



//function for setting initial time - current
function setTime(form,hour,minute,ampm)
{
  var now=new Date();
  var hours=now.getHours();
  var minutes=now.getMinutes();
  var ampms="";
  if(hours>=12)
  {
    hours-=12;
    ampms="pm";
  }
  else ampms="am";

  hours= (hours==12) ? 0 : hours;
  
  if(minutes<10)minutes="0"+minutes;
  
  if(hours<10)hours="0"+hours;
  

	var strhour = 'document.'+form+ '.' +hour +'.value="' +hours + '"';
	eval(strhour);	
	var strminute = 'document.'+form+ '.' +minute+'.value="' +minutes+ '"';	
	eval(strminute);
	var strampm = 'document.'+form+ '.' +ampm+'.value="' +ampms+ '"';
	eval(strampm);
}

//function for checking whether passed val is number or not ....if dec = 0 number without decimal eles number with decimal

function isNumber(checknumber,dec,msg)
{
	if(checknumber=="")
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
	}
	var len=checknumber.length;
	
	for(var i=0;i<len;i++)
	{
		var thechar = checknumber.substring(i,i+1);
		if(dec!=0)
		{
			if(i==1 && checknumber.substring(i-1,i)=="0" && thechar!=".")return false;
			if((thechar<"0" || thechar > "9") && thechar!=".")  
			{
			  Error=Error+"Invalid " +msg+"\n";
			  return false;
			}
		}
		else
		{
			if(thechar<"0" || thechar > "9")  
			{
			 Error=Error+"Invalid " +msg+"\n";
			 return false;
			}
		}

	}
	return true;
}	

//same as isNumber() but allows null..
function isnullNumber(checknumber,dec,msg)
{

 if(checknumber!="") {
	var len=checknumber.length;
	
	for(var i=0;i<len;i++)
	{
		var thechar = checknumber.substring(i,i+1);
		if(dec!=0)
		{
			if(i==1 && checknumber.substring(i-1,i)=="0" && thechar!=".")return false;
			if((thechar<"0" || thechar > "9") && thechar!=".")  
			{
			  Error=Error+"Invalid " +msg+"\n";
			  return false;
			}
		}
		else
		{
			if(thechar<"0" || thechar > "9")  
			{
			 Error=Error+"Invalid " +msg+"\n";
			 return false;
			}
		}

	}
		return true;
   }
	return true;
}			

		
			
//function for checking param is alphanum
		
function isalphanum(checkalphanum,a)
{
	var flag=0;
	if(checkalphanum=="")
	{
		return false;
	}
	var len=checkalphanum.length;
	
	for(var i=0;i<len;i++)
	{
		var thechar = checkalphanum.substring(i,i+1);
		
			if(!( (thechar>="0" && thechar <= "9") || (thechar>="a" && thechar<="z") || (thechar>="A" && thechar<="Z"))) 
			{
			 	for(var j=0;j<a.length;j++)
				{
					if(a[j]==thechar)flag=1;						
				}
				if(flag!=1)return false;
				flag=0;	
			}
	}
	return true;
}			
 
function truncateText(text,msg) {
var len= eval('document.forms[0].' +text+ '.value.length');
    if (len>249) {
        Error=Error+msg+" should contains less than 250 alphaNumerics\n";
	var temp=eval('document.forms[0].'+text+'.value');
		
        }	         

      
}



function checkMinLength(form,field,minLen,msg) //Function to check that length not less then minLen
{
  var str1= 'document.' + form + '.' + field + '.value';
  var str=eval(str1);
  var len=str.length;
  if(len<minLen)
  {
   Error=Error+"Minimun Length of "+msg+ " should be "+ minLen +"\n";
   return false;
   if(globalflag == 0)
   {
	var focusField =	'document.' +form+ '.' +field+ '.focus()';
	eval(focusField);
	globalflag=1;
   }
  }
  return true;
}

function checkMaxLength(str,field,maxLen,msg) //Function to check that length not greater than maxLen
{
  var len=str.length;
  if(len>maxLen)
  {
   Error = Error +msg +"\n";
   if(globalflag == 0)
   {
	var focusField =	'document.' +form+ '.' +field+ '.focus()';
	eval(focusField);
	globalflag=1;
   }
   return false;
  }
  return true;
}

//Setting Initial Date

function setDate(form,field)
{
	var now=new Date();
	var strday = now.getDate();
	if(strday < 10)strday="0"+strday;
	var strmonth = now.getMonth()+1;	
	if(strmonth < 10)strmonth="0"+strmonth;
	var stryear = now.getYear();		
	var strdate='document.'+form+ '.' +field +'.value="'+strday+ '-' +strmonth+ '-' + stryear+'"';	
	eval(strdate);	
}

function checkTime(form,hour,minute,ampm)
{
    var str1 = "document."+form+"."+hour+".value";
    var str2 = "document."+form+"."+minute+".value";
    var str3 = "document."+form+"."+ampm+".value";

    var hour = eval(str1);
    var minute = eval(str2);
    var ampm = eval(str3);

    if((hour == "" && minute == "" && ampm == "") || (hour != "" && minute != "" && ampm != ""))
    {
    }
    else
    {
	Error=Error+"Invalid Time\n";
	return false;
    }
}


function optionalDate(form,field1,field2,msg1,msg2)
{
   var str1 = "document."+form+"."+field1+".value";
   var str2 = "document."+form+"."+field2+".value";

   var date1 = eval(str1);
   var date2 = eval(str2);

   if(date1 == "" && date2 == "")
   {
	Error=Error+"Both "+msg1+ " and "+ msg2 +" must be entered\n";
	return false;
   }
   else
   {
	if(isNullDate(form,field1,'From Date') && isNullDate(form,field2,'To Date'))
	{
		return true;
	}
	else
	{
		Error=Error+"Invalid Date\n";
		return false;
	}
   }
}


/* new method exists with more no of argu so this never called     
function PickListCallClient(form,field)
{ 
   var field2 = null ;
   //alert( " PickListCallClient(form,field) ");
   PickListCallClient(form,field,field2 ) ;
  
}
*/

  
//Changes
function PickListCallClient(form,field,field2)
{ 
  //alert( " PickListCallClient(form,field,field2) ");
  var clientscope = "C";
  
  PickListCallClientWithModelOption(form,field, clientscope , field2 );

}

/* new method exists with more no of argu so this never called     
function PickListCallClientWithModelOption(form, field , clientscope )
{ 
  //alert( " PickListCallClientWithModelOption (form, field , clientscope ) " );
  var field2 = null ;
  PickListCallClientWithModelOption(form, field , clientscope , field2 );
}
*/

function PickListCallClientWithModelOption(form, field , clientscope , field2  )
{ 

  //alert( " PickListCallClientWithModelOption (form, field , clientscope , field2  ) " );

  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListClient.jsp?queryField=" + queryField + 
	    "&form=" + form + 
        "&clientscope=" + clientscope +             
	    "&field=" + field +
	    "&field2=" + field2 + "#" + queryField.substring(0,3) ;

  //alert(" ---> url " + url );

  window.open(url,"ClientList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
  
}

//Changes
function PickListCallMenu(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListMenu.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#" + queryField.substring(0,3)
  window.open(url,"MenuList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}
    
function PickListCallAction(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListAction.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#" + queryField.substring(0,3)
  window.open(url,"ActionList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}

function PickListCallBean(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListBean.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#" + queryField.substring(0,3)
  window.open(url,"BeanList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


// this function created by Tejal and yet not used anywhere ...
// ------------------07.09.02
function PickListCallGroup1(form,field,field2)
{ 
  str1="document." + form + "." + field + ".value";
  var queryField=eval(str1);
  //alert("Welcome...");
 var url = "protected/PickListGroup.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "&field2=" + field2 + "#" + queryField.substring(0,3)
 window.open(url,"GroupList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


//Changes
function PickListCallGroup(form,field)
{ 

  var groupscope = "G";
  
  //alert( " old PickListCallGroup called " );
  PickListCallGroupWithModelOption(form,field, groupscope );
 

}

function PickListCallGroupWithModelOption(form,field,groupscope)
{ 

  //alert( " new PickListCallGroupWithModelOption with groupscope arg called , groupscope = " + groupscope );

  
  str1="document." + form + "." + field +".value";
  
  var queryField=eval(str1);
  var url = "protected/PickListGroup.jsp?queryField=" + queryField + 
            "&form=" + form + 
            "&groupscope=" + groupscope +             
            "&field=" + field + "#" + queryField.substring(0,3) ; 


  //alert(" ---> url " + url );
            
  window.open(url,"GroupList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
  
}


/*
function PickListgroup_m(value)
{
 window.opener.document.forms[0].groupId.value = value;
 document.location.href = window.opener.document.forms[0];
 window.close();
}
*/

/* (Without symtype) */
function PickListCallSymbol(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListSymbol.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#"  +"#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}



function PickListSymbolCall(form,index)
{ 
  str1="document." + form + "." + field +".value";
  var l = document.queryRatesForm.elements.length;  
  var queryField=eval("document.queryRatesForm.elements.item(index).value");	
  var field = document.queryRatesForm.elements.item(index).name;
  var url = "protected/PickListSymbol.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");

}

function reportLabelPickList(form,category,index,index2)
{ 
  str1="document." + form + "." + field +".value";
  var l = document.masterFieldForm.elements.length;  
  var queryField=eval("document.masterFieldForm.elements.item(index).value");	
  var field = document.masterFieldForm.elements.item(index).name;
  var field2 = document.masterFieldForm.elements.item(index2).name;
  var catvalue = document.masterFieldForm.elements.item(category).value;
//  alert("field : "+field+" field2 : "+field2+" category : "+catvalue);
  var url = "protected/PickListLabel.jsp?queryField=" + queryField + "&form=" + form +  "&category=" + catvalue +"&field2=" + field2 +"&field=" + field + "#" + queryField.substring(0,3)
  window.open(url,"Labels","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");

}



function MakeString(idx)
{
  var frmname = document.forms.item(0).elements.name;
  return (frmname +".elements.item("+ idx + ")");
}

//Changes
function PickListCallSymbol(form,field,field2)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  
  var url = "protected/PickListSymbol.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field +  "&field2=" + field2 + "#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}
//Ch.

/* 
	Following function calls pop up the filtered symbol's list according to passed symtype. 
   	(With symtype)
*/

function SymbolTypePickListCall(form,field,symtype,clientId)
{ 

    var clid = 0 ; 

    if ( clientId != null ){
         //alert( " 111 ");
         clid = eval( "document." + form + "." + clientId +".value" ) ;
         if ( (clid <= 0 ) || (clid.length <= 0 ) ){
            clid = 0 ;
         }
    }else{
         //alert( " 222 ");
         clid = 0 ;     
    }

  
    str1="document." + form + "." + field +".value";
    var queryField=eval(str1);
    str2="document." + form + "." + symtype +".value";

  
    var symtype=eval(str2);
    var url = "protected/PickListSymbol.jsp?queryField=" + queryField + 
            "&form=" + form + 
            "&field=" + field + 
            "&clientid=" + clid + 
            "&symtype=" + symtype +
            "&queryField=" + queryField.substring(0,3);

    //alert( " check url " + url ) ;
              
    window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
   
}


function SymbolTypeClassifyPickListCall(form,field,symtype,classify,clientId)
{ 

    var clid = 0 ; 

    if ( clientId != null ){
         //alert( " 111 ");
         clid = eval( "document." + form + "." + clientId +".value" ) ;
         if ( (clid <= 0 ) || (clid.length <= 0 ) ){
            clid = 0 ;
         }
    }else{
         //alert( " 222 ");
         clid = 0 ;     
    }

  
    str1="document." + form + "." + field +".value";
    var queryField=eval(str1);
    str2="document." + form + "." + symtype +".value";
    var symtype=eval(str2);
    str3="document." + form + "." + classify +".value";
    var classify=eval(str3);

    var url = "protected/PickListSymbolClassify.jsp?queryField=" + queryField + 
            "&form=" + form + 
            "&field=" + field + 
            "&clientid=" + clid + 
            "&symtype=" + symtype +
	    "&classify=" + classify +
            "&queryField=" + queryField.substring(0,3);

    //alert( " check url " + url ) ;
              
    window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
   
}

function ClassifySymbolPickListCall(form,field,classify)
{ 

    str1="document." + form + "." + field +".value";
    var queryField=eval(str1);
    str3="document." + form + "." + classify +".value";
    var classify=eval(str3);

    var url = "protected/PickListSymbolClassify.jsp?queryField=" + queryField + 
            "&form=" + form + 
            "&field=" + field + 
		    "&classify=" + classify +
            "&queryField=" + queryField.substring(0,3);

	    //alert( " check url " + url ) ;
              
    window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
   
}



function CashSymbolPickListCall(form,field)
{ 
 
    str1="document." + form + "." + field +".value";
    var queryField=eval(str1);

    var url = "protected/PickListSymbolCS.jsp?queryField=" + queryField + 
            "&form=" + form + 
            "&field=" + field + 
	        "&queryField=" + queryField.substring(0,3);

    //alert( " check url " + url ) ;
              
    window.open(url,"CashAccountList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
   
}


/*
function PickListsymbol_m(value)
{
 window.opener.document.forms[0].symbolId.value = value;
 document.location.href = window.opener.document.forms[0];
 window.close();
}
*/

//Combo value  == -1 then error
function comboNotnull(form,field,msg)
{
	var str= 'document.'+form+ '.'+field+'.value';
	var value = eval(str);
	if(value==-1)
	{
		Error = Error +msg+" must be entered \n";	
		if(globalflag == 0)
		{
 			var focusField =	'document.' +form+ '.' +field+ '.focus()';
			eval(focusField);
			globalflag=1;
		}
		return false;
	}
	return true;
}

function DpInfoPickListCall( form, clientid, brokerCode, acId, dp, dpId, bankAcId, bankCode, bankactype , cashsymbol)
{
  var str1="document." + form + "." + clientid +".value";
  var cltid=eval(str1);
  if( (cltid == 0) || (cltid == ""))
  {
      alert("Client Id should be not be blank/ zero.");
      eval("document." + form + "." + clientid +".focus()");
      return;
  }
  
  str1 = "document." + form + "." + brokerCode +".value";
  var brkcode = eval(str1);
  if( (brkcode == 0) || (brkcode == ""))
  {
      alert("Broker Code should be not be blank/ zero.");
      return;
  }
  
  var url = "protected/PickListforDP.jsp?form=" + form + "&clientid=" + cltid + "&brokercode=" + brkcode + 
              "&acId=" + acId +"&dp=" + dp + "&dpId=" + dpId +
              "&bankAcId=" + bankAcId + "&bankCode=" + bankCode + 
              "&bankactype=" + bankactype ; 
              //"&cashsymbol=" + cashsymbol ;     
  window.open(url,"DPSelection","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}



function BankInfoPickListCall(form, clientid, bankAcId, bankCode, bankactype , cashsymbol )
{
  var str1="document." + form + "." + clientid +".value";
  var cltid=eval(str1);
  if( (cltid == 0) || (cltid == ""))
  {
      alert("Client Id should be not be blank/ zero.");
      eval("document." + form + "." + clientid +".focus()");
      return;
  }
    
  var url = "protected/PickListforBank.jsp?form=" + form + "&clientid=" + cltid + 
            "&bankAcId=" + bankAcId + 
            "&bankCode=" + bankCode + 
            "&bankactype=" + bankactype ; 
            //"&cashsymbol=" + cashsymbol;   
            
  window.open(url,"DPSelection","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}
 

function PickListCallCltwiseBroker(form, brokerCode, clientid, cashsymbol)
{
  var str1="document." + form + "." + clientid +".value";
  var cltid=eval(str1);
  
  if( (cltid == 0) || (cltid == ""))
  {
      alert("Client Id should be not be blank/ zero.");
      eval("document." + form + "." + clientid +".focus()");
      return;
  }

  var str2="document." + form + "." + brokerCode +".value";
  var brkval=eval(str2);
    
  var url = "protected/PickListforBroker.jsp?form=" + form + "&brokercode=" + 
			  brokerCode + "&brkval=" + brkval + "&clientid=" + cltid +
              "&cashsymbol=" + cashsymbol;        
  window.open(url,"BrokerList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function PickListCallCltwiseBrokerAcid(form, brokerCode, clientid, brokeracid)
{
  var str1="document." + form + "." + clientid +".value";
  var cltid=eval(str1);
  
  if( (cltid == 0) || (cltid == ""))
  {
      alert("Client Id should be not be blank/ zero.");
      eval("document." + form + "." + clientid +".focus()");
      return;
  }

  var str2="document." + form + "." + brokerCode +".value";
  var brkval=eval(str2);
    
  var url = "protected/PickListforBrokerAcid.jsp?form=" + form + "&brokercode=" + 
			  brokerCode + "&brkval=" + brkval + "&clientid=" + cltid +
              "&brokeracid=" + brokeracid;
  window.open(url,"BrokerList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function PickListCallBroker(form, brokerCode)
{

  var str2="document." + form + "." + brokerCode +".value";
  var brkval=eval(str2);
    
  var url = "protected/PickListforBroker.jsp?form=" + form + "&brokercode=" + brokerCode + "&brkval=" + brkval + "&clientid=-1" ;     
  window.open(url,"BrokerList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


//  -----------------------------------
/*
  GenericSymbolTypePickListCall
  to query and return 3 field values from picklist 
  symbolcode , symbolname and other field ( symtype , rate etc. ) can be quired
  actdbotherfield = value will be actual database name for other field
  which will be used for bring field value from dab and to display and return
  iterationid = value will be always 1 
      if func called for columns
      if func called for grid ( without logic:iteration tag use in JSP)

  iterationid = value can will be the row id ( func called from which row)
      if func called for grid ( with logic:iteration tag use in JSP)
  -- curr created for symbolcode , symbolname , rate 
  -- instead if rate , any other col can be used here.      
*/
//  -----------------------------------

function GenericSymbolTypePickListCall( 
    form , symbolcode, symbolname , otherfield , actdbotherfield , iterationid )
{ 

  str1 = "document." + form + "." + symbolcode +".value";
  str2 = "document." + form + "." + symbolname +".value";
  str3 = "document." + form + "." + otherfield +".value";
  str4 = actdbotherfield ;
  str5 = iterationid ;
/*
  alert (" -----> str1 " + str1 ) ;
  alert (" -----> str2 " + str2 ) ;
  alert (" -----> str3 " + str3 ) ;  
  alert (" -----> str4 " + str4 ) ;
  alert (" -----> str5 " + str5 ) ;
*/      
  var queryField = eval(str1);  
/*
  alert (" -----> str1 " + queryField ) ;
  alert (" -----> form " + form ) ;
  alert (" -----> symbolcode " + symbolcode ) ;  
  alert (" -----> symbolname " + symbolname ) ;
  alert (" -----> otherfield " + otherfield ) ;
  alert (" -----> actdbotherfield " + actdbotherfield ) ;
  alert (" -----> iterationid " + iterationid ) ;    
*/
  var url = 
      "protected/GenericPickListSymbol.jsp?"        + 
            "queryField="       +   queryField      + 
            "&form="            +   form            +   
            "&symbolcode="      +   symbolcode      + 
            "&symbolname="      +   symbolname      +   
            "&otherfield="      +   otherfield      + 
            "&actdbotherfield=" +   actdbotherfield +   
            "&iterationid=    " +   iterationid       ;


  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


//  -----------------------------------

function GenericSymbolTypeDatePickListCall( 
    form , symbolcode, symbolname , procdate, otherfield , actdbotherfield , iterationid )
{ 

  str1 = "document." + form + "." + symbolcode +".value";
  str2 = "document." + form + "." + symbolname +".value";
  str3 = "document." + form + "." + otherfield +".value";
  str4 = actdbotherfield ;
  str5 = iterationid ;
  str6 = "document." + form + "." + procdate +".value";
/*
  alert (" -----> str1 " + str1 ) ;
  alert (" -----> str2 " + str2 ) ;
  alert (" -----> str3 " + str3 ) ;  
  alert (" -----> str4 " + str4 ) ;
  alert (" -----> str5 " + str5 ) ;
*/      
  var queryField = eval(str1);  
  var querydate = eval(str6);  

  if ( querydate == null )  {
	return;
  }
  if ( querydate=="" )  {
	return;
  }	

/*
  alert (" -----> str1 " + queryField ) ;
  alert (" -----> form " + form ) ;
  alert (" -----> symbolcode " + symbolcode ) ;  
  alert (" -----> symbolname " + symbolname ) ;
  alert (" -----> otherfield " + otherfield ) ;
  alert (" -----> actdbotherfield " + actdbotherfield ) ;
  alert (" -----> iterationid " + iterationid ) ;    
*/
  var url = 
      "protected/GenericPickListSymbolDate.jsp?"        + 
            "queryField="       +   queryField      + 
            "&form="            +   form            +   
            "&symbolcode="      +   symbolcode      + 
            "&symbolname="      +   symbolname      +   
            "&procdate=" 	+   querydate        +   
            "&otherfield="      +   otherfield      + 
            "&actdbotherfield=" +   actdbotherfield +   
            "&iterationid=    " +   iterationid       ;


  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function GridSymbolSelection( 
    form , symbolcode, symbolname , otherfield , actdbotherfield , iterationid )
{ 
  var queryField = "";  
  var l = document.forms[0].elements.length;
  for(var i=0;i<l;i++)
  {
 	if( document.forms[0].elements.item(i).name == symbolcode)
	{
		queryField = document.forms[0].elements.item(i).value;
		break;
	}
  }		
  

/*
  alert (" -----> str1 " + queryField ) ;
  alert (" -----> form " + form ) ;
  alert (" -----> symbolcode " + symbolcode ) ;  
  alert (" -----> symbolname " + symbolname ) ;
  alert (" -----> otherfield " + otherfield ) ;
  alert (" -----> actdbotherfield " + actdbotherfield ) ;
  alert (" -----> iterationid " + iterationid ) ;    
*/
  var url = 
      "protected/GenericPickListSymbol.jsp?"        + 
            "queryField="       +   queryField      + 
            "&form="            +   form            +   
            "&symbolcode="      +   symbolcode      + 
            "&symbolname="      +   symbolname      +   
            "&otherfield="      +   otherfield      + 
            "&actdbotherfield=" +   actdbotherfield +   
            "&iterationid=    " +   iterationid       ;


  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function GridAllSymbolSelection( 
    form , symbolcode, symbolname , otherfield , actdbotherfield , iterationid )
{ 
  var queryField = "";  
  var l = document.forms[0].elements.length;
  for(var i=0;i<l;i++)
  {
 	if( document.forms[0].elements.item(i).name == symbolcode)
	{
		queryField = document.forms[0].elements.item(i).value;
		break;
	}
  }		
  

/*
  alert (" -----> str1 " + queryField ) ;
  alert (" -----> form " + form ) ;
  alert (" -----> symbolcode " + symbolcode ) ;  
  alert (" -----> symbolname " + symbolname ) ;
  alert (" -----> otherfield " + otherfield ) ;
  alert (" -----> actdbotherfield " + actdbotherfield ) ;
  alert (" -----> iterationid " + iterationid ) ;    
*/
  var url = 
      "protected/GenericPickListAllSymbol.jsp?"        + 
            "queryField="       +   queryField      + 
            "&form="            +   form            +   
            "&symbolcode="      +   symbolcode      + 
            "&symbolname="      +   symbolname      +   
            "&otherfield="      +   otherfield      + 
            "&actdbotherfield=" +   actdbotherfield +   
            "&iterationid=    " +   iterationid       ;


  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


// -->


function PickListCallSetNameForGroup(form, setName , groupid )
{
  var str3="document." + form + "." + setName +".disabled";
  var fieldedval=eval(str3);
  if ( fieldedval == true ) return ;

  var str1="document." + form + "." + groupid +".value";
  
  var grpid=eval(str1);
  
  if( (grpid == 0) || (grpid == ""))
  {
      alert("Group Id should be not be blank/ zero.");
      eval("document." + form + "." + groupid +".focus()");
      return;
  }

  var str2="document." + form + "." + setName +".value";
  var setNm=eval(str2);
    
  var url = "protected/PickListforSetName.jsp?form=" + form + "&setName=" + setName + "&setNm=" + setNm + "&groupid=" + grpid;     
  window.open(url,"SetNameList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
  
}

  function getRoundValue(in_val, digits)
  {

    var ret_val = 0;

    var digit_val = Math.pow(10, digits);

    ret_val = (Math.round(in_val * 100))/100;

    return ret_val;

  }

// Rounding off upto 'noofdecimal' decimal digits...
function roundOff(tempNumber, noofdecimal )
{
    var deci = noofdecimal + 1 ;  
    var str= tempNumber + "";
    var index=str.indexOf('.');

    if(index>0)    {    
       var len=str.length;
       
       if(len>index+deci)      {
          str=str.substring(0,index+deci);
       }
       
       if(len==index + noofdecimal )      {
          str=str+'0';
       }

       if(len==( index + noofdecimal - 1 )  )      {
          str=str+"00";
       }

       if(len==( index + noofdecimal - 2) )      {
          str=str+"000";
       }
    }

    var len=str.length;
    index = str.indexOf('.');

    var count=4;
    while(true)    {
       if(index>=count)       {
          str=str.substring(0,index-(count-1)) + str.substring(index-(count-1),len);

          index=index+1;
          count=count+3;
       }else      {
          if(str.charAt(0)=='-')      {
             if(str.charAt(1)==',')         {
                str=str.substring(0,1)+str.substring(2,len);
             }
          }
          break;
       }
    }

    return str;
}


// Account Id ( Client / Group / Advisor as per passed value of scope) Pick List....

function accountIdPickList(form, scope, role, personnelid, accountid, name)
{
   var scopeval = "" ;
   if(( scope != null) || ( scope == ""))   {
      scopeval = eval( "document." + form + "." + scope + ".value");
   }

   if( scopeval == "*" )  {
	return ;
   }	

   var queryField = eval("document." + form + "." + accountid + ".value");	
   var url = "protected/accountIdPickList.jsp?scope=" + scopeval + "&queryField=" + queryField + 
	  "&form=" + form + "&accountid=" + accountid + "&name=" + name + 
	  "&role=" + role + "&personnelid=" + personnelid;

   window.open(url,"AccountList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}
/*
function reportLabelPickList(form, category, descrkey)
{
   var queryField = eval("document." + form + "." + accountid + ".value");	
   var url = "protected/accountIdPickList.jsp?scope=" + scopeval + "&queryField=" + queryField + 
	  "&form=" + form + "&accountid=" + accountid + "&name=" + name + 
	  "&role=" + role + "&personnelid=" + personnelid;

   window.open(url,"AccountList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}
*/
// <<< MCP 18.09.2002...  Checking consolidate for against Report Coverage...

function CheckConsolidatefor(form, reportCoverage, consolidatefor)
{
  var reportCoverage = eval( "document." + form + "." + reportCoverage + ".value" );
  var consolidate 	   = eval( "document." + form + "." + consolidatefor + ".value" );

	
  if( ( (reportCoverage == "C") || (reportCoverage == "M") || (reportCoverage == "P")) && ( consolidate != "C") )  {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      

  }else if((reportCoverage == "F") && ( ( consolidate == "A") || (consolidate == "*") || (consolidate == "R") 
  							        ||  (consolidate == "B" ) || (consolidate == "G") || (consolidate == "O") 
  							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D") 
									  )
		  )  {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      

  }else if((reportCoverage == "O") && ( ( consolidate == "A") || (consolidate == "*") || (consolidate == "R") 
  							        ||  (consolidate == "B" ) || (consolidate == "G") || (consolidate == "F") 
  							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D") 
									  )
		  )  {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      

  }else if((reportCoverage == "G") && ( ( consolidate == "A") || (consolidate == "*") || (consolidate == "R") 
														      || (consolidate == "B") 
  							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D") 
									  )
		  )  {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      
  }else if((reportCoverage == "A") && ( (consolidate == "*") || ( consolidate == "R" ) || ( consolidate == "B" ) 
  							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D")  )  )  {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      

  }else if((reportCoverage == "R") && ( (consolidate == "*") || ( consolidate == "A" ) || ( consolidate == "B" ) 
    							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D") )  )   {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      

  }else if((reportCoverage == "B") && ( (consolidate == "*") || ( consolidate == "A" )
     							        ||  (consolidate == "I" ) || (consolidate == "S") || (consolidate == "D") )  )   {
      alert("Not in Scope.");
      eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
      return false;      
  }
	else if ( (reportCoverage == "I") && ((consolidate != "C") && (consolidate != "I")) )
	{
		alert("Not in Scope.");
		eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
		return false;
	}
	else if ( (reportCoverage == "S") && ((consolidate != "C") && (consolidate != "S")) )
	{
		alert("Not in Scope.");
		eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
		return false;
	}
	else if ( (reportCoverage == "D") && ((consolidate != "C") && (consolidate != "S") && (consolidate != "D")) )
	{
		alert("Not in Scope.");
		eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
		return false;
	}
		else if ( ( reportCoverage == "A1" || reportCoverage == "A2" || reportCoverage == "A3" || reportCoverage == "A4" || reportCoverage == "A5" || 
				reportCoverage == "A6" || reportCoverage == "A7" || reportCoverage == "A8" || reportCoverage == "A9" || reportCoverage == "A0" || 
				reportCoverage == "B1" || reportCoverage == "B2" || reportCoverage == "B3" || reportCoverage == "B4" || reportCoverage == "B5" || 
				reportCoverage == "B6" || reportCoverage == "B7" || reportCoverage == "B8" || reportCoverage == "B9" || reportCoverage == "B0" || 
				reportCoverage == "C1" || reportCoverage == "C2" || reportCoverage == "C3" || reportCoverage == "C4" || reportCoverage == "C5" 
				) )
	{
		var i;
		
		var relatioScope="*,A1,A2,A3,A4,A5,A6,A7,A8,A9,A0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B0,C1,C2,C3,C4,C5";
		var temp = new Array();
		temp = relatioScope.split(',');
		var index1;
		var index2;
		for(i in temp){
			if(temp[i] == reportCoverage){
				index1=i;
			}else if(temp[i] == consolidate){
				index2=i;
			}
		}
		
		
		if(index2 < index1){
			alert("Not in Scope.");
			eval( "document." + form + "." + consolidatefor + ".value = 'C'" );
			return false;
		}
	}

  return true;  
}


// <<< MCP 18.09.2002...  Ckeck and change status of account id field according to Report Coverage...
function onReportCoverageChange(form, rptCoverage, consolidatefor, accountid)
{
  var reportCoverage = eval( "document." + form + "." + rptCoverage + ".value");
  var consolidate    = eval( "document." + form + "." + consolidatefor + ".value");

  if( reportCoverage == "*")   {
      eval( "document." +form + "." + accountid + ".disabled = true") ;     
  }else {
      eval( "document." +form + "." + accountid + ".disabled = false") ;      
  }

  	
  if( ( rptCoverage != consolidatefor )   && ( ( consolidatefor != null) || ( consolidatefor != '')) )   {	
	  if(( reportCoverage == "C") || ( reportCoverage == "M") || ( reportCoverage == "P") ) {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");	
	  }else if (( reportCoverage == "F") && ( ( consolidate == "A")  || (consolidate == "*") || ( consolidate == "B" ) 
										   || ( consolidate == "R" ) || ( consolidate == "G" ) || ( consolidate == "O" )
										    )
			   ) {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");		
	  }else if (( reportCoverage == "O") && ( ( consolidate == "A")  || (consolidate == "*") || ( consolidate == "B" ) 
										   || ( consolidate == "R" ) || ( consolidate == "G" ) || ( consolidate == "F" )
										    )
			   ) {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");		
	  }else if (( reportCoverage == "G") && ( ( consolidate == "A")  || (consolidate == "*") || ( consolidate == "B" ) || ( consolidate == "R" ) ) )   {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");		
	  }else if (( reportCoverage == "A") && ( ( consolidate == "*") || (consolidate == "R" ) || ( consolidate == "B" )  )  )  {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");			
	  }else if (( reportCoverage == "R") && ( ( consolidate == "*") || (consolidate == "A" ) || ( consolidate == "B" )  )  )  {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");			
	  }else if (( reportCoverage == "B") && ( ( consolidate == "*") ||  (consolidate == "A" ) )  )  {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");			
		}
		else if ( (reportCoverage == "I") && ((consolidate != "C") && (consolidate != "I")) )
		{
			eval( "document." + form + "." + consolidatefor + ".value = 'C'");
		}
		else if ( (reportCoverage == "S") && ((consolidate != "C") && (consolidate != "S")) )
		{
			eval( "document." + form + "." + consolidatefor + ".value = 'C'");
		}
		else if ( (reportCoverage == "D") && ((consolidate != "C") && (consolidate != "S") && (consolidate != "D")) )
		{
			eval( "document." + form + "." + consolidatefor + ".value = 'C'");
		}
		else if ( ( reportCoverage == "A1" || reportCoverage == "A2" || reportCoverage == "A3" || reportCoverage == "A4" || reportCoverage == "A5" || 
					reportCoverage == "A6" || reportCoverage == "A7" || reportCoverage == "A8" || reportCoverage == "A9" || reportCoverage == "A0" || 
					reportCoverage == "B1" || reportCoverage == "B2" || reportCoverage == "B3" || reportCoverage == "B4" || reportCoverage == "B5" || 
					reportCoverage == "B6" || reportCoverage == "B7" || reportCoverage == "B8" || reportCoverage == "B9" || reportCoverage == "B0" || 
					reportCoverage == "C1" || reportCoverage == "C2" || reportCoverage == "C3" || reportCoverage == "C4" || reportCoverage == "C5" 
				) && ((consolidate == "*") || (consolidate == "P")))  {
	      eval( "document." + form + "." + consolidatefor + ".value = 'C'");			
		}
  }
  eval( "document." +form + "." + accountid + ".value = '0'") ;   
}


function reportOnLoad(form, reportCoverage, accountid)
{
    var reportCoverage = eval( "document." + form + "." + reportCoverage + ".value");	
    if( reportCoverage == "*")    {
	eval( "document." + form + "." + accountid + ".disabled=true");	
    }
}


function reportAccountIdCheck( form, reportCoverage, accountid)  
{
   var rptCoverage = eval( "document." + form + "." + reportCoverage + ".value");		
   var acid              = eval( "document." + form + "." + accountid + ".value");	

   if( isNaN(acid) )  {

	  if( rptCoverage == "C")  {	      
  	      alert("Account id should be numeric.");
	  }else if ( rptCoverage == "M") {
  	      alert("Model id should be numeric.");
	  }else if( rptCoverage == "F")  {	      
  	      alert("Account Portfolio id should be numeric.");
	  }else if( rptCoverage == "O")  {	      
  	      alert("Owner id should be numeric.");
	  }else if ( rptCoverage == "G")    {
  	      alert("Group id should be numeric.");
	  }else if ( rptCoverage == "A")    {
  	      alert("Advisor id should be numeric.");
	  }else if ( rptCoverage == "R")    {
  	      alert("Relationship Manager id should be numeric.");
	  }else if ( rptCoverage == "B")    {
  	      alert("Branch id should be numeric.");
	  }else if ( rptCoverage == "*")    {
  	      alert("Corporate id should be numeric.");
	  }else if ( rptCoverage == "I")    {
  	      alert("Intermediary id should be numeric.");
	  }else if ( rptCoverage == "S")    {
  	      alert("Scheme id should be numeric.");
	  }else if ( rptCoverage == "D")    {
  	      alert("Fund Manager id should be numeric.");
	  }	

 	  eval("document." + form + "." + accountid + ".focus();");
	  return false;
   }
   
   if ( ( acid == "") || ( ( rptCoverage != "*" ) && ( acid == 0)))
   {
	  if( rptCoverage == "C")  {	      
  	      alert("Account id is must.");
	  }else if ( rptCoverage == "M") {
  	      alert("Model id is must.");
	  }else if( rptCoverage == "F")  {	      
  	      alert("Account Portfolio id should be numeric.");
	  }else if( rptCoverage == "O")  {	      
  	      alert("Owner id should be numeric.");
	  }else if ( rptCoverage == "G")    {
  	      alert("Group id is must.");
	  }else if ( rptCoverage == "A")    {
  	      alert("Advisor id is must.");
	  }else if ( rptCoverage == "R")    {
  	      alert("Relationship Manager id is must.");
	  }else if ( rptCoverage == "B")    {
  	      alert("Branch id is must.");
	  }else if ( rptCoverage == "*")    {
  	      alert("Corporate id is must.");
	  }else if ( rptCoverage == "I")    {
  	      alert("Intermediary id is must.");
	  }else if ( rptCoverage == "S")    {
  	      alert("Scheme id is must.");
	  }else if ( rptCoverage == "D")    {
  	      alert("Fund Manager id is must.");
	  }	

 	  eval("document." + form + "." + accountid + ".focus()");
	  return false;
   }
   return true;
}


function reportCoverageIdCheck( form, reportCoverage, accountid)  
{
   var rptCoverage = eval( "document." + form + "." + reportCoverage + ".value");		
   var acid              = eval( "document." + form + "." + accountid + ".value");	
   if( isNaN(acid) )  {

	  if( rptCoverage == "C")  {	      
		  Error=Error+"Account id should be numeric.\n";
	  }else if ( rptCoverage == "M") {
		  Error=Error+"Model id should be numeric.\n";
	  }else if ( rptCoverage == "P") {
		  Error=Error+"Plan id should be numeric.\n";
	  }else if ( rptCoverage == "F")    {
		  Error=Error+"Account Portfolio id should be numeric.\n";
	  }else if ( rptCoverage == "O")    {
		  Error=Error+"Owner id should be numeric.\n";
	  }else if ( rptCoverage == "G")    {
		  Error=Error+"Group id should be numeric.\n";
	  }else if ( rptCoverage == "A")    {
		  Error=Error+"Advisor id should be numeric.\n";
	  }else if ( rptCoverage == "B")    {
		  Error=Error+"Branch id should be numeric.\n";
	  }else if ( rptCoverage == "R")    {
		  Error=Error+"Relationship Manager id should be numeric.\n";
	  }else if ( rptCoverage == "*")    {
		  Error=Error+"Corporate id should be numeric.\n";
	  }else if ( rptCoverage == "I")    {
  	      Error=Error+"Intermediary id should be numeric.\n";
	  }else if ( rptCoverage == "S")    {
  	      Error=Error+"Scheme id should be numeric.\n";
	  }else if ( rptCoverage == "D")    {
  	      Error=Error+"Fund Manager id should be numeric.\n";
	  }	

 	  eval("document." + form + "." + accountid + ".focus();");
	  return false;
   }
   
   if ( ( acid == "") || ( ( rptCoverage != "*" ) && ( acid == 0 ) ))
   {
	  if( rptCoverage == "C")  {	      
		  Error=Error+"Account id is must.\n";
	  }else if ( rptCoverage == "M") {
		  Error=Error+"Model id is must.\n";
	  }else if ( rptCoverage == "P") {
		  Error=Error+"Plan id is must.\n";
	  }else if ( rptCoverage == "F")    {
		  Error=Error+"Account Portfolio id is must.\n";
	  }else if ( rptCoverage == "O")    {
		  Error=Error+"Owner id is must.\n";
	  }else if ( rptCoverage == "G")    {
		  Error=Error+"Group id is must.\n";
	  }else if ( rptCoverage == "A")    {
		  Error=Error+"Advisor id is must.\n";
	  }else if ( rptCoverage == "B")    {
		  Error=Error+"Branch id is must.\n";
	  }else if ( rptCoverage == "R")    {
		  Error=Error+"Relationship Manager id is must.\n";
	  }else if ( rptCoverage == "*")    {
		  Error=Error+"Corporate id is must.\n";
	  }else if ( rptCoverage == "I")    {
  	      Error=Error+"Intermediary id is must.\n";
	  }else if ( rptCoverage == "S")    {
  	      Error=Error+"Scheme id is must.\n";
	  }else if ( rptCoverage == "D")    {
  	      Error=Error+"Fund Manager id is must.\n";
	  }	

 	  eval("document." + form + "." + accountid + ".focus()");
	  return false;
   }
   return true;
}

// Enable all forms fields while submitting form...
function enableAll()
{
  var l = document.forms[0].elements.length;
  for(var i=0;i<l;i++) {
  	document.forms[0].elements(i).disabled = false;
  }		
}


function PickListCallGridGroup( form, groupfld, gridrowno)
{
  var queryField = "";
  var l = document.forms[0].elements.length;
  for(var i=0;i<l;i++)    {
 	if( document.forms[0].elements.item(i).name == groupfld)     {
		queryField = document.forms[0].elements.item(i).value;
		break;
	}
  }		


  var url = 
      "protected/GroupPickList.jsp?"        	 + 
            "queryField="       +   queryField   + 
            "&form="	        +   form         +   
            "&groupfld="    	+   groupfld	 + 
            "&iterationid=" 	+   gridrowno;

  window.open(url,"PickList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");

}

function allocMethodPickList( form, symbol, symtype , detailtype , clientid)
{
   var symbl  = ""; 
   var symtyp = "";
   var dtltype= "";
   var clid   = "";
   
   symbl    = eval( "document." + form + "." + symbol + ".value"); 
   symtyp	= eval( "document." + form + "." + symtype + ".value");
   dtltyp 	= eval( "document." + form + "." + detailtype + ".value");
   clid     = eval( "document." + form + "." + clientid + ".value");

   if ( (clid <= 0 ) || (clid.length <= 0 ) ){
        clid = 0 ;
   }

   if( symbl.length <= 0 ){

        alert("Symbol not selected...");
        return;
   }
    
   var url = "protected/PickListAllocMethod.jsp?&form=" + form + 
                    "&symtype=" + symtyp + 
                    "&detailtype=" + dtltyp + 
                    "&symbol=" + symbl +
                    "&clientid=" + clid                     

   window.open(url,"AllocMethodList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}


function IndexesPickList( form , indexcode , descr , iterationid )
{ 

  //alert(" ============= 1" );

  var str = 'document.'+form+'.elements.length';
  var len = eval(str);

  var elename   = "";
  var myelename = indexcode + "[" + iterationid + "]" ;

  //alert(" ============= 2" + myelename  );
    
  for(var i=0; i<len; i++)
  {
    elename = eval('document.'+form+'.elements[i].name' ) ;
    if( elename == myelename ){
      //alert("match");  
      str1 = eval("document." + form + ".elements[i].value") ;
    }
  }

  //alert(" ============= 3 str1 " + str1  );
  
  var queryField = str1 ;  

  //alert(" ============= 4 queryField " + queryField  );

  var url = 
      "protected/IndexesPickList.jsp?"           + 
            "queryField="       +   queryField   + 
            "&form="            +   form         +   
            "&indexcode="       +   indexcode    + 
            "&indexname="       +   descr        +   
            "&iterationid="     +   iterationid   ;
            
  window.open(url,"IndexList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
        
}

function PickListCallSymbolCS(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListSymbolCS.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#"  +"#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}

function PickListCallSector(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListSector.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#"  +"#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function PickListCallWhatif(form,field,fieldaccount,scope)
{
  str1="document." + form + "." + field +".value";  
  str2="document." + form + "." + fieldaccount +".value";  
  str3="document." + form + "." + scope +".value";  
  var queryField=eval(str1);
  var accountField=eval(str2);
  var scope = eval(str3);
  var url = "protected/PickListWhatif.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field +"&accountid=" + accountField + "&scope=" + scope  + "#" + queryField.substring(0,3)
  window.open(url,"WhatIfParams","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}

function PickListCallSelectionSet(form,field,fieldselid,moduleflag)
{
  str1="document." + form + "." + field +".value";  
  str2="document." + form + "." + fieldselid +".value";  
  var queryField=eval(str1);
  var selectionid=eval(str2);
  var url = "protected/PickListSelectionSet.jsp?module=" + moduleflag + "&queryField=" + queryField + "&form=" + form + "&field=" + field + "&field2=" + fieldselid + "#" + queryField.substring(0,3)
  window.open(url,"SelectionSetList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function validateDate(form,dateval,msg,format)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);
	var len = date.length;
	var format = eval('document.'+form+'.'+format+'.value');
	
	if( len == 0)
        {
  	   Error = Error + msg + " is must.\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	}
	

        if(len != 10)
        {
           Error=Error+"Invalid " +msg+ ". Valid format of date is "+format+".\n";    
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	}
	var day = 0;
	var month = 0;
              var year = 0;
	var char1;
	var char2;

	if(format == null){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = '/';
	}
	var valchar;
              if(format == 'dd-MM-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM-dd-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
              else if(format == 'dd/MM/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM/dd/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}

	if((char1 != valchar) || (char2 != valchar))
	{
           Error=Error+"Invalid " +msg+ ". Valid format of date is "+format+".\n";    
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
	}
	

	

	if(isNaN(day) || isNaN(month) || isNaN(year))
	{
           Error=Error+"Invalid " +msg+ ". Valid format of date is "+format+".\n";    
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+msg+" is having invalid month.\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}

	if(day<1 || day>31)
	{
  	   Error=Error+msg+" is having invalid day.\n";
   	   if(globalflag == 0)
	   {
 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;	
	}

	switch(month)
	{
		case '02': 
			  //if(!(year%400==0 || (year%4==0 && year%100!=0)))
			  if(!(year%4==0))
			  {
				if(day>28)
				{
			  	   Error=Error + "Invalid " + msg + ", as entered date isn't fall in leap year.\nSo maximum days in Feb is 28.\n";
				   return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				}
			  }
			  if(day>29)
			  {
			  	 Error=Error + "Invalid " + msg+ ", as maximum days in Feb for leap year is 29.\n";
			   	 if(globalflag == 0)
				 {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				 }
				 return false;
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':
			  if(day==31)
			  {
			           Error=Error+"Invalid " +msg+"\n";
			   	   if(globalflag == 0)
				   {
			 		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				   return false;
                          }
			  break;
	}		    
	return true;
}

function compareDate(form,field1,field2,msg1,msg2,format)
{

	var str1= 'document.' +form+ '.' +field1+ '.value';
	var fdate=eval(str1);

	var str2= 'document.' +form+ '.' +field2+ '.value';
	var todate=eval(str2);
	var fday = 0;
	var fmonth = 0;
	var fyear = 0;
	var today = 0;
	var tomonth = 0;
	var toyear = 0;

	
	var format = eval('document.'+form+'.'+format+'.value');

	if(format == null){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);

		today  = todate.substring(0,2);
		tomonth = todate.substring(3,5);	
		toyear = todate.substring(6,10);

	}

	if(format.substring(0,1) == 'd'){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);

		today  = todate.substring(0,2);
		tomonth = todate.substring(3,5);	
		toyear = todate.substring(6,10);
	}
	else if(format.substring(0,1) == 'M'){
		fday  = fdate.substring(3,5);
		fmonth = fdate.substring(0,2);	
	              fyear = fdate.substring(6,10);

		today  = todate.substring(3,5);
		tomonth = todate.substring(0,2);	
		toyear = todate.substring(6,10);
	}
/*	if(format.substring(0,1) == 'y'){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);

		today  = todate.substring(0,2);
		tomonth = todate.substring(3,5);	
		toyear = todate.substring(6,10);
	}*/
	
	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date(toyear,tomonth-1,today);
	if(fdate != "" && todate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear())
		{
			
		}
		else if( !(date1.getTime() < date2.getTime()) )
		{
		   // Error = Error + msg1+" should be less than " +msg2+"\n";
		   Error = Error + msg2 + " should be greater than or equals to " + msg1 + "\n";
	           return false;
		   if(globalflag == 0)
		   {
 			var focusField ='document.' +form+ '.' +field1+ '.focus()';
			eval(focusField);
			globalflag=1;
		   }
		}
	}
	return true;
}

function validateNotNullDate(form,dateval,msg,format)
{
	var str1= 'document.' +form+ '.' +dateval+ '.value';
	var date=eval(str1);
	if(date.length != 0)
	{
	  if(!validateDate(form,dateval,msg,format))
	  {
		var focusField = 'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
//		Error= msg +  " is must.";
	  	return false;
          }
	}
	return true;
}

function validateCurrentDate(form,date,msg,format)
{

	var str= 'document.' +form+ '.' +date+ '.value';
	var fdate=eval(str);


	var fday = 0;
	var fmonth = 0;
	var fyear = 0;

	
	var format = eval('document.'+form+'.'+format+'.value');

	if(format == null){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);
	}
	else if(format.substring(0,1) == 'd'){
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);	
	              fyear = fdate.substring(6,10);
	}
	else if(format.substring(0,1) == 'M'){
		fday  = fdate.substring(3,5);
		fmonth = fdate.substring(0,2);	
	              fyear = fdate.substring(6,10);
	}


	var date1=new Date(fyear,fmonth-1,fday);
	var date2=new Date();

	if(fdate != "")
	{	
		if(date1.getDate()==date2.getDate() && date1.getMonth()==date2.getMonth() && date1.getYear()==date2.getYear()){}
		else if( !(date1.getTime() < date2.getTime()) )
		{
		Error=Error+ msg +" cannot be greater than current date\n";
	      return false;
	      if(globalflag == 0)
	      {
 			var focusField =	'document.' +form+ '.' +date+ '.focus()';
			eval(focusField);
			globalflag=1;
	      }
		}
	}
	
	return true;
}

// Date should be less than System Date (System Date is not valid date).....
function validateSystemDate(form,date,msg,format)
{
	var str= 'document.' +form+ '.' +date+ '.value';
	var fdate=eval(str);

	var fday = 0;
	var fmonth = 0;
	var fyear = 0;

	var format = eval('document.'+form+'.'+format+'.value');

	if(format == null)
	{
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);
		fyear = fdate.substring(6,10);
	}
	else if(format.substring(0,1) == 'd')
	{
		fday  = fdate.substring(0,2);
		fmonth = fdate.substring(3,5);
		fyear = fdate.substring(6,10);
	}
	else if(format.substring(0,1) == 'M')
	{
		fday  = fdate.substring(3,5);
		fmonth = fdate.substring(0,2);
		fyear = fdate.substring(6,10);
	}

	var date1 = new Date(fyear,fmonth-1,fday);
	var date2 = new Date();

	if(fdate != "")
	{
		if (date1.getDate() == date2.getDate() && date1.getMonth() == date2.getMonth() && date1.getYear() == date2.getYear())
		{
			Error = Error+ msg + " must be less than current date. \n";
			return false;
		}
		else if(!(date1.getTime() < date2.getTime()))
		{
			Error = Error+ msg + " must be less than current date. \n";
			return false;
		}
	}
	return true;
}


function validateNotNullDatedetail(form,dateval,msg,format)
{
	var retval=true;
	var str1= dateval+ '.value';
	var date=eval(str1);
	if(date.length != 0)
	{
	  retval = validateDatedetail(form,dateval,msg,format);
	}
	return retval;
}
//same as isNullDate and checkDate resp.. but for detail rows
// dateval >> takes the element's value directly..
//Date Validation - null date invalid
function validateDatedetail(form,dateval,msg,format)
{
	var str1= dateval+ '.value';
	var date=eval(str1);
	var format = eval('document.'+form+'.'+format+'.value');
	var len = date.length;
      if(len != 10)
	  {
  	   Error=Error+"Invalid " +msg+"\n";
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	   return false;
  	  }
	
	var day = 0;
	var month = 0;
              var year = 0;
	var char1;
	var char2;

	if(format == null){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = '/';
	}
	var valchar;
              if(format == 'dd-MM-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM-dd-yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
              else if(format == 'dd/MM/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(0,2);
		month = date.substring(3,5);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}
	else if(format == 'MM/dd/yyyy'){
		char1 = date.charAt(2);
		char2 = date.charAt(5);
		day  = date.substring(3,5);
		month = date.substring(0,2);	
        		year = date.substring(6,10);
		valchar = format.charAt(2);
	}


	if((char1 != valchar) || (char2 != valchar))
	{
	 Error=Error+"Invalid " +msg+"\n";
	 return false;
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}
	

/*	var day  = date.substring(0,2);
      var month = date.substring(3,5);	
      var year = date.substring(6,10);*/
	
	if(isNaN(day) || isNaN(month) || isNaN(year))
	{
   	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}	

	if(month<1 || month>12)
	{
  	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	if(day<1 || day>31)
	{
    	   Error=Error+"Invalid " +msg+"\n";
	   return false;	
   	   if(globalflag == 0)
	   {
 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
		eval(focusField);
		globalflag=1;
	   }
	}

	switch(month)
	{
		case '02': 
			  if(day>29)
			  {
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			  }
			  else if(!(year%400==0 || (year%4==0 && year%100!=0)))
			  {
				if(day>28)
				{
				 Error=Error+"Invalid " +msg+"\n";
				 return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
				}
			  }
			  break;			
		case '04':
		case '06':
		case '09':
		case '11':if(day==31)
			    {
				Error=Error+"Invalid " +msg+"\n";
				return false;
			   	   if(globalflag == 0)
				   {
			 		var focusField =	'document.' +form+ '.' +dateval+ '.focus()';
					eval(focusField);
					globalflag=1;
				   }
			    }
			    break;
	}		    
	
	return true;

}


//<<< MCP 18.09.2002...  Checking consolidate for against Report Coverage...

function CheckReportby(form, reportCoverage, reportby)
{
  var reportCoverage = eval( "document." + form + "." + reportCoverage + ".value" );
  var reportbyval 	   = eval( "document." + form + "." + reportby + ".value" );

  if ( (reportCoverage == "*") && (reportbyval != "" ) ) {
      return true;      
  }else if((reportCoverage == "A") && ( (reportbyval == "*")  )  )  {
      Error=Error+"Not a valid Report By "+"\n";
//      alert("Not a valid Report By.");
      eval( "document." + form + "." + reportby + ".value = 'B'" );
      return false;      

  }else if((reportCoverage == "R") && ( (reportbyval == "*") || ( reportbyval == "A" ) || ( reportbyval == "B" ) )  )   {
      Error=Error+"Not a valid Report By "+"\n";
//      alert("Not a Valid Report By");
      eval( "document." + form + "." + reportby + ".value = 'R'" );
      return false;      

  }else if((reportCoverage == "B") && ( (reportbyval == "*") || ( reportbyval == "A" ))  )   {
      Error=Error+"Not a valid Report By "+"\n";
//      alert("Not a Valid Report By.");
      eval( "document." + form + "." + reportby + ".value = 'R'" );
      return false;      
  }

  return true;  
}

// <<< MCP 18.09.2002...  Ckeck and change status of account id field according to Report Coverage...
function onReportCoverageChange1(form, rptCoverage, reportby, accountid)
{
  var reportCoverage = eval( "document." + form + "." + rptCoverage + ".value");
  var reportbyval              = eval( "document." + form + "." + reportby + ".value");

  if( reportCoverage == "*")   {
      eval( "document." +form + "." + accountid + ".disabled = true") ;     
  }else {
      eval( "document." +form + "." + accountid + ".disabled = false") ;      
  }

  	
  if( ( rptCoverage != reportbyval )   && ( ( reportbyval != null) || ( reportbyval != '')) )   {	
	  if (( reportCoverage == "A") &&  ( ( reportbyval == "*") )  )   {
	      eval( "document." + form + "." + reportby + ".value = 'A'");			
	  }else if (( reportCoverage == "R") && ( ( reportbyval == "*") || (reportbyval == "A" ) || ( reportbyval == "B" )  )  )  {
	      eval( "document." + form + "." + reportby + ".value = 'R'");			
	  }else if (( reportCoverage == "B") && ( ( reportbyval == "*") ||  (reportbyval == "A" ) )  )  {
	      eval( "document." + form + "." + reportby + ".value = 'B'");			
	  }	
  }
  eval( "document." +form + "." + accountid + ".value = '0'") ;   
}

function postingIdPickList(form, actionid, fromdate, todate, postingid,actioncode,blockflag)
{
   var actionval = eval( "document." + form + "." + actionid + ".value");
   var fromdateval = eval( "document." + form + "." + fromdate + ".value");
   var todateval = eval( "document." + form + "." + todate + ".value");

   var url = "protected/postingIdPickList.jsp?actionid=" + actionval + "&frmdtval=" + fromdateval + 
	  "&form=" + form + "&todtval=" + todateval + "&postingid=" + postingid+"&actioncode="+actioncode+"&blockflag="+blockflag; 


   window.open(url,"PostingIdList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}

function postingPickList(form, actionid, fromdate, todate, postingid,actioncode,blockflag)
{
   var actionval = eval( "document." + form + "." + actionid + ".value");
   var fromdateval = eval( "document." + form + "." + fromdate + ".value");
   var todateval = eval( "document." + form + "." + todate + ".value");
   var blockflagval = eval( "document." + form + "." + blockflag + ".value");

   var url = "protected/postingIdPickList.jsp?actionid=" + actionval + "&frmdtval=" + fromdateval + 
	  "&form=" + form + "&todtval=" + todateval + "&postingid=" + postingid+"&actioncode="+actioncode+"&blockflag="+blockflagval; 


   window.open(url,"PostingIdList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}


function STPTranidPickList(form,tranid)
{
   var url = "protected/STPTranidPickList.jsp?form=" + form + "&tranid=" + tranid; 

   window.open(url,"STPTranidList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}



function blockpostingIdPickList(form, actionid, fromdate, todate, postingid,actioncode,blockflag)
{
   var actionval = eval( "document." + form + "." + actionid + ".value");
   var fromdateval = eval( "document." + form + "." + fromdate + ".value");
   var todateval = eval( "document." + form + "." + todate + ".value");

   var url = "protected/blockpostingIdPickList.jsp?actionid=" + actionval + "&frmdtval=" + fromdateval + 
	  "&form=" + form + "&todtval=" + todateval + "&postingid=" + postingid+"&actioncode="+actioncode+"&blockflag="+blockflag; 


   window.open(url,"BlockPostingIdList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}


function fdblockpostingIdPickList(form, actionid, fromdate, todate, postingid,actioncode,blockflag)
{
   var actionval = eval( "document." + form + "." + actionid + ".value");
   var fromdateval = eval( "document." + form + "." + fromdate + ".value");
   var todateval = eval( "document." + form + "." + todate + ".value");

   var url = "protected/fdblockpostingIdPickList.jsp?actionid=" + actionval + "&frmdtval=" + fromdateval + 
	  "&form=" + form + "&todtval=" + todateval + "&postingid=" + postingid+"&actioncode="+actioncode+"&blockflag="+blockflag; 


   window.open(url,"FDBlockPostingIdList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}


function mapIdPickList(form, mapid,source,actioncode)
{
   var url = "protected/mapIdPickList.jsp?form=" + form +"&mapid=" + mapid+"&source="+source+"&actcode="+actioncode ; 
   window.open(url,"MappingList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}

function PickListCallIntermediary(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/intermediaryPickList.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#"  +"#" + queryField.substring(0,3)
  window.open(url,"List","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}



function CallModifiedBy(form,modifiedby)
{
  var queryfield=document.forms[0].roleassigned.value;
  if(queryfield == '')
	return;
  var url = "protected/ModifiedByPop.jsp?queryField=" + queryfield + "&form=" + form + "&modifiedby=" + modifiedby
  window.open(url,"Modified_By_Selection_List","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");

}


function GridCashSymbolSelection( 
    form , symbolcode, symbolname , otherfield , actdbotherfield , iterationid )
{ 
  var queryField = "";  
  var field="";	
  var l = document.forms[0].elements.length;
  for(var i=0;i<l;i++)
  {
 	if( document.forms[0].elements.item(i).name == symbolcode)
	{
		field = document.forms[0].elements.item(i).name;
		queryField = document.forms[0].elements.item(i).value;
		break;
	}
  }		

  var url = "protected/PickListSymbolCS.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "#"  +"#" + queryField.substring(0,3)
  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");

}




function PickListCallPortfolioSet(form,field,fieldselid)
{
  str1="document." + form + "." + field +".value";  
  str2="document." + form + "." + fieldselid +".value";  
  var queryField=eval(str1);
  var selectionid=eval(str2);
  var url = "protected/PickListPortfolioSet.jsp?queryField=" + queryField + "&form=" + form + "&field=" + field + "&field2=" + fieldselid + "#" + queryField.substring(0,3)
  window.open(url,"PortfolioSetList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}


function mergeDocPickList(form, scope, scopevalue, consolidate, reportname )
{
   var val = eval( "document." + form + "." + scope + ".value");
   var val1 = eval( "document." + form + "." + scopevalue + ".value");

   if ( val1 == null) val1="0";
  
   var consolidateval = eval( "document." + form + "." + consolidate + ".value");

   var url = "protected/mergeDocPickList.jsp?scope=" + val + "&scopevalue=" + val1 + 
	  "&form=" + form + "&consolidate=" + consolidateval + "&reportname=" + reportname; 

   window.open(url,"AttachmentList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}


function settlementPickList(form, setlno, fromdate, todate, exchg)
{
   var a = eval( "document." + form + "." + setlno + ".disabled") ;
   if ( a == true ) {
	alert('Can not select Settlement without exchange code..');
	return;
   }
   var fromdateval = eval( "document." + form + "." + fromdate + ".value");
   var todateval = eval( "document." + form + "." + todate + ".value");
   var exchgval = eval( "document." + form + "." + exchg + ".value");

   var url = "protected/SetlNoPickList.jsp?form=" + form + "&setlno=" + setlno+
	  "&frmdtval=" + fromdateval + "&todtval=" + todateval +  "&exchg="+exchgval; 

   window.open(url,"SettlementNoList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");	
}




function GridSymbolListSelection( 
    form , symbolcode, symbolname , otherfield , actdbotherfield , iterationid )
{ 
  var queryField = "";  
  var l = document.forms[0].elements.length;
/*
  for(var i=0;i<l;i++)
  {
 	if( document.forms[0].elements.item(i).name == symbolcode)
	{
		queryField = document.forms[0].elements.item(i).value;
		break;
	}
  }		
  
	*/

/*
  alert (" -----> str1 " + queryField ) ;
  alert (" -----> form " + form ) ;
  alert (" -----> symbolcode " + symbolcode ) ;  
  alert (" -----> symbolname " + symbolname ) ;
  alert (" -----> otherfield " + otherfield ) ;
  alert (" -----> actdbotherfield " + actdbotherfield ) ;
  alert (" -----> iterationid " + iterationid ) ;    
*/
  var url = 
      "protected/GenericPickListSymbol.jsp?"        + 
            "queryField="       +   queryField      + 
            "&form="            +   form            +   
            "&symbolcode="      +   symbolcode      + 
            "&symbolname="      +   symbolname      +   
            "&otherfield="      +   otherfield      + 
            "&actdbotherfield=" +   actdbotherfield +   
            "&iterationid=    " +   iterationid       ;


  window.open(url,"SymbolList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}



function PickListCallRelationId(form,field)
{ 
  var url = "protected/relationIdPickList.jsp?form="+form+"&field="+field ;
  window.open(url,"List","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10");
}


function PickListCallBank(form,field)
{ 
  str1="document." + form + "." + field +".value";
  var queryField=eval(str1);
  var url = "protected/PickListBankCode.jsp?queryField=" + field + "&queryFieldValue=" + queryField + "&form=" + form;
  window.open(url,"BankList","width=450,height=200,resizable=yes,scrollbars=yes,border=0,top=195,left=220,screenX=200,screenY=10"); 
}
