// (C) Copyright 2004 - 2011 TraciDesign and Jeppessen Productions.
// Prepared for the Property Power Disc.
// Copyright: This software is protected by copyright laws and international copyright treaties, 
// as well as other intellectual property laws and treaties. The software is licensed not sold.
// Restriction: You may not attempt to reverse compile, modify, translate or disassemble this software 
// in whole or in part. You may not remove or modify any copyright notice.

function RoundNumbers(TheNum) {
	return TheNum;
}

function addComma(TheNum)
{
    numVar=String(TheNum);
    var commaNumber = "";
    var thenumber = ""
    var thefraction = "";
    var j = numVar.indexOf(".");
    var l = numVar.length;
    
    if (j > 0)
    {    
	 tvar=numVar+"00"; 
	 numVar=numVar.substr(0,j);
         for(i = j; i<j+3; i++) {     
               thefraction = thefraction + tvar.charAt(i); }
    }  else { 
	    thefraction = ".00"; }
	j = numVar.length;

    for (i = j; i > 0; i--) {
         if ((i != j) && ((j - i) % 3 == 0))
                thenumber = thenumber + ",";
         thenumber = thenumber + numVar.charAt(i-1);
    }
    j = thenumber.length;
    for (i = j; i >= 0; i--)
        commaNumber = commaNumber + thenumber.charAt(i);
    
    commaNumber=commaNumber+thefraction; 
    return commaNumber;
}


function ValidateNumberOnlyInput(allowdot) {
    if (!((event.keyCode>=48) && (event.keyCode<=57))) {
    	event.returnValue = false;
	}
    	
    if ((allowdot>0) && (event.keyCode==46)) {
        event.returnValue = true;
	}
}

function UpdateInfo() {
	var PPDiscCost = 123.00;
	//var PPMagCost = 98.00;
	var postcost = 0.00;
	
	NoCopies=(document.OrderForm.txtCopiesPPDisc.value*1);
	//NoCopies=(document.OrderForm.txtCopiesPPDisc.value*1) + (document.OrderForm.txtCopiesPPMag.value*1);
	
	//alert(NoCopies);
	document.OrderForm.txtCostCopiesPPDisc.value=addComma((document.OrderForm.txtCopiesPPDisc.value*1)*PPDiscCost);
	//document.OrderForm.txtCostCopiesPPMag.value=addComma((document.OrderForm.txtCopiesPPMag.value*1)*PPMagCost);
		
	//document.OrderForm.txtCostPost1.value = 0;
	//document.OrderForm.txtCostPost2.value = 0;
	
	//if (document.OrderForm.rdgAcquire[0].checked) {
		//REGULAR POST to postal address @ R9.50 per copy
		postcost=(postcost*NoCopies);
	//	document.OrderForm.txtCostPost1.value=addComma(postcost);		
	//} else 
	//	if (document.OrderForm.rdgAcquire[1].checked) {
		//REGULAR POST to physical address @ R9.50 per copy
	//	postcost=(9.50*NoCopies);
	//	document.OrderForm.txtCostPost2.value=addComma(postcost);
	//} 
	document.OrderForm.txtCostPost.value=addComma(postcost);
	//document.OrderForm.txtCostTotal.value=addComma((document.OrderForm.txtCostCopiesPPDisc.value*1)+(document.OrderForm.txtCostCopiesPPMag.value*1)+postcost);
	document.OrderForm.txtCostTotal.value=addComma((document.OrderForm.txtCostCopiesPPDisc.value*1)+postcost);
	document.OrderForm.txtTotalTransfer.value=addComma((document.OrderForm.txtCostTotal.value));
	
	
}


