var finito = true; // our fuse variable
var elementToToggle = '';

function beforeStartCallMe(obj) { // this gives you the div object obj.
  finito = false; // we started an Effect.
}
 
function afterFinishCallMe(obj) {
  finito = true; // the effect is finished
  if($(elementToToggle).style.display != 'none') {      
    if($(elementToToggle).visible() == false) { // and div not visible
      Effect.SlideDown(elementToToggle, {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe});
    }
  } else {
    if($(elementToToggle).visible()) { // if visible div but not checked checkbox
      Effect.SlideUp(elementToToggle, {beforeStart:beforeStartCallMe, afterFinish: afterFinishCallMe});
    }
  }
}
 
function toggleContent(el) {
  elementToToggle = el;
  if($(el).style.display == 'none') {           
    if(finito) {
      Effect.SlideDown(el, {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe});
    }
} else {
    if(finito) {
      Effect.SlideUp(el, {beforeStart: beforeStartCallMe, afterFinish: afterFinishCallMe});
    }
  }
}


function preview(file) {
	document.getElementById("foto").src = file;
}


function append_text(myField, myValue) {
	myValue = " :" + myValue + ": ";
	var comment = document.getElementById(myField);
	if (document.selection) {
		comment.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	} else if (myField.selectionStart || myField.selectionStart == "0") {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
	} else {
		var selLength = comment.textLength;
		var selStart = comment.selectionStart;
		var selEnd = comment.selectionEnd;
		if (selEnd == 1 || selEnd == 2) {
			selEnd = selLength;
		}
		var s1 = comment.value.substring(0, selStart);
		var s2 = comment.value.substring(selStart, selEnd);
		var s3 = comment.value.substring(selEnd, selLength);
		comment.value = s1 + myValue + s2 + s3;
		comment.selectionStart = selStart + myValue.length;
	}
}


function toggle_admin(div) {
	layer = document.getElementById(div);
	if (layer.style.display == "none") {
		layer.style.display = "";
	} else {
		layer.style.display = "none";
	}
}


function blockuser(userid) {
	r = prompt("Grund f\xFCr die Usersperre:");
	location.href = "index.html?x=profile&a=block&id=" + userid + "&reason=" + r;
}


function reportuser(userid) {
	r = prompt("Bitte nenne uns den Grund f\xFCr die Userbeschwerde:");
	location.href = "index.html?x=profile&a=report&id=" + userid + "&reason=" + r;
}


function textCounter(field, countfield, maxlimit) {
	entry = document.getElementById(field);
	counter = document.getElementById(countfield);
	if (entry.value.length + 1 > maxlimit) {
		entry.value = entry.value.substring(0, maxlimit);
	} else {
		counter.value = entry.value.length + 1 + " von " + maxlimit;
	}
}


function selectall(obj) {
	var checkBoxes = document.getElementsByTagName("input");
	for (i = 0; i < checkBoxes.length; i++) {
		if (obj.checked == true) {
			checkBoxes[i].checked = true;
		} else {
			checkBoxes[i].checked = false;
		}
	}
}


function mail_del_multiples(box) {
	var checkBoxes = document.getElementsByName("delmessage[]");
	var sDels = "";
	for (i = 0; i < checkBoxes.length; i++) {
		if (checkBoxes[i].checked == true) {
			if (sDels == "") {
				sDels = checkBoxes[i].value;
			} else {
				sDels = sDels + "," + checkBoxes[i].value;
			}
		}
	}
	if (sDels != "") {
		xajax_mail_del_multiples(sDels, box);
	}
}

function getPageScroll() {
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array("", yScroll);
	return arrayPageScroll;
}


function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement &&
		document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if (xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
	return arrayPageSize;
}


function pause(numberMillis) {
	var now = new Date;
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date;
		if (now.getTime() > exitTime) {
			return;
		}
	}
}


function getKey(e) {
	if (e == null) {
		keycode = event.keyCode;
	} else {
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	if (key == "x") {
		hideLightbox();
	}
}


function listenKey() {
	document.onkeypress = getKey;
}


function showLightbox(objLink) {
	var objOverlay = document.getElementById("overlay");
	var objLightbox = document.getElementById("lightbox");
	var objCaption = document.getElementById("lightboxCaption");
	var objImage = document.getElementById("lightboxImage");
	var objLoadingImage = document.getElementById("loadingImage");
	var objLightboxDetails = document.getElementById("lightboxDetails");
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	if (objLoadingImage) {
		objLoadingImage.style.top = arrayPageScroll[1] + (arrayPageSize[3] - 35 - objLoadingImage.height) / 2 + "px";
		objLoadingImage.style.left = (arrayPageSize[0] - 20 - objLoadingImage.width) / 2 + "px";
		objLoadingImage.style.display = "block";
	}
	objOverlay.style.height = arrayPageSize[1] + "px";
	objOverlay.style.display = "block";
	imgPreload = new Image;
	imgPreload.onload = function () {objImage.src = objLink.href;var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] - 35 - imgPreload.height) / 2;var lightboxLeft = (arrayPageSize[0] - 20 - imgPreload.width) / 2;objLightbox.style.top = lightboxTop < 0 ? "0px" : lightboxTop + "px";objLightbox.style.left = lightboxLeft < 0 ? "0px" : lightboxLeft + "px";objLightboxDetails.style.width = imgPreload.width + "px";if (objLink.getAttribute("title")) {objCaption.style.display = "block";objCaption.innerHTML = objLink.getAttribute("title");} else {objCaption.style.display = "none";}if (navigator.appVersion.indexOf("MSIE") != -1) {pause(250);}if (objLoadingImage) {objLoadingImage.style.display = "none";}selects = document.getElementsByTagName("select");for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}objLightbox.style.display = "block";arrayPageSize = getPageSize();objOverlay.style.height = arrayPageSize[1] + "px";listenKey();return false;};
	imgPreload.src = objLink.href;
}


function showLightbox_from_ajax(url, title) {
	var objOverlay = document.getElementById("overlay");
	var objLightbox = document.getElementById("lightbox");
	var objCaption = document.getElementById("lightboxCaption");
	var objImage = document.getElementById("lightboxImage");
	var objLoadingImage = document.getElementById("loadingImage");
	var objLightboxDetails = document.getElementById("lightboxDetails");
	var objProfileBox = document.getElementById("profile_left_box");
	if (objProfileBox) {
		objProfileBox.style.overflow = "hidden";
	}
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	if (objLoadingImage) {
		objLoadingImage.style.top = arrayPageScroll[1] + (arrayPageSize[3] - 35 - objLoadingImage.height) / 2 + "px";
		objLoadingImage.style.left = (arrayPageSize[0] - 20 - objLoadingImage.width) / 2 + "px";
		objLoadingImage.style.display = "block";
	}
	objOverlay.style.height = arrayPageSize[1] + "px";
	objOverlay.style.display = "block";
	imgPreload = new Image;
	imgPreload.onload = function () {objImage.src = url;var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] - 35 - imgPreload.height) / 2;var lightboxLeft = (arrayPageSize[0] - 20 - imgPreload.width) / 2;objLightbox.style.top = lightboxTop < 0 ? "0px" : lightboxTop + "px";objLightbox.style.left = lightboxLeft < 0 ? "0px" : lightboxLeft + "px";objLightboxDetails.style.width = imgPreload.width + "px";if (title != "") {objCaption.style.display = "block";objCaption.innerHTML = title;} else {objCaption.style.display = "none";}if (navigator.appVersion.indexOf("MSIE") != -1) {pause(250);}if (objLoadingImage) {objLoadingImage.style.display = "none";}selects = document.getElementsByTagName("select");for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}objLightbox.style.display = "block";arrayPageSize = getPageSize();objOverlay.style.height = arrayPageSize[1] + "px";listenKey();return false;};
	imgPreload.src = url;
}


function hideLightbox() {
	objOverlay = document.getElementById("overlay");
	objLightbox = document.getElementById("lightbox");
	objOverlay.style.display = "none";
	objLightbox.style.display = "none";
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
	var objProfileBox = document.getElementById("profile_left_box");
	if (objProfileBox) {
		objProfileBox.style.overflow = "auto";
	}
	document.onkeypress = "";
}


function initLightbox() {
	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") == "lightbox") {
			anchor.onclick = function () {showLightbox(this);return false;};
		}
	}
	var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute("id", "overlay");
	objOverlay.onclick = function () {hideLightbox();return false;};
	objOverlay.style.display = "none";
	objOverlay.style.position = "absolute";
	objOverlay.style.top = "0";
	objOverlay.style.left = "0";
	objOverlay.style.zIndex = "90";
	objOverlay.style.width = "100%";
	objBody.insertBefore(objOverlay, objBody.firstChild);
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var imgPreloader = new Image;
	imgPreloader.onload = function () {var objLoadingImageLink = document.createElement("a");objLoadingImageLink.setAttribute("href", "#");objLoadingImageLink.onclick = function () {hideLightbox();return false;};objOverlay.appendChild(objLoadingImageLink);var objLoadingImage = document.createElement("img");objLoadingImage.src = loadingImage;objLoadingImage.setAttribute("id", "loadingImage");objLoadingImage.style.position = "absolute";objLoadingImage.style.zIndex = "150";objLoadingImageLink.appendChild(objLoadingImage);imgPreloader.onload = function () {};return false;};
	imgPreloader.src = loadingImage;
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute("id", "lightbox");
	objLightbox.style.display = "none";
	objLightbox.style.position = "absolute";
	objLightbox.style.zIndex = "100";
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	var objLink = document.createElement("a");
	objLink.setAttribute("href", "#");
	objLink.setAttribute("title", "schliessen");
	objLink.onclick = function () {hideLightbox();return false;};
	objLightbox.appendChild(objLink);
	var imgPreloadCloseButton = new Image();
	var objCloseButton = document.createElement("img");
	objCloseButton.src = closeButton;
	objCloseButton.setAttribute('id','closeButton');
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.zIndex = '200';
	objLink.appendChild(objCloseButton);
	imgPreloadCloseButton.src = closeButton;
	var objImage = document.createElement("img");
	objImage.setAttribute("id", "lightboxImage");
	objLink.appendChild(objImage);
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute("id", "lightboxDetails");
	objLightbox.appendChild(objLightboxDetails);
	var objCaption = document.createElement("div");
	objCaption.setAttribute("id", "lightboxCaption");
	objCaption.style.display = "none";
	objLightboxDetails.appendChild(objCaption);
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {oldonload();func();};
	}
}


function form_mail_reply_save_data() {
	xajax.$("submitButton").value = "bitte warten ...";
	xajax_mail_reply_save_data(xajax.getFormValues("replyForm"));
	return false;
}


function form_mail_new_save_data() {
	xajax.$("submitButton").value = "bitte warten ...";
	xajax_mail_new_save_data(xajax.getFormValues("replyForm"));
	return false;
}


function form_guestbook_add_save() {
	if (document.getElementById("gbook_gbentry").value == "") {
		alert("Du musst schon einen Text eingeben ;-)");
		document.getElementById("gbook_gbentry").focus();
		textCounter("gbook_gbentry", "count", 500);
		return false;
	}
	xajax.$("gbook_add_form_submit").value = "bitte warten ...";
	xajax_profile_guestbook_add(xajax.getFormValues("gbook_add_form"));
	return false;
}


function form_blog_add_save() {
	if (document.getElementById("blog_title").value == "") {
		alert("Du musst schon einen Titel eingeben ;-)");
		document.getElementById("blog_title").focus();
		return false;
	}
	if (document.getElementById("blog_fulltext").value == "") {
		alert("Du musst schon einen Text eingeben ;-)");
		document.getElementById("blog_fulltext").focus();
		return false;
	}
	xajax.$("blog_add_form_submit").value = "bitte warten ...";
	xajax_profile_blog_add(xajax.getFormValues("blog_add_form"));
	return false;
}


function profile_mail_new(id) {
	action(id);
}

var pre_selected;
function select_new_tab(targetobj, sLoadingId) {
	if (!targetobj.id) {
		targetobj = document.getElementById(targetobj);
	}else {
		if (sLoadingId != " ") {
			document.getElementById(sLoadingId).innerHTML = loadstatustext;
		}
	}
	var ullist = targetobj.parentNode.parentNode.getElementsByTagName("li");
	for (var i = 0; i < ullist.length; i++) {
		ullist[i].className = "";
	}
	document.getElementById(pre_selected).className = "";
	targetobj.parentNode.className = "selected";
	targetobj.className = "selected";
	pre_selected = targetobj.id;
}




function v3_ob() {
	document.getElementById("v3_o").style.textAlign = "center";
	document.getElementById("v3_o").style.width = "132px";
	document.getElementById("v3_o").style.paddingTop = "35px";
	document.getElementById("v3_o").innerHTML = loadstatustext;
	document.getElementById("v3_om_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_m.png)";
	document.getElementById("v3_ow_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_w.png)";
	wis_m = uri_images + "left_wio_on_m.png";
	wis_w = uri_images + "left_wio_on_w.png";
	wis_b = uri_images + "left_wio_on_b_.png";
	xajax_v3_ob();
}


function v3_ow() {
	document.getElementById("v3_o").style.textAlign = "center";
	document.getElementById("v3_o").style.width = "132px";
	document.getElementById("v3_o").style.paddingTop = "35px";
	document.getElementById("v3_o").innerHTML = loadstatustext;
	if (document.getElementById("v3_om_off")) {
		document.getElementById("v3_om_off").style.backgroundImage = "url(" + uri_images + "left_wio_off_m.png)";
		wis_m = uri_images + "left_wio_off_m.png";
	}
	if (document.getElementById("v3_om_on")) {
		document.getElementById("v3_om_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_m.png)";
		wis_m = uri_images + "left_wio_on_m.png";
	}
	if (document.getElementById("v3_ob_on")) {
		document.getElementById("v3_ob_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_b.png)";
	}
	wis_w = uri_images + "left_wio_" + onoff + "_w_.png";
	xajax_v3_ow();
}


function v3_om() {
	document.getElementById("v3_o").style.textAlign = "center";
	document.getElementById("v3_o").style.width = "132px";
	document.getElementById("v3_o").style.paddingTop = "35px";
	document.getElementById("v3_o").innerHTML = loadstatustext;
	if (document.getElementById("v3_ow_off")) {
		document.getElementById("v3_ow_off").style.backgroundImage = "url(" + uri_images + "left_wio_off_w.png)";
		wis_w = uri_images + "left_wio_off_w.png";
	}
	if (document.getElementById("v3_ow_on")) {
		document.getElementById("v3_ow_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_w.png)";
		wis_w = uri_images + "left_wio_on_w.png";
	}
	if (document.getElementById("v3_ob_on")) {
		document.getElementById("v3_ob_on").style.backgroundImage = "url(" + uri_images + "left_wio_on_b.png)";
	}
	wis_m = uri_images + "left_wio_" + onoff + "_m_.png";
	xajax_v3_om();
}


function hover_wis(bIn, sElement) {
	if (sElement == "v3_om_off") {
		if (bIn == 1) {
			document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_off_m_.png)";
		}
		if (bIn == 0) {
			if (wis_m == uri_images + "left_wio_off_m.png") {
				document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_off_m.png)";
			}
		}
	}
	if (sElement == "v3_ow_off") {
		if (bIn == 1) {
			document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_off_w_.png)";
		}
		if (bIn == 0) {
			if (wis_w == uri_images + "left_wio_off_w.png") {
				document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_off_w.png)";
			}
		}
	}
	if (sElement == "v3_om_on") {
		if (bIn == 1) {
			document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_m_.png)";
		}
		if (bIn == 0) {
			if (wis_m == uri_images + "left_wio_on_m.png") {
				document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_m.png)";
			}
		}
	}
	if (sElement == "v3_ow_on") {
		if (bIn == 1) {
			document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_w_.png)";
		}
		if (bIn == 0) {
			if (wis_w == uri_images + "left_wio_on_w.png") {
				document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_w.png)";
			}
		}
	}
	if (sElement == "v3_ob_on") {
		if (bIn == 1) {
			document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_b_.png)";
		}
		if (bIn == 0) {
			if (wis_b == uri_images + "left_wio_on_b.png") {
				document.getElementById(sElement).style.backgroundImage = "url(" + uri_images + "left_wio_on_b.png)";
			}
		}
	}
}


function initScrollFunction_userlist_onw() {
	if (Element.getHeight("scrollcontent_onw") > Element.getHeight("scrollbox_onw")) {
		Element.show("track_onw");
		var currentScrollPosition_onw = 0;
		var mySlider_onw = new Control.Slider("handle_onw", "track_onw", {axis:"vertical", onSlide:function (value) {updateScrollBox_onw(value);}, onChange:function (value) {updateScrollBox_onw(value);}});
		scrollcontentheight_onw = Element.getHeight("scrollcontent_onw") - Element.getHeight("scrollbox_onw");
		scrollstep_onw = scrollcontentheight_onw / 100;

		function updateScrollBox_onw(value) {
			tmpvalue_onw = value;
			value = (value * 100).toFixed(0);
			$("scrollcontent_onw").style.top = Math.floor(0 - scrollstep_onw * value) + "px";
			currentScrollPosition_onw = tmpvalue_onw;
		}

	}
}


function initScrollFunction_userlist_onm() {
	if (Element.getHeight("scrollcontent_onw") > Element.getHeight("scrollbox_onw")) {
		Element.show("track_onw");
		var currentScrollPosition_onw = 0;
		var mySlider_onw = new Control.Slider("handle_onw", "track_onw", {axis:"vertical", onSlide:function (value) {updateScrollBox_onw(value);}, onChange:function (value) {updateScrollBox_onw(value);}});
		scrollcontentheight_onw = Element.getHeight("scrollcontent_onw") - Element.getHeight("scrollbox_onw");
		scrollstep_onw = scrollcontentheight_onw / 100;
	}
}

if (self.innerWidth) {
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientWidth) {
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
} else if (document.body) {
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
}
var Carousel = Class.create();
Carousel.prototype = {initialize:function (carouselElemID) {this.carouselElemID = carouselElemID;this.options = Object.extend({numVisible:4, scrollInc:3, animParameters:{}, buttonStateHandler:null, animHandler:null, ajaxHandler:null, initDoneHandler:null, queue:"carousel", size:0, prevElementID:"prev-arrow", nextElementID:"next-arrow", ajaxParameters:null, url:null}, arguments[1] || {});this.initDone = false;this.animRunning = "none";this.requestIsRunning = false;this.animAfterFinish = this.options.animParameters.afterFinish;Object.extend(this.options.animParameters, {afterFinish:this._animDone.bind(this), queue:{position:"end", scope:this.options.queue}});this.prevScroll = this._prevScroll.bindAsEventListener(this);this.nextScroll = this._nextScroll.bindAsEventListener(this);this.onComplete = this._onComplete.bindAsEventListener(this);this.onFailure = this._onFailure.bindAsEventListener(this);Event.observe(this.options.prevElementID, "click", this.prevScroll);Event.observe(this.options.nextElementID, "click", this.nextScroll);var carouselListClass = "carousel-list";this.carouselList = document.getElementsByClassName(carouselListClass, $(carouselElemID))[0];this.options.size = $(this.carouselList.getElementsByTagName("li")).length;this._init();}, destroy:function () {Event.stopObserving(this.options.prevElementID, "click", this.prevScroll);Event.stopObserving(this.options.nextElementID, "click", this.nextScroll);}, scrollTo:function (newStart) {var old_inc = this.options.scrollInc;this.ignoreNoMoreImages = true;if (newStart > this.currentIndex) {this.options.scrollInc = newStart - this.currentIndex;this._nextScroll(this);} else {this.options.scrollInc = this.currentIndex - newStart;this._prevScroll(this);}this.options.scrollInc = old_inc;}, _init:function () {this.currentIndex = 0;if (this.options.url) {this._request(this.currentIndex, this.options.numVisible);} else {this._getLiElementSize();this._updateButtonStateHandler(this.options.prevElementID, false);this._updateButtonStateHandler(this.options.nextElementID, this.options.size > this.options.numVisible);}}, _prevScroll:function (event) {if (this.animRunning != "none" || this.currentIndex == 0) {return;}var inc = this.options.scrollInc;if (this.currentIndex - inc < 0) {inc = this.currentIndex;}this._scroll(inc);return false;}, _nextScroll:function (event) {if (this.animRunning != "none") {return false;}if (this.currentIndex + this.options.numVisible + this.options.scrollInc <= this.options.size) {this._scroll(- this.options.scrollInc);} else {this.nbInCache = this.options.size - (this.currentIndex + this.options.numVisible);if (this.options.url && this.noMoreImages == false) {this._request(this.currentIndex + this.options.numVisible + this.nbInCache, this.options.scrollInc - this.nbInCache);} else {if (this.nbInCache > 0) {this._scroll(- this.nbInCache);}}}return false;}, _request:function (start, nb) {if (this.options.url && !this.requestIsRunning) {this.requestIsRunning = true;if (this.options.ajaxHandler) {this.options.ajaxHandler(this, "before");}var params = "start=" + start + "&nb=" + nb;if (this.options.ajaxParameters != null) {params += "&" + this.options.ajaxParameters;}new Ajax.Request(this.options.url, {parameters:params, onComplete:this.onComplete, onFailure:this.onFailure});}}, _onComplete:function (originalRequest) {this.requestIsRunning = false;this.carouselList.innerHTML += originalRequest.responseText;var size = this.options.size;this.options.size = this.carouselList.getElementsByTagName("li").length;var inc = this.options.size - size;if (this.initDone == false) {this._getLiElementSize();this.currentIndex = 0;this.initDone = true;if (this.options.initDoneHandler) {this.options.initDoneHandler(this);}this._updateButtonStateHandler(this.options.prevElementID, false);this._updateButtonStateHandler(this.options.nextElementID, this.options.size == this.options.numVisible);this.noMoreImages = this.options.size < this.options.numVisible;} else {if (!this.ignoreNoMoreImages) {this.noMoreImages = inc != this.options.scrollInc;} else {this.ignoreNoMoreImages = false;}if (inc > 0) {this._scroll(- inc, this.noMoreImages);} else {if (this.nbInCache > 0) {this._scroll(- this.nbInCache, true);}this._updateButtonStateHandler(this.options.nextElementID, false);}}if (this.options.ajaxHandler) {this.options.ajaxHandler(this, "after");}}, _onFailure:function (originalRequest) {this.requestIsRunning = false;}, _animDone:function (event) {if (this.options.animHandler) {this.options.animHandler(this.carouselElemID, "after", this.animRunning);}this.animRunning = "none";if (this.animAfterFinish) {this.animAfterFinish(event);}}, _updateButtonStateHandler:function (button, state) {if (this.options.buttonStateHandler) {this.options.buttonStateHandler(button, state);}}, _scroll:function (delta, forceDisableNext) {this.animRunning = delta > 0 ? "prev" : "next";if (this.options.animHandler) {this.options.animHandler(this.carouselElemID, "before", this.animRunning);}new Effect.MoveBy(this.carouselList, 0, delta * this.elementSize, this.options.animParameters);this.currentIndex -= delta;this._updateButtonStateHandler(this.options.prevElementID, this.currentIndex != 0);if (this.options.url && this.noMoreImages == false) {enable = true;} else {enable = this.currentIndex + this.options.numVisible < this.options.size;}this._updateButtonStateHandler(this.options.nextElementID, forceDisableNext ? false : enable);}, _getLiElementSize:function () {var li = $(this.carouselList.getElementsByTagName("li")[0]);this.elementSize = li.getDimensions().width + parseFloat(li.getStyle("margin-left")) + parseFloat(li.getStyle("margin-right"));}};

function animHandler(carouselID, status, direction) {
	var region = $(carouselID).down(".carousel-clip-region");
	if (status == "before") {
		Effect.Fade(region, {to:0.3, queue:{position:"end", scope:"carousel"}, duration:0.2});
	}
	if (status == "after") {
		Effect.Fade(region, {to:1, queue:{position:"end", scope:"carousel"}, duration:0.2});
	}
}


function initCarouselBday() {
	carousel = new Carousel("small-carousel", {animParameters:{duration:0.4}, buttonStateHandler:buttonStateHandler, nextElementID:"next-arrow-small", prevElementID:"prev-arrow-small", wrap:true, scrollInc:5, numVisible:5});
	document.getElementById("small-carousel").style.width = frameWidth - 450 + "px";
}


function initCarouselNeue() {
//	carousel = new Carousel("small-carousel", {animParameters:{duration:0.4}, buttonStateHandler:buttonStateHandler, nextElementID:"next-arrow-neue", prevElementID:"prev-arrow-neue", numVisible:3, orientation:"vertical"});
	carousel = new Carousel("neue-carousel", {animParameters:{duration:0.4}, buttonStateHandler:buttonStateHandler, nextElementID:"next-arrow-neue", prevElementID:"prev-arrow-neue", wrap:true, scrollInc:5, numVisible:5});
	document.getElementById("neue-carousel").style.width = frameWidth - 450 + "px";
}


// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);



// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[ul]','[/ul]','[ol]','[/ol]','[img size=150]','[/img]','[url]','[/url]','[li]','[/li]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
   document.forum_reply.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
   for (i = 0; i < thearray.length; i++) {
      if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
         return i;
      }
   return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
   thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
   thearraysize = getarraysize(thearray);
   retval = thearray[thearraysize - 1];
   delete thearray[thearraysize - 1];
   return retval;
}


function bbstyle(bbnumber) {

   var txtarea = document.forum_reply.forum_messages_text_message;

   txtarea.focus();
   donotinsert = false;
   theSelection = false;
   bblast = 0;

   if (bbnumber == -1) { // Close all open tags & default button names
      while (bbcode[0]) {
         butnumber = arraypop(bbcode) - 1;
         txtarea.value += bbtags[butnumber + 1];
         buttext = eval('document.forum_reply.addbbcode' + butnumber + '.value');
         eval('document.forum_reply.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
      }
      imageTag = false; // All tags are closed including image tags :D
      txtarea.focus();
      return;
   }

   if ((clientVer >= 4) && is_ie && is_win)
   {
      theSelection = document.selection.createRange().text; // Get text selection
      if (theSelection) {
         // Add tags around selection
         document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
         txtarea.focus();
         theSelection = '';
         return;
      }
   }
   else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
   {
      mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
      return;
   }

   // Find last occurance of an open tag the same as the one just clicked
   for (i = 0; i < bbcode.length; i++) {
      if (bbcode[i] == bbnumber+1) {
         bblast = i;
         donotinsert = true;
      }
   }

   if (donotinsert) {      // Close all open tags up to the one just clicked & default button names
      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];
            buttext = eval('document.forum_reply.addbbcode' + butnumber + '.value');
            eval('document.forum_reply.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
            imageTag = false;
         }
         txtarea.focus();
         return;
   } else { // Open tags

      if (imageTag && (bbnumber != 14)) {    // Close image tag before adding another
         txtarea.value += bbtags[15];
         lastValue = arraypop(bbcode) - 1;   // Remove the close image tag from the list
         document.forum_reply.addbbcode14.value = "Img";  // Return button back to normal state
         imageTag = false;
      }

      // Open tag
      txtarea.value += bbtags[bbnumber];
      if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
      arraypush(bbcode,bbnumber+1);
      eval('document.forum_reply.addbbcode'+bbnumber+'.value += "*"');
      txtarea.focus();
      return;
   }
   storeCaret(txtarea);
}

function mozWrap(txtarea, open, close)
{
   var selLength = txtarea.textLength;
   var selStart = txtarea.selectionStart;
   var selEnd = txtarea.selectionEnd;
   if (selEnd == 1 || selEnd == 2)
      selEnd = selLength;

   var s1 = (txtarea.value).substring(0,selStart);
   var s2 = (txtarea.value).substring(selStart, selEnd)
   var s3 = (txtarea.value).substring(selEnd, selLength);
   txtarea.value = s1 + open + s2 + close + s3;
   return;
}

function storeCaret(textEl) {
   if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}


function bbfontstyle(bbopen, bbclose) {
   var txtarea = document.forum_reply.forum_messages_text_message;

   if ((clientVer >= 4) && is_ie && is_win) {
      theSelection = document.selection.createRange().text;
      if (!theSelection) {
         txtarea.value += bbopen + bbclose;
         txtarea.focus();
         return;
      }
      document.selection.createRange().text = bbopen + theSelection + bbclose;
      txtarea.focus();
      return;
   }
   else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
   {
      mozWrap(txtarea, bbopen, bbclose);
      return;
   }
   else
   {
      txtarea.value += bbopen + bbclose;
      txtarea.focus();
   }
   storeCaret(txtarea);
}

function textCounter(field, countfield, maxlimit) {
	entry = document.getElementById(field);
	counter = document.getElementById(countfield);
	if (entry.value.length + 1 > maxlimit) {
		entry.value = entry.value.substring(0, maxlimit);
	} else {
		counter.value = entry.value.length + 1 + " von " + maxlimit;
	}
}


function emo($e)
{
 document.forum_reply.forum_messages_text_message.value=document.forum_reply.forum_messages_text_message.value+$e;
 document.forum_reply.forum_messages_text_message.focus();
}
function submitForm() {

 submitme=1;

 formname=document.forum_reply.sb_authorname.value;
 if ((formname.length<1)) {
    alert("You forgot to enter your name");
    submitme=0;
 }

 formmail=document.forum_reply.email.value;
 if ((formmail.length<1)) {
    alert("You forgot to enter your email");
    submitme=0;
  }
  formsubject=document.forum_reply.subject.value;
  if ((formsubject.length<1)) {
    alert("You forgot to enter a subject");
    submitme=0;
  }

  if (submitme>0) {
  //change the following line to true to submit form
    return true;

  }else{
    return false;
  }
}

function cancelForm() {
   document.forms['forum_reply'].action.value = "cancel";
   return true;
}

//**********************************************
// Helpline messages
b_help = "fetter Text: [b]Text[/b] ";
i_help = "kursiver Text: [i]Text[/i]";
u_help = "unterstrichener Text: [u]Text[/u]";
q_help = "angegebener Text: [quote]Text[/quote]";
c_help = "Code Anzeige: [code]Code[/code]";
k_help = "Ungeordnete Liste: [ul] [li]Text[/li] [/ul] - Hinweis: Eine Liste muß Listenbegriffe beinhalten";
o_help = "Geordnete List: [ol] [li]Text[/li] [/ol] - Hinweis: Eine Liste muß Listenbegriffe beinhalten";
w_help = "Link: [url=http://www.zzz.com/]Das ist ein Link[/url]";
a_help = "Schliesse alle offenen bbCode tags";
s_help = "Farbe: [color=#FF6600]text[/color]";
f_help = "Größe: [size=1]text size[/size] - Hinweis: Ränge von 1 bis 5";
l_help = "Listen Begriff: [li] Listen Begriff [/li]";
submit_help = "Klicke hier, um Deinen Beitrag anzusehen";
cancel_help = "Klicke hier, um die Nachricht abzubrechen";

//**************************************************
// Open the preview window (with some post parsing)
function Preview(stylesheet, sbs, template, disemoticons) {
//changed to fix the preview problem in IE with mod_login
//message=document.getElementById('message');
var message = document.forum_reply.forum_messages_text_message;

//these gotta be in both... I don't knwo why, but it works...
messageString = message.innertext;
messageString = message.value;

messageString = messageString.replace(/<(.*?)>/g,"&lt;$1&gt;");
messageString = messageString.replace(/</g,"&lt;");
messageString = messageString.replace(/\n/g,"<br>");
messageString = messageString.replace(/\[b\]/g,"<b>");
messageString = messageString.replace(/\[\/b\]/g,"</b>");
messageString = messageString.replace(/\[i\]/g,"<i>");
messageString = messageString.replace(/\[\/i\]/g,"</i>");
messageString = messageString.replace(/\[u\]/g,"<u>");
messageString = messageString.replace(/\[\/u\]/g,"</u>");
messageString = messageString.replace(/\[quote\]/g,'<div class="sb_review_quote">');
messageString = messageString.replace(/\[\/quote\]/g,'</div>');
messageString = messageString.replace(/\[code\]/g,'<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr><td><b>Code:</b></span></td></tr><tr><td class="sb_code"><pre>');
messageString = messageString.replace(/\[\/code\]/g,'</pre></tr></table>');
messageString = messageString.replace(/\[code:1\]/g,'<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr><td><b>Code:</b></span></td></tr><tr><td class="sb_code"><pre>');
messageString = messageString.replace(/\[\/code:1\]/g,'</pre></tr></table>');
messageString = messageString.replace(/\[ul\]/g,"<ul>");
messageString = messageString.replace(/\[\/ul\]/g,"</ul>");
messageString = messageString.replace(/\[ol\]/g,"<ol>");
messageString = messageString.replace(/\[\/ol\]/g,"</ol>");
messageString = messageString.replace(/\[li\]/g,"<li>");
messageString = messageString.replace(/\[\/li\]/g,"</li>");

if (disemoticons == 0) {
messageString = messageString.replace(/B\)/g,'<img src="'+sbs+'/emoticons/cool.png">');
messageString = messageString.replace(/;\)/g,'<img src="'+sbs+'/emoticons/wink.png">');
messageString = messageString.replace(/:\)/g,'<img src="'+sbs+'/emoticons/smile.png">');
messageString = messageString.replace(/:laugh:/g,'<img src="'+sbs+'/emoticons/laughing.png">');
messageString = messageString.replace(/:ohmy:/g,'<img src="'+sbs+'/emoticons/shocked.png">');
messageString = messageString.replace(/:sick:/g,'<img src="'+sbs+'/emoticons/sick.png">');
messageString = messageString.replace(/:angry:/g,'<img src="'+sbs+'/emoticons/angry.png">');
messageString = messageString.replace(/:blink:/g,'<img src="'+sbs+'/emoticons/blink.png">');
messageString = messageString.replace(/:P/g,'<img src="'+sbs+'/emoticons/tongue.png">');
messageString = messageString.replace(/:\(/g,'<img src="'+sbs+'/emoticons/sad.png">');
messageString = messageString.replace(/:unsure:/g,'<img src="'+sbs+'/emoticons/unsure.png">');
messageString = messageString.replace(/:lol:/g,'<img src="'+sbs+'/emoticons/grin.png">');
messageString = messageString.replace(/:huh:/g,'<img src="'+sbs+'/emoticons/wassat.png">');
messageString = messageString.replace(/:kiss:/g,'<img src="'+sbs+'/emoticons/kissing.png">');
messageString = messageString.replace(/:sick:/g,'<img src="'+sbs+'/emoticons/sick.png">');
messageString = messageString.replace(/:evil:/g,'<img src="'+sbs+'/emoticons/devil.png">');
messageString = messageString.replace(/:whistle:/g,'<img src="'+sbs+'/emoticons/whistling.png">');
messageString = messageString.replace(/:blush:/g,'<img src="'+sbs+'/emoticons/blush.png">');
messageString = messageString.replace(/:woohoo:/g,'<img src="'+sbs+'/emoticons/w00t.png">');
messageString = messageString.replace(/:silly:/g,'<img src="'+sbs+'/emoticons/silly.png">');
messageString = messageString.replace(/:S/g,'<img src="'+sbs+'/emoticons/dizzy.png">');
messageString = messageString.replace(/:side:/g,'<img src="'+sbs+'/emoticons/sideways.png">');
messageString = messageString.replace(/:cheer:/g,'<img src="'+sbs+'/emoticons/cheerful.png">');
messageString = messageString.replace(/:ermm:/g,'<img src="'+sbs+'/emoticons/ermm.png">');
messageString = messageString.replace(/:pinch:/g,'<img src="'+sbs+'/emoticons/pinch.png">');
}

messageString = messageString.replace(/\[img size=([1-4][0-9][0-9])\](.*?)\[\/img\]/g,"<img src=\"$2\" border\"0\" width=\"$1\">");
messageString = messageString.replace(/\[img\](.*?)\[\/img\]/g,"<img src=\"$1\" border\"0\">");
messageString = messageString.replace(/(\[url\])(.*?)(\[\/url\])/g,"<a href=$2 target=\"_blank\">$2</a>");
messageString = messageString.replace(/\[url=(.*?)\](.*?)\[\/url\]/g,"<a href=\"$1\" target=\"_blank\">$2</a>");
messageString = messageString.replace(/\[size=([1-7])\](.+?)\[\/size\]/g,"<font size=\"$1\">$2</font>");
messageString = messageString.replace(/\[color=(.*?)\](.*?)\[\/color\]/g,"<span style=\"color: $1\">$2</span>");
messageString = messageString.replace(/\[file name=(.*?) size=(.*?)\](.*?)\[\/file\]/g,"<div class=\"sb_file_attachment\"><span class=\"contentheading\">File Attachment:</span><br>File name: <a href=\"$3\">$1</a><br>File size:$2 bytes</div>");

//and finally open the window for displaying the lot
win = window.open('','Preview','width=640, height=480, toolbar = no, status = no, resizable, scrollbars');
win.document.write("<link media=\"all\" type=\"text/css\" href=\""+ stylesheet + "\" rel=\"stylesheet\">");
win.document.write("<link media=\"all\" type=\"text/css\" href=\""+ sbs + "/template/" + template + "/forum.css\" rel=\"stylesheet\">");
win.document.write("<div class=\"sectiontableentry1\" style=\"margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;\">");
win.document.write('' + messageString + '');
win.document.write("</div><div style=\"text-align: center; \">");
win.document.write("<a href=\"javascript:window.close()\"> Schliesse das Fenster </a> ");
win.document.write("</div>");
}


/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll) {
   var winl = (screen.width - w) / 2;
   var wint = (screen.height - h) / 2;
   winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
   win = window.open(mypage, myname, winprops);
   if (win.opener == null) win.opener = self;
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function popUp(URL) {
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=250,left = 262,top = 184');");
}


var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

function hidebox(){
  crossobj=ns6? document.getElementById("showimage") : document.all.showimage
  if (ie4||ns6)
  crossobj.style.visibility="hidden"
  else if (ns4)
  document.showimage.visibility="hide"
  setCookie("box", "hide");
}


function showBox (w,h) {
  if (getCookie("box") != "hide") {
  	var winl = (frameWidth - w) / 2;
  	var wint = (frameHeight - 3*h) / 2;

    crossobj=ns6? document.getElementById("showimage") : document.all.showimage;

    if (ie4||ns6)
      crossobj.style.visibility="visible"
    else if (ns4)
      crossobj.visibility="none"

    crossobj.style.position = "absolute";
    crossobj.style.left = winl +  "px";
    crossobj.style.top = wint + "px";
    crossobj.style.width = w + "px";
    crossobj.style.cursor = "default";
  }
}

function resetCookie(vars) {
  document.cookie="msgs="+vars;
}

function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function kp(event) {
  if (p > 1) {if(event.keyCode==37){t(p-1);}}
  if (p+1 <= iAnzahlderFotos) {if(event.keyCode==39){t(p+1);}}
}
function t(i){
  document.getElementById('g_'+i).style.backgroundImage = "url("+uri_images+"gallery_boxfoto_.png)";
	if (p > 0) {
		document.getElementById('g_'+p).style.backgroundImage = "url("+uri_images+"gallery_boxfoto.png)";
	}
  p = i;
  document.getElementById('div_pic').src         = 'http://'+shortname+'.images.liebt.de/public/'+iEvent+'/'+aPics[i]["file"];
  document.getElementById('div_scout').innerHTML = 'Foto '+i+' von '+iAnzahlderFotos+', aufgenommen von: <a href="?x=profile&id='+aPics[i]["scout_id"]+'" target="_blank">'+aPics[i]["scout"]+'</a>';
	if (username != '') {
	  document.getElementById('div_me').innerHTML    = 'Hey '+username+', bist Du auf dem Foto? <a href="javascript:xajax_addpartyfoto(\''+aPics[i]["file"]+','+iEvent+'\');javascript:void(false);" onlick="">klick hier!</a>';
	} else {
	  document.getElementById('div_me').innerHTML    = '';
	}
}

function hidebuddiebox(){
  document.getElementById("buddiebox").innerHTML = document.getElementById("buddieboxformhelper").innerHTML;
  crossobj=ns6? document.getElementById("buddiebox") : document.all.buddiebox
  if (ie4||ns6)
  crossobj.style.visibility="hidden"
  else if (ns4)
  document.showimage.visibility="hide"
}

function buddie_add (id) {
	buddieid = id;
	document.getElementById("buddiebox").innerHTML = document.getElementById("buddieboxformhelper").innerHTML;
	document.getElementById("buddieboxformhelper").innerHTML = '';
	
	var winl = (frameWidth - 250) / 2;
	var wint = (frameHeight - 3*100) / 2;
	crossobj=ns6? document.getElementById("buddiebox") : document.all.buddiebox;
	if (ie4||ns6)
	  crossobj.style.visibility="visible"
	else if (ns4)
	  crossobj.visibility="none"
	
	crossobj.style.position = "absolute";
	crossobj.style.left = winl +  "px";
	crossobj.style.top = wint + "px";
	crossobj.style.width = 250 + "px";
	crossobj.style.cursor = "default";
	
	//return false;
}
function buddie_add_ok () {
	if (buddieid != null) {
		xajax.$("saveinputbox").disabled = true;
		xajax.$("saveinputbox").style.backgroundImage = "url(" + uri_images + "loadingsmall.gif)";
		xajax.$("buddie_reason").disabled = true;
		xajax_profile_buddie_add(buddieid,encodeURIComponent(document.getElementById("buddie_reason").value));
	};
	return false;
}