$(document).ready(function(){

	$(function(){
		$('#top').stop().animate({width: "180%"}, 50000);
	});
	
	$('.loader').load('hnt_story.php #map>img');
	$('.loader').load('contact.php .modal_info');
	$(function(){
		var filas = $(".gallery_page:first-child .pictures_row").length;
		var base = $(".pictures_row").height() + 30;
		var alto = filas * base;
		if(filas <= 4){
			$("#scroleable").stop().animate({height: alto+'px'});
		}
		
		$("#scroleable").scrollable({
			
			speed:1300,
			onBeforeSeek:function(){
				$(".gallery_page").fadeOut('slow');
			},
			onSeek: function(){
				var small = $(".gallery_page:last-child").height();
				var original = $(".gallery_page").height();
				var paginas = $(".gallery_page").length;
				var ancho = $(".gallery_page").width();
				var position = $("#items").position();
				var anchoTotal = paginas * ancho - ancho;
				if(-anchoTotal == position.left){
					$("#scroleable").stop().animate({height: small+'px'});
					$(".gallery_page").fadeIn('slow');
				}else{
					$(".gallery_page").fadeIn('slow');
					$("#scroleable").stop().animate({height: original+'px'});
				}
				
			}		
		}).navigator();
	});
	
	$(function(){
		var counter = 1;
		$('#new_picture').bind('click',function(){
			switch(counter){
				case 1:
					$('#upload').animate({height: '+=300'}, 'slow');
					$('.hidden').fadeIn('slow');
					$('.upl_divs').fadeIn('slow');
					$('.hidden:last').hide();
					$('.upl_divs:last').hide();
					counter++;
					break;
				case 2:
					$('#upload').animate({height: '+=300'}, 'slow');
					$('.hidden:last').fadeIn('slow');
					$('.upl_divs:last').fadeIn('slow');
					counter++;
					break;
				case 3:
					$('#upload').animate({height: '+=300'}, 'slow');
					$('.hidden:last').fadeIn('slow');
					$('.upl_divs:last').fadeIn('slow');
					counter++;
					break;
				case 4:
					$('#upload').animate({height: '+=300'}, 'slow');
					$('.hidden:last').fadeIn('slow');
					$('.upl_divs:last').fadeIn('slow');
					counter++;
					break;
				default:
					alert("you can only upload 10 files at the same time");
			}
		});		
	});	
});



	

