$(document).ready(function(){
	
	// Settings for the banner image rotation
	$('#flipper').cycle({
		random: 1,
		timeout: 5000,
		speed: 0			
	});
	
	// Toggle the visibility of linking examples
	$('#view_examples').click(function() {
		$('#linking_examples').toggle();
		$(this).toggleClass('active');
	});
	
	// Delete banner image from DB and remove it from the DOM
	$('.delete_image').click(function() {
		//alert( $(this).attr('id') );
		var id = $(this).attr('id');
		
		// AJAX - Delete image from DB
		$(this).closest('.img_holder').load("banner_ajax.php", 
			{ 
				id: id
			}, 
			function(data) 
			{
				if ( data == 1 ) {
					$(this).html('<span class="v_message">Successfully Removed</span>');
					$(this).delay(1000).slideUp(500).fadeOut(500);
				} else {
					$(this).html('<span class="v_message">ERROR: Item not removed.<br />Refresh the page and try again.</span>');
				}
			}
		);
	});	
	
	// Show Delete text when hovering the 'X'
	$('.delete_image').hover(
		function () {
			$(this).next('.delete_label').show();
		}, 
		function () {
			$(this).next('.delete_label').hide();
		}
	  );


});
