

$(document).ready( function() {
	
	// --> Input Field
		/*if ( $('.inputFieldGreen').length > 0 )
		{
			
			$('.inputFieldGreen input').focus( function() {
				var divEl = $(this).parent('div');
				divEl.addClass( divEl.attr('class') + 'Green_bkg');
				$(this).attr('value','');
			}).blur( function() {
				var divEl = $(this).parent('div');
				divEl.removeClass( divEl.attr('class') + 'Green_bkg');
				$(this).parent('div').removeClass('green_bkg');
			});
		
		}*/
		
	// --> 
		//$('.two-cols').columnize({columns:2});
	
	
	if ( $('.write-comment').length > 0 )
	{
		$('.write-comment').click( function() {
			$('#respond').css('display', 'block');
			return false;
		});
	}
		
		if ( $('.dbem-calendar-table ').length > 0 )
		{
				$('.dbem-calendar-table thead td:first').addClass('calPrev');
				$('.dbem-calendar-table thead td:last').addClass('calNext');
		}
		
		
		$('.inputFieldGreen input').focus( function() {
				$(this).parent('.inputFieldGreen').css('background-position', '0px -50px');
				$(this).attr('value', '');
		}).blur( function() {
				$(this).parent('.inputFieldGreen').css('background-position', '0px 0px');
		});
		
		$('.ifgLongField input').focus( function() {
				$(this).parent('.ifgLongField').css('background-position', '-70px -300px');
				$(this).attr('value', '');
		}).blur( function() {
				$(this).parent('.ifgLongField').css('background-position', '-70px -250px');
		});
		
		
		// --> Charte
		$('.checkArt').click( function() {
			var whichOne = $(this).attr('rel');
			$('.article-' + whichOne ).slideUp();
			$('.checked-' + whichOne ).fadeIn();
			
			var nbCheckbox = $('.checkArt').length;
			var nbCheck = $(".checkArt:checked").length;
			
			if ( nbCheckbox == nbCheck )
			{
				$('.submitCharte').fadeIn();
			}
			
			
		});
		
		
		
		/*.ifgLongField {
				background: url(images/sprites-input.png) no-repeat -70px -250px;*/
	

});


function willBeThere ( idUser, idEvent, action )
{
		$.ajax({
						url: 'wp-content/themes/jeunes-ambassadeurs-th/ajax-functions.php',
						type: 'POST',
						data: { id_user: idUser, id_event: idEvent, flag: action },
						success: function(data) {
								if ( $('.acceptBT').hasClass('will-be-there-actif') )
								{
										$('.acceptBT').removeClass('will-be-there-actif');
								}
								if ( $('.refuseBT').hasClass('will-notbe-there-actif') )
								{
										$('.refuseBT').removeClass('will-notbe-there-actif');
								}
								
								if (data == "1")
								{
										if ( action == true )
										{
												$('.acceptBT').addClass('will-be-there-actif');
										}
										else
										{
												$('.refuseBT').addClass('will-notbe-there-actif');
										}
								}
								
						}
				});
}
