/**
 * @author Greg
 */


var Navigation = {
		
		init: function(){
	   $("a[rel='lightbox']").colorbox();
			$('section#homepage div.prix div.prix1 a.moreinfo').colorbox({href: function(){ return $(this).attr('href')+'/embedded/1'; }, iframe:true, width:650,height:450});
			
		}
};

$(document).ready(function(){
	/*
	$('div.menugen').hover(function(){
	  $('nav.menugeneral').css('display','block');
	},
	function(){
    $('nav.menugeneral').css('display','none');
	});
	*/
	Navigation.init();
	
	$('#slideshow').cycle();
	
	$('img.cadre-droite').each(function(){
		var round = $('<div></div>').attr('class','supercadre');
        $(this).wrap(round);
        $(this).parent('div.supercadre').append('<div class="cadre-droite"></div>');
	});
	$('img.cadre-gauche').each(function(){
		var round = $('<div></div>').attr('class','supercadre');
        $(this).wrap(round);
        $(this).parent('div.supercadre').append('<div class="cadre-gauche"></div>');
	});
	
	$('div.share').delegate('a','click',function(e){
		e.preventDefault();
		if($(this).hasClass('email')){
			var url = $(this).attr('href');
			url = url + '/embedded/1';
			////console.debug(url);
			$.colorbox({
				href:	url,
				title:  "Partager/share",
		        height: 500,
		        width:  600,
		        iframe:true
			}); 
		}
		
		if($(this).hasClass('twitter')){
			var url = $(this).attr('href')+'?';
			var params = [];
			if($(this).attr('data-url')){
				params.push('url='+encodeURIComponent($(this).attr('data-url')));
			}else{
				params.push('url='+encodeURIComponent(window.location.href));
			}
			if($(this).attr('data-text')){
				params.push('text='+encodeURIComponent($(this).attr('data-text')));
			}
			if($(this).attr('data-via')){
				params.push('via='+encodeURIComponent($(this).attr('data-via')));
			}
			if($(this).attr('data-related')){
				params.push('related='+encodeURIComponent($(this).attr('data-related')));
			}
			if($(this).attr('data-count')){
				params.push('count='+encodeURIComponent($(this).attr('data-count')));
			}
			if($(this).attr('data-lang')){
				params.push('lang='+encodeURIComponent($(this).attr('data-lang')));
			}
			
			var url = url + params.join('&');
			window.open( url, "Twitter", "status = 0, height = 400, width = 500, resizable = 0" );

		}

		if($(this).hasClass('facebook')){
			var url = $(this).attr('href');
			window.open( url, "Twitter", "status = 0, height = 400, width = 500, resizable = 0" );
		}
	});
	
});
