

(function(){
		  /*
	var scaler=Scaler('bg'),els=$('#bg').children(),width=100/els.length;
	var float=$('<span />').css({position:'absolute',color:'#fff',cursor:'pointer',zIndex:2});
	var div=$('<div/>').css({position:'absolute',left:0,bottom:0,marginRight:-20,height:'100%'});
	div.width(els.css({float:'left',width:width+'%'}).length+'00%').append(els);

	var move=function(e){
			float[0].style.left=(e=e||window.event).clientX+20+'px';
			float[0].style.top=e.clientY+20+'px';
			if(float[0].nxt!=(e.clientX>(document.body.offsetWidth/2)))float[0].innerHTML=(float[0].nxt=!float[0].nxt)?'next':'previous';	//Change html only if needed
		},
		swap=function(e){
			var key=e.type=='click'?(e.clientX>(document.body.clientWidth/2)?40:37):e.keyCode;
			if(key>36&&key<41)div.animate({left:(scaler(key>38?'+1':'-1').to*-1)+'00%'});	//swap with animation
		}

	$(window).bind('keydown',swap);
	$('#bg').bind('mousemove',move).bind('click',swap).css('cursor','pointer').append(div,float);
	*/
	
	

	/*$('#bg').cycle({ //if using jquery.cycle-plugin the window resizing won't behave too good - fixable
		timeout:2000,
		after:function(a,b,c){scaler(c.currSlide)}, //but this part is important - scale the current photo
		fx:'scrollLeft'
	});*/
	
if($("body").attr("id")=="homepage"){	
	
	
	var cur_img = $("#bg > b:first-child").attr("id");
	var first_img = cur_img;
	var last_img = $("#bg > b:last-child").attr("id");
	
	/*		OBIGES DYNAMISIEREN	*/
	
		
	$("#" + cur_img).css("display","block");
	$("#news_" + cur_img).css("display","block");
		
	

	
	$("#homepage .next").click(function(){
	
	var next_id = $("#"+cur_img).next("b").attr("id");
	if(next_id){
		$("#"+cur_img).fadeOut("slow");
		$("#news_"+cur_img).css("display","none");
		$("#"+next_id).fadeIn("slow");
		$("#news_"+next_id).css("display","block");
		cur_img = next_id;
	}
	else{
		$("#"+cur_img).fadeOut("slow");
		$("#news_"+cur_img).css("display","none");
		
		$("#"+first_img).fadeIn("slow");
		$("#news_"+first_img).css("display","block");
		cur_img = first_img;
	}
								 
	})
	
	
	$("#homepage .prev").click(function(){
	
	var prev_id = $("#"+cur_img).prev("b").attr("id");
	if(prev_id){
		$("#"+cur_img).fadeOut("slow");
		$("#news_"+cur_img).css("display","none");
		$("#"+prev_id).fadeIn("slow");
		$("#news_"+prev_id).css("display","block");
		cur_img = prev_id;
	}
	else{
		$("#"+cur_img).fadeOut("slow");
		$("#news_"+cur_img).css("display","none");
		
		$("#"+last_img).fadeIn("slow");
		$("#news_"+last_img).css("display","block");
		cur_img = last_img;
	}
								 
	})



var mousePosY = $(document).height()/2;



$("#homepage #content").bind("mousemove",function(e){

        mousePosY = e.pageY - 80;
		
});// mousemove




var t = setInterval(function(){
							 
			var topOffset=$("#teaser").offset();
			var topOffset=topOffset.top;
		topOffset += (mousePosY - topOffset)/5;
		var setOffset = Math.round(topOffset);
    	//
		if(setOffset>135){
		$("#teaser").offset({top:(setOffset)})
		}
		else
		{
		$("#teaser").offset({top:(135)})
		}
		
		
		
},50);




}// if HOMEPAGE




	
})();
