function updatetype () {

type = document.hardcoverform.type.value;

if (type == '1')
{
	bookprice=11.99;
		paypaldeschtml='<input type="hidden" name="item_name" value="Creamy Stories - Hardcover | Sold out, will be shipped late February"><input type="hidden" name="item_number" value="#CSCCHCp"><input type="hidden" name="amount" value="11.99">';

}
if (type == '2')
{
	bookprice=9.99;
		paypaldeschtml='<input type="hidden" name="item_name" value="Creamy Stories - Softcover"><input type="hidden" name="item_number" value="#CSCCSC"><input type="hidden" name="amount" value="9.99">';


}

document.getElementById('bookcost').innerHTML=bookprice;

document.getElementById('paypaldesc').innerHTML=paypaldeschtml;

hq = document.hardcoverform.hcquantity.value;
totalbookprice=parseFloat(hq);
totalbookprice=totalbookprice*bookprice;
totalbookprice=totalbookprice.toFixed(2);
document.getElementById('totaldispprice').innerHTML=totalbookprice;


document.getElementById('hcpostage').innerHTML='';
document.getElementById('speed').innerHTML='';
document.getElementById('hardcountry').innerHTML='<select name="delivery" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardspeed();"><option value="--" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Deliver to:</option><option value="UK">UK</option><option value="EU">Europe</option><option value="US">USA/Canada</option><option value="NN">Other</option></select>'
}


function updatehardrest () {
		hq = document.hardcoverform.hcquantity.value;
type = document.hardcoverform.type.value;

if (type == '1')
{
	bookprice=11.99;
		paypaldeschtml='<input type="hidden" name="item_name" value="Creamy Stories - Hardcover"><input type="hidden" name="item_number" value="CSCCHC"><input type="hidden" name="amount" value="11.99">';

}
if (type == '2')
{
	bookprice=9.99;
		paypaldeschtml='<input type="hidden" name="item_name" value="Creamy Stories - Softcover"><input type="hidden" name="item_number" value="CSCCSC"><input type="hidden" name="amount" value="9.99">';


}

totalbookprice=parseFloat(hq);
totalbookprice=totalbookprice*bookprice;
totalbookprice=totalbookprice.toFixed(2);

document.getElementById('totaldispprice').innerHTML=totalbookprice;


update='<input type="hidden" name="quantity" value="'+hq+'">';
document.getElementById('hcppquantity').innerHTML=update;

document.getElementById('hcpostage').innerHTML='';
document.getElementById('speed').innerHTML='';
document.getElementById('hardcountry').innerHTML='<select name="delivery" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardspeed();"><option value="--" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Deliver to:</option><option value="UK">UK</option><option value="EU">Europe</option><option value="US">USA/Canada</option><option value="NN">Other</option></select>';

}

function updatehardspeed () {

	hregion = document.hardcoverform.delivery.value;

if (hregion=='UK')
{
	speedhtml='<select name="postage" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardpostage();"><option value="" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Choose Postage:</option><option value="1">Standard(2-4 days)</option><option value="2">First Class(1-2 days)</option></select>';
}
if (hregion=='EU')
{
	speedhtml='<select name="postage" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardpostage();"><option value="" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Choose Postage:</option><option value="1">Surface mail(2-5 weeks)</option><option value="2">Airmail(4-5 days)</option></select>';
}
if (hregion=='US')
{
	speedhtml='<select name="postage" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardpostage();"><option value="" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Choose Postage:</option><option value="1">Surface mail(<6 weeks)</option><option value="2">Airmail(4-5 days)</option></select>';
}
if (hregion=='NN')
{
	speedhtml='<select name="postage" STYLE="width: 150px; font-size:14px;color:#000000;background: #FFFFFF;" onChange="javascript:updatehardpostage();"><option value="" selected="selected" STYLE="color:#13729E;background:#D6E8FE;font-weight:bold">Choose Postage:</option><option value="1">Surface mail(<12 weeks)</option><option value="2">Airmail(7-10 days)</option></select>';
}

document.getElementById('speed').innerHTML=speedhtml;

}

function updatehardpostage () {

	hcq = document.hardcoverform.hcquantity.value;
	hregion = document.hardcoverform.delivery.value;
	hcs = document.hardcoverform.postage.value;

	if (hcs =='1')
	{
		hcspaypal='Surface';
	}
	if (hcs =='2')
	{
		hcspaypal='Air';
	}

type = document.hardcoverform.type.value;

if (type == '1')
{


if (hregion=='UK')
{
		postage = new Array(1.31,1.31,4.95,5.59,7.7,8.14,7.7,10.69,7.7,13.24,8.74,15.79,8.74,18.5,8.74,18.5,9.97,18.5,9.97,18.5);
}
if (hregion=='EU')
{
		postage = new Array(3.84,4.23,7.44,7.68,11.28,11.28,14.64,14.43,18.48,18.03,21.84,21.18,21.84,24.78,29.04,27.93,32.88,31.53,36.24,31.98);

}
if (hregion=='US')
{
		postage = new Array(3.84,8.11,7.44,15.51,11.28,23.51,14.64,30.51,18.48,38.51,21.84,45.51,21.84,53.51,29.04,60.51,32.88,68.51,36.24,69.51);

}
if (hregion=='NN')
{
		postage = new Array(3.84,8.11,7.44,15.51,11.28,23.51,14.64,30.51,18.48,38.51,21.84,45.51,21.84,53.51,29.04,60.51,32.88,68.51,36.24,69.51);

}

}
if (type == '2')
{


if (hregion=='UK')
{
		postage = new Array(1.31,1.31,4.95,5.59,5.31,7.29,7.7,9.84,7.7,11.54,7.7,14.09,8.74,15.79,8.74,18.5,8.74,18.5,9.97,18.5);
}
if (hregion=='EU')
{
		postage = new Array(3.36,3.63,6.48,6.69,9.36,9.48,12.72,12.63,15.6,14.88,18.48,18.03,21.84,21.18,24.72,23.88,27.6,26.58,30.93,29.73);

}
if (hregion=='US')
{
		postage = new Array(3.36,6.91,6.48,13.31,9.36,19.51,12.72,26.51,15.6,31.51,18.48,38.51,21.84,45.51,24.72,51.51,27.6,57.51,30.93,64.51);

}
if (hregion=='NN')
{
		postage = new Array(3.84,8.11,7.44,15.51,11.28,23.51,14.64,30.51,18.48,38.51,21.84,45.51,21.84,53.51,29.04,60.51,32.88,68.51,36.24,69.51);

}

}

hcqtest=hcq-1;
hcqtest2=hcqtest*2;
hcs=parseFloat(hcs);
relevantP=hcqtest2+hcs-1;

postageRate=postage[relevantP];
postageRate=postageRate.toFixed(2);

document.getElementById('hcpostage').innerHTML=postageRate;

document.getElementById('paypalpost').innerHTML='<input type="hidden" name="os1" value="'+hcspaypal+'"><input type="hidden" name="shipping" value="'+postageRate+'">';


}
