
function tS(){ x=new Date(); x.setTime(x.getTime()); return x; } 
function lZ(x){ return (x>9)?x:'0'+x; } 
function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } 

function calculate1(){

var mydate=new Date()
var date_day=mydate.getDay()         //0=sun; 1=mon; 2=tue ...
var date_dd=mydate.getDate()         //1 to 31
var date_mm=mydate.getMonth()+1 //0=jan; 1=feb; 2=mar... to 11=dec
var date_yyyy=mydate.getYear()

var date_hh=lZ(mydate.getHours())
var date_ms=lZ(mydate.getMinutes())
var date_ss=lZ(mydate.getSeconds())

total = 0;
if (isNaN(document.giving1.dtd.value)){document.giving1.dtd.value = 0;}
if (isNaN(document.giving1.ffm.value)){document.giving1.ffm.value = 0;}
if (isNaN(document.giving1.ipmc.value)){document.giving1.ipmc.value = 0;}

dtd = document.giving1.dtd.value*1;
ffm = document.giving1.ffm.value*1;
ipm = document.giving1.ipmc.value*1;

total = dtd + ffm + ipm;
document.giving1.amount_a3.value = total;


var item_number="DTD-OTG";
dx = "-x";
fx = "-x";
ix = "-x";

if (document.giving1.dtd.value >0){dx = "-DT";}
if (document.giving1.ffm.value >0){fx = "-FF";}
if (document.giving1.ipmc.value >0){ix = "-IP";}

fname = document.giving1.fname.value;
fname = fname.toUpperCase();
if (fname.length > 1)
	{y=1;}else{y=fname.length}
fname = fname.substring(0, y)

lname = document.giving1.lname.value;
lname = lname.toUpperCase();
if (lname.length > 3)
	{y=3;}else{y=lname.length}
lname = lname.substring(0, y)

if (date_mm < 10){date_mm = "0"+date_mm;}
if (date_dd  < 10){date_dd   = "0"+date_dd;}

item_number =  item_number + "-" + lname + "-" + fname + date_mm + date_dd + date_hh + date_ms + date_ss + dx+fx+ix;
document.giving1.item_number.value= item_number;

}



function calculate2(){

var mydate=new Date()
var date_day=mydate.getDay()         //0=sun; 1=mon; 2=tue ...
var date_dd=mydate.getDate()         //1 to 31
var date_mm=mydate.getMonth()+1 //0=jan; 1=feb; 2=mar... to 11=dec
var date_yyyy=mydate.getYear()

subtotal=0; 
total_a3=0;

gt = document.giving2.gift_type.value;
a3 = document.giving2.amount_a3.value*1;
p3 = document.giving2.billing_cycle_p3.value*1;
t3 = document.giving2.billing_cycle_t3.value;
srt = document.giving2.how_many_srt.value*1;

if (document.giving2.gift_type.value == "DT"){document.giving2.type.value = "DTD";}
if (document.giving2.gift_type.value == "FF"){document.giving2.type.value = "FFMWOC";}
if (document.giving2.gift_type.value == "IP"){document.giving2.type.value = "IPMC";}

document.giving2.p3.value = document.giving2.billing_cycle_p3.value;

if (document.giving2.billing_cycle_t3.value == "W"){document.giving2.t3.value = "WEEK(S)";}
if (document.giving2.billing_cycle_t3.value == "M"){document.giving2.t3.value = "MONTH(S)";}
//if (document.giving2.billing_cycle_t3.value == "W"){document.giving2.t3x.value = "WEEK(S)";}
//if (document.giving2.billing_cycle_t3.value == "M"){document.giving2.t3x.value = "MONTH(S)";}
document.giving2.t3x.value = "INSTALLMENTS";

total_a3 = a3*srt;
document.giving2.total_a3.value = total_a3;

var date_hh=lZ(mydate.getHours())
var date_ms=lZ(mydate.getMinutes())
var date_ss=lZ(mydate.getSeconds())

var item_number="DTD-ARG";

fname = document.giving2.fname.value;
fname = fname.toUpperCase();
if (fname.length > 1)
	{y=1;}else{y=fname.length}
fname = fname.substring(0, y)

lname = document.giving2.lname.value;
lname = lname.toUpperCase();
if (lname.length > 3)
	{y=3;}else{y=lname.length}
lname = lname.substring(0, y)

if (date_mm < 10){date_mm = "0"+date_mm;}
if (date_dd  < 10){date_dd   = "0"+date_dd;}

item_number = item_number + "-" + lname + "-" + fname + date_mm + date_dd + date_hh + date_ms + date_ss + "-" + gt + "-" + a3 + "-EA" + p3 + t3 + "X"+ srt;
document.giving2.item_number.value= item_number;

}
