var i = 70;
var lauf;

var ahover = new Image(); ahover.src = '/buero/etc/_hover.gif';
var drucker = new Image(); drucker.src = '/buero/etc/drucker_h.gif';
var ordner = new Image(); ordner.src = '/buero/etc/ordner_h.gif';
var ordner_l = new Image(); ordner_l.src = '/buero/etc/ordner_lh.gif';
var seite = new Image(); seite.src = '/buero/etc/seite_h.gif';
var seite_l = new Image(); seite_l.src = '/buero/etc/seite_lh.gif';

function scrollit( strf ) {
	s = strf;
	i--;
	if( i < -s ) i = 70;
	unten = 70 - i;
	oben = - i;
	document.getElementById("innen").style.top = i;
	lauf = setTimeout( "scrollit(s)", 60 );
}

function machBild( mbNr, mbWidth, mbHeight ) {
	var mbLeft = parseInt(( screen.availWidth - ( mbWidth / 2 )) / 5 );
	var mbTop = parseInt(( screen.availHeight - ( mbHeight / 2 )) / 5 );
	if( open( 'viewer.php?bild=' + mbNr, 'Bild' + mbNr, 'width=' + mbWidth + ',height=' + mbHeight + ',left=' + mbLeft + ',top=' + mbTop + ',resizable' )) return false;
	else return true;
}

function pic( pNr, pW, pH ) {
	var pL = parseInt(( screen.availWidth - pW ) / 2 );
	var pT = parseInt(( screen.availHeight - pH ) / 4 );
	if( open( 'pic.php?bild=' + pNr, 'Bild' + pNr, 'width=' + pW + ',height=' + pH + ',left=' + pL + ',top=' + pT + ',resizable' )) return false;
	return true;
}

function popup( pUrl, pName, pWidth, pHeight ) {
	var pLeft = parseInt(( screen.availWidth - ( pWidth / 2 )) / 5 );
	var pTop = parseInt(( screen.availHeight - ( pHeight / 2 )) / 5 );
	if( open( 'popup.php?url=' + pUrl, pName, 'width=' + pWidth + ',height=' + pHeight + ',left=' + pLeft + ',top=' + pTop + ',resizable' )) return false;
	else return true;
}

function gross( bNr, bWidth, bHeight ) {
	var bLeft = parseInt(( screen.availWidth - ( bWidth / 2 )) / 5 );
	var bTop = parseInt(( screen.availHeight - ( bHeight / 2 )) / 5 );
	if( open( 'projekte/bild.php?bild=' + bNr, 'Bild_' + bNr, 'width=' + bWidth + ',height=' + bHeight + ',left=' + bLeft + ',top=' + bTop + ',resizable' )) return false;
	else return true;
}

function machgross( url, breite, hoehe ) {
	vlinks = parseInt(( screen.availWidth - breite / 2 ) / 5 );
	voben  = parseInt(( screen.availHeight - hoehe / 2 ) / 5 );
	if( open( url, url, 'width=' + breite + ',height=' + hoehe + ',left=' + vlinks + ',top=' + voben + ',resizable' )) return false;
	else return true;
}

var stat = 0;

function bildwechsel() {
	if( stat ) {
		document.plan.src = "../images/anfahrt1.gif";
		document.plan.title = "Anfahrtsplan vergr&ouml;&szlig;ern";
		document.plan.alt = "Anfahrtsplan vergr&ouml;&szlig;ern";
		stat = 0;
	} else {
		document.plan.src = "../images/anfahrt2.gif";
		document.plan.title = "Anfahrtsplan verkleinern";
		document.plan.alt = "Anfahrtsplan verkleinern";
		stat = 1;
	} 
}

var text = "";

function setSmilie( nr ) {
	var insText = ':sm' + nr + ':';
	var input = document.forms['Eintrag'].elements['Text'];
	input.focus();

	if( typeof document.selection != 'undefined' ) {
		input.caretPos = document.selection.createRange();
		if( input.createTextRange && input.caretPos ) {
			var caretPos = input.caretPos;
			caretPos.text = insText;
		} else input.value  += insText;
	} else if( typeof input.selectionStart != 'undefined' ) {
		var pos = input.selectionStart;
		input.value = input.value.substring( 0, input.selectionStart ) + insText + input.value.substring( input.selectionEnd, input.value.length);
		input.selectionStart = pos + insText.length;
		input.selectionEnd = input.selectionStart;
	} else input.value  += text;
	input.focus();

	chkComment(300);
}

function chkComment( zeichen ) {
	var inhalt = document.Eintrag.Text.value
	var anzahl = inhalt.length;
	if( anzahl >= zeichen ) {
		document.Eintrag.Text.value = inhalt.substr( 0, zeichen );
		ausgabe = '(Limit erreicht!)';
	} else ausgabe = '(noch ' + ( zeichen - anzahl ) + ' Zeichen)';
	document.getElementById('Check').innerHTML = ausgabe;
}

function setComment( zeichen ) {
	document.getElementById('Check').innerHTML = '(max. ' + zeichen + ' Zeichen)';
}