function linksMore (obj) {
var item=new htmlTag1(obj,"div","formItem");
var line=new htmlTag1(item,"div","formLine");
var label=new htmlTag1(line,"label","");
var text=document.createTextNode("Link url:");
label.appendChild(text);
var inp=new htmlTag(line,"input","");
inp.att("name","link[]");
inp.obj.onchange=function(){checkLink(this);};
inp.obj.onfocus=function () {this.select();}
inp.obj.onclick=function () {this.select();}
inp=inp.append();
var stat=new htmlTag1(line,"div","statusCheck");
line=new htmlTag1(item,"div","formLine");
label=new htmlTag1(line,"label","");
text=document.createTextNode("Description:");
label.appendChild(text);
var inp=new htmlTag(line,"input","");
inp.att("name","des[]");
inp=inp.append();
var but=new htmlTag(line,"input","button");
but.att("type","button");
but.att("value","cancel");
but.obj.onclick=function() {
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
}
but=but.append();
}
function checkLink (obj) {
obj.parentNode.removeChild(obj.parentNode.children[2]);
var obj1=new htmlTag1(obj.parentNode,"div","statusCheck");
if (obj.value=='') return;
advAJAX.post ({
url: documentAddress,
cmd: '_checkLink',
link: obj.value,
onSuccess: function (res) {
if (error=getAjaxResponse(res,"error")) {
obj.parentNode.children[2].style.backgroundImage="url(images/exclamation.png)";
var text=document.createTextNode(error);
obj.parentNode.children[2].appendChild(text);
}
else if (getAjaxResponse(res,"status")=="present") {
obj.parentNode.children[2].style.backgroundImage="url(images/exclamation.png)";
var text=document.createTextNode('Link is already present');
obj.parentNode.children[2].appendChild(text);
}
else if (getAjaxResponse(res,"status")=="ok") {
obj.parentNode.children[2].style.backgroundImage="url(images/ok.png)";
}
}
});
}
function linkSend (form) {
var cu=new curtain(document.getElementById("linksSendForm"));
advAJAX.submit (form, {
onSuccess: function (res) {
cu.stop();
if (error=getAjaxResponse(res,"error")) {
alert (error);
}
else
location.href=base+"links/showFolder/0.html";
}
});
}
function editItem (obj,Obj) {
location.href=base+Obj.page+'/editItem/'+Obj.id+'.html';
}
function linkSave(form,id) {
applyCommand(form,'links','showLink',id);
}
function deadLink (obj,id,page,subPage) {
var body=document.getElementsByTagName('body')[0];
var root=obj.parentNode.parentNode.parentNode.parentNode;
var father=root.parentNode;
if (root.done==undefined)
root.done=false;
if (father.applier==undefined) {
father.applier=false;
father.count=0;
father.list=new deadList();
}
if (root.done) {
uncheck(root);
if (father.count==0) {
closeApplier();
return;
}
}
else {
root.done=true;
root.style.opacity='0.3';
father.count++;
father.list.add(id);
if (!father.applier) {
var applier=new htmlTag(body,'div','deadLinkApply');
new htmlTag1(applier.obj,'span','deadLinkInfo');
new htmlTag1(applier.obj,'span','deadLinkCounter');
applier.obj.children[0].appendChild(document.createTextNode('dead links:'));
applier.obj.children[1].appendChild(document.createTextNode("1"));
new htmlTag1(applier.obj,'a','deadLinkOk');
new htmlTag1(applier.obj,'a','deadLinkCancel');
applier=applier.append();
father.applier=true;
applier.children[3].onclick=cancelAll;
applier.children[2].onclick=applyAll;
}
}
updateCounter(body.lastChild.children[1],father.count);
function updateCounter(obj,c) {
obj.childNodes[0].nodeValue=c;
}
function uncheck (r) {
unset(r);
father.list.rem(id);
}
function unset (r) {
r.done=false;
r.style.opacity='1';
father.count--;
}
function closeApplier() {
body.removeChild(body.lastChild);
father.applier=false;
father.count=0;
father.list=new deadList();
}
function applyAll() {
advAJAX.post({
url: documentAddress,
cmd: '_deadLinksRemove',
reason: 1,
links: father.list.lista(),
onSuccess: function (res) {
if (error=getAjaxResponse(res,"error")) {
alert (error);
return;
}
else if (getAjaxResponse(res,"status")=='ok')
location.reload();
else alert ('Unknown error');
}
})
}
function cancelAll() {
var i;
for (i=0;i