function nxtpmt(n) {
 o=document.pmt
 o.step.value=n
 o.submit()
 }
function gopage() {
 o=document.pg
 o.pg.value=o.gopg.value
 o.submit()
 }
function yn(msg) {
 if (confirm(msg)) {return true;}
 return false;
 }
function yn2(msg,url) {
 if (confirm(msg)) {location.replace(url);}
 return false;
 }
function gourl(url) {
document.frm.action=url
document.frm.submit()
//location.replace(url);
}
function hvr(o,newColor) {
 if(document.all){
  o.style.cursor='hand';	
  o.style.background=newColor;
  }
 }

 var __months = [,31,28,31,30,31,30,31,31,30,31,30,31]

function DateOK(Y,M,D) {var ML=__months[M];
 return D>0 && ML && (D<=ML || D==29 && Y%4==0 && (Y%100!=0 || Y%400==0) ) 
}
function stripBlanks(fld) {
 var result="";
 for (i=0; i<fld.length; i++)
  if (fld.charAt(i)!=" ") result += fld.charAt(i);
 return result;
 }
function stripBlanks2(fld) {var result="";for (i=0; i<fld.length; i++) {
 if (fld.charAt(i)!=" " || c > 0) {result += fld.charAt(i);
 if (fld.charAt(i)!=" ") c=result.length;}}
return result.substr(0,c);
}
function chkfld(typ,fld) {if (typ=='m') return true;
if (fld.indexOf(':')>-1) {
 fld2=fld.substring(fld.indexOf(':')+1,999); 
 fld=fld.substring(0,fld.indexOf(':'));
 }
var ss="0123456789.-/";
var OK=true;
var c;
var msg='';
var d1=new Array(0,0,0);
var o=document.frm[fld]; var s=stripBlanks(o.value);
if (typ=='n' || typ=='a') {
 if (s.length==0) {o.value='0';return true;}
 var vs='0123456789'+ ((typ=='a')?'.':'')
 for (i=0; i<s.length && OK==true; i++) {if (vs.indexOf(s.charAt(i))==-1) OK=false;}
 if (OK==false) msg='Invalid '+ ((typ=='a')?'numeric':'integer') +' value'
 }
if (typ=='d') {
 if (s.length==0) return true; 
 for (i=0; i<s.length; i++) {if (ss.indexOf(s.charAt(i))==-1) OK=false;}
 if (OK==true) {
  var d1=s.split('/');
  if (d1.length!=3) OK=false;  
  else {
   var n=parseFloat(d1[2]);
   if (n<100) {n+=2000; d1[2]=n;}
   OK=(DateOK(parseFloat(n), parseFloat(d1[1]), parseFloat(d1[0])));
   }
  }
 if (OK==true) {
  //d1[2]-=2000; 
  d1[2]+='';
  for (i=0; i<3; i++) {if (d1[i].length==1) d1[i]='0'+d1[i];}
  o.value=d1[0]+'/'+d1[1]+'/'+ d1[2]; return true;}
 else msg='Invalid Date value (dd/mm/yy)'
 }
if (typ=='y') {
 if (s.length==0) return true; 
 if (s!='N' || s!='Y' || s!=' ') msg='Invalid entry: "Y" or "N" expected.'
 }
if (typ=='e') {// email
 if (s.length==0) return true; 
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(s)){return (true)}
 else msg='Invalid email address'; 
 }
if (typ=='h') {
 if (s.length==0) return true;
 for (i=0; i<s.length && OK==true; i++) {if ('0123456789:'.indexOf(s.charAt(i))==-1) OK=false;}
 if (OK==true) {
  if (s.indexOf(':')==-1) {var dd=new Array(s,'0');}
  else {var dd=s.split(':'); OK=(dd.length<=2);}
  if (OK==true) OK=(parseInt(dd[0])>23 || parseInt(dd[1])>59);
  }
 if (OK==true) {
  for (i=0; i<2; i++)
   if (dd[i].length>2) OK=false;
   else {while (dd[i].length<2) dd[i]='0'+dd[i];}
  if (OK==true) {o.value=dd[0]+':'+dd[1]; return true;}
  }
 if (OK==false) msg='Invalid Time value (hh:mm)'
 }
if (typ=='!') o.value=o.value.toUpperCase();
if (msg>'') {alert(msg); o.focus(); 
 setTimeout(function() {o.focus()},50);
 return false;}
return true;
}

function addCommas(nStr) {
 nStr+='';
 var x =nStr.split('.');
 var x1=x[0];
 var x2=x.length>1 ? '.'+x[1] : '';
 var rgx=/(\d+)(\d{3})/;
  while (rgx.test(x1)) {
  x1=x1.replace(rgx, '$1'+','+'$2');
  }
 return x1+x2;
 }

function opnwnd(url) {o=window.open(url);}

function chkcat() {
o=document.frm
var s1=o.cat.value
var s0=o.cat0.value
if (s1!=s0) {
 n=o.cat.selectedIndex
 document.getElementById("subcatid").innerHTML="<select name=subcat class=edt2><option value=''>Sub-Category"+cats[n]+'</select>'
 }
}
