jQuery(document).ready( function() {
    jQuery("input.alert_field").live('change',
		function() {
			var idreq = jQuery(this).attr('id');
			var expl_idreq = idreq.split('_');
			var id = expl_idreq[1];
			var vaction = 'alerte';
                        var alerte = expl_idreq[0];
                        var valeur;
                            if (jQuery(this).is(':checked')) {
                                valeur = 1;
                            } else {
                                valeur = 0;
                            }

			var responsediv = '#div_'+idreq;

			jQuery.post(gdn_ajaxurl, {
				action: vaction,
                                'alerte' : alerte,
				'id': id,
                                'valeur' : valeur
				},

				function(response) {
					jQuery(responsediv).fadeOut(200,
						function() {
							jQuery(responsediv).html(response);
							jQuery(responsediv).fadeIn(200);
						}
					);
				});
	});

        jQuery("div#testbutton").live('click',
		function() {
			
			var id = 'test';
			var vaction = 'testalerte';

			var responsediv = '#ajaxtest';

			jQuery.post(gdn_ajaxurl, {
				action: vaction,
                               
				'id': id
                              
				},

				function(response) {
					jQuery(responsediv).fadeOut(200,
						function() {
							jQuery(responsediv).html(response);
							jQuery(responsediv).fadeIn(200);
						}
					);
				});
	});


    jQuery("img.action").live('click',
		function() {
			var idreq = jQuery(this).attr('id');
			var expl_idreq = idreq.split('_');
			var id = expl_idreq[1];
			var vaction = expl_idreq[0];
			
			var responsediv = '#gdn_formdiv';

			jQuery.post(gdn_ajaxurl, {

				action: vaction,
				'id': id
				

				},

				function(response) {
					jQuery(responsediv).fadeOut(200,
						function() {
							jQuery(responsediv).html(response);
							jQuery(responsediv).fadeIn(200);
						}
					);
				});
	});


         jQuery("input.gameupdate").live('click',
		function() {
			var idreq = jQuery(this).attr('id');
			var expl_idreq = idreq.split('_');
			var id = expl_idreq[1];
			var vaction = expl_idreq[0];

			var responsediv = '#gdn_gestion';

                        var url =  jQuery("input#mvet_url").attr('value');
                        var nom =  jQuery("input#mvet_nom").attr('value');
                        var adr1 =  jQuery("input#mvet_adr1").attr('value');
                        var adr2 =  jQuery("input#mvet_adr2").attr('value');
                        var cp =  jQuery("input#mvet_cp").attr('value');
                        var ville =  jQuery("input#mvet_ville").attr('value');
                        var tel =  jQuery("input#mvet_tel").attr('value');
                        var telmob =  jQuery("input#mvet_telmob").attr('value');
                        var fax =  jQuery("input#mvet_fax").attr('value');
                        var email =  jQuery("input#mvet_email").attr('value');


			jQuery.post(gnd_ajaxurl, {

				action: vaction,
				'id': id,
                                'url' : url,
                                'nom' : nom,
                                'adr1' : adr1,
                                'adr2' : adr2,
                                'cp' : cp,
                                'ville' : ville,
                                'tel' : tel,
                                'telmob' : telmob,
                                'fax' : fax,
                                'email' : email



				},

				function(response) {
					jQuery(responsediv).fadeOut(200,
						function() {
							jQuery(responsediv).html(response);
							jQuery(responsediv).fadeIn(200);
						}
					);
				});
	});

        jQuery("a.iconeaction").live('click',
		function() {
			var idreq = jQuery(this).attr('id');
			var expl_idreq = idreq.split('_');
                        var vaction = expl_idreq[0];
                        var iaction = expl_idreq[1];
			var id_user = expl_idreq[2];
                        var id_post = expl_idreq[3];
                        var bddaction = expl_idreq[4];

                        if (id_user == 0) {
                            document.location='http://www.gagnantdunet.net/register';
                            exit();
                        }


			var responsediv = '#userarea_'+id_post;

			jQuery.post(gdn_ajaxurl, {

				action: vaction,
                                'iaction': iaction,
				'id_user': id_user,
                                'id_post': id_post,
                                'bddaction': bddaction


				},

				function(response) {
					jQuery(responsediv).fadeOut(200,
						function() {
							jQuery(responsediv).html(response);
							jQuery(responsediv).fadeIn(200);
						}
					);
				});
	});

} ); // fin jquery