function OpenImage(nome,w,h)
{
 newWin=this.open(nome + ".jpg","newWin","menubar=no,scrollbars=no,resize=no,height=" + h + ",width=" + w)
 }

function DataFine ()
{
  
//this.options[this.selectedIndex].text
  document.MyForm.PREZZO_TOT.value = "";
  
//traformo in DATA la stringa del primo combo
  startObj = document.MyForm.INIZIO_SOGG;
  settObj = document.MyForm.NUM_SETTIMANE;
  x = startObj.options[startObj.selectedIndex].text.split("/");
  y = settObj.options[settObj.selectedIndex].text;
  if (y != "")
  	{timeA = new Date (x[2],x[1]-1,x[0]);
	//sommo le settimane del secondo combo con la data del primo (tutto in millisec)
  	millA = Date.parse(timeA);
  	timeB = new Date (millA + y * 7 * 24 * 60 * 60 * 1000);
	//alert (millA + y * 7 * 24 * 60 * 60 * 1000);  
	
	//formattazione alla padovana della data di fine soggiorno
  	dayB = timeB.getDate();
  	dayB = dayB.toString();
  	if (dayB.length == 1)
  	    {dayB = "0" + dayB};
  	monthB = timeB.getMonth() + 1;
  	monthB = monthB.toString();
  	if (monthB.length == 1)
       		{monthB = "0" + monthB};
  
	//scrivo la data di fine nella casella di testo
	document.MyForm.DATA_FINE.value = dayB + "/" + monthB + "/" + timeB.getFullYear();
	}
  else
	{document.MyForm.DATA_FINE.value = startObj.options[startObj.selectedIndex].text};

  if (x != "" && y != "")
  {Prezzo(startObj.selectedIndex, settObj.selectedIndex)}
}


function Prezzo (a,b)
 {
  p = new Array (250,250,250,250,300,300,350,350,400,400,400,350,250,250,250);
  valore = 0;
  for (count = a - 1; count < a -1 + b; count++)
     valore = valore + p[count];  

  valore = valore.toString();
  if (valore.length > 3 )
   {valFormat = valore.substr(0,valore.length-3) + "." + valore.substr(valore.length-3) + ",00 €"}  
  else
    {valFormat = valore + ",00 €"}

  document.MyForm.PREZZO_TOT.value = valFormat;
  alert("Il prezzo per il perido richiesto e' di " + valFormat);
 }

function Verifica ()
 {
  if (document.MyForm.FROM_EMAIL.value.length == 0 ||
      document.MyForm.FROM_EMAIL.value.search("@") == -1 || 
      document.MyForm.INIZIO_SOGG.selectedIndex == 0 ||
      document.MyForm.NUM_SETTIMANE.selectedIndex == 0)
      {alert ("Devi compilare i campi obbligatori del form:\n" +
	      "- indirizzo e-mail valido;\n- data inizio soggiorno;\n- nro settimane di soggiorno.");
       return false}
  else
      {return true}
 }