<!--

function external($i) {
  var link = document.getElementById($i);
  link.setAttribute("target","_blank");
}

function windowHeight(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	document.getElementById('confirm_delete').style.height = yWithScroll+'px';
	//Detect IE
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1) {
		temp=navigator.appVersion.split("MSIE");
		version=parseFloat(temp[1]);
	}
	if (document.getElementById('confirm_delete').style.height == '0px') {
		document.getElementById('confirm_delete').style.height = '100%';
	}
}

function popUp(e) {
	day = new Date();
	id = 'cake_window'; //day.getTime();
	eval("page" + id + " = window.open(e, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=400,left=0,top=0');");
}

function hideConfirm() {
	document.getElementById('confirm_delete').style.display = 'none';
}

function giantCakePriceUpdate(qty,option)
{
	if(option == true)
	{
		var price = 50.00;
	}
	else 
	{
		var price = 35.00;
	}
	var subtotal = parseFloat(qty) * price;
	document.getElementById('price_giantcake').innerHTML = '<em>sub-total:</em> &pound;'+subtotal.toFixed(2);
	document.getElementById('subtotal_giantcake').value = subtotal;
	totalPriceUpdate(); // update total too!
}




function selectionPriceUpdate(tick,qty)
{
	var number_of_flavours = 0;
	var maximum_flavours = qty/3;
	var unit_price = 1.25;
	var subtotal = 0;

	var tickgroup = document.getElementsByName('flavours[]');
	for(i = 0;i < tickgroup.length; i++)
	{
		if(tickgroup[i].checked)
		{
			number_of_flavours++;
		}
	}
	if(maximum_flavours > 8)
	{	
		maximum_flavours = 8;
	}
	if(number_of_flavours > maximum_flavours)
	{
		document.getElementsByName('flavours[]')[tick].checked = false;
		alert('You have selected too many flavours!\nYou may select up to '+maximum_flavours+' different flavours with your current quantity'); 
		return false;
	}
	if(qty > 0 && number_of_flavours == 0)
	{
		alert('You must choose at least one flavour!');
		//document.getElementsByName('flavours[]')[tick].checked = true;
		return false;
	}


	// calculate prices...
	if(number_of_flavours == 1) 
	{
		if(document.getElementsByName('flavours[]')[0].checked)
		{
			unit_price = 1.25;
		}
		else
		{
			unit_price = 1.50;
		}
	}
	else 
	{
		if(number_of_flavours >= 3 && number_of_flavours <= 4)		unit_price = 1.80;
		else if(number_of_flavours >=5 && number_of_flavours <=6)	unit_price = 2.30;
		else if(number_of_flavours >=7 && number_of_flavours <=8)	unit_price = 2.80;
		else 														unit_price = 1.50;
	}
	
	// update prices
	subtotal = parseInt(qty) * unit_price;
	document.getElementById('subtotal_selection').value = subtotal;
	document.getElementById('price_selection').innerHTML = '<em>sub-total:</em> &pound;'+subtotal.toFixed(2);	
	totalPriceUpdate(); // update total too!	
	
}

function selectionQtyUpdate(qty)
{
	var maximum_flavours = qty/3;
	var number_of_flavours = 0;
	
	for(i = 0;i < 16; i++)
	{
		if(document.getElementsByName('flavours[]')[i].checked)
		{
			if(++number_of_flavours > maximum_flavours)
			{
				document.getElementsByName('flavours[]')[i].checked = false;
			}
		}
	}	
	if(number_of_flavours == 0)
	{
		alert('Now choose at least one flavour below...');
		return false;		
	}
	// calculate prices...
	if(number_of_flavours == 1) 
	{
		if(document.getElementsByName('flavours[]')[0].checked)
		{
			unit_price = 1.25;
		}
		else
		{
			unit_price = 1.50;
		}
	}
	else 
	{
		if(number_of_flavours >= 3 && number_of_flavours <= 4)		unit_price = 1.80;
		else if(number_of_flavours >=5 && number_of_flavours <=6)	unit_price = 2.30;
		else if(number_of_flavours >=7 && number_of_flavours <=8)	unit_price = 2.80;
		else 														unit_price = 1.50;
	}
	
	// update prices
	subtotal = parseInt(qty) * unit_price;
	document.getElementById('subtotal_selection').value = subtotal;
	document.getElementById('price_selection').innerHTML = '<em>sub-total:</em> &pound;'+subtotal.toFixed(2);	
	totalPriceUpdate(); // update total too!
}


function giftboxPriceUpdate(size, qty)
{
	var subtotal = parseFloat(size) * parseInt(qty);
	document.getElementById('price_giftbox').innerHTML = '<em>sub-total:</em> &pound;'+subtotal.toFixed(2);
	document.getElementById('subtotal_giftbox').value = subtotal;
	totalPriceUpdate(); // update total too!
}

function seasonalboxPriceUpdate(size, qty)
{
	var subtotal = parseFloat(size) * parseInt(qty.substring(0,1));
	document.getElementById('price_seasonal').innerHTML = '<em>sub-total:</em> &pound;'+subtotal.toFixed(2);
	document.getElementById('subtotal_seasonal').value = subtotal;
	totalPriceUpdate(); // update total too!
}


function totalPriceUpdate()
{
	var total = 5.00 + 
				parseFloat(document.getElementById('subtotal_seasonal').value) +
				parseFloat(document.getElementById('subtotal_giftbox').value) +
				parseFloat(document.getElementById('subtotal_selection').value);
	document.getElementById('price_total').innerHTML = '<em>Total (including P&amp;P at &pound;5.00):</em> <strong>&pound;'+total.toFixed(2)+'</strong>';
	document.getElementById('final_total').value = total;
}

// -->