function fiSelectEl(elId) {
var element = document.getElementById(elId);
if ( document.selection ) {
	var range = document.body.createTextRange();
	range.moveToElementText(element);
	range.select();
	}
if ( window.getSelection ) {
	var range = document.createRange();
	range.selectNodeContents(element);
	var blockSelection = window.getSelection();
	blockSelection.removeAllRanges();
	blockSelection.addRange(range);
	}
}

function fiResizeEl(elId,elState) {
divId = document.getElementById(elId);
divExpId = document.getElementById('ex' + elId);
divLnkCntrct = '<a class="cattitle" href="#" onclick="fiResizeEl(\'' + elId + "');return false;\">" + Cntrct + "</a> &#8250;";
divLnkExpnd = '<a class="cattitle" href="#" onclick="fiResizeEl(\'' + elId + "','1');return false;\">" + ExPnd + "</a> &#8250;";
if (!elState) {
	divId.style.height = 40;
	divId.parentNode.style.height = 0;
	divId.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.height = 0;
	divExpId.innerHTML = divLnkExpnd;
} else if (divId.scrollHeight > 40) {
	divId.style.height = divId.scrollHeight + 3;
	divId.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.height = divId.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.scrollHeight + 3;
	divExpId.innerHTML = divLnkCntrct;
	}
}
function Spoil(parent,elId)
{
  var element = document.getElementById(elId);
  if (element.style.visibility=='hidden')
  {
    parent.innerText='hide';
    element.style.visibility='visible';
  }
  else
  {
    parent.innerText='show';
    element.style.visibility='hidden';
  }
}


function docWrite(type) {
	Cntrct = 'Contract';
	ExPnd = 'Expand';
	randomId = 'd' + Math.floor(Math.random() * 2000);
  if (type=='quote')
	  document.write('</span></div><div style="width:auto" id="' + randomId + '" class="' + type + '">');
  else
  if (type=='spoiler')
	  document.write('&#8249; <a class="cattitle" href="#" onclick="Spoil(this,\'' + randomId + '\');return false;">Show</a> &#8250;</span></div><div style="visibility:hidden" id="' + randomId + '" class="' + type + '">');
  else
	  document.write('&#8249; <a class="cattitle" href="#" onclick="fiSelectEl(\'' + randomId + '\');return false;">Select</a> &#8250;&#8249; <span id="ex' + randomId + '"><a class="cattitle" href="#" onclick="fiResizeEl(\'' + randomId + '\',\'1\');return false;">Expand</a> &#8250;</span></div><div id="' + randomId + '" class="' + type + '">');
}
