var aniDestX;
var aniDestY;
var aniObj = null;
var aniStepX;
var aniStepY;
var aniStepWidth;
var aniStepHeight;
var aniCount;
var endWidth;
var endHeight;
function getNumNoPx(num){
	if(num.indexOf("px") !=- 1)return num.substring(0, num.length - 2);
	return num;
}
function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}else if(obj.x){
		curleft += obj.x;
	}
	return curleft;
}
function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}else if(obj.y){
		curtop += obj.y;
	}
	return curtop;
}
function getWidth(obj){
	if (obj.innerWidth) {	// all except Explorer
		__windowWidth = obj.innerWidth;
	}else{ // other Explorers
		__windowWidth = obj.clientWidth;
	}	
	return __windowWidth;
}
function getHeight(obj){
	if (obj.innerHeight) {	// all except Explorer
		__windowHeight = obj.innerHeight;
	}else{ // other Explorers
		__windowHeight = obj.clientHeight;
	}	
	return __windowHeight;
}
function showAddSticky(){
	aniCount = 12;
	var startWidth = 0;
	var startHeight = 0;
	
	var po = document.getElementById('tpl_content_mitte');
	var so = document.getElementById("tpl_seitemerken_nummer");
	endWidth = getWidth(so);
	endHeight = getHeight(so);
	
	if(po != null && so != null){
		var px = findPosX(po);
		var py = findPosY(po);
		aniDestX = findPosX(so);
		aniDestY = findPosY(so);
		startWidth = getWidth(po);
		startHeight = getHeight(po)+30;
		if(aniObj == null){
			var wi = document.createElement("div");
			wi.className= "seitemerkenanimation";
			document.body.appendChild(wi);
			aniObj = wi;
		}else {
			aniObj.style.display = "block";
		}
		aniObj.style.width = startWidth+'px';
		aniObj.style.height = startHeight+'px';
		aniObj.style.left = px+'px';
		aniObj.style.top = py+'px';
		var centerX = px + startWidth / 2;
		var centerY = py + startHeight / 2;
		aniStepX = Math.round((aniDestX - centerX) / aniCount);
		aniStepY = Math.round((aniDestY - centerY) / aniCount);
		aniStepWidth = Math.round((startWidth - endWidth) / aniCount);
		aniStepHeight = Math.round((startHeight - endHeight) / aniCount);
		animateSticky();
	}
}
function animateSticky(){
	var x = 0;
	var y = 0;
	if(aniCount == 0){
		if(aniObj != null){
			aniObj.style.display = "none";
		}
		//blinkStickyLink(3);
		return;
	}else if(aniCount == 1){
		x = aniDestX;
		y = aniDestY;
		aniObj.style.width = endWidth+'px';
		aniObj.style.height = endHeight+'px';
	}else {
		var curWidth = getNumNoPx(aniObj.style.width);
		var curHeight = getNumNoPx(aniObj.style.height);
		var newWidth = curWidth - aniStepWidth;
		var newHeight = curHeight - aniStepHeight;
		var curX = findPosX(aniObj);
		var curY = findPosY(aniObj);
		var curCenterX = curX + curWidth / 2;
		var curCenterY = curY + curHeight / 2;
		var newCenterX = curCenterX + aniStepX;
		var newCenterY = curCenterY + aniStepY;
		aniObj.style.width = newWidth+'px';
		aniObj.style.height = newHeight+'px';
		x = newCenterX - newWidth / 2;
		y = newCenterY - newHeight / 2;
	}
	aniObj.style.left = x+'px';
	aniObj.style.top = y+'px';
	--aniCount;
	setTimeout("animateSticky()", 30);
}
function blinkStickyLink(num){
	obj = getEl("sticlink");
	if(obj != null){
		if(num % 2 == 0){
			obj.style.color = "#8F0100";
			if(num != 0){
				setTimeout("blinkStickyLink(" + (num - 1) + ")", 400);
			}
		}else {
			obj.style.color = "#ffffff";
			setTimeout("blinkStickyLink(" + (num - 1) + ")", 400);
		}
	}
}