function changerblock(didrb,dtext) {
var obtextar = document.getElementById(didrb);
var valobtextar=obtextar.value;
var date_var = new Date();
ny=date_var.getFullYear();
nm=date_var.getMonth()+1;
nd=date_var.getDate();
nm=""+nm;
nd=""+nd;
if (nm.length==1) nm="0"+nm;
if (nd.length==1) nd="0"+nd;
tperon=nd+"."+nm+"."+ny;
if (dtext.length !=0) {
if (valobtextar.length !=0) {
valobtextar=valobtextar+"\r\n"+tperon+" "+dtext;
} else {
valobtextar=tperon+" "+dtext;
}
obtextar.value=valobtextar;
//alert(valobtextar);
}
}
function wiper()
{
  if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
  if (stcnt-- < -40) stcnt=31;
  status = str;
  clearTimeout(timeID);
  timeID = setTimeout("wiper()",100);
}
function SetStatusText(text){
msg=text;
timeID = 10;
stcnt = 16;
wmsg = new Array(33);
wmsg[0]=msg;
blnk = "                                                               ";
for (i=1; i<32; i++)
{
  b = blnk.substring(0,i);
  wmsg[i]="";
  for (j=0; j<msg.length; j++) wmsg[i]=wmsg[i]+msg.charAt(j)+b;
}
//wiper();
}
//SetStatusText('Каталог интернет ресурсов');
function changecat(){
idcat=document.addurl.cat.options[document.addurl.cat.selectedIndex].value;
document.addurl.padcat.length=0;  //this clears the select box
document.addurl.padcat.options[0] = new Option('Невыбрано',0,true,true);
n=0 ;
i=1;
while(n != (arrpodcat.length)){
idcat1=arrpodcat[n];
namepadcat=arrpodcat[n+1];
idpadcat=arrpodcat[n+2];
if (idcat==idcat1) {
document.addurl.padcat.options[i] = new Option(namepadcat,idpadcat);
i=i+1;
}
n=n+3;
}
}
function setcat_pcat(){
idsetcat=document.addurl.selidcat.value;
idsetpadcat=document.addurl.selidpadcat.value;
n=0;
while(n != (document.addurl.cat.length)){
if (document.addurl.cat.options[n].value==idsetcat)
document.addurl.cat.options[n].selected=1;
n=n+1;
}
changecat();
if (idsetpadcat>0){
n=0;
while(n != (document.addurl.padcat.length)){
if (document.addurl.padcat.options[n].value==idsetpadcat)
document.addurl.padcat.options[n].selected=1;
n=n+1;
}
}
}
function changeeditcat(){
idcat=document.addurl.cat.options[document.addurl.cat.selectedIndex].value;
document.addurl.padcat.length=0;  //this clears the select box
document.addurl.padcat.options[0] = new Option('Невыбрано',0,true,true);
n=0 ;
i=1;
while(n != (arrpodcat.length)){
idcat1=arrpodcat[n];
namepadcat=arrpodcat[n+1];
idpadcat=arrpodcat[n+2];
if (idcat==idcat1) {
document.addurl.padcat.options[i] = new Option(namepadcat,idpadcat);
i=i+1;
}
n=n+3;
}
document.addurl.namecat.value=document.addurl.cat.options[document.addurl.cat.selectedIndex].text;
}
function changeeditpadcat(){
document.addurl.namepadcat.value=document.addurl.padcat.options[document.addurl.padcat.selectedIndex].text;
}
function treeExpand(i,trname) {
tr = document.getElementById(trname);
var d;
if (tr.style.display == '') d='none'; else d='';
tr.style.display=d;
return true;
}
function editpad_cat(name,id,id2){
//alert(name);
//alert(id);
//alert(id2);
typeedit=document.feditpadcat.typeedit.value;
if (typeedit==1){
document.feditpadcat.idcat.value=id;
document.feditpadcat.Submit.value="Добавить подкатегорию в катигорию "+name;
}

if (typeedit==2){
if (id2==0){
document.feditpadcat.idcat.value=id;
document.feditpadcat.idpadcat.value=0;
document.feditpadcat.strname.value=name;
document.feditpadcat.Submit.value="Сохранить категорию";
}
else {
document.feditpadcat.idcat.value=id;
document.feditpadcat.idpadcat.value=id2;
document.feditpadcat.strname.value=name;
document.feditpadcat.Submit.value="Сохранить подкатегорию";
}
}
if (typeedit==3){
if (id2==0){
document.feditpadcat.idcat.value=id;
document.feditpadcat.idpadcat.value=0;
document.feditpadcat.strname.value=name;
document.feditpadcat.Submit.value="Удалить категорию";
}
else {
document.feditpadcat.idcat.value=id;
document.feditpadcat.idpadcat.value=id2;
document.feditpadcat.strname.value=name;
document.feditpadcat.Submit.value="Удалить подкатегорию";
}
}
}
function setCookie(name, value) {
  expDate = new Date();
  expDate.setYear(expDate.getYear() + 1);
  document.cookie = name+"="+escape(value)+";expires="+expDate.toGMTString()+";";
}
function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++){
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return -1;
}
function SaveOpenMenu(nommenu,idtr,idtr2,idpadmenu){
setCookie('nommenu',nommenu);
setCookie('idmenu',idtr);
setCookie('idmenu2',idtr2);
setCookie('idpadmenu',idpadmenu);
}
function openmenu() {
var nommenu=GetCookie('nommenu');
var idmenu=GetCookie('idmenu');
var idmenu2=GetCookie('idmenu2');
var idpadmenu=GetCookie('idpadmenu');
if ((idpadmenu!=0) && (idpadmenu!=-1)){
img = document.getElementById(idpadmenu);
if (nommenu==1) img.src='img/menu_check.png';
if (nommenu==2) img.src='img/folder-open.gif';
if (nommenu==3) img.src='img/user-open.gif';
}
if (idmenu!=-1) {treeExpand(1,idmenu);}
if ((idmenu2!=-1) && (idmenu2!=0)) {treeExpand(1,idmenu2);}
}
function setperon(nmonth){
nmonth=parseInt(nmonth);
dat=document.advert.perwith.value;
darray = dat.split("-");
date_var = new Date(parseInt(darray[0]),parseInt(darray[1])+nmonth-1,parseInt(darray[2]));
ny=date_var.getFullYear();
nm=date_var.getMonth()+1;
nd=date_var.getDate();
nm=""+nm;
nd=""+nd;
if (nm.length==1) nm="0"+nm;
if (nd.length==1) nd="0"+nd;
tperon=ny+"-"+nm+"-"+nd;
document.advert.peron.value=tperon;
price=parseInt(document.advert.price.value);
pricebegin=nmonth*price;
document.advert.pricebegin.value=pricebegin;
}