function fixm( inp ) {
	return inp.replace( "#" , "@" ).replace( "," , "." );
}
function listm( inp, outp ) {
	document.write( "<a href='" + "m4ilto:".replace( "4" , "a" ) + fixm( inp ) + "'>" + outp + "</a>" );
}

/* Show/Hide
----------------------*/
function show(element) {
	document.getElementById(element).style.display = "none";
	document.getElementById(element+"-hidden").style.display = "";
}

function hide(element) {
	document.getElementById(element).style.display = "";
	document.getElementById(element+"-hidden").style.display = "none";
}
function toggle(element) {
	if (document.getElementById(element).style.display == "none") {
		document.getElementById(element).style.display = "";
	} else {
		document.getElementById(element).style.display = "none";
	}
}

/* Show/Hide comment info
----------------------*/
function ShowInfo() {
	document.getElementById("comment-author").style.display = "";
	document.getElementById("showinfo").style.display = "none";
	document.getElementById("hideinfo").style.display = "";
}

function HideInfo() {
	document.getElementById("comment-author").style.display = "none";
	document.getElementById("showinfo").style.display = "";
	document.getElementById("hideinfo").style.display = "none";
}
function hideOnLoad(element) {
	document.getElementById(element).style.display = "none";
}

/* Show/Hide formatting info
----------------------*/
formattingOpen = false;
function toggleFormatting() {
	if (formattingOpen == false) {
		document.getElementById("tags-allowed").style.display = "";
		formattingOpen = true;
	} else {
		document.getElementById("tags-allowed").style.display = "none";
		formattingOpen = false;
	}
}

/* 

	Quote comment
	
*/
function addQuote(comment,quote){
	/*
	
		Derived from Alex King's JS Quicktags code (http://www.alexking.org/)
		Released under LGPL license
		
	*/
	
	// IE support
	if (document.selection) {
		comment.focus();
		sel = document.selection.createRange();
		sel.text = quote;
		comment.focus();
	}
	// Mozilla support
	else if (comment.selectionStart || comment.selectionStart == '0') {
		var startPos = comment.selectionStart;
		var endPos = comment.selectionEnd;
		var cursorPos = endPos;
		var scrollTop = comment.scrollTop;
		if (startPos != endPos) {
			comment.value = comment.value.substring(0, startPos)
			              + quote
			              + comment.value.substring(endPos, comment.value.length);
			cursorPos = startPos + quote.length
		}
		else {
			comment.value = comment.value.substring(0, startPos) 
				              + quote
				              + comment.value.substring(endPos, comment.value.length);
			cursorPos = startPos + quote.length;
		}
		comment.focus();
		comment.selectionStart = cursorPos;
		comment.selectionEnd = cursorPos;
		comment.scrollTop = scrollTop;
	}
	else {
		comment.value += quote;
	}
	
	// If Live Preview Plugin is installed, refresh preview
	try {
		ReloadTextDiv();
	}
	catch ( e ) {
	}	
}
function quote(postid, author, commentarea, commentID, textile) {
	var posttext = '';
	if (window.getSelection){
		posttext = window.getSelection();
	}
	else if (document.getSelection){
		posttext = document.getSelection();
	}
	else if (document.selection){
		posttext = document.selection.createRange().text;
	}
	else {
		return true;
	}
	
	if (posttext==''){
		
		// quote entire comment as html
		var posttext = document.getElementById(commentID).innerHTML;
		var posttext = posttext.replace(/	/g, "");
		var posttext = posttext.replace(/<p>/g, "\n");
		var posttext = posttext.replace(/<\/\s*p>/g, "");
		var posttext = posttext.replace(/<br>/g, "")

		// remove nested blockquotes
		var posttext = posttext.replace(/<blockquote>[^>]*<\/\s*blockquote>/g, "");
		var posttext = posttext.replace(/<blockquote>[^>]*<\/\s*blockquote>/g, "");

		var quote='<blockquote>\n'+posttext+'</blockquote>\n\n';

		var comment=document.getElementById(commentarea);
		addQuote(comment,quote);
		
	} else {
		
		// quote selection a html or textile
		if (textile) {
			var quote='bq. '+posttext+'\n\n';
		} else {
			var quote='<blockquote>\n\n'+posttext+'\n\n</blockquote>\n';
		}
		var comment=document.getElementById(commentarea);
		addQuote(comment,quote);
		
	}
	return false;
}


/* Event Listener by Scott Andrew - http://scottandrew.com, edited by Mark Wubben
----------------------*/
function addEvent(obj, evType, fn){
	if(obj.addEventListener){
		obj.addEventListener(evType, fn, false); 
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
}
//addEvent(window, 'load', functionname);




/* Write a Flash Object
--------------------------------------- */
function embedFlash(src, width, height, name) {
	if (!name) { // If no name given, make one
		newName = src.split('.');
		name = newName[0];
	}
	l1 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	l2 = ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
	l3 = ' width="'+width+'" height="'+height+'" id="'+name+'" align="">';
	l4 = '	<param name="movie" value="../meta/'+src+'" />';
	l5 = '	<param name="menu" value="false" />';
	l6 = '	<param name="quality" value="best" />';
	l7 = '	<embed src="'+src+'" menu="false" quality="best" width="'+width+'" height="'+height+'" name="'+name+'" align=""';
	l8 = ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	l9 = '</object>';
	
	document.writeln(l1+l2+l3+l4+l5+l6+l7+l8+l9);
};







/* Put in / after li's */
function addSlashes ( containerNode ) {
	var el = document.getElementById(containerNode);
	var els = el.getElementsByTagName("li");
	
	for (i=0; i<els.length -1; i++) {
		els[i].innerHTML += " / ";
	}
}
function addAllSlashes() {
	try { addSlashes('subcategories'); } catch (e) {}
	try { addSlashes('subpages'); } catch (e) {}
	try { addSlashes('subsubpages'); } catch (e) {}
}

if (navigator.appName=="Microsoft Internet Explorer") {
	addEvent(window, 'load', addAllSlashes);
}















