function writeBestPrice(depAir, arrAir, outDate, retDate, id,titleHref)
{
  var url = '/capitanprice/Search';
  var pars = 'departureAirport=' + depAir + '&arrivalAirport=' + arrAir + '&outboundDate=' + outDate;
  
  var docHref =""  
  
  //2007 09 07
  docHref = '<a href="' ;
  docHref = docHref + 'http://www.volagratis.com/vg1/searching.do?departureAirport=' + depAir ;
  docHref = docHref + '&amp;arrivalAirport=' + arrAir;
  docHref = docHref + '&amp;roundtrip=true';
  docHref = docHref + '&amp;outboundDay=' + outDate.slice(6,outDate.length);
  docHref = docHref + '&amp;outboundMonthYear=' + outDate.slice(4,6) + "" +  outDate.slice(0,4);
  docHref = docHref + '&amp;returnDay=' + retDate.slice(6,retDate.length);
  docHref = docHref + '&amp;returnMonthYear=' + retDate.slice(4,6) + "" +  retDate.slice(0,4);
  docHref = docHref + '&amp;url=search3.do';
  docHref = docHref + '" title="' + titleHref + '"';
  docHref = docHref + '>' ;
  
  if (depAir == "" || arrAir == "" || outDate == "")
  {
    document.getElementById(id).innerHTML = '-';
    return;
  }
  if (retDate != "" && retDate != "00000000")
  {
    pars = pars + '&returnDate=' + retDate;
  }

  var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, asynchronous: true,
    onSuccess: function(req)
    {
      var text;
      var responseText;
      if (req.responseText == "-")
      {         
        document.getElementById(id).innerHTML = docHref + "Cerca il prezzo" + "</a>";
      }
      else
      {      	
        var pos = req.responseText.indexOf("|");
        document.getElementById(id).innerHTML = docHref + req.responseText.substring(0, pos) + "</a>";        
      }
    }});
}


function writePrices(){
var text1 = 'Volo a/r Milano Marsiglia 07/09 - 09/09';
var text2 = 'Volo a/r Milano Marsiglia 07/09 - 10/09';
var text3 = 'Volo a/r Roma Marsiglia 07/09 - 09/09';
var text4 = 'Volo a/r Roma Marsiglia 07/09 - 10/09';
var text5 = 'Volo a/r Milano Marsiglia 11/09 - 13/09';
var text6 = 'Volo a/r Milano Marsiglia 11/09 - 14/09';
var text7 = 'Volo a/r Roma Marsiglia 11/09 - 13/09';
var text8 = 'Volo a/r Roma Marsiglia 11/09 - 14/09';
var text9 = 'Volo a/r Milano Parigi 18/09 - 20/09';
var text10 = 'Volo a/r Milano Parigi 18/09 - 21/09';
var text11 = 'Volo a/r Venezia Parigi 18/09 - 20/09';
var text12 = 'Volo a/r Venezia Parigi 18/09 - 21/09';
var text13 = 'Volo a/r Bologna Parigi 18/09 - 20/09';  
var text14 = 'Volo a/r Bologna Parigi 18/09 - 21/09';
var text15 = 'Volo a/r Roma Parigi 18/09 - 20/09';
var text16 = 'Volo a/r Roma Parigi 18/09 - 21/09';
var text17 = 'Volo a/r Napoli Parigi 18/09 - 20/09';
var text18 = 'Volo a/r Napoli Parigi 18/09 - 21/09';
var text19 = 'Volo a/r Milano Lione 28/09 - 30/09';
var text20 = 'Volo a/r Milano Lione 28/09 - 01/10';
var text21 = 'Volo a/r Roma Lione 28/09 - 30/09';
var text22 = 'Volo a/r Roma Lione 28/09 - 01/10';
writeBestPrice('MIL', 'MRS', '20070907', '20070909', '1', text1);
writeBestPrice('MIL', 'MRS', '20070907', '20070910', '2', text2);
writeBestPrice('ROM', 'MRS', '20070907', '20070909', '3', text3);
writeBestPrice('ROM', 'MRS', '20070907', '20070910', '4', text4);
writeBestPrice('MIL', 'MRS', '20070911', '20070913', '5', text5);
writeBestPrice('MIL', 'MRS', '20070911', '20070914', '6', text6);
writeBestPrice('ROM', 'MRS', '20070911', '20070913', '7', text7);
writeBestPrice('ROM', 'MRS', '20070911', '20070914', '8', text8);
writeBestPrice('MIL', 'PAR', '20070918', '20070920', '9', text9);
writeBestPrice('MIL', 'PAR', '20070918', '20070921', '10', text10);
writeBestPrice('VCE', 'PAR', '20070918', '20070920', '11', text11);
writeBestPrice('VCE', 'PAR', '20070918', '20070921', '12', text12);
writeBestPrice('BLQ', 'PAR', '20070918', '20070920', '13', text13);
writeBestPrice('BLQ', 'PAR', '20070918', '20070921', '14', text14);
writeBestPrice('ROM', 'PAR', '20070918', '20070920', '15', text15);
writeBestPrice('ROM', 'PAR', '20070918', '20070921', '16', text16);
writeBestPrice('NAP', 'PAR', '20070918', '20070920', '17', text17);
writeBestPrice('NAP', 'PAR', '20070918', '20070921', '18', text18);
writeBestPrice('MIL', 'LYS', '20070928', '20070930', '19', text19);
writeBestPrice('MIL', 'LYS', '20070928', '20071001', '20', text20);
writeBestPrice('ROM', 'LYS', '20070928', '20070930', '21', text21);
writeBestPrice('ROM', 'LYS', '20070928', '20071001', '22', text22);	
}