/*
 * Il codice si impegna ad estrarre dal database
 * tutte le aziende che hanno impression disponibili e
 * con un utente associato.
 *
 * @author		Vincenzo Miele
 * @copyright  	2008 Neikos s.n.c.
 * @link       	http://www.neikos.it
 * @version		1.0

*/
function adv(){
	caricaAziendaAdvHeader();
	//var interval = new PeriodicalExecuter(caricaAziendaAdvHeader, 10);
}

function fadeEntrata(){
	$('advAzienda').appear({ duration: 3.0 });
	return false;
}

function fadeUscita(){
	$('advAzienda').fade();
	return false;
}


function caricaAziendaAdvHeader(){
	
	var url = "/includes/ajax/getAdvHeader.php?numAdv=1";
	/*
	$('advAzienda').setStyle({
  				display: 'none'
				});
	
	*/
	$('advAzienda').hide();
	new Ajax.Request(url, {
	  method: 'post',
	  evalJSON: true,
	  onSuccess:function(transport) {
				var ritorno = transport.responseJSON;
				var azienda = ritorno.profilo;
				if(ritorno.profiloFound){
					$('advAzienda').update(azienda);
				}
				$('advAzienda').show();	
			}
			
	});
		
}


function caricaAziendaAdvBox(numAdv){
	var url = "/includes/ajax/getAdvHeader.php?numAdv="+numAdv;
	$('boxAdvContenuto').innerHTML = "";
	$('boxAdvContenuto').setStyle({
  				display: 'none'
				});

	$('loadAdv').setStyle({
  				display: 'block'
				});
	
	new Ajax.Request(url, {
	  method: 'post',
	  onSuccess:function(transport) {
				var azienda = transport.responseText;
				$('boxAdvContenuto').innerHTML = azienda;
				$('loadAdv').setStyle({
  					display: 'none'
				});
				$('boxAdvContenuto').appear({ duration: 2.0 });
			}
	});
		
}

Event.observe(window, 'load', function() {
	//adv();
});
