$(document).ready(
	function($)
	{
	
      $('a[rel*=facebox]').facebox({
        loading_image : 'loading.gif',
        close_image : 'closelabel.gif'
      });
		// Toggle Single Portlet
		$('a.selfclose').click(function()
			{
				//$(this).parent("div").parent("div").parent("div").fadeOut();
				$(this).parent('div').parent("div").next("div").toggle();
				//alert($(this).parent('div').parent("div").next("div").html());
				var current=$(this).children("img").attr("src");
				if (current=="images/iconbopen.png")
				{
				$(this).children("img").attr("src","images/iconbclose.png");
				}else{
				$(this).children("img").attr("src","images/iconbopen.png");
				}
				return false;
			}
		);
		$('a.continenttoogle').click(function()
			{	
				$(this).next('div').slideToggle();
				$("div#dropDowncountry  ul li div ul li:last-child").css('background','none');
				return false;
				
			}
		);
		$('a.isparentcat').click(function()
			{	
			$(this).next("a").next('div').slideToggle();
			
				$("div#dropDownMenu ul li ul li:last-child").css('background','none');
				
				
			}
		);
		$('a.passerelle_link').click(function()
			{	
			  $(".mc_details_2").html($(this).attr("title"));
				$(".mc_details_2").slideToggle("slow");
			
				
			}
		)

	
		
	}
);
function ajax_get_country (continent,target){
	$.ajax(
		   {
      			type: "POST",
      			url: "ajax_get_country.php",
				data:"id="+continent,
      			dataType : "html",
      			error:function(msg, string){
      			alert( "Error !: " + string );
     	 		},
     		 success:function(data){
				document.getElementById(target).innerHTML = data;
      		}
	 	 }
	  );
}

function ajax_get_opvalues(option,target){
	
	$.ajax(
		   {
      			type: "POST",
      			url: "ajax_get_optionval.php",
				data:"id="+option+"trg="+target,
      			dataType : "html",
      			error:function(msg, string){
      			alert( "Error !: " + string );
     	 		},
     		 success:function(data){
				document.getElementById(target).innerHTML = data;
      		}
	 	 }
	  );
}
function popup(page,t,w,h,s) {
	window.open(page,t,"width="+w+",height="+h+",scrollbars="+s);
}
function pictos() {
	popup('popup_pictos.php','pictos',570,500,1);
}

function show() {
	$(document).ready(
	function()
	{
    $('.moncompte').css('background', 'url(images/moncomptebg1.png)');
    $('.mc_details').css('top', '35px');
    $('.mc_details').css('left', '10px');
    $('.mc_details').fadeIn('fast');
	}
	);
}
$(document).ready(
	function()
	{

   		 $('.mc_details').bind('mouseleave', function() {
        $('.moncompte').css('background', 'none');
        $('.mc_details').fadeOut('fast');
    });
}); 

$(function(){

	$('<div id="scrolltotop"><a href="javascript:void(0);">Retour en haut</a></div>').appendTo('body').css({opacity: 0});
	$(window).scroll(function(){
		
		// Position of the scroll (by the top)
		var scrollTop = $(window).scrollTop();

		$('#scrolltotop a').click(function(){
	    $('html,body').stop().animate({scrollTop: 0}, 'slow');
		});

   
		// Si la position du scroll est à la moitié de la taille du document on affiche la div pour remonter.
		var div = $('#scrolltotop');
		
		if(scrollTop >= 300){
			if(div.css('opacity') == 0){
				div.stop().animate({opacity: 1}, 500);
			}
		}else{
			
			// Sinon, on affiche pas la div
			if(div.css('opacity') > 0){
				div.stop().animate({opacity: 0}, 500);	
			} 
		}
	});
	$(window).scroll();
});
