function calculate(){

		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()

price=0, qty=0; subtotal=0;

if (document.summit.qty.value ==1 )
		{
			document.summit.sfname.value="";
			document.summit.slname.value="";
}

qty = document.summit.qty.value*1;

// PRICE DAILY RATE
if (document.summit.price[0].checked){price = 75;}
if (document.summit.price[1].checked){price = 85;}
document.summit.prices.value = price;


//CALCULATING DISCOUNT
var discount = 0;
//if (document.summit.member.checked && document.summit.price[0].checked){discount = 10;}
//if (document.summit.member.checked && document.summit.price[1].checked){discount = 20;}
document.summit.discount.value = discount;

//EARLY BIRD SPECIAL - REGISTER FOR THE FULL CONFERENCE BY JUNE 15TH $15 OFF
//var early_bird_discount=0;
//var dd=30;
//var mm=10;
//var yyyy=2009;
//var early_bird_date=new Date(yyyy,mm-1,dd+1);  //(mm-1) because 0=jan; 1=feb; 2=mar; 3=apr; 4=may; 5=jun... to 11=dec
//var today_date=new Date(); 
//var early_bird_days = early_bird_date - today_date; //days remaining
//document.summit.early_bird_days.value= early_bird_days;

//if (today_date < early_bird_date){early_bird_discount = 15;}


//CALCULATING TOTAL AMOUNTS
subtotal = price * qty;

//if (document.summit.price[0].checked){ discount = subtotal * discount;}
//if (document.summit.price[1].checked){ discount = (subtotal/2) * discount;}


//CALCULATING TOTAL REGISTRATION
total = subtotal - discount;

document.summit.subtotal.value = subtotal;
document.summit.total.value = total;

build_item_number();

}

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 build_item_number(){
			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 item_number="", type="REG", qty1="0", days="", dayM="x", dayT="x", total="0";

		qty1=document.summit.qty.value;

			if (document.summit.dayM.checked)	{dayM="-M";} 
			if (document.summit.dayT.checked){dayT="-T";} 
			
		
			fname = document.summit.fname.value;
			fname = fname.toUpperCase();
      if (fname.length > 1)
				{y=1;}else{y=fname.length}
			fname = fname.substring(0, y)

			lname = document.summit.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 = lname + "-" + fname + date_mm + date_dd + date_hh + date_ms + type + qty1 + dayM + dayT;;
			document.summit.item_number.value= item_number;

}
