function setVal() {

dz=document.form.duration.options[document.form.duration.selectedIndex].value;

standard=document.form.standard.options[document.form.standard.selectedIndex].value;
penthouse=document.form.penthouse.options[document.form.penthouse.selectedIndex].value;
sofab1=document.form.sofab1.options[document.form.sofab1.selectedIndex].value;
sofab2=document.form.sofab2.options[document.form.sofab2.selectedIndex].value;

stanextra=document.form.stanextra.options[document.form.stanextra.selectedIndex].value;
pentextra=document.form.pentextra.options[document.form.pentextra.selectedIndex].value;


lang=document.form.lang.value;
arrivalday=document.form.arrivalday.options[document.form.arrivalday.selectedIndex].value;
arrivalmonth=document.form.arrivalmonth.options[document.form.arrivalmonth.selectedIndex].value;
arrivalyear=document.form.arrivalyear.options[document.form.arrivalyear.selectedIndex].value;



dollarconv=document.form.dollareuro.value;
poundeuro=document.form.poundeuro.value;

var d = new Date()
secs=d.getTime()
secss=("" + secs)
stamp=secss.substr(0,10)

sstemp = new Date(arrivalyear,arrivalmonth-1,arrivalday);
ss = sstemp.getTime();



nodis=0; 
minimum(dz,ss)

if (lang == "eng")
{text = "There is only 1 sofa-bed per apartment. The number of sofa beds cannot be more than the number of rooms.";}

if (lang == "span")
{text = "Solo hay 1 sofa cama en cada apartamento. El numero de sofas cama no puede ser más de la cantidad de apartamentos.";}


if (lang == "eng")
{penttext = "There is only 1 extra-bed per apartment. The number of extra beds cannot be more than the number of rooms.";}

if (lang == "span")
{penttext = "Solo hay 1 cama supletoria en cada apartamento. El numero de sofas cama no puede ser más de la cantidad de apartamentos.";}


if (sofab1 > standard)
{window.alert(text);}

if (sofab2 > penthouse)
{window.alert(text);}

if (stanextra > standard)
{window.alert(penttext);}

if (pentextra > penthouse)
{window.alert(penttext);}



price= "0";

holidaydate(dz,ss)

combined = holdhigh + holdlow;
holdmid = dz - combined; 

price_high=0;
price_mid=0;
price_low=0;


//HIGH PRICES 

stan_base_high = standard *(dz * 75);
stan_sofa_high = sofab1 * (dz * 55);
stan_extra_high = stanextra * (dz * 30);

//work out penthouse price.

penthouse_base_high = penthouse * (dz * 75);
penthouse_sofa_high = sofab2 * (dz * 55);
penthouse_extra_high = pentextra * (dz * 30);


price_high = stan_base_high + stan_sofa_high + penthouse_base_high + penthouse_sofa_high + stan_extra_high + penthouse_extra_high; 

ppn_high =  price_high/dz; 
price_high = holdhigh * ppn_high

//END HIGH PRICES 



//mid PRICES 

stan_base_mid = standard *(dz * 65);
stan_sofa_mid = sofab1 * (dz * 55);
stan_extra_mid = stanextra * (dz * 30);


//work out penthouse price.

penthouse_base_mid = penthouse * (dz * 65);
penthouse_sofa_mid = sofab2 * (dz * 55);
penthouse_extra_mid = pentextra * (dz * 30);

price_mid = stan_base_mid + stan_sofa_mid + penthouse_base_mid + penthouse_sofa_mid + stan_extra_mid + penthouse_extra_mid; 

ppn_mid =  price_mid/dz; 
price_mid = holdmid * ppn_mid

//END mid PRICES 



//low PRICES 

stan_base_low = standard *(dz * 55);
stan_sofa_low = sofab1 * (dz * 35);
stan_extra_low = stanextra * (dz * 20);



//work out penthouse price.

penthouse_base_low = penthouse * (dz * 55);
penthouse_sofa_low = sofab2 * (dz * 35);
penthouse_extra_low = pentextra * (dz * 20);


price_low = stan_base_low + stan_sofa_low + penthouse_base_low + penthouse_sofa_low + stan_extra_low + penthouse_extra_low; 

ppn_low =  price_low/dz; 
price_low = holdlow * ppn_low

//END low PRICES 



fullprices = price_high + price_mid + price_low;

discountsup(dz,fullprices,ss)
fullprices = fullprices + holsup_zz;

fianth = fullprices/4;
if (fianth < 51 )
{fianth = 50}

dollars= fullprices*dollarconv; 
pounds= fullprices*poundeuro; 
fianza=fianth;

pricepn = fullprices/dz;
pesetass = fullprices*166.386;
maxp = 2*((standard*1)+(penthouse*1)+(sofab1*1)+(sofab2*1)+(stanextra*0.5)+(pentextra*0.5)); 
document.form.maxp.value=maxp;
pppp = fullprices/maxp;
document.form.howmanyap.value=1*((standard*1)+(penthouse*1)); 
 document.form.fullprice.value=Math.round(+fullprices*100)/100;
 document.form.pounds.value=Math.round(+pounds*100)/100;
 document.form.dollars.value=Math.round(+dollars*100)/100;
 document.form.ppn.value=Math.round(+pricepn*100)/100;

document.form.holdhigh.value=holdhigh;
document.form.holdmid.value=holdmid;
document.form.holdlow.value=holdlow;

document.form.holsupdays.value=holsupdays_zz;
document.form.holsup.value=holsup_zz;

}
