//ALAMO RATES
function calculational(){
datecalculation();

var dd=(document.prices.dd.value)*1 ;
var ww=(document.prices.ww.value)*1 ; 
var ee=(document.prices.ee.value)*1 ; 
var xe=document.prices.xrate.value; //rate
var xd=document.prices.xe.value; //desc

if(ww>0 && ee>0){dd=ee;}

var ins=document.prices.insurance.value;
var pu=document.prices.Collect.value;
var dp=document.prices.Drop.value;
if (dp=="XXX-000"){dp=pu;}


var sppd1=0; var sppd2=0; var sppd3=0; var sppd4=0; var sppd5=0; var sppd6=0; var sppd7=0; var sppd8=0; 
var sppd9=0; var sppd10=0; var sppd11=0; var sppd12=0; var sppd13=0; var sppd14=0; var sppd15=0; 
var sppd16=0; var sppd17=0; var sppd18=0; var sppd19=0; var sppd20=0;
var sppw1=0; var sppw2=0; var sppw3=0; var sppw4=0; var sppw5=0; var sppw6=0; var sppw7=0; var sppw8=0; 
var sppw9=0; var sppw10=0; var sppw11=0; var sppw12=0; var sppw13=0; var sppw14=0; var sppw15=0; 
var sppw16=0; var sppw17=0; var aydfd=0; aywfd=0;
var slw=0; var sld=0; var sll=0;
var ssatd=0; var ssatw=0; var sydfd=0; var sydfw=0; var sdd=dd; var sww=ww;

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;

var peakxmas2011from=new Date(2011, 11, 18);
var peakxmas2011to=new Date(2011, 11, 31);
var slsd1=0;
var slsw1=0;
var slsd2=0;
var slsw2=0;
var peaksummer2011from=new Date(2011, 5, 10);
var peaksummer2011to=new Date(2011, 7, 21);
if (vstartdate.getTime() <= peaksummer2011to.getTime() ){
slsd1=4;
slsw1=18;
slsd2=7;
slsw2=36;
}

var start2011=new Date(2011, 3, 01);
var end2011=new Date(2012, 2, 31);
var start2012=new Date(2012, 3, 01);
var end2012=new Date(2013, 2, 31);

if(ww==0 && dd > 4) {ww=1;dd=0;}
if(ww>0 && ee > 0) {dd=ee;}

if (ins==4 || ins==5 || ins==6){
var ssatd=8;
var ssatw=39;
}

var aydfd=0;
var aydfw=0;
if (ins==3){
aydfd=13;
aydfw=67;
}

//national christmas loading
//if ((vstartdate.getTime() >= peakxmas2010from.getTime() && vstartdate.getTime() <= peakxmas2010to.getTime() )||
//    (vstartdate.getTime() >= peakxmas2011from.getTime() && vstartdate.getTime() <= peakxmas2011to.getTime() )){
//sld=0;
//slw=0;/
//}

var late=0;
if (nodo<3){late=5;}
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;}
}

if(ww==0 && dd==1){dd=2;}
sydfd=sydfd+ssatd+sld;
sydfw=sydfw+ssatw+slw;

//2011/2012
if (vstartdate.getTime() <= end2011.getTime())
{
if (ins==1 || ins==4){
sppd1=22;
sppd2=23;
sppd3=24;
sppd4=25;
sppd5=26;
sppd6=26;
sppd7=29;
sppd8=30;
sppd9=35;
sppd10=39;
sppd11=37;
sppd12=39;
sppd13=37;
sppd14=53;
sppd15=65;
sppd16=32;
sppd17=43;
sppw1=109;
sppw2=113;
sppw3=120;
sppw4=123;
sppw5=131;
sppw6=134;
sppw7=142;
sppw8=149;
sppw9=175;
sppw10=193;
sppw11=186;
sppw12=193;
sppw13=186;
sppw14=263;
sppw15=327;
sppw16=160;
sppw17=215;

}
if (ins==2 || ins==5 || ins==3)
{
sppd1=28;
sppd2=29;
sppd3=30;
sppd4=30;
sppd5=32;
sppd6=32;
sppd7=34;
sppd8=35;
sppd9=42;
sppd10=46;
sppd11=44;
sppd12=46;
sppd13=44;
sppd14=59;
sppd15=72;
sppd16=40;
sppd17=51;
sppw1=136;
sppw2=141;
sppw3=147;
sppw4=151;
sppw5=158;
sppw6=162;
sppw7=169;
sppw8=176;
sppw9=211;
sppw10=229;
sppw11=222;
sppw12=229;
sppw13=222;
sppw14=299;
sppw15=359;
sppw16=196;
sppw17=251;
}
}
//end 2011/2012

// 2012/2013
if (vstartdate.getTime() >= start2012.getTime() && vstartdate.getTime() <= end2012.getTime())
{
if (ins==1 || ins==4){
sppd1=24;
sppd2=24;
sppd3=26;
sppd4=26;
sppd5=29;
sppd6=30;
sppd7=31;
sppd8=32;
sppd9=39;
sppd10=42;
sppd11=45;
sppd12=42;
sppd13=42;
sppd14=59;
sppd15=73;
sppd16=36;
sppd17=50;
sppw1=120;
sppw2=122;
sppw3=130;
sppw4=134;
sppw5=145;
sppw6=151;
sppw7=156;
sppw8=160;
sppw9=190;
sppw10=207;
sppw11=223;
sppw12=207;
sppw13=208;
sppw14=296;
sppw15=363;
sppw16=184;
sppw17=248;

}
if (ins==2 || ins==5 || ins==3)
{
sppd1=30;
sppd2=30;
sppd3=32;
sppd4=33;
sppd5=35;
sppd6=36;
sppd7=37;
sppd8=37;
sppd9=44;
sppd10=47;
sppd11=51;
sppd12=47;
sppd13=48;
sppd14=66;
sppd15=79;
sppd16=43;
sppd17=56;
sppw1=149;
sppw2=151;
sppw3=158;
sppw4=163;
sppw5=174;
sppw6=179;
sppw7=185;
sppw8=188;
sppw9=222;
sppw10=239;
sppw11=255;
sppw12=239;
sppw13=240;
sppw14=328;
sppw15=395;
sppw16=216;
sppw17=279;
}
}
//end 2012/2013

ssatd=ssatd+aydfd;
ssatw=ssatw+aydfw;

document.prices.s1.value=(xd+Math.round(late+(dd*(ssatd+sppd1))+(ww*(ssatw+sppw1))));
document.prices.s2.value=(xd+Math.round(late+(dd*(ssatd+sppd2))+(ww*(ssatw+sppw2))));
document.prices.s3.value=(xd+Math.round(late+(dd*(ssatd+sppd3))+(ww*(ssatw+sppw3))));
document.prices.s4.value=(xd+Math.round(late+(dd*(ssatd+sppd4))+(ww*(ssatw+sppw4))));
document.prices.s5.value=(xd+Math.round(late+(dd*(ssatd+sppd5))+(ww*(ssatw+sppw5))));
document.prices.s6.value=(xd+Math.round(late+(dd*(ssatd+sppd6))+(ww*(ssatw+sppw6))));
document.prices.s7.value=(xd+Math.round(late+(dd*(ssatd+sppd7))+(ww*(ssatw+sppw7))));
document.prices.s8.value=(xd+Math.round(late+(dd*(ssatd+sppd8))+(ww*(ssatw+sppw8))));
document.prices.s9.value=(xd+Math.round(late+(dd*(ssatd+sppd9))+(ww*(ssatw+sppw9))));
document.prices.s10.value=(xd+Math.round(late+(dd*(ssatd+sppd10))+(ww*(ssatw+sppw10))));

document.prices.s11.value=(xd+Math.round(late+(dd*(slsd1+ssatd+sppd11))+(ww*(slsw1+ssatw+sppw11))));
document.prices.s12.value=(xd+Math.round(late+(dd*(slsd2+ssatd+sppd12))+(ww*(slsw2+ssatw+sppw12))));
document.prices.s13.value=(xd+Math.round(late+(dd*(slsd2+ssatd+sppd13))+(ww*(slsw2+ssatw+sppw13))));
document.prices.s14.value=(xd+Math.round(late+(dd*(slsd2+ssatd+sppd14))+(ww*(slsw2+ssatw+sppw14))));
document.prices.s15.value=(xd+Math.round(late+(dd*(slsd2+ssatd+sppd15))+(ww*(slsw2+ssatw+sppw15))));
document.prices.s16.value=(xd+Math.round(late+(dd*(slsd1+ssatd+sppd16))+(ww*(slsw1+ssatw+sppw16))));
document.prices.s17.value=(xd+Math.round(late+(dd*(slsd1+ssatd+sppd17))+(ww*(slsw1+ssatw+sppw17))));

if (document.prices.message.value=="invalid dates" || ins==6 || pu=="2036" || dp=="2036" || document.prices.alamoid.value>" " ) { //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";
}

}
