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 href="#" onclick="fiResizeEl(\'' + elId + "');return false;\">" + Cntrct + "</a> ›";
divLnkExpnd = '<a href="#" onclick="fiResizeEl(\'' + elId + "','1');return false;\">" + ExPnd + "</a> ›";
if (!elState) {
   divId.style.height = 80;
   divId.parentNode.style.height = 0;
   divId.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.height = 0;
   divExpId.innerHTML = divLnkExpnd;
} else if (divId.scrollHeight > 80 ) {
   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 docWrite(type) {
   Cntrct = 'Skupi';
   ExPnd = 'Proširi';
   randomId = 'd' + Math.floor(Math.random() * 2000);
   document.write('‹ <a href="#" onclick="fiSelectEl(\'' + randomId + '\');return false;">Označi</a> ›‹ <span id="ex' + randomId + '"><a href="#" onclick="fiResizeEl(\'' + randomId + '\');return false;">Skupi</a> ›</span></div><div id="' + randomId + '" class="' + type + '">');
}