function calculation(){
datecalculation();

var dd=document.prices.dd.value ;var ww=(document.prices.ww.value)*1 ;
var ee=document.prices.ee.value ;var ins=document.prices.insurance.value;
var pu=document.prices.Collect.value;

if (ww==0 && dd>4){dd=0; ww=1;}

var vstartyear=document.prices.startyear.value;
var vstartmonth=(document.prices.startmonth.value)-1;
var vstartday=document.prices.startday.value;
var vstartdate=new Date(vstartyear , vstartmonth , vstartday);
var one_day=1000*60*60*24;
var vendyear=document.prices.endyear.value;
var vendmonth=(document.prices.endmonth.value)-1;
var vendday=document.prices.endday.value;
var venddate=new Date(vendyear , vendmonth , vendday);

var nodo=document.prices.howlong.value;
if (nodo==1){nodo=2;}

var asatd=0;
var asatw=0;

if (ins==4 || ins==5 || ins==6){
asatd=8;
asatw=39;
}

var alamofrom2=new Date(2010, 3, 01);
var alamoto2=new Date(2011, 2, 31);

var alamofrom3=new Date(2010, 3, 01);
var alamoto3=new Date(2011, 2, 31);

var peak1afrom=new Date(2010, 11, 18);
var peak1ato=new Date(2010, 11, 31);
var peak1bfrom=new Date(2011, 11, 18);
var peak1bto=new Date(2011, 11, 31);

var eoy=new Date(2010, 02, 31);
var eoy2011=new Date(2011, 02, 31);

var nod=0; var add=dd; var uppd1=0;  var wppd1=0;  var eppd1=0; 

if(ww>0)
{
	if (ee > 5) 
	{
		ww=ww+1;
		ee=0;
	}
add=ee;
}

//alamo christmas loading
if (vstartdate.getTime() >= peak1afrom.getTime() && vstartdate.getTime() <= peak1ato.getTime() )
{
bld=5;
blw=20;
}


if (ins==1 || ins==4){

if (vstartdate.getTime() >= alamofrom2.getTime() && vstartdate.getTime() <= alamoto2.getTime()) 
{
sppd1=26;
sppd2=28;
sppd3=29;
sppd4=29;
sppd5=32;
sppd6=32;
sppd7=34;
sppd8=34;
sppd9=42;
sppd10=44;
sppd11=44;
sppd12=44;
sppd13=42;
sppd14=46;
sppd15=64;
sppd16=36;
sppd17=46;
sppw1=123;
sppw2=127;
sppw3=131;
sppw4=135;
sppw5=142;
sppw6=146;
sppw7=156;
sppw8=160;
sppw9=194;
sppw10=206;
sppw11=209;
sppw12=206;
sppw13=198;
sppw14=235;
sppw15=325;
sppw16=172;
sppw17=226;
}
if (vstartdate.getTime() >= alamofrom3.getTime() && vstartdate.getTime() <= alamoto3.getTime()) 
{

sppd1=28;
sppd2=29;
sppd3=30;
sppd4=30;
sppd5=33;
sppd6=33;
sppd7=36;
sppd8=36;
sppd9=44;
sppd10=46;
sppd11=46;
sppd12=46;
sppd13=46;
sppd14=58;
sppd15=78;
sppd16=36;
sppd17=56;
sppw1=129;
sppw2=133;
sppw3=138;
sppw4=142;
sppw5=153;
sppw6=157;
sppw7=164;
sppw8=167;
sppw9=204;
sppw10=216;
sppw11=231;
sppw12=216;
sppw13=215;
sppw14=268;
sppw15=352;
sppw16=202;
sppw17=251;

}
}


if (ins==2 || ins==3 || ins==5 || ins==6){


if (vstartdate.getTime() >= alamofrom2.getTime() && vstartdate.getTime() <= alamoto2.getTime()) 
{
sppd1=33;
sppd2=34;
sppd3=35;
sppd4=35;
sppd5=39;
sppd6=39;
sppd7=41;
sppd8=41;
sppd9=50;
sppd10=52;
sppd11=52;
sppd12=52;
sppd13=50;
sppd14=54;
sppd15=72;
sppd16=44;
sppd17=54;
sppw1=154;
sppw2=157;
sppw3=162;
sppw4=166;
sppw5=177;
sppw6=180;
sppw7=187;
sppw8=190;
sppw9=231;
sppw10=243;
sppw11=246;
sppw12=243;
sppw13=235;
sppw14=273;
sppw15=362;
sppw16=209;
sppw17=263;
}
if (vstartdate.getTime() >= alamofrom3.getTime() && vstartdate.getTime() <= alamoto3.getTime()) 
{
sppd1=34;
sppd2=36;
sppd3=37;
sppd4=37;
sppd5=41;
sppd6=41;
sppd7=43;
sppd8=43;
sppd9=52;
sppd10=54;
sppd11=54;
sppd12=54;
sppd13=54;
sppd14=66;
sppd15=86;
sppd16=44;
sppd17=64;
sppw1=162;
sppw2=165;
sppw3=169;
sppw4=174;
sppw5=186;
sppw6=189;
sppw7=196;
sppw8=199;
sppw9=242;
sppw10=255;
sppw11=268;
sppw12=255;
sppw13=252;
sppw14=306;
sppw15=389;
sppw16=240;
sppw17=288;
}
}
var late=0;
if (nodo<3){late=5;}
var pu=document.prices.Collect.value;
var dr=document.prices.Drop.value;
if (dr=="2130" || dr=="000" || dr=="F00"){dr=pu;}
var today=new Date();
var one_day=1000*60*60*24;
var soon=Math.ceil((vstartdate.getTime()-today.getTime())/(one_day));
if (soon<4){
if (soon==3){late=late+5;}
if (soon==2){late=late+10;}
if (soon==1){late=late+20;}
}

var x=((dd*1)+(ee*1));

var tdd=x; var tww=ww;
if (tdd>4){tdd=0;tww=tww+1;}
if (ins==2 && nodo<7)
{
tdd=0;
tww=1;
}

//alamo special offer bookings made b4 booked < 1/9/2010
var asoend=new Date(2010, 7, 31);
if(today.getTime()<=asoend.getTime()){
if (ins==1 || ins==4){
sppd1=23;
sppd2=24;
sppd3=25;
sppd4=26;
sppd5=29;
sppd6=30;
sppd7=31;
sppd8=31;
sppd9=40;
sppd10=41;
sppd11=45;
sppd12=41;
sppd13=42;
sppd14=53;
sppd15=69;
sppd16=40;
sppd17=54;
sppw1=117;
sppw2=121;
sppw3=124;
sppw4=130;
sppw5=141;
sppw6=144;
sppw7=150;
sppw8=153;
sppw9=196;
sppw10=200;
sppw11=222;
sppw12=200;
sppw13=205;
sppw14=260;
sppw15=345;
sppw16=194;
sppw17=270;
}
if (ins==2 || ins==3 || ins==5 || ins==6){
sppd1=29;
sppd2=30;
sppd3=31;
sppd4=32;
sppd5=34;
sppd6=35;
sppd7=35;
sppd8=35;
sppd9=47;
sppd10=46;
sppd11=52;
sppd12=46;
sppd13=48;
sppd14=61;
sppd15=77;
sppd16=46;
sppd17=62;
sppw1=144;
sppw2=149;
sppw3=150;
sppw4=155;
sppw5=166;
sppw6=170;
sppw7=175;
sppw8=180;
sppw9=235;
sppw10=232;
sppw11=255;
sppw12=230;
sppw13=235;
sppw14=295;
sppw15=380;
sppw16=225;
sppw17=305;
}
}
document.prices.s1.value=Math.round(late+(add*(asatd+sppd1))+(ww*(asatw+sppw1)));
document.prices.s2.value=Math.round(late+(add*(asatd+sppd2))+(ww*(asatw+sppw2)));
document.prices.s3.value=Math.round(late+(add*(asatd+sppd3))+(ww*(asatw+sppw3)));
document.prices.s4.value=Math.round(late+(add*(asatd+sppd4))+(ww*(asatw+sppw4)));
document.prices.s5.value=Math.round(late+(add*(asatd+sppd5))+(ww*(asatw+sppw5)));
document.prices.s6.value=Math.round(late+(add*(asatd+sppd6))+(ww*(asatw+sppw6)));
document.prices.s7.value=Math.round(late+(add*(asatd+sppd7))+(ww*(asatw+sppw7)));
document.prices.s8.value=Math.round(late+(add*(asatd+sppd8))+(ww*(asatw+sppw8)));
document.prices.s9.value=Math.round(late+(add*(asatd+sppd9))+(ww*(asatw+sppw9)));
document.prices.s10.value=Math.round(late+(add*(asatd+sppd10))+(ww*(asatw+sppw10)));
document.prices.s11.value=Math.round(late+(add*(asatd+sppd11))+(ww*(asatw+sppw11)));
document.prices.s12.value=Math.round(late+(add*(asatd+sppd12))+(ww*(asatw+sppw12)));
document.prices.s13.value=Math.round(late+(add*(asatd+sppd13))+(ww*(asatw+sppw13)));
document.prices.s14.value=Math.round(late+(add*(asatd+sppd14))+(ww*(asatw+sppw14)));
document.prices.s15.value=Math.round(late+(add*(asatd+sppd15))+(ww*(asatw+sppw15)));
document.prices.s16.value=Math.round(late+(add*(asatd+sppd16))+(ww*(asatw+sppw16)));
document.prices.s17.value=Math.round(late+(add*(asatd+sppd17))+(ww*(asatw+sppw17)));

// Alamo special offer valid for bookings placed until 30th June 2010 and with start date between 01/01/2009 - 31/3/2009
var asostart=new Date(2009, 0, 01);
var asoend=new Date(2010, 5, 30);
if(vstartdate>=asostart && vstartdate<=asoend){
document.prices.s5.value=Math.round(late+(add*(asatd+sppd3))+(ww*(asatw+sppw3)));
document.prices.s6.value=Math.round(late+(add*(asatd+sppd4))+(ww*(asatw+sppw4)));
document.prices.s7.value=Math.round(late+(add*(asatd+sppd5))+(ww*(asatw+sppw5)));
document.prices.s8.value=Math.round(late+(add*(asatd+sppd6))+(ww*(asatw+sppw6)));
}
// End Alamo Special Offer


//if ((pu == "961" || pu == "28") && (dr == "961" || dr == "28"))  //mco and sfb
//{
//document.prices.b17.value=Math.round(late+(dd*(bydfd+bppd17))+(ww*(bydfw+bppw17))+(ee*(bydfd+bppe17))+bll);  //8 seater minivan
//document.prices.b17.value="SOLDOUT";
//}
if (dr!="000" && dr!="F00" && pu!=dr){ //Alamo do not allow one way drop in economy cars
document.prices.s1.value="N/A";
document.prices.s2.value="N/A";
}

if (pu!="961" && pu!="1025" && pu!="28"){ //Alamo 12/15 seater only available in Miami Sanford  Orlando
document.prices.s15.value="N/A";
}

if (pu!="961" && pu!="1025" && pu!="28" && pu!="10"){ //7 seater SUV only available in Miami Sanford  Orlando Tampa
document.prices.s17.value="N/A";
}

if (document.prices.message.value=="invalid dates" || ins==3 || ins==6 || pu=="2036" || dr=="2036" ) { //YDP and Sat Nav + Cape Canaveral
document.prices.s1.value="N/A";
document.prices.s2.value="N/A";
document.prices.s3.value="N/A";
document.prices.s4.value="N/A";
document.prices.s5.value="N/A";
document.prices.s6.value="N/A";
document.prices.s7.value="N/A";
document.prices.s8.value="N/A";
document.prices.s9.value="N/A";
document.prices.s10.value="N/A";
document.prices.s11.value="N/A";
document.prices.s12.value="N/A";
document.prices.s13.value="N/A";
document.prices.s14.value="N/A";
document.prices.s15.value="N/A";
document.prices.s16.value="N/A";
document.prices.s17.value="N/A";
document.prices.t1.value="N/A";
document.prices.t2.value="N/A";
document.prices.t3.value="N/A";
document.prices.t4.value="N/A";
document.prices.t5.value="N/A";
document.prices.t6.value="N/A";
document.prices.t7.value="N/A";
document.prices.t8.value="N/A";
document.prices.t9.value="N/A";
document.prices.t10.value="N/A";
document.prices.t11.value="N/A";
document.prices.t12.value="N/A";
document.prices.t13.value="N/A";
document.prices.t14.value="N/A";
document.prices.t15.value="N/A";
document.prices.t16.value="N/A";
document.prices.t17.value="N/A";
}
if (document.prices.message.value=="invalid dates" || vstartdate.getTime() > eoy2011.getTime() || ins==3 || ins==6 || pu=="2036" || dr=="2036" || (vstartdate.getTime() < alamofrom3.getTime() && (ins==4 || ins==5) )) { //YDP  + Cape Canaveral + Sat Nav before 1/4/2010

document.prices.d1.value="N/A";
document.prices.d2.value="N/A";
document.prices.d3.value="N/A";
document.prices.d4.value="N/A";
document.prices.d5.value="N/A";
document.prices.d6.value="N/A";
document.prices.d7.value="N/A";
document.prices.d8.value="N/A";
document.prices.d9.value="N/A";
document.prices.d10.value="N/A";
document.prices.d11.value="N/A";
document.prices.d12.value="N/A";
document.prices.d13.value="N/A";
document.prices.d14.value="N/A";
document.prices.d15.value="N/A";
document.prices.d16.value="N/A";
document.prices.d17.value="N/A";
}

}
