<!-- Begin calculate suremark products order form

function CalTotalPrice(){
	var i;
	var tRows = 3;
	var itemsSummary = "";
	var qty_id = new Array(tRows);
	var price_id = new Array(tRows);
	var itemsDesc = new Array(tRows);
	var unitprice = new Array(tRows);
	var zones = new Array(7);
	
	zones[0]="A";
	zones[1]="B";
	zones[2]="C";
	zones[3]="D";
	zones[4]="E";
	zones[5]="F";
	zones[6]="G";
	unitprice[0]=39.9;
	unitprice[1]=39.9;
	unitprice[2]=19.9;
	itemsDesc[0]="SUREGOOD";
	itemsDesc[1]="SUREPLUS";
	itemsDesc[2]="EXTRASHAMPOO";
	
	for (i=0;i<tRows;i++){
		qty_id[i] = document.getElementById? document.getElementById('qty'+i): document.all? document.all['qty'+i]: null;
		price_id[i] = document.getElementById? document.getElementById('tPrice'+i): document.all? document.all['tPrice'+i]: null;
	}

	var grandtotal = 0.0;
	var tPrice;

	for (i=0;i<tRows;i++){
		tPrice = parseInt(qty_id[i].value)*unitprice[i];
		grandtotal += tPrice;
		price_id[i].innerHTML = tPrice.toFixed(2);
		if (tPrice > 0.0){
			itemsSummary += itemsDesc[i] + ": " + qty_id[i].value + " = USD" + tPrice.toFixed(2) + "; ";
		}
	}
	
	var grandtotal_id = document.getElementById? document.getElementById('gPrice'): document.all? document.all['gPrice']: null;		
	var subtotal_id = document.getElementById? document.getElementById('subTotalPrice'): document.all? document.all['subTotalPrice']: null;		
	var zones_id = document.getElementById? document.getElementById('czones'): document.all? document.all['czones']: null;		
	var dilevery_id = document.getElementById? document.getElementById('dcharge'): document.all? document.all['dcharge']: null;		
	var discount_id = document.getElementById? document.getElementById('discount'): document.all? document.all['discount']: null;		
	var percent_id = document.getElementById? document.getElementById('percent'): document.all? document.all['percent']: null;		
	
	var bvdiscount = 0;
	var bvdiscountAmt = 0.0;
	bvdiscount = BigVolumeDiscount(grandtotal);
	percent_id.innerHTML = bvdiscount+"%";
	bvdiscountAmt = grandtotal * (bvdiscount/100);
	discount_id.innerHTML = bvdiscountAmt.toFixed(2);
	grandtotal = grandtotal - bvdiscountAmt;
	subtotal_id.innerHTML = grandtotal.toFixed(2);
	itemsSummary += "Discount: " + bvdiscountAmt.toFixed(2) + "; ";
	
	var deliverycharge = 0.0;
	if (grandtotal <= 199.0) deliverycharge = DeliveryCharge(zones_id.value);
	dilevery_id.innerHTML = deliverycharge.toFixed(2);
	grandtotal += deliverycharge;
	itemsSummary += "Delivery Charge: " + deliverycharge.toFixed(2) + " Zone "+ zones[zones_id.value];

	grandtotal_id.innerHTML = grandtotal.toFixed(2);
	
	var orderform = document.getElementById? document.getElementById('Order'): document.all? document.all['Order']: null;
	orderform.amount.value = grandtotal.toFixed(2);
	orderform.item_name.value = itemsSummary;	
}

function ValidatingField(qty,itemid){
	if(isNaN(qty)){
		alert("Please enter only numers for quantities.");
		focus_id = document.getElementById? document.getElementById('qty'+itemid): document.all? document.all['qty'+itemid]: null;	
		focus_id.focus();
	}else{
		CalTotalPrice();
	}
}

function ValidatingOrder(){
	var subtotal_id = document.getElementById? document.getElementById('subTotalPrice'): document.all? document.all['subTotalPrice']: null;		
	ordervalue = parseInt(subtotal_id.innerHTML);
	if (ordervalue <=0){
		alert("Sorry, you have not entered any quantity for the products.");	
		return false;
	}else{
		return true;	
	}
}

function DeliveryCharge(z){
	var zones = new Array(7);
	var forex = 1.3; //USD to SGD
	zones[0] = 0.0; // zone A
	zones[1] = 50.0/forex; // zone B
	zones[2] = 60.0/forex; // zone C
	zones[3] = 70.0/forex; // zone D
	zones[4] = 80.0/forex; // zone E
	zones[5] = 90.0/forex; // zone F
	zones[6] = 120.0/forex; // zone G
	return zones[z];
}

function BigVolumeDiscount(z){
	var discount = 0;
	if (z > 470.0) discount = 5;
	if (z > 950.0) discount = 10;
	if (z > 1430.0) discount = 15;
	if (z > 1900.0) discount = 20;
	return discount;
}

//  End calculate suremark products order form-->