function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
			/* anchor.style.padding = "0px 14px 0px 0px";
			anchor.style.backgroundImage = "url('../inc/img/external.png')";
			anchor.style.backgroundRepeat = "no-repeat";
			anchor.style.backgroundPosition = "right -1px"; */
		}
	} 
}

window.onload = externalLinks;

sfHover = function() {
        var sfEls = document.getElementById("mainmenu").getElementsByTagName("LI");
        for (var i=0; i<sfEls.length; i++) {
                sfEls[i].onmouseover=function() {
                        this.className+=" sfhover";
                }
                sfEls[i].onmouseout=function() {
                        this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
                }
        }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function zxcAnimate(mde,obj,fin) {
	this.to=null;
	this.obj=typeof(obj)=='object'?obj:document.getElementById(obj);
	this.mde=mde.replace(/\W/g,'');
	this.data=[fin||0];
	return this;
}

zxcAnimate.prototype.update=function(srtfin,ms,scale,c) {
	clearTimeout(this.to);
	this.time=ms||this.time||0;
	this.data=[srtfin[0],srtfin[0],srtfin[1]];
	this.mS=this.time*(!scale?1:Math.abs((srtfin[1]-srtfin[0])/(scale[1]-scale[0])));
	this.c=typeof(c)=='string'?c.charAt(0).toLowerCase():this.c?this.c:'';
	this.inc=Math.PI/(2*this.mS);
	this.srttime=new Date().getTime();
	this.cng();
}

zxcAnimate.prototype.cng=function() {
	var oop=this,ms=new Date().getTime()-this.srttime;
	this.data[0]=(this.c=='s')?Math.floor((this.data[2]-this.data[1])*Math.sin(this.inc*ms)+this.data[1]):(this.c=='c')?(this.data[2])-Math.floor((this.data[2]-this.data[1])*Math.cos(this.inc*ms)):(this.data[2]-this.data[1])/this.mS*ms+this.data[1];
	this.apply();
	if (ms<this.mS) this.to=setTimeout(function(){oop.cng()},10);
	else {
		this.data[0]=this.data[2];
		this.apply();
		if (this.Complete) this.Complete(this);
	}
}

zxcAnimate.prototype.apply=function() {
	if (isFinite(this.data[0])) {
		if (this.mde!='left'&&this.mde!='top'&&this.data[0]<0) this.data[0]=0;
		if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
		else zxcOpacity(this.obj,this.data[0]);
	}
}

function zxcOpacity(obj,opc)
{
	if (opc<0||opc>100) return;
	obj.style.filter='alpha(opacity='+opc+')';
	obj.style.opacity=obj.style.MozOpacity=obj.style.KhtmlOpacity=opc/100-.001;
	if(opc == 0)
	{
		obj.style.top = '-500px';
		if(xPosition == 1)
			obj.style.marginLeft = 25 + 'px';
		else if(xPosition == 2)
			obj.style.marginLeft = 375 + 'px';
		else if(xPosition == 3)
			obj.style.marginLeft = 400 + 'px';
	}
	else
	{
		obj.style.top = tempY +'px';
		//obj.style.left = tempX +'px';
	}
	
	if(opc == 100)
	{
		obj.style.zIndex = 2;
	}
	else
	{
		obj.style.zIndex = -2;
	}
}

function Fade(id,opc,xPos) {
	var ms = 10;
	xPosition = xPos;
	var obj=document.getElementById(id);
	if (!obj.oop) {
		obj.oop=new zxcAnimate('opacity',obj,0);
		obj.oop.Complete=function() {
			if (obj.oop.data[0]==0) {
				obj.style.visibility='hidden';
			}
		}
	}
  
	if(obj.style.visibility == 'visible')
	{
	}
	else
	{
		var IE = document.all?true:false;
		if (IE)
		{
			// grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.y + document.body.scrollTop;
		}
		else
		{
			// grab the x-y pos.s if browser is NS
			tempX = e.pageX;
			tempY = e.pageY;
		}
		
		if (tempX < 0){tempX = 0;}
		if (tempY < 0){tempY = 0;}
	}
	
	obj.style.visibility='visible';
	obj.oop.update([obj.oop.data[0],opc||0],ms||100);
}

function showWindow(winkel_name)
{
	win = new Window( { className: 'spread', url: 'winkel.php?name='+winkel_name,
	title: 'Simple Window', width:400,
	height:300, destroyOnClose: true, recenterAuto:false } );
	win.showCenter();
}
