/** bird related stuff */
function hideBirdStuff(first){
	
	$("a.colored-bird").not(".current").each(function(){
		$(this).siblings("."+$(this).attr("id")).hide();
		if ( first == true)
		{
			$(this).siblings("."+$(this).attr("id")).hover(function(){
				window.clearTimeout(bird_timer);
			},function(){
				//alert($(this).attr("class"));
				hideBirdStuff();
			});
		}
	});
}
var bird_timer = null;

$(document).ready(function(){
	// hide all siblings of birds
	hideBirdStuff(true);

	// show siblings of birds if any
	$('a.colored-bird').not('.current').hover(
		function(){
			hideBirdStuff();
			$(this).siblings('.'+$(this).attr('id')).show();
			window.clearTimeout(bird_timer);
		},
		function(){
			bird_timer = setTimeout(hideBirdStuff, 250);
		}
	);
	$('a#shop1, a#shop2').click(function(){return false;});
});
/** **/


$(function() {

$('input[type="text"]').change(function(){

	if(isNaN($(this).val())) {
		$(this).val(0);
	}
	else
	{
		id = $(this).attr('name').split('_', 2);
		if($('input#max_cant_prod_'+id[1]).val() < $(this).val()) {
			$(this).val($('input#max_cant_prod_'+id[1]).val());
			alert('Max quantity is '+$('input#max_cant_prod_'+id[1]).val());
		}
	}


	});


	$('a[id^="addToCart_"]').click(function(){

		id = $(this).attr("id").split('_', 2);

		$('form#prod_'+id[1]).submit();
		return false;

	});
	$('a[id^="remove_item_"]').click(function(){

		id = $(this).attr("id").split('_', 3);
		$('form#remove_item_'+id[2]).submit();
		return false;

	});



	$('a.submit').click(function(){
			 $('form#rfm').submit();
	});


});
