var called=false;       //to make sure the function compute() is called

var Unit_Price=0;



function compute(form){

called=true;



function formatNum(expr,decplaces) {

	var str = (Math.round(parseFloat(expr) * Math.pow(10,decplaces))).toString()

	while (str.length <= decplaces) {

		str = "0" + str

	} 

	var decpoint = str.length - decplaces

	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length)

}



//-------PROCESSOR-----------	



processor_flag=parseFloat(form.processor[form.processor.selectedIndex].price)



//-------Case-----------	



pccase_flag=parseFloat(form.pccase[form.pccase.selectedIndex].price)





//-------MEMORY-----------	



memory_flag=parseFloat(form.ram[form.ram.selectedIndex].price)



//-------VIDEO CARDS-----------	



//video_flag=parseFloat(form.video[form.video.selectedIndex].price)



//-------FLOPPY-----------	



floppy_flag=parseFloat(form.floppy[form.floppy.selectedIndex].price)

            

//-------CDROM-----------	



//cdrom_flag=parseFloat(form.cd_rom[form.cd_rom.selectedIndex].price)


//-------OPTICAL-----------	



optical_flag=parseFloat(form.optical[form.optical.selectedIndex].price)



//-------DVD-----------	



//dvd_flag=parseFloat(form.dvd[form.dvd.selectedIndex].price)



//-------CDRW-----------	



//cdrw_flag=parseFloat(form.cdrw[form.cdrw.selectedIndex].price)

            

//-------HARD DRIVES-----------	



harddrive_flag=parseFloat(form.harddrive[form.harddrive.selectedIndex].price)

            

//-------OPERATING SYSTEM-----------	



operatingsystem_flag=parseFloat(form.operatingsystem[form.operatingsystem.selectedIndex].price)



//-------MONITOR-----------	



monitor_flag=parseFloat(form.monitor[form.monitor.selectedIndex].price)

           

//-------KEYBOARD-----------	



keyboard_flag=parseFloat(form.keyboard[form.keyboard.selectedIndex].price)

   

//-------Network Card-----------	



//nic_flag=parseFloat(form.nic[form.nic.selectedIndex].price)

          

//--------Mouse---------------



mouse_flag=parseFloat(form.mouse[form.mouse.selectedIndex].price)



//--------Install Image---------------



installimage_flag=parseFloat(form.installimage[form.installimage.selectedIndex].price)



//--------INSTALL SYSTEM---------------



installsystem_flag=parseFloat(form.installsystem[form.installsystem.selectedIndex].price)


//-------RESTORE UTILITY SOFTWARE-----------

restore_utility_flag=parseFloat(form.restore_utility[form.restore_utility.selectedIndex].price)


//-------OTHER SERVICES-----------

sticker_flag=parseFloat(form.sticker[form.sticker.selectedIndex].price)

//-------WARRANTY-----------

warranty_flag=parseFloat(form.warranty[form.warranty.selectedIndex].price)


//-------QUANTITY-----------	



quantity_flag=form.quantity.value;



//-------FIX PRICE-----------	



fPrice_flag=parseFloat(form.fPrice.value);

        

//-------UNIT PRICE-----------	



Unit_Price=(fPrice_flag + processor_flag + pccase_flag + memory_flag + floppy_flag + optical_flag + harddrive_flag + monitor_flag + keyboard_flag + operatingsystem_flag + mouse_flag + installimage_flag + installsystem_flag + restore_utility_flag + sticker_flag + warranty_flag );




Unit_Price=formatNum(Unit_Price,2)

form.Unit_Price.value=Unit_Price;





//-------FEATURED PRICE UNIT PRICE FOR TOP OF DOCUMENT-----------	



Featured_Price=(Unit_Price);

Featured_Price=formatNum(Featured_Price,2)

form.Featured_Price.value=Featured_Price;



//-------SUB TOTAL-----------	



Sub_Total=(Unit_Price * quantity_flag);

Sub_Total=formatNum(Sub_Total,2)

form.Sub_Total.value=Sub_Total;



//-------GST-----------	



GST=(Sub_Total * 0.06);

GST=formatNum(GST,2)

form.GST.value=GST;



//-------TOTAL OF THE ORDER-----------

Total_Order=Sub_Total * 1.06;

Total_Order=formatNum(Total_Order,2)

form.Total.value=Total_Order;





}

                  






