function setVal() {
  dz=document.form.duration.options[document.form.duration.selectedIndex].value;
  mz=document.form.numberofpeople.options[document.form.numberofpeople.selectedIndex].value;
  hma=document.form.howmanyap.options[document.form.howmanyap.selectedIndex].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;
  lang=document.form.lang.value;


sstemp = new Date(arrivalyear,arrivalmonth-1,arrivalday);
ss = sstemp.getTime();


nodis=0; 
min34 = minimum(dz,ss)
if (min34 == false) 
{return false;}

onenite = one_nightt()
if (onenite == false) 
{return false;}


supp = 0;


texteng = "It is not possible for "+mz+" people to stay in "+hma+" apartment(s) becuase the max. per apartment is 7. \nPlease increase the number of apartments to correct the error.";
textspan = ""+mz+" personas no caben en "+hma+" apartamento(s) porque el máximo por apartamento es 7. \nPor favor, aumenta el número de apartamentos para conincidir con el número de personas.";

if (lang == "eng")
{text = texteng}
if (lang == "span")
{text = textspan}

//if too many people per ap
if ( mz >  (hma * 7) ) 
{window.alert(text)
return false;
}



holidaydates_santiago(dz,ss)



//less than a week.
price= "0";

if (dz < 7)
{
price = (dz * 75) * hma
supp = 0;

if (mz > (hma * 2))
{
extrapeople = mz - (hma * 2)

if (extrapeople == 1) 
{supp = supp + (dz * 20) 
}

if (extrapeople == 2) 
{supp = supp + (dz * 45) 
}

if (extrapeople == 3) 
{supp = supp + (dz * 60) 
}

if (extrapeople == 4) 
{supp = supp + (dz * 75) 
}

if (extrapeople == 5) 
{supp = supp + (dz * 85) 
}

if (extrapeople > 5) 
{supp = supp + dz * (extrapeople * 15) 
}

price = supp + price
}
}

 
//7 days or more .
if (dz > 6) 
{price = (dz * 55.71) * hma 

if (mz > (hma * 2))
{
extrapeople = mz - (hma * 2)
supp = supp + dz * (extrapeople * 10) 
price = supp + price
}

}



normalprice = price;

//find price per night of booking with no sups
price_per_nite = (price/dz); 

//find out number of nights not affected by sups.
not_supdays =  (dz - holsupdays) 

//window.alert(holsupdays)

//find price of the days which have no supplements.
not_supdays_price = (price_per_nite * not_supdays)

supdays_price = hma * (holsupdays * 180)




price = (not_supdays_price + supdays_price) 

price =  Math.round(price);

//price = price * hma;

holsup = price - normalprice

fullprices = price;

//texteng = "It is not possible for "+mz+" people to stay in "+hma+" apartment(s) because the max. per apartment is 7. \nPlease //increase the number of apartments to correct the error.";
//textspan = ""+mz+" personas no caben en "+hma+" apartamento(s) porque el máximo por apartamento es 7. \nPor favor, aumenta el //número de apartamentos para conincidir con el número de personas.";
//
//if (lang == "eng")
//{text = texteng}
//if (lang == "span")
//{text = textspan}

//if too many people per ap
//if ( mz >  (hma * 7) ) 
//window.alert(text)


fullprices = fullprices;


discountsup(dz,fullprices,ss)
fullprices = fullprices + holsup_zz;


//GIVE FREE NIGHT ON LOW SEASON DATES IN JANURY & FEBRUARY
//not_supdays
discount = 0

if (((arrivalmonth == 1)|| (arrivalmonth == 2)) && (not_supdays > 2) && (dz>1))
{
discount = (price_per_nite + (holsup_zz/dz))
}
//window.alert(price_per_nite)

fullprices = fullprices - discount

if (fullprices < 100 )
{fullprices = 100;}
//END GIVE FREE NIGHT ON LOW SEASON DATES IN JANURY & FEBRUARY




//START DISCOUNT ONLY FOR MIDWEEK STAYS IN JUNE, JULY AND AUGUST - DISCOUNT APPLIED USING DISCOUNT SYSTEM, THEREFORE ADD DISCOUNT BACK IN //THESE //CASES (0.17 equivalent to 15% AND 0.25 EQUIVALENT TO 20%)
//
//if (((arrivalmonth == 6)|| (arrivalmonth == 7)|| (arrivalmonth == 8))) 
//
//{
//if (dz == 1)
//{
//fullprices = fullprices + (fullprices*0.176)
//holsupdays_zz = 0
//holsup_zz = 0
//}
//
//if ((dayuvweak == 5) && (dz == 2))
//{
//fullprices = fullprices + (fullprices*0.176)
//holsupdays_zz = 0
//holsup_zz = 0
//}
//}
//
//END DISCOUNT ONLY FOR MIDWEEK STAYS IN JUNE, JULY AND AUGUST//////////////////////////////////////////




//START 0 EURO DEPOSIT
fianth = 0;
//START 0 EURO DEPOSIT


//START 25% DEPOSIT
//fianth = fullprices/4;
//if (fianth < 51 )
//{fianth = 50}
//END 25% DEPOSIT

dollars = fullprices*dollarconv; 
pounds = fullprices*poundeuro; 
fianza = fianth;
pricepn = fullprices/dz;
pricepp = fullprices/mz;
restante = fullprices - fianth;
priceppn = fullprices/mz/dz;
priceppn = fullprices/mz/dz;


holsupdays_zz = holsupdays_zz + holsupdays;
holsup_zz = holsup_zz + holsup;

document.form.fullprice.value=Math.round(+fullprices);
document.form.pounds.value=Math.round(+pounds);
document.form.dollars.value=Math.round(+dollars);
document.form.deposit.value=Math.round(+fianza);
document.form.ppn.value=Math.round(+pricepn);
document.form.ppp.value=Math.round(+pricepp);
document.form.depositeuros.value=Math.round(+restante);
document.form.holsupdays.value=holsupdays_zz;
document.form.holsup.value=Math.round(+holsup_zz);
document.form.pppn.value=Math.round(+priceppn);

}


function one_nightt() {

sstemp = new Date(arrivalyear,arrivalmonth-1,arrivalday);
ss = sstemp.getTime();

dayuvweak = new Date (ss);
dayuvweak = dayuvweak.getDay()



//IF USING THE FRENCH WE HAVE NO LANG
if (lang == undefined)
{
lang="eng"
} 

if (lang == "eng")
{oneday_textt = "It is not possible to book only one night on a Friday or Saturday.";}

if (lang == "span")
{oneday_textt = "No se puede reservar una noche los viernes o sábados.";}





if ((dayuvweak > 4) && (dz == 1))
{
window.alert(oneday_textt)
nodis = false;
return false;
}
}



          
