$(document).ready(function(){

	
	function flynotes(whereat){
		//alert(whereat);
		
		$("#notebox").css("left",whereat+"px");	
		$("#notebox img").each(function(){
			
			notespeed=(Math.floor(Math.random()*1000)+500);
			//alert (notespeed);
			
	
	$(this).stop().animate({"top":'-150px'},{queue:false, duration:notespeed});
	
});
		
		
		
	}
	
	function returnnotes(){
		
		
		$("#notebox img").stop().css("top","0px");
	
		
	}
	
	
$("#notebox").css("top","100px");	//put this back
startnoteleft=0;  //put this back
$("#notebox img").each(function(){
	$(this).css("left",startnoteleft+"px"); //put this back
	startnoteleft=startnoteleft+20; //put this back
});
	
	
	
	
	
	
	
//$(".choices").eq(5).css('left', '-72px'); //hard coded...not ideal
//$(".mainchoice").eq(5).css('top', $(".mainchoice").eq(4).css("top")); //hard coded...not ideal
	


	$(".choices").prepend( '<div class="curtainspace"/>');  //put this back
	var timeOut=new Array();
	$(".choices").css("opacity","0");	
	
	$(".mainchoice").each(function() {  
	
					   
					//$(this).width($("#div"+this.id).width());  //put this back
					//alert($("#div"+this.id).width());
					   })
	
	
	$(".maintrigger").each(function() {  
					   
					//$(this).width($("#div"+this.id).width());
					//alert(this.id);
					   })
	
	
	
	//Remove outline from links
	$("a").click(function(){
		//$(this).blur(); //put this back
	});
	
	
	//When mouse rolls over
	
	$(".maintrigger").mouseover(function(){
		
		
	
	
		
		
		
		myoverid=$(this).attr("id");
		pullup(myoverid);
		
		if(timeOut["div"+myoverid]){
		clearTimeout(timeOut["div"+myoverid]);
		}
		//clearTimeout(timeOut);
		//addon=$(this).find("img").height()-50;
		addon=0;
										// alert(this.id);
			//$("#div"+this.id).css("opacity",0);		
			flynotes(Math.round($(this).parents(".maintitle").position().left));					
			$("#div"+this.id).stop().animate({"top":addon+'px'},{queue:false, duration:1500, easing: 'easeOutExpo'});	
			$("#div"+this.id).animate({"opacity":"1"},{queue:false, duration:1500, easing: 'easeOutExpo'});
			//$(this).stop().animate({height:$("#div"+this.id).height()+40},{queue:false, duration:1500, easing: 'easeOutExpo'})
										});
	
	
	$(".choices").mouseover(function(){
		thisid=$(this).attr("id");
		if(timeOut[thisid]){
		clearTimeout(timeOut[thisid]);
		}
		
		//$("#div"+this.idnumber).stop().animate({"top":'100px'},{queue:false, duration:600, easing: 'easeOutBounce'})
		//$(this).stop().animate({height:'350px'},{queue:false, duration:600, easing: 'easeOutBounce'})
		//$(this).stop().animate({"top":'20px'},{queue:false, duration:0, easing: 'easeOutExpo'});
		$(this).stop().animate({"top":'0px'},{queue:false, duration:10});
		//$(this).stop();
		$(this).animate({"opacity":"1"},{queue:false, duration:0, easing: 'easeOutExpo'});
		//$(this).stop().animate({height:$("#div"+this.id).height()+40},{queue:false, duration:1500, easing: 'easeOutExpo'})
		//$(this).stop().animate({height:$("#div1").height()},{queue:false, duration:600, easing: 'easeOutBounce'})
	});
	
	//When mouse is removed
	$(".choices").mouseout(function(){
		//$("#div"+this.id).stop().animate({"top":'-500px'},{queue:false, duration:600, easing: 'easeOutBounce'})
		
		$(this).stop().animate({"top":'-'+$(this).height()},{queue:false, duration:1500, easing: 'easeOutExpo'});
		$(this).animate({"opacity":"0"},{queue:false, duration:0, easing: 'easeOutExpo'});
		//$(this).stop().animate({height:'30px'},{queue:false, duration:1500, easing: 'easeOutExpo'})
	});
	$(".maintrigger").mouseout(function(){
		
	returnnotes();
		
		
		
		
		myid=$(this).attr("id");
		timeOut["div"+myid] = setTimeout(function(){
			//alert("troy"+myid);
		//$("#div"+this.id).stop().animate({"top":'-500px'},{queue:false, duration:600, easing: 'easeOutBounce'})
		$("#div"+myid).stop().animate({"top":'-'+$("#div"+myid).height()},{queue:false, duration:1500, easing: 'easeOutExpo'})
		$("#div"+myid).animate({"opacity":"0"},{queue:false, duration:0, easing: 'easeOutExpo'});
		//$(this).stop().animate({height:'30px'},{queue:false, duration:1500, easing: 'easeOutExpo'})
		},600);
	});
	
	function pullup(whichup){
		checkup=whichup;
		$(".choices").each(function(){
			if($(this).attr("id")!="div"+checkup){
				$(this).stop().animate({"top":'-'+$(this).height()},{queue:false, duration:1500, easing: 'easeOutExpo'});
				$(this).animate({"opacity":"0"},{queue:false, duration:0, easing: 'easeOutExpo'});
				
			}
			
		});
		
		
		
	}
	
});
