function calc_total(cost, quantity){
amount = cost * quantity;
alert (amount);
}

function update_total(inid){

	special_quantity = eval("document.cart_quantity.special_quantity_"+inid);
	special_price = eval("document.cart_quantity.special_price_"+inid);	
	
	the_special_quantity = 0;
	
	if (special_quantity){
	the_special_quantity = parseInt(special_quantity.value, 10);
	the_special_price = parseFloat(special_price.value, 10);
	}
	
	outputid = "total_"+inid;

	// DETERMINE VALUES TO MULTIPLY

	var selectBox = document.cart_quantity.elements[0];
	samount = selectBox.options[selectBox.selectedIndex].text;


	//DETERMINE IF WE HAVE A SPECIAL OPTION OR NOT TO HANDLE
	option_special = (samount.lastIndexOf("SPECIAL OFFER BUY "));
	
		if (option_special > -1){
		the_special_quantity_end = (samount.indexOf(" ",(option_special+18)));
		the_special_quantity = parseInt(samount.substring((option_special+18),the_special_quantity_end));
		
	// NOW LET'S GET THE AMOUNT
	
		option_special = (samount.lastIndexOf("FOR ONLY £"));
	
		the_special_price_end = (samount.indexOf(" ",(option_special+10)));
		the_special_price = parseFloat(samount.substring((option_special+10),the_special_price_end));
		
		}


	cutstart = (samount.lastIndexOf("("))+2;
	cutend = samount.length-1;

	samount = samount.substring(cutstart,cutend);
	samount = parseFloat(samount,10);

	var selectBox = document.cart_quantity.cart_quantity;
	syear = selectBox.options[selectBox.selectedIndex].value;



	// DETERMINE THE FINAL AMOUNT
	
		if (the_special_quantity > 0){
		outtotal = (syear % the_special_quantity) * samount;

		outtotal += (Math.floor((syear / the_special_quantity)) * the_special_price);
		outtotal= outtotal.toFixed(2);

		} else {
		outtotal = (samount * syear).toFixed(2);
		}

	document.getElementById(outputid).innerHTML = "Total: &pound;" + (outtotal);
}












function update_named_total(inid, formid){


	special_quantity = eval("document."+formid+".special_quantity_"+inid);
	special_price = eval("document."+formid+".special_price_"+inid);	
	
	the_special_quantity = 0;
	
	if (special_quantity){
	the_special_quantity = parseInt(special_quantity.value, 10);
	the_special_price = parseFloat(special_price.value, 10);
	}

	outputid = "total_"+inid;

	// DETERMINE VALUES TO MULTIPLY

	var selectBox = eval("document."+formid+".elements[0]");
	samount = selectBox.options[selectBox.selectedIndex].text;


	//DETERMINE IF WE HAVE A SPECIAL OPTION OR NOT TO HANDLE
	option_special = (samount.lastIndexOf("SPECIAL OFFER BUY "));
	
		if (option_special > -1){
		the_special_quantity_end = (samount.indexOf(" ",(option_special+18)));
		the_special_quantity = parseInt(samount.substring((option_special+18),the_special_quantity_end));
		
	// NOW LET'S GET THE AMOUNT
	
		option_special = (samount.lastIndexOf("FOR ONLY £"));
	
		the_special_price_end = (samount.indexOf(" ",(option_special+10)));
		the_special_price = parseFloat(samount.substring((option_special+10),the_special_price_end));		
		
		}


	
	cutstart = (samount.lastIndexOf("("))+2;
	cutend = samount.length-1;

	samount = samount.substring(cutstart,cutend);
	samount = parseFloat(samount,10);

	

	var selectBox = eval("document."+formid+".cart_quantity");
	syear = selectBox.options[selectBox.selectedIndex].value;
	
	// DETERMINE THE FINAL AMOUNT
	
		if (the_special_quantity > 0){
		outtotal = (syear % the_special_quantity) * samount;

		outtotal += (Math.floor((syear / the_special_quantity)) * the_special_price);
		outtotal= outtotal.toFixed(2);

		} else {
		outtotal = (samount * syear).toFixed(2);
		}

	document.getElementById(outputid).innerHTML = "Total: &pound;" + (outtotal);
}