// JavaScript Document

//******************************************//
var px_blase = 5;//mehr=schneller 
var timer_blase;
function scrollDiv_blase(val){ 
	clearTimeout(timer_blase); 	
	d=document.getElementById('blase'); 
	y=d.scrollTop; 
	if(val==1)y-=px_blase; 
	if(val==2)y+=px_blase; 
	if(y<=d.scrollHeight-d.offsetHeight+px_blase&&y>=0-px_blase){ 
		d.scrollTop=y; 
		timer_blase=setTimeout('scrollDiv_blase('+val+')',50); 
	} 
	if(y<0||y>d.scrollHeight-d.offsetHeight){ 
		clearTimeout(timer_blase); 
	} 
}

var px_link_list = 5;//mehr=schneller 
var timer_link_list;
function scrollDiv_link_list(val){ 
	clearTimeout(timer_link_list); 	
//	 var maxScroll = $("#content-scroll").attr("scrollHeight") - $("#content-scroll").height();	 
//	d=document.getElementById('linkList'); 
//	y=d.scrollTop; 
	y = $("#linkList").attr("scrollTop");
	var dsH = $("#linkList").attr("scrollHeight");
	var doH = $("#linkList").attr("offsetHeight");	
	if(val==1)y-=px_link_list; 
	if(val==2)y+=px_link_list; 
//	if(y<=d.scrollHeight-d.offsetHeight+px_link_list&&y>=0-px_link_list){ 
		if(y<=dsH-doH+px_link_list&&y>=0-px_link_list){ 
		//d.scrollTop=y; 
    	$("#linkList").attr({scrollTop: y });
	
		timer_link_list=setTimeout('scrollDiv_link_list('+val+')',50); 
	} 
	//if(y<0||y>d.scrollHeight-d.offsetHeight){ 
	if(y<0||y>dsH-doH){ 
		clearTimeout(timer_link_list); 
	} 
}

function get_scrollDiv_link_list() {
	
	//d=document.getElementById('linkList'); 	
	//y=d.scrollTop; 
	y =  $("#linkList").attr("scrollTop");
	return y;	
}

function set_scrollDiv_link_list(val) {
	
	d=document.getElementById('linkList'); 
	d.scrollTop = val; 
}




var px_list_left = 5;//mehr=schneller 
var timer_list_left;
function scrollDiv_list_left(val){ 
	clearTimeout(timer_list_left); 	
	d=document.getElementById('list_left');
	y=d.scrollTop; 
	if(val==1)y-=px_list_left; 
	if(val==2)y+=px_list_left; 
	if(y<=d.scrollHeight-d.offsetHeight+px_list_left&&y>=0-px_list_left){ 
		d.scrollTop=y; 
		timer_list_left=setTimeout('scrollDiv_list_left('+val+')',50); 
	} 
	if(y<0||y>d.scrollHeight-d.offsetHeight){ 
		clearTimeout(timer_list_left); 
	} 
}

function get_scrollDiv_list_left() {
	
	d=document.getElementById('list_left'); 
	y=d.scrollTop; 
	return y;	
}

function set_scrollDiv_list_left(val) {
	
	d=document.getElementById('list_left'); 
	d.scrollTop = val; 
}

var px_list_left2 = 5;//mehr=schneller 
var timer_list_left2;
function scrollDiv_list_left2(val){ 
	clearTimeout(timer_list_left2); 	
	d=document.getElementById('list_left2'); 
	y=d.scrollTop; 
	if(val==1)y-=px_list_left2; 
	if(val==2)y+=px_list_left2; 
	if(y<=d.scrollHeight-d.offsetHeight+px_list_left&&y>=0-px_list_left2){ 
		d.scrollTop=y; 
		timer_list_left2=setTimeout('scrollDiv_list_left2('+val+')',50); 
	} 
	if(y<0||y>d.scrollHeight-d.offsetHeight){ 
		clearTimeout(timer_list_left2); 
	} 
}


//**********************************************//
function handleSliderChange(e, ui)
{
	/*
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
  */
    var maxScroll = $("#content-scroll").attr("scrollHeight") - $("#content-scroll").height();
  $("#content-scroll").animate({scrollTop: maxScroll - (ui.value * (maxScroll / 100)) }, 1000);

}

function handleSliderSlide(e, ui)
{
	/*
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
  */
  var maxScroll = $("#content-scroll").attr("scrollHeight") - $("#content-scroll").height();
  $("#content-scroll").attr({scrollTop: maxScroll - (ui.value * (maxScroll / 100)) });

}


$(document).ready(function(){						   
						   
  ani_block('1',nz_i);
  ani_block('2',nz_b); 
  ani_block('3',nz_f);  
  ani_block('4',nz_e);  
  ani_block('5',nz_n);  
  
  $("#content-slider").slider({
    animate: false,
    change: handleSliderChange,
    slide: handleSliderSlide,
	orientation: 'vertical',
	value: 100
  });
  
  $("#Berufswahl").mouseenter(function(){ $("#Berufswahl_menu").show();  });
  $("#Wunschberuf").mouseenter(function(){ $("#Wunschberuf_menu").show();  });    
  $("#Menschen").mouseenter(function(){ $("#Menschen_menu").show();  });  
  $("#Anhalt").mouseenter(function(){ $("#Anhalt_menu").show();  });  
  $("#Kalender").mouseenter(function(){ $("#Kalender_menu").show();  });  
  $("#Pimp").mouseenter(function(){ $("#Pimp_menu").show();  });  
  
 
  $(".menu_entry").mouseleave(function(){ $(".menu_entry").hide();  });

  
  
	$('#scrollWnd').attr('style', 'top:-'+spos+'px;');
  
 /* $(document).pngFix();  */

	$("input").focus(function(){ 
		$(this).parent().addClass("active");
	});
	$("input").blur(function(){ 
		$(this).parent().removeClass();
	});
			
	$(".button")
			.ajaxStart(function(){
				$("#messages div").remove();
				$("#messages").append('<div id="ajax_load">Überprüfe Daten...</div>');
			});			
});
