function RTrim(str)
{
  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    var i = s.length - 1;       // Get length of string
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;
    s = s.substring(0, i+1);
  }
  return s;
}
function trim(s){
while(s.substring(0,1)==' '){s=s.substring(1,s.length);
}while(s.substring(s.length-1,s.length)==' '){s=s.substring(0,s.length-1);}return s;		}
function fnError(frm,ctrl,msg,val){
	if(trim(document[eval("frm")][eval("ctrl")].value)==val){
		alert(msg);
		document[eval("frm")][eval("ctrl")].focus();
		return false;
		}
		else{
			return true;
		}
	}
function LessThanCurrent(frm,lstyear,lstmonth,lstday,msg){
	vari;varyr="";varmnth="";varday="";varcur_yr="";varcur_mnth="";varcur_day="";
	mnth=document[eval("frm")][eval("lstmonth")].value;
	day=document[eval("frm")][eval("lstday")].value;
	yr=document[eval("frm")][eval("lstyear")].value;
	dat=mnth+"-"+day+"-"+yr;date_chk=yr+"-"+mnth+"-"+day;varlen=date_chk.length;d=newDate();
	cur_yr=d.getFullYear();cur_mnth=d.getMonth()+1;cur_day=d.getDate();cur_date=cur_yr+"-"+cur_mnth+"-"+cur_day;if(yr>cur_yr){alert(msg);
	document[eval("frm")][eval("lstyear")].focus();
	return false;
	}else if(yr==cur_yr&&mnth>cur_mnth){alert(msg);document[eval("frm")][eval("lstmonth")].focus();
	returnfalse;}
	else if(yr==cur_yr&&mnth==cur_mnth&&day>cur_day){
		alert(msg);document[eval("frm")][eval("lstday")].focus();
		returnfalse;
		}else{
			for(i=0;i<len;i++){if(i==2||i==5){}else{if(dat.substr(i,1)<"0"||dat.substr(i,1)>"9"){alert(msg);document[eval("frm")][eval("lstday")].focus();returnfalse;break;}}}}
			returntrue;
			}
	function fnDate(frm,lstyear,lstmonth,lstday,msg){mnth=document[eval("frm")][eval("lstmonth")].value;
	day=document[eval("frm")][eval("lstday")].value;
	yr=document[eval("frm")][eval("lstyear")].value;if(mnth=="-1"||day=="-1"||yr=="-1"){
	alert(msg);
	if(yr=="-1"||(mnth=="-1"&&day=="-1"&&yr=="-1"))document[eval("frm")][eval("lstyear")].focus();
	else if(mnth=="-1")document[eval("frm")][eval("lstmonth")].focus();else if(day=="-1")document[eval("frm")][eval("lstday")].focus();return false;}
	return true;}function fnDate_valid(frm,lstyear,lstmonth,lstday,msg){alert(document[eval("frm")][eval("lstmonth")].value);mnth=document[eval("frm")][eval("lstmonth")].value;
	day=document[eval("frm")][eval("lstday")].value;yr=document[eval("frm")][eval("lstyear")].value;alert(mnth+""+day+""+yr);if(yr!="-1"){if(mnth=="-1"||day=="-1"){alert(msg);if(mnth=="-1")document[eval("frm")][eval("lstmonth")].focus();else if(day=="-1")document[eval("frm")][eval("lstday")].focus();return false;}}if(mnth!="-1"){if(day=="-1"||yr=="-1"){alert(msg);if(yr=="-1")document[eval("frm")][eval("lstyear")].focus();else if(day=="-1")document[eval("frm")][eval("lstday")].focus();return false;}}if(day!="-1"){if(mnth=="-1"||yr=="-1"){alert(msg);if(yr=="-1")document[eval("frm")][eval("lstyear")].focus();
	else if(mnth=="-1")document[eval("frm")][eval("lstmonth")].focus();return false;}}return true;}function fnDays(frm,lstyear,lstmonth,lstday){year=document[eval("frm")][eval("lstyear")].value;month=Number(document[eval("frm")][eval("lstmonth")].value);document[eval("frm")][eval("lstday")].length=0;document[eval("frm")][eval("lstday")].options[0]=newOption("DD","-1");
	if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){for(i=1;i<=31;i++){dd=i;if(dd<10)dd="0"+dd;document[eval("frm")][eval("lstday")].options[i]=newOption(dd,dd);}}if(month==4||month==6||month==9||month==11){for(i=1;i<=30;i++){dd=i;if(dd<10)dd="0"+dd;document[eval("frm")][eval("lstday")].options[i]=newOption(dd,dd);}}if(month==2){if(year%4==0||year%400==0){for(i=1;i<=29;i++){dd=i;if(dd<10)dd="0"+dd;document[eval("frm")][eval("lstday")].options[i]=newOption(dd,dd);}}else{for(i=1;i<=28;i++){dd=i;if(dd<10)dd="0"+dd;document[eval("frm")][eval("lstday")].options[i]=newOption(dd,dd);}}}}
	function fnYear(frm,lstyear,lstmonth,lstday){mnth=document[eval("frm")][eval("lstmonth")].value;day=document[eval("frm")][eval("lstday")].value;
	yr=document[eval("frm")][eval("lstyear")].value;if(yr=="-1"){alert("PleaseselecttheYearfirst.");document[eval("frm")][eval("lstyear")].focus();return false;}}function fnInitialize(frm,lstyear,lstmonth,lstday){dat=newDate();year=dat.getFullYear();vari;document[eval("frm")][eval("lstyear")].options[0]=newOption("YYYY",-1);j=1;for(i=year;i>=year-5;i--){document[eval("frm")][eval("lstyear")].options[j]=newOption(i,i);j++;}document[eval("frm")][eval("lstmonth")].options[1]=newOption("Jan","01");document[eval("frm")][eval("lstmonth")].options[2]=newOption("Feb","02");document[eval("frm")][eval("lstmonth")].options[3]=newOption("Mar","03");document[eval("frm")][eval("lstmonth")].options[4]=newOption("Apr","04");document[eval("frm")][eval("lstmonth")].options[5]=newOption("May","05");document[eval("frm")][eval("lstmonth")].options[6]=newOption("Jun","06");document[eval("frm")][eval("lstmonth")].options[7]=newOption("Jul","07");document[eval("frm")][eval("lstmonth")].options[8]=newOption("Aug","08");document[eval("frm")][eval("lstmonth")].options[9]=newOption("Sep","09");document[eval("frm")][eval("lstmonth")].options[10]=newOption("Oct","10");document[eval("frm")][eval("lstmonth")].options[11]=newOption("Nov","11");
	document[eval("frm")][eval("lstmonth")].options[12]=newOption("Dec","12");}function GrtrThanCurrent(frm,lstyear,lstmonth,lstday,msg){vari;varyr="";varmnth="";varday="";varcur_yr="";varcur_mnth="";varcur_day="";mnth=document[eval("frm")][eval("lstmonth")].value;day=Number(document[eval("frm")][eval("lstday")].value);yr=document[eval("frm")][eval("lstyear")].value;dat=mnth+"-"+day+"-"+yr;date_chk=yr+"-"+mnth+"-"+day;varlen=date_chk.length;d=newDate();cur_yr=d.getFullYear();cur_mnth=d.getMonth()+1;cur_day=Number(d.getDate());if(yr<cur_yr){alert(msg);document[eval("frm")][eval("lstyear")].focus();return false;}else if(yr==cur_yr&&mnth<cur_mnth){alert(msg);document[eval("frm")][eval("lstmonth")].focus();return false;}else if(yr==cur_yr&&mnth==cur_mnth&&day<cur_day){alert(msg);document[eval("frm")][eval("lstday")].focus();return false;}else{for(i=0;i<len;i++){if(i==2||i==5){}else{if(dat.substr(i,1)<0||dat.substr(i,1)>9){alert(msg);document[eval("frm")][eval("lstday")].focus();return false;break;}}}}return true;}function fnCompareDate(frm,flstyear,flstmonth,flstday,tlstyear,tlstmonth,tlstday,msg){vari;varyr="";varmnth="";varday="";varcur_yr="";varcur_mnth="";varcur_day="";dmnth=document[eval("frm")][eval("flstmonth")].value;dday=Number(document[eval("frm")][eval("flstday")].value);dyr=document[eval("frm")][eval("flstyear")].value;dat=dday+"-"+dmnth+"-"+dyr;date_chk=yr+"-"+mnth+"-"+day;varlen=date_chk.length;amnth=document[eval("frm")][eval("tlstmonth")].value;aday=Number(document[eval("frm")][eval("tlstday")].value);ayr=document[eval("frm")][eval("tlstyear")].value;dat1=aday+"-"+amnth+"-"+ayr;if(ayr<dyr){alert(msg);document[eval("frm")][eval("tlstyear")].focus();return false;}else if(ayr==dyr&&amnth<dmnth){alert(msg);document[eval("frm")][eval("tlstmonth")].focus();return false;}else if(ayr==dyr&&amnth==dmnth&&aday<dday){alert(msg);document[eval("frm")][eval("tlstday")].focus();
	return false;
	}else{for(i=0;i<len;i++){if(i==2||i==5){}else{if(dat1.substr(i,1)<0||dat1.substr(i,1)>9){alert(msg);document[eval("frm")][eval("tlstday")].focus();return false;break;}}}}return true;}function fnImage(frm,Img){if(trim(document[eval("frm")][eval("Img")].value)!=""){x=document[eval("frm")][eval("Img")].value.toLowerCase();if(x.indexOf(".jpg")==-1&&x.indexOf(".gif")==-1&&x.indexOf(".png")==-1&&x.indexOf(".swf")==-1){alert("PleaseselectvalidImage.");document[eval("frm")][eval("Img")].focus();return false;}}return true;}function fnDate_select(frm,lstyear,lstmonth,lstday,yr,mth,day){dat=newDate();year=dat.getFullYear();vari;varj=1;for(i=year;i>=year-5;i--){if(yr==i){document[eval("frm")][eval("lstyear")].options[j].selected=true;break;}j++;}varmon=Number(mth);for(m=1;m<=12;m++){if(mon==m){document[eval("frm")][eval("lstmonth")].options[m].selected=true;break;}}vardd=Number(day);fnDays(frm,lstyear,lstmonth,lstday);for(d=1;d<=31;d++){if(dd==d){document[eval("frm")][eval("lstday")].options[d].selected=true;break;}}}