if (document.ELEMENT_NODE == null) {
 document.ELEMENT_NODE = 1;
 document.TEXT_NODE = 3;
}

var dhr="=============================================================================================";

function zetXoffline(theImage) {
 theImage.src="images/avatar_error.jpg";
 theImage.onerror = null;
}

function trim(inputString) {
if (typeof inputString != "string") { return inputString; }
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") {
 retValue = retValue.substring(1, retValue.length);
 ch = retValue.substring(0, 1);
 }
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") { // Check for spaces at the end of the string
 retValue = retValue.substring(0, retValue.length-1);
 ch = retValue.substring(retValue.length-1, retValue.length);
 }
while (retValue.indexOf("  ") != -1) {
 retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
 }
return retValue;
}

function getTextValue(el) {
var i;
var s;
var nl=0;
s = "";
for (i = 0; i < el.childNodes.length; i++) {
 if (el.childNodes[i].nodeType == document.TEXT_NODE) {
	s += el.childNodes[i].nodeValue;
	nl=0;
	} else if (el.childNodes[i].nodeType == document.ELEMENT_NODE && el.childNodes[i].tagName == "BR") {
	s += "\r\n";
	nl=1;
	} else if (el.childNodes[i].nodeType == document.ELEMENT_NODE && el.childNodes[i].tagName == "HR") {
	if (nl==0) {
		s += "\r\n"+dhr+"\r\n";
		} else {
		s += dhr+"\r\n";
		}
	nl=1;
	} else if (el.childNodes[i].nodeType == document.ELEMENT_NODE && el.childNodes[i].tagName == "TABLE") {
	s += "[QUOTE]";
	nl=0;
	} else {
	nl=0;
	s += getTextValue(el.childNodes[i]);
	}
 } // end for
return trim(s);
}

function copypost(topic,rij) {
var sx;
var ch;
sx=getTextValue(document.getElementById(rij));
sx=sx.replace(/\r\n\r\nrank:[A-Za-z 0-9_]*\r\n[A-Za-z 0-9_]*\r\nGeplaatst:/i," op");
sx="In http://www.mangadvd.nl/frm_psts.php?topicid="+topic+" schreef "+sx;

if (document.all) {
 document.tmpfrm.tempStr.value=sx;
 document.tmpfrm.tempStr.createTextRange().execCommand('Copy');

 } else {
 nb=window.open("");
 nb.document.write(sx.replace(/\r\n/g,"<br>"));
 nb.document.close();
 }
}

function InsTxt(text) {
var target=parent.document.frmreply.pbericht;
if ( target ) {
 if ( document.all && target.cursorPos) {
  var cursorPos = target.cursorPos;
  cursorPos.text = cursorPos.text.charAt(cursorPos.text.length - 1) == ' ' ? text + ' ' : text;
  target.focus();
  } else {
  target.value += text;
  target.focus();
  }
 }
}

function copypastepost(rij) {
var sx;
sx=getTextValue(document.getElementById(rij));
sx=sx.replace(/\r\n\r\nrank:[A-Za-z 0-9_]*\r\n[A-Za-z 0-9_]*\r\nGeplaatst:/i," schreef op");
sx=sx.replace(/\r\nrank:[A-Za-z 0-9_]*\r\n[A-Za-z 0-9_]*\r\nGeplaatst:/i," schreef op");
sx=sx.replace(dhr+"\r\n","");
sx=sx.replace(dhr+"\r\n","");
sx=sx.replace(/\[QUOTE\]/i,"");
sx="\r\n[QUOTE]"+sx+"[/QUOTE]\r\n";
InsTxt(sx);
}

function dtp() { // deltopic
return confirm('Wil je echt dit topic en alle posts die daarbij horen verwijderen?');
}
function dpt() { // delpost
return confirm('Wil je echt deze post verwijderen?');
}
function mtp() { // movetopic
return confirm('Wil je echt dit topic verplaatsen?');
}
function mpp() { // movepost
return confirm('Wil je echt deze post verplaatsen?');
}
function ltp() { // locktopic
return confirm('Wil je dit topic echt op slot zetten?');
}
function utp() { // unlocktopic
return confirm('Wil je dit topic echt weer vrijgeven?');
}

