Event.observe(window, 'load', function() {
	$$(".selectvid").each(function(el) {
		Event.observe(el, 'click', function(evt) {
			Event.stop(evt);
			id = ($(el).id).split("_");
			var url = 'xhr-video.php';
			var parametres='id_video='+id[1];
			var myAjax = new Ajax.Updater(
				'centre',
				url,
				{
					method: 'get',
					parameters: parametres,
					evalScripts : true
				}
			);
		});
	});
	
	$$(".rubrique").each(function(el) {
		Event.observe(el, 'click', function(evt) {
			Event.stop(evt);
			id_cat = ($(el).id).split("_");
			var url = 'xhr-gauche.php';
			var parametres='id_rubrique='+id_cat[1];
			var myAjax = new Ajax.Updater(
				'gauche',
				url,
				{
					method: 'get',
					parameters: parametres,
					evalScripts : true
				}
			);
			
			var myAjax2 = new Ajax.Updater(
				'publicite',
				'xhr-publicite.php',
				{
					method: 'get',
					parameters: parametres,
					evalScripts : true
				}
			);
		});
	});
	
	Event.observe('search_1', 'click', function(evt) {
		Event.stop(evt);
		var url = 'xhr-search.php';
		recherche = $F("recherche");
		var parametres='id_search=1'+'&recherche='+recherche;
		if ($('gauche') == undefined) {
			if ($('gauche2') == undefined) {
				$('interieur-page-simple').replace('<div id="gauche"></div><div id="centre"></div>');
			} else {
				$('gauche2').replace('<div id="gauche"></div>');
			}
		}
		
		var myAjax = new Ajax.Updater(
			'gauche',
			url,
			{
				method: 'get',
				parameters: parametres,
				evalScripts : true
			}
		);
	});
	
	Event.observe('form1', 'submit', function(evt) {
		Event.stop(evt);
		var url = 'xhr-search.php';
		recherche = $F("recherche");
		var parametres='id_search=1'+'&recherche='+recherche;
		if ($('gauche') == undefined) {
			if ($('gauche2') == undefined) {
				$('interieur-page-simple').replace('<div id="gauche"></div><div id="centre"></div>');
			} else {
				$('gauche2').replace('<div id="gauche"></div>');
			}
		}
		var myAjax = new Ajax.Updater(
			'gauche',
			url,
			{
				method: 'get',
				parameters: parametres,
				evalScripts : true
			}
		);
	});
	
	
	Event.observe('search_2', 'click', function(evt) {
		Event.stop(evt);
		var url = 'xhr-search.php';
		var parametres='id_search=2';
		if ($('gauche') == undefined) {
			if ($('gauche2') == undefined) {
				$('interieur-page-simple').replace('<div id="gauche"></div><div id="centre"></div>');
			} else {
				$('gauche2').replace('<div id="gauche"></div>');
			}
		}
		var myAjax = new Ajax.Updater(
			'gauche',
			url,
			{
				method: 'get',
				parameters: parametres,
				evalScripts : true
			}
		);
	});
	
	if ($('connexion') != undefined) {
		Event.observe('connexion', 'click', function(evt) {
			Event.stop(evt);
			var url = 'xhr-connexion.php';
			if ($('centre') == undefined) {
				$('interieur-page-simple').replace('<div id="gauche"></div><div id="centre"></div>');
				var url2 = 'xhr-index.php';
				var parametres2;
				var myAjax = new Ajax.Updater(
					'gauche',
					url2,
					{
					method: 'get',
					parameters: parametres2,
					evalScripts : true
					}
				);
			}
			
			var myAjax = new Ajax.Updater(
				'centre',
				url,
				{
					method: 'get',
					evalScripts : true
				}
			);
		});
	}
	
	if ($('ajout_connexion') != undefined) {
		Event.observe('ajout_connexion', 'click', function(evt) {
			Event.stop(evt);
			var url = 'xhr-connexion.php';
			if ($('centre') == undefined) div = 'interieur-page-simple'; else div = 'centre';
			var myAjax = new Ajax.Updater(
				div,
				url,
				{
					method: 'get',
					evalScripts : true
				}
			);
		});
	}
});

function appel_xhr() {
	if ($('search2') != undefined) {
		Event.observe("search2", 'click', function(evt) {
			Event.stop(evt);
			var url = 'xhr-search.php';
			var parametres='id_search=2';
			var myAjax = new Ajax.Updater(
				'gauche',
				url,
				{
					method: 'get',
					parameters: parametres,
					evalScripts : true
				}
			);
		});
	}

	if ($$('.selectvid') != undefined) {
		$$(".selectvid").each(function(el) {
			Event.observe(el, 'click', function(evt) {
				Event.stop(evt);
				id = ($(el).id).split("_");
				var url = 'xhr-video.php';
				var parametres='id_video='+id[1];
				var myAjax = new Ajax.Updater(
					'centre',
					url,
					{
						method: 'get',
						parameters: parametres,
						evalScripts : true
					}
				);
			});
		});
	}

	if ($('allvid') != undefined) {
		Event.observe('allvid', 'click', function(evt) {
			Event.stop(evt);
			var url = 'xhr-index.php';
			var parametres;
			var myAjax = new Ajax.Updater(
				'gauche',
				url,
				{
				method: 'get',
					parameters: parametres,
					evalScripts : true
				}
			);
		});
	}
}





