/*
* Copyright (c) 2010, Maiora Labs Srl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the <organization> nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Maiora Labs Srl ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Maiora Labs Srl BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// dicembre 2010
// aggiorna il programma del festival


function festival_aggiorna_programma(){

document.getElementById("nw_mixer_contenuti_ajax").innerHTML="<br><br><center><img src='/festival/images/aggiornamento_programma.gif' style='margin-left:30px;'></center>";

elenco_id_temi = 0;
elenco_id_citta = 0;

params = "";
params = params + "data_inizio="+document.getElementById("inizio").options[document.getElementById("inizio").selectedIndex].value;
params = params + "&data_fine="+document.getElementById("fine").options[document.getElementById("fine").selectedIndex].value;




for (t=1;t<30;t++) {  
    if (document.getElementById("img_valore_tema_"+t) != null) {
        if (document.getElementById("img_valore_tema_"+t).value>0) {
            elenco_id_temi = elenco_id_temi + "," + t ;                                   
        }                        
    }                                                  
}
params = params + "&elenco_id_temi="+elenco_id_temi+",";


for (t=1;t<30;t++) {  
    if (document.getElementById("img_valore_citta_"+t) != null) {
        if (document.getElementById("img_valore_citta_"+t).value>0) {
            elenco_id_citta = elenco_id_citta + "," + t ;                                   
        }                        
    }                                                  
}
params = params + "&elenco_id_citta="+elenco_id_citta+",";



//alert(params);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="/festival/festival_aggiorna_programma.php";

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.send(params);


}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 && xmlHttp.status == 200)
{ 
r=xmlHttp.responseText;
      
        document.getElementById("nw_mixer_contenuti_ajax").innerHTML=r;


}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
