$(document).ready(function() {
	
	$.landing_images = $('#landing_image img');
	$.image_index = 1;
	
	if ($.landing_images.length > 1) {
   
   	setInterval(function(){
   		
   		if ($.image_index >= $.landing_images.length) {
   			$.image_index = 0;
   		}
   		
   		$('#landing_image img:visible').hide()
   		
   		$($.landing_images[$.image_index]).fadeIn();
   		$.image_index++;
   		
   	}, $.landing_image_timer);
   }
	
	$('#animal_list li a').tooltip(
		{
			showURL:false,
			track:true,
			top:-140,
			left:-46,
			extraClass:'home_adoption',
			bodyHandler: function() {

				// get id for image
				id = $(this).attr('href').split('=').pop();
				output = "<img src=\"images/adoption_banner/" + id + ".jpg\" alt=\"Evlat edinin\" />";
				output = output + "<p>Evlat edinin</p>"; 
				return output;
			}
		}
	);
	

	$('#membership,#donation').find('form').submit(function(e) {
		// see if other amount has the required minimum value
		other_amount = $(this).find('input.other_amount');
		
		if(other_amount.val()) {
			min_amount = other_amount.attr('class').split(' ').pop().split('_').pop();
			
			if(other_amount.val() < min_amount) {
				
				other_amount.addClass('error');
				notice = other_amount.parents('form').find('div.notice'); 
				notice.fadeIn('fast',function() {
					
					setTimeout(function() {
						notice.fadeOut();
						other_amount.removeClass('error');
					},4000)
				});
				e.preventDefault();
			}
		}
	})
	
});

