var FH,FW;
var LH=380;
var NLH;


function viewPortSize() {
	var O;

	if(typeof(window.innerWidth) == 'number') {
		//Non-IE
		return({x:window.innerWidth, y:window.innerHeight});
	}
	else if((O=document.documentElement) && (O.clientWidth || O.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		return({x:O.clientWidth, y:O.clientHeight});
	}
	else if((O=document.body) && (O.clientWidth || O.clientHeight)) {
		//IE 4 compatible
		return({x:O.clientWidth, y:O.clientHeight});
	}
	return(null);
}

function getScrollXY() {
	var O;

	if(typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		return({x:window.pageXOffset, y:window.pageYOffset});
	}
	else if((O=document.body) && (O.scrollLeft || O.scrollTop)) {
		//DOM compliant
		return({x:O.scrollLeft, y:O.scrollTop});
	}
	else if((O=document.documentElement) && (O.scrollLeft || O.scrollTop)) {
		//IE6 standards compliant mode
		return({x:O.scrollLeft, y:O.scrollTop});
	}
	return(null);
}
function FindPos(obj) {
	var x=0,y=0;

	if(obj.offsetParent) {
		while(obj.offsetParent) {
			x += obj.offsetLeft
			y += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		x += obj.x;
		y += obj.y;
	}
	return { x:x, y:y };
} 
function scrollMenu(L) {
	if(L && L.oriPOS) {
		var NY,P=getScrollXY();
		NY=P.y-L.oriPOS.y;
		if(NY<1) NY=0;
		L.style.top=NY+'px';
	}
}
function PrepareLeft() {
	var L,P;

	L=document.getElementById('left');
	if(L) {
		P=FindPos(L);
		L.oriPOS=P;
		L.style.position='relative';
		L.style.top='0px';

		window.onscroll=(function() {
			return(function() {
				scrollMenu(L);
			});
		})();
	}
}

function menuonload() {
	var	S,C,O,E;
	
	PrepareLeft();
	S=location.href.split('/');
	if(S.length>4 && S[3]=='Fotoalbum')
		C="fotoalbum.shtml";
	else if (S[S.length-1]=='fotoalbum_a.shtml')
		C="fotoalbum.shtml";
	else if (S[S.length-1]=='')
		C="index.shtml";
	else
		C=S[S.length-1];

	for(var i=0;i<99;i++) {
		O=document.getElementById('menuid'+i);
		if(!O) break;
		S=O.href.split('/');
		E=S[S.length-1];
		if(E==C) {
			O.parentNode.className='mgoldbox';
		}
	}
}

function myonload() {
	thelogo('blogo');
	menuonload();
	if(typeof localonload == 'function')
		localonload();
}
function thelogo(n) {
	if(document.getElementById) {
		var O=document.getElementById(n);
		var S=viewPortSize();
		if(O && S) {
			if(S.x>1200 && S.y>800) NLH=LH;
			else if(S.x<1024 && S.y<700) NLH=Math.floor(LH/2);
			else NLH=Math.floor((LH/4)*3);
			O.style.height=NLH+'px';
			O.onclick=function() {
				this.style.height=(this.style.height=='20px') ? NLH+'px':'20px';
			}
		}
	}
}

function getElementsByClassName(tagname, findClass) {
	var ret=[];
	var rx = new RegExp("\\b" + findClass + "\\b");
	if(tagname) {
		var aElm=document.getElementsByTagName(tagname);
		for(var i=0; i<aElm.length; i++) {
			if(rx.test(aElm[i].className)) {
				ret.push(aElm[i]);
			}
		}
	}
	return(ret);
}

function datestrip(O) {
	if(O) {
		if(O.title) {
			var A=O.title.split(".");
			var N=new Date();
			var V=new Date(A[2],A[1]-1,A[0]);
			if((N.getTime()-V.getTime())>86400000)
				return(true);
		}
	}
	return(false);
}

function datewahl(O) {
	var N=new Date();
	var Std = N.getHours();
	var Txt;
	if(O) {
		for(var i=O.length-1;i>=0;i--) {
			var	I=O[i];
			if(I.date) {
				var A=I.date.split(".");
				var V=new Date(A[2],A[1]-1,A[0]);
				if(N.getTime()>=V.getTime()) {
					if(I.title!='') return(I.title);
					else break;
				}
			}
		}
	}
	if (Std >= 5 && Std < 11) {
		Txt="wünscht einen Guten Morgen!";
	}
	else if (Std >= 11 && Std < 13) {
		Txt=("sagt, Mahlzeit!");
	}
	else if (Std >= 13 && Std < 17) {
		Txt="wünscht einen Guten Tag!";
	}
	else if (Std >= 17 && Std < 23) {
		Txt="wünscht einen Guten Abend!";
	}
	else if (Std >= 23 || Std < 5) {
		Txt="sagt, Zeit, ins Bett zu gehen!";
	}
	else Txt='wünscht Ihnen eine gute Zeit';

	return("Das Scheckpony-Team "+Txt);
}

function SlideShow(SU)
{
	var Me=this;
	this.O = document.getElementById(SU.div);
	this.oO = document.getElementById(SU.odiv);
	this.siz = SU.siz;
	this.running = false;
	this.fpl = 0;
	this.TMR=null;
	this.dly=SU.dly||5000;
	this.I=null;
	this.PV=SU.PV;
	this.PVc=SU.PVc;
	this.sFN=[];
	this.iFN=SU.iFN;


	function reset() {
		if(Me.iFN) Me.iFN('Reset',Me);
		Me.O.style.width=Me.siz+'px';
		Me.O.style.height=Me.siz+'px';
	}

	function reinit(FN) {
		if(Me.iFN) Me.iFN('ReInit',Me);
		if(Me.running) Me.sFN.push(FN);
		else FN();
	}
	this.setsize=function(v) {
		if(typeof v!=='undefined') {
			var t=parseInt(v);
			if(t==-1) Me.stop();
			else reinit(function(){Me.siz=t;});
		}
		return(false);
	};
	this.delay=function(v) {
		if(typeof v!=='undefined') {
			var t=parseInt(v);
			if(t==-1) Me.stop();
			else reinit(function(){Me.dly=t;});
		}
		return(false);
	};
	this.start=function() {
		if(!Me.running) {
			if(Me.iFN) Me.iFN('Start',Me);
			reset();
			Me.running=true;
			if(Me.oO)
				Me.oO.style.visibility='visible';
			Me.next(true);
		}
		return(false);
	};
	this.Enext=function() {
		if(Me.running) {
			if(Me.sFN.length) {
				while(Me.sFN.length) {
					var FN=Me.sFN.shift();
					FN();
				}
				reset();
			}
			var Xn=new Date;
			var x=Me.I.width;
			var y=Me.I.height;
			var a=x/y;
			if(Me.siz) {
				if(y>x) {
					Me.I.height = Me.siz;
					Me.I.width = Math.floor(Me.siz*a);
					x=Math.floor((Me.siz-Me.siz*a)/2);
					y=0;
				}
				else {
					Me.I.width=Me.siz;
					Me.I.height = Math.floor(Me.siz/a);
					x=0;
					y=Math.floor((Me.siz-Me.siz/a)/2);
				}
			}
			Me.O.innerHTML='';
			Me.O.appendChild(Me.I);
			Me.O.firstChild.style.marginLeft=x+'px';
			Me.O.firstChild.style.marginTop=y+'px';
			if(Me.iFN) Me.iFN('Next',Me);
			Me.next(false);
		}
	};
	this.next=function(first) {
		if(!this.running)
			return;
		if(this.I) delete this.I;
		this.cupic=Math.floor(Math.random()*this.PVc);
		this.I=new Image();
		this.I.onload=(function() {
			var O=Me;
			return function() {
				if(first || O.dly==0) O.Enext();
				else {
					var Xd,Xn=(new Date).getTime();
					Xd=Math.max(0,O.dly-(Xn-O.fpl));
					O.TMR=window.setTimeout(O.Enext,Xd);
				}
			}
		})();
		this.fpl=(new Date).getTime();
		this.I.src=this.PV[this.cupic];
	};
	this.stop=function() {
		if(Me.running) {
			Me.running=false;
			if(Me.TMR)
				window.clearTimeout(Me.TMR);
			Me.TMR=null;
			Me.O.innerHTML='';
			if(Me.oO)
				Me.oO.style.visibility='hidden';
			if(Me.iFN) Me.iFN('Stop',Me);
		}
		return(false);
	};
}

