function setVal() {




dz=document.form.duration.options[document.form.duration.selectedIndex].value;

standard=document.form.standard.options[document.form.standard.selectedIndex].value;
family=document.form.family.options[document.form.family.selectedIndex].value;
sofab1=document.form.sofab1.options[document.form.sofab1.selectedIndex].value;
sofab2=document.form.sofab2.options[document.form.sofab2.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();

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 número de sofá-camas no puede ser más de la cantidad de apartamentos.";}

if (sofab1 > standard)
{window.alert(text)}

if (sofab2 > family)
{window.alert(text)}

nodis=0; 
minimum(dz,ss)

holidaydate(dz,ss)

combined = holdhigh + holdlow;
holdmid = dz - combined; 

price_high=0;
price_mid=0;
price_low=0;


//HIGH SEASON

stan_base_high = standard *(dz * 75);
stan_sofa_high = sofab1 * (dz * 55);

family_base_high = family * (dz * 160);
family_sofa_high = sofab2 * (dz * 0);

price_high = stan_base_high + stan_sofa_high + family_base_high + family_sofa_high;
ppn_high =  price_high/dz; 

price_high = holdhigh * ppn_high

//END  HIGH SEASON



//MID SEASON

stan_base_mid = standard *(dz * 65);
stan_sofa_mid = sofab1 * (dz * 55);

if (dz > 6) 
{
stan_base_mid = standard * (dz * 60);
stan_sofa_mid = sofab1 * (dz * 47.14);
}

family_base_mid = family * (dz * 150);
family_sofa_mid = sofab2 * (dz * 0);


if (dz > 6) 
{
family_base_mid = family * (dz * 121.43);
family_sofa_mid = sofab2 * (dz * 0);
}

price_mid = stan_base_mid + stan_sofa_mid + family_base_mid + family_sofa_mid;
ppn_mid =  price_mid/dz; 

price_mid = holdmid * ppn_mid

//END  mid SEASON


//low SEASON

stan_base_low = standard *(dz * 55);
stan_sofa_low = sofab1 * (dz * 35);

if (dz > 6) 
{
stan_base_low = standard * (dz * 55);
stan_sofa_low = sofab1 * (dz * 35);
}

family_base_low = family * (dz * 110);
family_sofa_low = sofab2 * (dz * 0);

if (dz > 6) 
{
family_base_low = family * (dz * 110);
family_sofa_low = sofab2 * (dz * 0);
}

price_low = stan_base_low + stan_sofa_low + family_base_low + family_sofa_low;
ppn_low =  price_low/dz; 

price_low = holdlow * ppn_low

//END  low SEASON


fullprices = price_high + price_mid + price_low;


//GIVE FREE NIGHT IF DATE IS ALL MIDSEASON IN MAY

//discount = 0

//if ((dz < 4 && dz > 2) && holdmid == dz  && arrivalmonth == 5 ) {
//discount = ppn_mid}
//fullprices = fullprices - discount

//GIVE FREE NIGHT IF DATE IS ALL MIDSEASON



//GIVE FREE NIGHT IF DATE IS LOW SEASON IN NOVEMBER

//discount = 0

//if (dz > 2 && holdlow == dz && (arrivalmonth == 11 || arrivalmonth == 12 ||  arrivalmonth == 1 )) 
//
//
//{
//discount = ppn_low}
//fullprices = fullprices - discount

//GIVE FREE NIGHT IF DATE BEFORE 27/2/2010

discount = 0

//window.alert(ss)
//FREE DAY BEFORE 24/2/2010
if  ((dz > 2) && (holdlow == dz) && (ss < 1266969600000))
{
discount = ppn_low}

//FREE DAY IN MARCH EXCEPT SAN JOSE WEEKEND
if  ((dz > 2) && (holdlow == dz) && (arrivalmonth == 3))
{
discount = ppn_low}





fullprices = fullprices - discount




fullprices = Math.round(fullprices);

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)+(family*2)+(sofab1*1)+(sofab2*1)); 
document.form.maxp.value=maxp;
pppp = fullprices/maxp;
document.form.howmanyap.value=1*((standard*1)+(family*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;




}

          
