
var Life_urbano = {
		
	newsletter: function()
	{
		jQuery('#urbanoError').html('');
		jQuery('#urbanoInfo').html('');
		var email = jQuery("#emailnewsletter").val() ;
		var url = PmsUrl.getBaseUrl() + 'life/urbanophiles/inscription-newsletter' ; 
		// enregistrement de l'adresse mail
		jQuery.post(url, { email: email }, Life_urbano.newsletterProcess);
	},
	
	newsletterProcess: function(jsonResponse)
	{
		var json = eval('('+jsonResponse+')');
		if(!json.isValid)
		{
			jQuery('#urbanoError').html(json.message);
		} else {
			document.location = 'urbanophiles/changer-de-vie/confirme-newsletter.html';
			//jQuery('#urbanoInfo').html(json.message);
		}
	},
	
	monreseau: function()
	{
		jQuery('#urbanoError2').html('');
		jQuery('#urbanoInfo2').html('');
		var url = PmsUrl.getBaseUrl() + 'life/urbanophiles/monreseau' ;
		jQuery.post( url, jQuery('#formMonreseau').serialize() , Life_urbano.monreseauProcess) ;
	},
	
	monreseauProcess: function(jsonResponse)
	{
		var json = eval('('+jsonResponse+')');
		if(!json.isValid)
		{
			jQuery('#urbanoError2').html(json.message);
		} else {
			document.location = 'urbanophiles/changer-de-vie/confirme-mail.html';
			//jQuery('#urbanoInfo2').html(json.message);
		}
	},
	
	videomail: function()
	{
		jQuery('#urbanoError3').html('');
		jQuery('#urbanoInfo3').html('');
		var url = PmsUrl.getBaseUrl() + 'life/urbanophiles/videomail' ;
		jQuery.post( url, jQuery('#formVideoMail').serialize() , Life_urbano.videomailProcess) ;
	},
	
	videomailProcess: function(jsonResponse)
	{
		var json = eval('('+jsonResponse+')');
		if(!json.isValid)
		{
			jQuery('#urbanoError3').html(json.message);
		} else {
			jQuery('#urbanoInfo3').html(json.message);
		}
	},
	
	share: function(reseau)
	{
		videoUrl = encodeURIComponent(document.getElementById('videoUrl').value) ;
		switch(reseau)
		{
			case 'facebook': url = "http://www.facebook.com/share.php?u="+videoUrl; break;
			case 'twitter': url = 'http://twitter.com/home?status=Vidéo urbanophile sur le site auvergne life : '+videoUrl; break;
			case 'viadeo' : url = 'http://www.viadeo.com/shareit/share/?urlaffiliate=32004&url='+videoUrl; break;
			case 'blogger' : url = 'http://wd.sharethis.com/api/sharer.php?destination=blogger&url='+videoUrl; break;
		}
		window.open(url);
	}
	
};


jQuery(document).ready( 
	function() {
		
		jQuery("#bt_newsletter").click(function(){
			Life_urbano.newsletter();
		});
		
		jQuery('#bt_monreseau').click(function() {
			Life_urbano.monreseau();
		});
		
		jQuery('#bt_partage').click(function() {
			jQuery('#divMonreseau').show();
			jQuery('#bt_partage').hide();
			return false;
		});
		
		jQuery('#bt_videoMail').click(function(){
			Life_urbano.videomail();
		});
		
		jQuery('#videoMailLink').click(function(){
			jQuery('#divVideoMail').show();
		});
	}
);


