// JavaScript Document

/* INICIO DROPDOWN PÁGINA PRINCIPAL */
		
		var overScroll=false;

		if (window.addEventListener)
		{
			// DOMMouseScroll is for mozilla. 
			window.addEventListener('DOMMouseScroll', wheel, false);
		}
		// IE/Opera. 
		window.onmousewheel = document.onmousewheel = wheel;
		
		function wheel(event)
		{
		
			var delta = 0;
			if (!event)
			{
				// For IE.
				event = window.event;
			}
			
			if (event.wheelDelta) 
			{ 
				// IE/Opera. 
				delta = event.wheelDelta/120;
				/*if (window.opera)
				{
					delta = delta;
				}*/
				
			} 
			else if (event.detail)
			{ 
				// Mozilla case. 
				delta = -event.detail/3;
			}
			
			
			if(overScroll)
			{
				
				if (event.preventDefault)
				{
					event.preventDefault();
				}
				
				event.returnValue = false;
				
				moveWithWheel(delta);
			}
		}
		
		function moveWithWheel(delta)
		{
			if(delta > 0)
			{
				cima('ul_acompanhe');
			}
			else
			{
				baixo('ul_acompanhe');
			}
		}

		function mexer(quem)
		{
			var id = $(quem).attr("id");
			var tamCom = $("#"+id+" div:eq(1)").attr("scrollHeight")-$("#"+id+" div:eq(1)").height();
			var tamRol = $("#"+id+" div:first").height() - $("#"+id+" div:first img:first").height();
			var pos = $("#"+id+" div:first img:first").position().top - $("#"+id+" div:first").position().top;
			var val = (tamCom/tamRol)*(pos);
			$("#"+id+" div:eq(1)").scrollTop(val);
		}
		
		function baixo(quem)
		{
			var id = $('#'+quem).parent().attr("id");
			var tamRol = $("#"+id+" div:first").height() - $("#"+id+" div:first img:first").height();
			var num = $("#"+id+" div:first img:first").position().top-$("#"+id+" div:first").position().top+10;
			if(num < tamRol){
				$("#"+id+" div:first img:first").css("top", num);
				mexer($('#'+quem).parent());
			} else {
				$("#"+id+" div:first img:first").css("top", tamRol);
				mexer($('#'+quem).parent());
			}
		}
		
		function cima(quem)
		{
			var id = $('#'+quem).parent().attr("id");
			var topRol = $("#"+id+" div:first").position().top;
			var num = $("#"+id+" div:first img:first").position().top-$("#"+id+" div:first").position().top-10;
			if(num > 0){
				$("#"+id+" div:first img:first").css("top", num);
				mexer($('#'+quem).parent());
			} else {
				$("#"+id+" div:first img:first").css("top", 0);
				mexer($('#'+quem).parent());
			}
		}
		
		
		/* FIM DROPDOWN PÁGINA PRINCIPAL */
		
function rolageminit(){
						
			
			/* INICIO DROPDOWN */
			$("#lista_acompanhe").mouseenter(
				function()
				{
					overScroll=true;
				}
			);
			
			$("#lista_acompanhe").mouseleave(
				function()
				{
					overScroll=false;
				}
			);
			
			$(".rolagem").click(function(event){
				
				$(this).find("img").css("top", event.clientY-($(this.parentNode).position().top+6)+$(document).scrollTop());
				mexer($(this).parent());
			})
		
			$(".rolagem img:first").draggable({ 
			axis: 'y', 
			scroll: false, 
			containment: 'parent',
			drag: function() {
				mexer($(this).parent().parent());
				}
			});
		
		
			//$("#lista_acompanhe").hide();
			
			/*$("a.botao_escolha").click(
				function(){
				
					$("#lista_acompanhe").slideToggle(500);
				}
			);*/
			/* FIM DROPDOWN */

			/*<div id="lista_acompanhe">
                        <div class="rolagem"><img src="img/bt_rolagem.gif" alt="Botão de rolagem" /></div>
                        <div id="ul_acompanhe">
                            
                        </ul>
                    </div>*/
		
	
		};
		
