﻿function sky_addEvent(elm, evType, fn, useCapture){
	if (elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}

function slicePages(){
	var content = document.getElementById('wrapContent');
	var pages = document.getElementById('pages');
	if(!content || !pages) return false;
	var scrollHeight = content.scrollHeight;
	var height = content.offsetHeight;
	var len = Math.ceil(scrollHeight/height);
	var current = 0;
	var count = 0;
	var scoll = 0;
	if(len>1){
		for(var i=0; i<len; i++){
			var a = document.createElement('a');
			a.setAttribute('href','javascript:void(0);');
			a.innerHTML = (i+1);
			pages.appendChild(a);
		}
	}
	if(pages.innerHTML == ''){
		pages.style.display = 'none';
	}else{
		var as = pages.getElementsByTagName('a');
		as[current].className = 'current';
		for(var i=0,len = as.length; i<len; i++){
			(function(i){
				as[i].onclick = function(){
					as[current].className = '';
					if(i>current){
						slideUp(i);
					}else{
						slideDown(i);
					}
				}
			})(i);
		}
	}

	function slideUp(i){
		var sH = (i-current)*height;
		if(count < sH){
			count += Math.ceil((sH-count)/10)
			content.scrollTop = scoll + count;
			setTimeout(function(){slideUp(i)},15);
		}else{
			count = 0;
			scoll = content.scrollTop;
			current = i;
			as[i].className = 'current';
			return false;
		}
	}

	function slideDown(i){
		var sH = (current - i)*height;
		if(count < sH){
			count += Math.ceil((sH-count)/10)
			content.scrollTop = scoll - count;
			setTimeout(function(){slideDown(i)},15);
		}else{
			count = 0;
			scoll = content.scrollTop;
			current = i;
			as[i].className = 'current';
			return false;
		}
	}
}
//sky_addEvent(window,'load',slicePages);


function wOpen(){
	var link = 'http://www.facebook.com/sharer.php?u=';
    link += encodeURIComponent(location.href) + '&t=';
    link += encodeURIComponent(document.title);
	window.open(link);
}

function hideNode(){
	for(var i=0,len=arguments.length; i<len; i++){
		var node = document.getElementById(arguments[i]);
		if(!node) return false;
		if(node.innerHTML == '<!--TYPO3SEARCH_begin--><!--TYPO3SEARCH_end-->') node.className = 'hide';//node.style.display = 'none';
	}

}
sky_addEvent(window,'load',function(){hideNode('mainContentMid','mainContentBot')});



(function($){
	$(document).ready(function(){
		var height = $('#open img').height();
		$('#open img').prependTo($('#open').parent());
		$('a.left,a.right,#open').css('height',height)
		$('.ImageBox a.open').lightBox();
		$('div.tx-srfeuserextend-contact-list img, dl.myfn img, ul.friendboxSide img').each(function(){
			var height = $(this).height();
			$(this).css('marginTop',-(height/2)+ 'px');
		});
        $('.tx-srfeuserextend-collect-deleteAll a').click(function(){
            return confirm("Möchtest Du wirklich alle beobachteten Artikel löschen?");
        });
		

		$('div.divArea_inner_box').hover(function(){
			$(this).find('div.divAreaInfo').show();
		},function(){
			//var _this = $(this);
			//timer = setTimeout(function(){_this.find('div.divAreaInfo').hide();},1000);
			$(this).find('div.divAreaInfo').hide();
		});
		
		$('div.divAreaInfo').hover(function(){
			$(this).show();
		},function(){
			$(this).hide();
		});
	});
})(jQuery);



