var ni = new Array();

tdClassNames = new Array;
tdClassNames["nomer"] = true;
tdClassNames["name"] = true;
tdClassNames["opisanie"] = true;

function getPrjFotoId(trid){
		arrTrIdIzm = trid.split("r");
		trIdIzm = parseInt(arrTrIdIzm[1]);
		return trIdIzm;
}

function insertFotoHref(){
  trs = document.getElementsByTagName("p");
  if (trs){
	for (ii in trs) if ((trs[ii].className)&&(trs[ii].className=="project")){
		if ((trs[ii])&&(trs[ii].id)){
			trId = getPrjFotoId(trs[ii].id)
			ahref=document.createElement("a");
			ahref.href="javascript: dokladno('" + trs[ii].id  +"');";
			if ((ni)&&(ni[trId])){
				img = document.createElement("img");
				img.src = "http://images.baudata.net.ua/" + ni[trId] + "sm.jpg"
				img.align="left";
				ahref.appendChild(img);
			}
			else ahref.appendChild(document.createTextNode(""));
			trs[ii].insertBefore(ahref, trs[ii].firstChild);
		}
	}/* for if */
	//else alert(trs[ii].className);
  }
}

function excludeBr(x){
	txt = x;
	arrTxt = txt.split("<br>");
	txt2 = arrTxt.join("");
	arrTxt = txt2.split("<br />");
	txt = arrTxt.join("");
	arrTxt = txt.split("<br/>");
	txt2 = arrTxt.join("");
	return txt2;
}

function dokladno(id){
	zakrytydokladno();
	trs = document.getElementById(id);
	mes = 'Внимание! Доступ к полным данным объектов строительства Украины разрешен на уcловиях подписки.';
  if (trs){
	if ((trs.className)&&(trs.className.indexOf("project")>=0)){
		txt = "";
		cur = trs.firstChild;
		
		while (cur) 
			{if ( (cur.className) && (tdClassNames[cur.className]) ){
				txt = txt + excludeBr(cur.innerHTML)  + " ";
			}
			cur = cur.nextSibling;
		}
		trid = trs.id;
		trId = getPrjFotoId(trid);
		ahref=document.createElement("a");
		ahref.href="javascript: zakrytydokladno();";
		ahref.className = "podrobno";
		ahref.id="podrobnenko";
		mb = document.createElement("b");
		mb.appendChild(document.createTextNode(mes));
		ahref.appendChild(mb);
		ahref.appendChild(document.createElement("br"));
		if ((ni)&&(ni[trId])){
			img = document.createElement("img");
			img.src = "http://images.baudata.net.ua/" + ni[trId] + ".jpg"
			ahref.appendChild(img);
		}/* if */
		ahref.appendChild(document.createElement("br"));
		ahref.appendChild(document.createTextNode(txt))
		document.body.appendChild(ahref);
	}/* if */
	//else alert(txt);
  }/* if */
  else  alert(mes);

}

function zakrytydokladno(){
	el = document.getElementById("podrobnenko");
	if (el){
		while(el.firstChild) el.removeChild(el.firstChild);
		document.body.removeChild(el);
	}/* if */
}/* fn-n */
