var sauv_id_pub = 0;
var tab_type = new Array();
var tab_id = new Array();

function MAJ_pub() 
{
	var div_pub_accueil = $('pub_accueil');
	if (div_pub_accueil) {
		req_pub(1, div_pub_accueil);
	}
	else {
		var div_pub_interne = $('pub_interne');
		if (div_pub_interne) {
			req_pub(2, div_pub_interne);
		}	
	}
		
	setTimeout("MAJ_pub()", 30000);
	return true;
}


function req_pub (format, id)
{
	var req = new Ajax.Request(
		'ajax/maj_pub.php', 
		{
			method: 'post',
			parameters: {
				format : format
			},
			onSuccess: 	function(transport)
						{
							xmlResponse = transport.responseXML;
							afficher_pub(xmlResponse, id);
						}
		}
	);
	
}


function afficher_pub(xml, id)
{
	var pub = xml.getElementsByTagName("pub")[0];
	var code_html = pub.getElementsByTagName("code_html")[0].firstChild.nodeValue;

	$(id).innerHTML = code_html;
}


function clic(id, verif) 
{
	var req = new Ajax.Request(
		'ajax/clic_pub.php', 
		{
			method: 'post',
			parameters: {
				id : id,
				verif : verif
			}
		}
	);
}
