jQuery(document).ready(function($){


var templateDirectory = '/wp-content/themes/euroNaval/';


//
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Resize the images 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
	
			$('#news-list img').one('load', function() {
				
		  		pic_real_width = $(this).width(); 
	       		pic_real_height = $(this).height(); 

	       		if (pic_real_width > 100) 
				{
					var ratio = (pic_real_height / pic_real_width );
					var new_width = 100;
					var new_height = (new_width * ratio);
					$(this).height(new_height).width(new_width);
				}
			}).each(function() {
				if(this.complete) $(this).load();
			});
			
		
		
//
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Add remove selection on page -> exposants -> liste des exposants
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
			
		

			// Fonction qui se base sur la presence ou l'absence de class "selected" pour generer un tableau des ids selectionné
			var refresh = function(){
				
				$('.add-to-selection').each(function() {
					if ($(this).hasClass('selected'))
					{
						$(this).attr('src',templateDirectory+'images/images-css/puce-11.png');
					}else{
						$(this).attr('src',templateDirectory+'images/images-css/puce-10.png');
					}
				});

			};
			
			
			
			
			
			// Sur le click sur les puces
			$('.add-to-selection').click(function() {
				if (!$(this).hasClass('selected'))
				{
					$(this).addClass('selected');
					$(this).attr('src',templateDirectory+'images/images-css/puce-11.png');
				}else{
					$(this).removeClass('selected');
					$(this).attr('src',templateDirectory+'images/images-css/puce-10.png');
				}
				$.post(templateDirectory + "libs/saveSelection.php", { id: $(this).attr('id') },
						function(data) {
							//console.log(data);
					});
			});

			refresh();
			
//
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Remove links from non clickable pages
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
			
			
			if ($(this).find('#page_langue').val() == 'fr')
			{
				message = 'prochainement';
			}else{
				message = 'soon';
			}
			
			$('.page-item-350').find('a:first').removeAttr('href');	
			$('.page-item-95').find('a:first').removeAttr('href');	
			$('.page-item-125').find('a:first').removeAttr('href');	
			$('.page-item-149').find('a:first').removeAttr('href');	
			$('.page-item-169').find('a:first').removeAttr('href');	
			$('.page-item-193').find('a:first').removeAttr('href');	
			$('.page-item-83').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');
			$('.page-item-214').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');	
			$('.page-item-85').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');
			$('.page-item-71').find('a:first').removeAttr('href');	
			$('.page-item-97').find('a:first').removeAttr('href');	
			$('.page-item-127').find('a:first').removeAttr('href');	
			$('.page-item-107').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');
			$('.page-item-111').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');
			$('.page-item-147').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			$('.page-item-145').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');	
			$('.page-item-165').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			$('.page-item-167').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			/*$('.page-item-206').find('a:first').removeAttr('href');	
			$('.page-item-208').find('a:first').removeAttr('href');	*/
			$('.page-item-954').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			$('.page-item-1091').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			$('.page-item-216').find('a:first').removeAttr('href').append(' <span class="soon">['+message+']</span>');		
			
			
			
			
			
			
	
	
	$('.print-btn').click(function() {
			w=window.open();
			w.document.write(
					'<link rel="stylesheet" type="text/css" media="all" href="http://www.euronavale.local/wp-content/themes/euroNaval/css/print.css" /> '+
					'<br />'+
					$('#section_to_print').html()
				
			);
			//w.print();
			//w.close();
	});
	
	
//
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Newsletter
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
	$('#newsletter-btn').click(function() {	
		var mail = $(this).parent().find('#newsletter-mail').val();
		var langue = $(this).parent().find('#langue').val();
		$.post(templateDirectory+"/libs/newsletter.php", { mail: mail, langue : langue },
			function(data) {
				$('#newsletter #alert').html(data);
				
	   });
	});	
})



	function getCurrentIds(pOldIds){
		oldIdsArray = pOldIds.split(',');
		//alert(pOldIds);
	}


