/**
*
* @package Brylle
* @version 1.0
* @copyright (c) 2007 J. Seyfried, http://www.joerg-seyfried.de
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
* Demo at http://www.macmini-forum.de
*/

// brylle_post.js - functions for the post-form part
// needs either brylle.js or brylle_nonajax.js 
// which have to be included AFTER this file.


//
// detach - open a separate shoutbox window

function detach() {
	//document.getElementById('brylleall').style.display = 'none';
	window.open(path+"index.php?s=1", "Shoutbox", 
	"width=190,height=500,left=100,top=200,menubar=no,location=no,resizable=no,scrollbars=no,status=no");
	//document.getElementById('brylleall').style.display = "none";
}

//
// admin - open a separate admin window

function admin() {
	window.open(path+"admin/index.php", "Shoutbox-Admin", 
	"width=600,height=600,left=120,top=100,menubar=no,location=no,resizable=no,scrollbars=yes,status=no");
}


function textCounter(field, cntfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

function setAdminLinks(style) {
	if (typeof(noAJAX)!="undefined") ul = window.frames['brylleframe'].document.getElementById('brylle');
	else ul = document.getElementById('brylle');
	for (i=0; i<ul.childNodes.length; i++) {
		if (ul.childNodes[i]) {
			licontent = ul.childNodes[i].childNodes;
			if (licontent)
				for (j=0; j<licontent.length; j++) {
					if ((licontent[j]) && (licontent[j].className=="admin"))
						licontent[j].style.display = style;				
			}
		}
	}
}

function toggleAdminView() {
	e = document.getElementById('AdminToggle');
	if (e.innerText == "Mod") {
		e.innerText = "Normal";	
		setAdminLinks("inline");
	} else {
		e.innerText = "Mod";	
		setAdminLinks("none");	
	}
}


