    function Interier(id_db, strname, goods, image, width, comments, single)
    {
        if(single == null) single = false;
        this.width = width;
        this.id_db = id_db;
        this.navObj = 0;

        this.StrName  =  strname;
        this.Goods = goods;
        this.image = image;
        this.Comments = comments;

        this.draw = draw_in_viewer;
        this.ibyid = ibyid;
        this.show = showInt;
        this.hide = hideInt;
        this.single = single;
    }
    function showInt()
    {
        this.navObj.style.visibility = "visible";
        this.navObj.style.display = "block";
    }
    function hideInt()
    {
        this.navObj.style.visibility = "hidden";
        this.navObj.style.display = "none";
    }
    function ibyid(id_good)
    {
        for(var i = 0; i < this.Goods.length; i++)
        {
             if(this.Goods[i].id_db == id_good)
                          return i;
        }
        return -1;
    }
    function draw_in_viewer(num)
    {
       document.write("<table border='1' bordercolor='#333366' cellspacing='0' cellpadding='3' width='" + this.width +
           "' id='int" + this.id_db + "' style='visibility:hidden;display:none;font-size:14px;color:ffffff;font-family:arial' bgcolor='#666699'><tr><td width='" +
           this.width + "' colspan='2' bgcolor='#333366'><b>" + this.StrName + "</b></td></tr><tr><td width='200'><img src='images/ints/" +
           this.image + "' width='200' name='imgInt" + this.id_db + "' onClick='ClickOnZoomInterier(" + this.id_db + ")' alt='Увеличить' style='cursor:hand'><br>"+
           "<input type=image src='icons/allgoods.gif' name='allgoods"+this.id_db+"' height='32' width='32' onClick='ClickOnAllGoods(" + this.id_db + ")' alt='Посмотреть все элементы интерьера'>&nbsp;&nbsp;"+
           "<input type=image src='icons/zoom.gif' name='zoom_int"+this.id_db+"' height='32' width='32' onClick='ClickOnZoomInterier(" + this.id_db + ")' alt='Увеличить'>&nbsp;&nbsp;"+
           "<input type=image src='icons/article.gif' name='article_int"+this.id_db+"' height='32' width='32' onClick='ClickOnArticleInterier(" + this.id_db + ")' alt='Перейти к статье'>"+
           "</td><td width='" + (this.width - 200) +
           "' valign='top'>&nbsp;&nbsp;&nbsp;&nbsp;В интерьер входят<br><center><table cellspacing='0' cellpadding='0' border='1' bordercolor='#333366' style='font-size:14px;color:ffffff;font-family:arial' width='" + (this.width - 220) + "'><tr>"+
           "<td width='20' height='20' bgcolor='#333366'>&nbsp;</td>"+
           "<td width='140' height='20' align='center' bgcolor='#333366'>Наименование</td>"+
           "<td width='75' height='20' align='center' bgcolor='#333366'>Цена</td>"+
           "<td width='60' height='20' align='center' bgcolor='#333366'>Остаток</td>"+
           "<td width='65' height='20' align='center' bgcolor='#333366'>В корзину</td>"+
           "</tr>");
       for(var i = 0; i < this.Goods.length; i++)
       {
            document.write("<tr>"+
               "<td width='20' height='20'><input type='checkbox' value='off' name='checkbox" + this.id_db + "c" + this.Goods[i].id_db + "'></td>"+
               "<td width='150' height='20' align='center'>" + this.Goods[i].StrName + "</td>"+
               "<td width='60' height='20' align='center'>" + this.Goods[i].Price + " р.</td>"+
               "<td width='60' height='20' align='center'><span id='resti" + this.Goods[i].id_db + "'>" + this.Goods[i].Rest + "</span>&nbsp;" + this.Goods[i].dim + "</td>"+
               "<td width='70' height='20' align='center'><input name='qni" + this.Goods[i].id_db + "' type='text' value='0' size='3'>"+
               "<input type=image src='icons/korzina.jpg' name='to_basket"+this.id_db+"' heigth='15' width='15' onClick='ClickOnToBasket(" + this.Goods[i].id_db + "," + this.id_db + ")' alt='Добавить в корзину'></td>"+
               "</tr>");

            this.Goods[i].quantity = document.all["qni" + this.Goods[i].id_db];
            this.Goods[i].checkbox = document.all["checkbox" + this.id_db + "c" + this.Goods[i].id_db];
            this.Goods[i].restfield = document.all["resti" + this.Goods[i].id_db];
       }
       document.write("</table></center><br><input height='25' width='66' type=image src='icons/all_select.jpg' name='to_basket_"+this.id_db+"' heigth='15' width='15' onClick='ClickOnToBasketGoods(" + this.id_db + ")' alt='Добавить выделенные в корзину'>");
       document.write("</td></tr><tr><td width='" + this.width + "' colspan='2'>"+this.Comments);
       if(this.Comments != "" && !this.single)
          document.write("..&nbsp;&nbsp;<a href='javascript:ClickOnArticleInterier(" + this.id_db +
             ")' style='color:ffffff;font-size:11px;font-family:arial'>Подробнее&gt;&gt;</a>");

       document.write("</td></tr></table>");

       this.navObj = document.all["int" + this.id_db];
       this.navObj.num = num;
    }
    function Good(id_db, strname, price, rest, properties, images, width, dim, comments, single)
    {
        if(single == null) single = false;
        this.width = width;
        this.id_db = id_db;
        this.navObj = 0;

        this.restfield = 0;
        this.quantity = 0;
        this.checkbox = 0;

        this.StrName  =  strname;
        this.Price = price;
        this.Rest = rest;
        this.Properties = properties;
        this.image = image;
        this.dim = dim;
        this.Comments = comments;

        this.draw = draw_good;
        this.show = showGood;
        this.hide = hideGood;
        this.isIntegerQ = isIntegerQ;
        this.single = single;
    }
    function showGood()
    {
        this.navObj.style.visibility = "visible";
        this.navObj.style.display = "block";
    }
    function hideGood()
    {
        this.navObj.style.visibility = "hidden";
        this.navObj.style.display = "none";
    }
    function draw_good(num)
    {
       document.write("<table border='1' bordercolor='#333366' cellspacing='0' cellpadding='3' width='" + this.width + "' id='good" + this.id_db +
           "' style='visibility:hidden;display:none;font-size:14px;color:ffffff;font-family:arial' bgcolor='#666699'><tr><td width='" +
           this.width + "' colspan='2' bgcolor='#333366'><b>" + this.StrName + "</b></td></tr><tr><td width='200' valign='top'><img src='images/goods/" + this.image +
           "' width='200' name='imgGood" + this.id_db + "' alt='Увеличить' onClick='ClickOnZoomGood(" + this.id_db + ")' style='cursor:hand'><br>"+
           "<input type=image src='icons/allgoods.gif' name='to_interier" + this.id_db+"' height='32' width='32' onClick='ClickOnToInterier(" + this.id_db + ")' alt='Посмотреть в интерьере'>&nbsp;&nbsp;"+
           "<input type=image src='icons/zoom.gif' name='zoom_good" + this.id_db+"' height='32' width='32' onClick='ClickOnZoomGood(" + this.id_db + ")' alt='Увеличить'>&nbsp;&nbsp;"+
           "<input type=image src='icons/article.gif' name='article_good"+this.id_db+"' height='32' width='32' onClick='ClickOnArticleGood(" + this.id_db + ")' alt='Подробнее'>"+
           "</td><td width='"+ (this.width - 200) +
           "'  valign='top'><center><br><br><table border='1' cellspacing='0' cellpadding='3' bordercolor='#333366' width='" + (this.width - 240) + "' style='font-size:12px;color:ffffff;font-family:arial'>");
            document.write("<tr>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='left' bgcolor='#333366'>Характеристики</td>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='left' bgcolor='#333366'>&nbsp;</td></tr>");
       for(var i = 0; i < this.Properties.length; i++)
            document.write("<tr>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='right'>" + this.Properties[i].StrName + "&nbsp;&nbsp;</td>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='left'>&nbsp;&nbsp;" + this.Properties[i].Value + "</td></tr>");
       document.write("<tr>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='right'>Остаток&nbsp;&nbsp;</td>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='left'><span id='rest" + this.id_db + "'>&nbsp;&nbsp;" + this.Rest + "</span>&nbsp;" + this.dim + "</td></tr>");
       document.write("<tr>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='right'>Цена&nbsp;&nbsp;</td>"+
               "<td width='" + ((this.width - 240)/2) + "' height='20' align='left'>&nbsp;&nbsp;" + this.Price + " руб.</td></tr>");
       document.write("<tr><td width='" + ((this.width - 240)/2) + "' height='20' align='center'>&nbsp;</td><td width='" + ((this.width - 240)/2) + "' height='20' align='left'>&nbsp;&nbsp;В корзину <input name='qn" + this.id_db + "' type='text' value='0' size='3'>"+
           "&nbsp;" + this.dim + "<input type=image src='icons/korzina.jpg' name='to_basket"+this.id_db+"' heigth='20' width='20' onClick='ClickOnToBasket(" + this.id_db + ")' alt='Добавить в корзину'></td>"+
           "</tr>");


       document.write("</table><br>");
       document.write("</td></tr><tr><td width='" + this.width + "' colspan='2'>" + this.Comments) ;
       if(this.Comments != "" && !this.single)
                document.write("..&nbsp;&nbsp;<a href='javascript:ClickOnArticleGood(" + this.id_db +
                      ")' style='color:ffffff;font-size:11px;font-family:arial'>Подробнее&gt;&gt;</a>");
       document.write("</td></tr></table>");


       this.navObj = document.all["good" + this.id_db];
       this.navObj.num = num;
       this.quantity = document.all["qn" + this.id_db];
       this.restfield = document.all["rest" + this.id_db];
    }
    function Property(str_name, value)
    {
       this.StrName = str_name;
       this.Value = value;
    }
    // Обработчики нажатия на Good
    function isIntegerQ(str_value)
    {
       if((str_value == '0') || (str_value == '')) return false;

       for(count = 0, OK = true; count < str_value.length; count++)
       if ((str_value.charAt(count) < '0') || (str_value.charAt(count) > '9')) OK = false;
          return OK;
    }
    function ClickOnToBasket(id_good, id_interier)
    {

        var quantity;
        var rest;
        if(id_interier == null)
        {
             quantity = document.getElementById("qn" + id_good);
             rest = document.getElementById("rest" + id_good);
        }
         else
        {
             quantity = document.getElementById("qni" + id_interier + "c" + id_good);
             rest = document.getElementById("resti" + id_interier + "c" + id_good);
             id_good  =  quantity.id_db;
        }

        if(!isIntegerQ(quantity.value))
        {
             alert("Некорректно введенное количество !");
             quantity.value = 0;
             quantity.focus();
             return;
        }

        openWin("commands.php?command=add_basket&id_good=" + id_good + "&num=" +
                                quantity.value, 450, 120);
        quantity.value = 0;
    }
    function ClickOnToInterier(id_good)
    {
       window.location = "goods.php?owngood=" + id_good;
    }
    function ClickOnZoomGood(id_good)
    {
        var win = window.open("zoom.php?good_id=" + id_good, "", "status=no,scrollbars=yes,resizable=yes,width=530,height=600");
    }
    function ClickOnArticleGood(url)
    {
        window.open(url);
    }
    // обработчик нажатия на Interier
    function ClickOnAllGoods(id_interier)
    {
       window.location = "goods.php?parint=" + id_interier;
    }
    function ClickOnZoomInterier(id_interier)
    {
        var win = window.open("zoom.php?int_id=" + id_interier, "", "status=no,scrollbars=yes,resizable=yes,width=530,height=600");
    }
    function ClickOnArticleInterier(url)
    {
        window.open(url);
    }
    function ClickOnToBasketGoods(id_interier)
    {
        var ids = new Array();
        var nums = new Array();

        iCounter = 0;
        //alert("checkbox" + id_interier + "c" + iCounter);
        //document.getElementByName()
        /*var tempEl = document.getElementsByName("checkbox" + id_interier + "c" + iCounter);
        console.log(tempEl);
        alert(tempEl[0]);
        if (document.getElementsByName("checkbox" + id_interier + "c" + iCounter) != null)
        {
            tempElement = document.getElementsByName("checkbox" + id_interier + "c" + iCounter);
            for (var i=0; i<tempElement.length; i++){
                if ( tempElement[i].checked){
                     var id_db =  tempElement[i].id_db;
                     var val =  tempElement[i].value;
                     if(!isIntegerQ(val))
                     {
                         alert("В позиции " + ( iCounter + 1 ) + " некорректно введенное количество\n");
                         return;
                     }
                     var rest =  document.all["resti" + id_interier + "c" + iCounter];
        
                     ids.push(id_db);
                     nums.push(val);
                }
            }
           
          if ( document.all["checkbox" + id_interier + "c" + iCounter].checked)
          {
            
             var id_db =  document.all["qni" + id_interier + "c" + iCounter].id_db;
             var val =  document.all["qni" + id_interier + "c" + iCounter].value;
             if(!isIntegerQ(val))
             {
                 alert("В позиции " + ( iCounter + 1 ) + " некорректно введенное количество\n");
                 return;
             }
             var rest =  document.all["resti" + id_interier + "c" + iCounter];

             ids.push(id_db);
             nums.push(val);
          }
        iCounter++;
        }*/
         while( document.getElementById("checkbox" + id_interier + "c" + iCounter) != null)
        {

          if ( document.getElementById("checkbox" + id_interier + "c" + iCounter).checked)
          {
            
             var id_db =  document.getElementById("qni" + id_interier + "c" + iCounter).getAttribute('id_db');
             var val =  document.getElementById("qni" + id_interier + "c" + iCounter).value;
             if(!isIntegerQ(val))
             {
                 alert("В позиции " + ( iCounter + 1 ) + " некорректно введенное количество\n");
                 return;
             }
             //????
             var rest =  document.getElementById("resti" + id_interier + "c" + iCounter);
                //alert("resti" + id_interier + "c" + iCounter);
            // alert(id_db+' '+val);   
             ids.push(id_db);
             nums.push(val);
          }
        iCounter++;
        }
        /*while( document.all["checkbox" + id_interier + "c" + iCounter] != null)
        {

          if ( document.all["checkbox" + id_interier + "c" + iCounter].checked)
          {
            
             var id_db =  document.all["qni" + id_interier + "c" + iCounter].id_db;
             var val =  document.all["qni" + id_interier + "c" + iCounter].value;
             if(!isIntegerQ(val))
             {
                 alert("В позиции " + ( iCounter + 1 ) + " некорректно введенное количество\n");
                 return;
             }
             var rest =  document.all["resti" + id_interier + "c" + iCounter];
                alert("resti" + id_interier + "c" + iCounter);
             ids.push(id_db);
             nums.push(val);
          }
        iCounter++;
        }*/
     if(!ids.length)
     {
         alert("Необходимо отметить интересующие Вас товары !");
         return;
     }
     openWin("commands.php?command=add_basket&id_good=" + ids.join(",") + "&num=" +
                                nums.join(","), 500, 150);
    }

    function gdShowImage(id, num)
    {
        var image_obj = eval("imgGood" + id);
        var image_mas = eval("images_for_good_" + id);

        image_obj.src = "images/goods/" + image_mas[num];
    }
    function intShowImage(id, num)
    {
        var image_obj = eval("imgInt" + id);
        var image_mas = eval("images_for_int_" + id);

        image_obj.src = "images/ints/" + image_mas[num];
    }
    function ClickOnQuestionInterier(interier_id)
    {
        window.location = "goods.php?q_int_id=" + interier_id;
    }
    function ClickOnQuestionGood(good_id)
    {
        window.location = "goods.php?q_good_id=" + good_id;
    }

    function navigate_by_id(id, isGood, path)
    {
        parent.ViewElement.path = path;
        if(isGood)
        {
           parent.ViewElement.location = "view.php?goodid=" + id;
           parent.ViewElement.locate();
        }
          else
        {
           parent.ViewElement.location = "view.php?interierid=" + id;
           parent.ViewElement.locate();
        }
        document.body.scrollTop=0;
}
//------------------------------------------------------------------------
function basket_item(id, image, num, price, rest, str_name, width)
{
    this.id_db = id;
    this.image = image;
    this.num = num;
    this.price = price;
    this.rest = rest;
    this.str_name = str_name;
    this.width = width;

    this.navObj = 0;
    this.quantity = 0;
    this.restfield = 0;

    this.draw = draw_basket_item;
    this.show = show_basket_item;
    this.hide = hide_basket_item;
    this.isIntegerQ = isIntegerQ;
}

function draw_basket_item(n)
{
    document.write("<table border='0' cellspacing='0' cellpadding='0' width='" + this.width + "' id='basketItem" +
    this.id_db + "' style='visibility:hidden;display:none;font-size:12px;color:ffffff;font-family:arial'><tr><td width='" + this.width + "' align='center'><b>" +
    this.str_name + "</b></td></tr><tr><td width='" + this.width + "' align='center'><img src='images/goods/" +
    this.image + "' width='" + (this.width - 4) + "'></td></tr><tr></tr><td width='" + this.width +"'><b>Стоимость " +
    this.price + "</b></td><tr><td width='" + this.width + "'>" +
    "<font class='newstext'>Количество</font> <input size='4' type='text' name='editbox" + this.id_db + "' value='" + this.num +
    "'>&nbsp;<input type=image src='icons/change.jpg' onClick='editItem(" + this.id_db + ")' width='80' height='20' alt='Изменить'>&nbsp;<font class='newstext'>&nbsp;&nbsp;(Осталось&nbsp;&nbsp;<span id='rest" + this.id_db + "'>" + this.rest +
    "</span>)</font><br>&nbsp;<input type=image src='icons/delete.jpg' onClick='deleteBasketItem(" + this.id_db + ")' width='80' height='20' alt='Удалить'></td></tr></table>");
}
function  editItem(counter)
{
    var edit_object = document.all[ "editbox" + counter ];
    var error = 0;

    if(!isIntegerQ(edit_object.value))
    {
      alert("Некорректно введенное число !");
      edit_object.value = edit_object.old_value;
      return;
    }
    if(edit_object.value == edit_object.old_value) return;

    window.location = "commands.php?command=edit_basket&counter=" + counter
                            + "&new_num=" + edit_object.value;
}
function deleteBasketItem(counter)
{
    if(confirm("Вы уверены, что хотите удалить заказ из корзины ?"))
       window.location = "commands.php?command=del_basket&counter=" + counter;
}
function show_basket_item()
{
    this.navObj.style.visibility = "visible";
    this.navObj.style.display = "block";
}
function hide_basket_item()
{
    this.navObj.style.visibility = "hidden";
    this.navObj.style.display = "none";
}
function print_basket(basket, gettings)
{
  if(!basket.length)
     document.write("<table width='610' height='300' cellspacing='0' cellpadding='0'><tr><td width='610' align='center' valign='center'><font class='red'>Ваша корзина пуста !</font></td></tr></table>");
  else
  {
    width = basket[0].width;
    var total = 0;
    document.write("<table width='"+(2*width)+"' border='1' bordercolor='#333366' cellspacing='0' cellpadding='0' bgcolor='#666699'>");
    for(var iCounter = 0; iCounter < basket.length; iCounter++)
    {
       total += basket[iCounter].num * basket[iCounter].price;
       if(iCounter%2)
       {
          document.write("<td width='"+width+"' valign='top'>");
          basket[iCounter].draw(iCounter);
          basket[iCounter].show();
          document.write("</td></tr>");
       }
         else
       {
          document.write("<tr><td width='"+width+"' valign='top'>");
          basket[iCounter].draw(iCounter);
          basket[iCounter].show();
          document.write("</td>");
       }
    }
    if(basket.length%2) document.write("<td width='"+width+"' valign='top'></td></tr>");

    document.write("</table><br>");
    document.write("<table width='"+(2*width + 6)+"' border='1' style='font-size:12px;color:ffffff;font-family:arial' bordercolor='#333366' cellspacing='0' cellpadding='3' bgcolor='#666699'><tr>"+
                   "<td width='"+(2*width + 6)+"' align='left' bgcolor='#333366' colspan='2'><font class='newsdate'><b>Действия</b></font></td></tr><tr>");
    document.write("<td width='"+width+"' valign='bottom'><input type=image src='icons/clear2.jpg' onClick='clearOnClick()' alt='Очистить'></td>");
    document.write("<td width='"+width+"'><font style='font-size:18px'>Общая стоимость <span id='total_price' style='font-weight:bold'>" + total + "</span> руб.</font><hr>Предпочитаемая доставка - стоимость<br>");
    for(var i = 0; i < gettings.length; i++)
        document.write("<input name='Getting' type='radio' value='" + gettings[i][0] + "'>&nbsp;" + gettings[i][1] + " - <b>" + gettings[i][2] + "</b> руб.<br>");
    document.write("Место доставки и другие пожелания<br><textarea name='Comment' rows=5 cols=40 wrap='on'></textarea>"+
                   "<input type=image src='icons/zakaz2.jpg' onClick='order_on_click()' alt='Заказать'></td>");
    document.write("</tr></table>");
  }
}
function order_on_click()
{
  var gt_value = 0;
  for(var i = 0; i < Getting.length; i++)
    if(Getting[i].checked)
       gt_value = Getting[i].value;
  window.location='commands.php?command=order&Getting=' + gt_value + '&Comment=' + Comment.value;
}
function clearOnClick()
{
 if(confirm("Вы уверены, что хотите очистить корзину ?"))
        window.location='commands.php?command=clear_basket';
}
//------------------------------------------------------------------------
function drawbackArrow(classid)
{
    document.write("<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tr>"+
                   "<td width='100%' align='center' valign='center' height='30'><font class='small'>Назад</font></td></tr>"+
                   "<tr><td width='100%' align='center'><img alt='Назад' style='cursor:hand' height='50' src='../icons/back.gif' onClick='javascript:goBack(" +
                    classid + ")'></td></tr></table>");
}
function  goBack(classid)
{
    if(classid != 0) window.location = "?select=goods&classid=" + classid;
}
//------------------------------------------------------------------------
function groupItem(classid, par_classid, name, date, time, w, h)
{
    this.classid = classid;
    this.par_classid = par_classid;
    this.name = name;
    this.date = date;
    this.time = time;
    this.width = w;
    this.height = h;

    this.draw = drawGI;
}
function drawGI()
{
    document.write("<table width='" + this.width + "' height='" + this.height +
             "' cellspacing='0' cellpadding='0'><tr><td width='" + this.width +
             "' align='center' valign='center' height='20' colspan='3'><font class='small'>" + this.name +
             "</font></td></tr><tr><td width='" + this.width +
             "' align='center' colspan='3'><img alt='Раздел' style='cursor:hand' height='" + (this.height - 60) +
             "' src='../icons/folderb.gif' onClick='javascript:enterInFolder(" + this.classid + ")'></td></tr>"+
             "<tr><td width='25' height='25'><img style='cursor:hand' src='../icons/edit.gif' height='15' width='15' onClick='changeFolder(" + this.classid +
             "," + this.par_classid + ")' alt='Изменить'></td><td width='25' height='25'><img style='cursor:hand' src='../icons/del.gif' height='15' width='15' onClick='deleteFolder(" + this.classid + "," + this.par_classid + ")' alt='Удалить'></td>"+
             "<td width='25' height='25'><img style='cursor:hand' src='../icons/korzina.jpg' height='15' width='15' onClick='moveFolder(" + this.classid + "," + this.par_classid + ")' alt='Перенести'></td></tr></table>");
}
function enterInFolder(classid)
{
    window.location = "?select=goods&classid=" + classid;
}
function changeFolder(classid, par_classid)
{
    openScrlWin("group.php?classid=" + classid + "&par_classid=" + par_classid, 530, 500);
}
function deleteFolder(classid, par_classid)
{
 if(par_classid != 0)
 {
  if(confirm("Вы уверены, что хотите удалить данный раздел ?"))
    window.location = "commands.php?command=delfolder&classid=" + classid + "&par_classid=" + par_classid;
 } else  alert("Данный раздел не подлежит удалению");
}
function moveFolder(classid, par_classid)
{
 if(par_classid != 0)
 {
        var ret = "||";
        ret = window.showModalDialog("dialog/sd_dialog.php?filter=CZ_FOLDER", "", "dialogWidth:310px;dialogHeight:380px;center:yes");
        var ret_mas = ret.split("|");
        if(ret_mas[2] != par_classid && ret_mas[2] != "")
            window.location = "commands.php?command=moveclass&classid_s=" + classid +
                              "&classid_d=" + ret_mas[2] + "&par_classid=" + par_classid;
 }  else  alert("Данный раздел не подлежит перемещению");
}
//------------------------------------------------------------------------------
function goodItem(id_db, par_classid, name, date, time, w, h, image)
{
    this.id_db = id_db;
    this.par_classid = par_classid;
    this.name = name;
    this.date = date;
    this.time = time;
    this.width = w;
    this.height = h;
    this.image = image;

    this.draw = drawGIT;
}
function drawGIT()
{
    document.write("<table width='" + this.width + "' height='" + this.height +
             "' cellspacing='0' cellpadding='0'><tr><td width='" + this.width +
             "' align='center' valign='center' height='20' colspan='3'><font class='small'>" + this.name +
             "</font></td></tr><tr><td width='" + this.width +
             "' align='center' colspan='3'><img alt='Товар' style='cursor:hand' height='" + (this.height - 60) +
             "' src='../images/goods/" + this.image + "' onClick='javascript:showGIT(" + this.id_db + ")'></td></tr>" +
             "<tr><td width='25' height='25'><img style='cursor:hand' src='../icons/edit.gif' height='15' width='15' onClick='changeGIT(" + this.id_db +
             ")' alt='Изменить'></td><td width='25' height='25'><img style='cursor:hand' src='../icons/del.gif' height='15' width='15' onClick='deleteGIT(" + this.id_db + "," +
             this.par_classid + ")' alt='Удалить'></td><td width='25' height='25'><img style='cursor:hand' src='../icons/korzina.jpg' height='15' width='15' onClick='moveGIT(" +
             this.id_db + "," + this.par_classid + ")' alt='Перенести'></td><td width='25' height='25'>"+
             "<img height='15' src='../icons/link.gif' width='15' style='cursor:hand' onClick='javascript:genGood(" + this.id_db + ")' alt='Получить ссылку'></td></tr></table>");
}
function showGIT(id_db)
{
    openScrlWin("good.php?id=" + id_db, 920, 680);
}
function changeGIT(id_db)
{
    openScrlWin("good.php?id=" + id_db, 920, 680);
}
function deleteGIT(id_db, classid_p)
{
   if(confirm("Вы уверены, что хотите удалить данный товар ?"))
    window.location = "commands.php?command=delgood&id_good=" + id_db + "&classid_p=" + classid_p;
}
function moveGIT(id_db, classid_p)
{
        var ret = "||";
        ret = window.showModalDialog("dialog/sd_dialog.php?filter=CZ_FOLDER", "", "dialogWidth:310px; dialogHeight:380px; center:yes");
        var ret_mas = ret.split("|");
        if(ret_mas[2] != classid_p && ret_mas[2] != "")
            window.location = "commands.php?command=movegood&id_good=" + id_db +
                              "&classid_d=" + ret_mas[2] + "&classid_p=" + classid_p;
}
function genGood(good_id)
{
   openWin("link.php?good_id=" + good_id, 410, 180);
}
//------------------------------------------------------------------------------
function intItem(id_db, par_classid, name, date, time, w, h, image)
{
    this.id_db = id_db;
    this.par_classid = par_classid;
    this.name = name;
    this.date = date;
    this.time = time;
    this.width = w;
    this.height = h;
    this.image = image;

    this.draw = drawINT;
}
function drawINT()
{
    document.write("<table width='" + this.width + "' height='" + this.height +
             "' cellspacing='0' cellpadding='0'><tr><td width='" + this.width +
             "' align='center' valign='center' height='20' colspan='4'><font class='small'>" + this.name +
             "</font></td></tr><tr><td width='" + this.width +
             "' align='center' colspan='4'><img alt='Интерьер' style='cursor:hand' height='" + (this.height - 60) +
             "' src='../images/ints/" + this.image + "' onClick='javascript:showINT(" + this.id_db + ")'></td></tr>"+
             "<tr><td width='25' height='25'><img style='cursor:hand' src='../icons/edit.gif' height='15' width='15' onClick='changeINT(" + this.id_db +
             ")' alt='Изменить'></td><td width='25' height='25'><img src='../icons/del.gif' height='15' style='cursor:hand' width='15' onClick='deleteINT(" + this.id_db + "," + this.par_classid + ")' alt='Удалить'></td>"+
             "<td width='25' height='25'><img height='15' src='../icons/korzina.jpg' width='15' style='cursor:hand' onClick='javascript:moveINT(" + this.id_db + "," + this.par_classid + ")' alt='Переместить'></td>"+
             "<td width='25' height='25'><img height='15' src='../icons/link.gif' width='15' style='cursor:hand' onClick='javascript:genInt(" + this.id_db + ")' alt='Получить ссылку'></td></tr></table>");
}
function showINT(id_db)
{
    openScrlWin("interier.php?id=" + id_db, 600, 600);
}
function changeINT(id_db)
{
    openScrlWin("interier.php?id=" + id_db, 600, 600);
}
function deleteINT(id_db, classid_p)
{
   if(confirm("Вы уверены, что хотите удалить данный интерьер ?"))
    window.location = "commands.php?command=delint&id_interier=" + id_db + "&classid_p=" + classid_p;
}
function moveINT(id_db, classid_p)
{
    var ret = "||";
    ret = window.showModalDialog("dialog/sd_dialog.php?filter=CZ_FOLDER", "", "dialogWidth:310px; dialogHeight:380px; center:yes");
    var ret_mas = ret.split("|");
    if(ret_mas[2] != classid_p && ret_mas[2] != "")
        window.location = "commands.php?command=moveint&id_interier=" + id_db +
                          "&classid_d=" + ret_mas[2] + "&classid_p=" + classid_p;
}
function genInt(interier_id)
{
   openWin("link.php?interier_id=" + interier_id, 410, 180);
}
//------------------------------------------------------------------------
scren_h = 0;
scren_w = 0;

function setDims()
{
   parent.scren_h = document.body.scrollHeight;
   parent.scren_w = document.body.scrollWidth;
}

function openWin(name, width, height)
{
  win = window.open(name,'','top=' + (screen.height/2 - height/2) + ',left=' +
             (screen.width/2 - width/2) + ',width='+width+',height='+height+
              'status=no,toolbar=no,menubar=no,scrollbars=no');
  return win;
}
function openScrlWin(name, width, height)
{
  win = window.open(name,'','top=10,left=' +
             (screen.width/2 - width/2) + ',width='+width+',height='+height+
              'status=no,toolbar=no,menubar=no,scrollbars=yes');
  return win;
}
//------------------------------------------------------------------------
function cdate(str_date)
{
   this.calObj = null;
   this.navObj = null;
   this.targetField = null;
   this.year = str_date.substr(0, 4);
   this.month = str_date.substr(5, 2);
   this.day = str_date.substr(8, 2);

   this.define_tf = define_tf;
   this.draw = draw_tt;
   this.show = show_tt;
   this.hide = hide_tt;
   this.set = set_tt;
 }
 function define_tf(targetField)
 {
    this.targetField = targetField;
 }
 function draw_tt()
 {
   document.write('<div id="myCalendar" style="top:0;position:absolute;visibility:hidden">' +
      '<table border="1" bordercolor="00004b" cellspacing="0" cellpadding="3">' +
          '<tr><td bgcolor="#dddddd"><OBJECT style="left: 0px; top: 0px" classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02" id="TimeTable">'+
                '<PARAM NAME="_Version" VALUE="524288">' +
                '<PARAM NAME="_ExtentX" VALUE="7620">' +
                '<PARAM NAME="_ExtentY" VALUE="5080">' +
                '<PARAM NAME="_StockProps" VALUE="1">' +
                '<PARAM NAME="BackColor" VALUE="-2147483633">' +
                '<PARAM NAME="Year" VALUE="' + this.year + '">' +
                '<PARAM NAME="Month" VALUE="' + this.month + '">' +
                '<PARAM NAME="Day" VALUE="' + this.day + '">' +
                '<PARAM NAME="DayLength" VALUE="1">' +
                '<PARAM NAME="MonthLength" VALUE="2">' +
                '<PARAM NAME="DayFontColor" VALUE="0">' +
                '<PARAM NAME="FirstDay" VALUE="2">' +
                '<PARAM NAME="GridCellEffect" VALUE="1">' +
                '<PARAM NAME="GridFontColor" VALUE="10485760">' +
                '<PARAM NAME="GridLinesColor" VALUE="-2147483632">' +
                '<PARAM NAME="ShowDateSelectors" VALUE="1">' +
                '<PARAM NAME="ShowDays" VALUE="-1">' +
                '<PARAM NAME="ShowHorizontalGrid" VALUE="1">' +
                '<PARAM NAME="ShowTitle" VALUE="1">' +
                '<PARAM NAME="ShowVerticalGrid" VALUE="1">' +
                '<PARAM NAME="TitleFontColor" VALUE="000000">' +
                '<PARAM NAME="ValueIsNull" VALUE="0">' +
             '</OBJECT>' +
             '</td>' +
          '</tr>' +
          '<tr>' +
             '<td align=right bgcolor="#dddddd">' +
                '<a class="blue" href="javascript:__chDate()">Задать</a>' +
                '<a class="del" href="javascript:__hideCalendar()">Отмена</a>' +
             '</td>' +
          '</tr></table></div>');

     this.calObj = document.all.TimeTable;
     this.navObj = document.all.myCalendar;
   }
   function __chDate()
   {
      date_tt.set();
   }
   function __hideCalendar()
   {
      date_tt.hide();
   }
   function set_tt()
   {
      this.targetField.value = this.calObj.Year + "-" +
           this.calObj.Month + "-" + this.calObj.Day;
      this.hide();
   }
   function hide_tt()
   {
      this.navObj.style.visibility = "hidden";
      this.navObj.style.display = "none";
   }
   function show_tt(x, y)
   {
      this.navObj.style.visibility = "visible";
      this.navObj.style.display = "block";
      this.navObj.style.left = x;
      this.navObj.style.top = y;
   }
// -----------------------------------------------------------------------
  fontsArray = new Array("Arial", "Arial Black", "Arial Narrow", "Book Antiqua",
   "Century Gothic", "Comic Sans MS", "Courier New", "Fixedsys",
   "Franklin Gothic Medium", "Garamond", "Georgia", "Impact", "Lucida Console",
   "Lucida Sans Unicode", "Microsoft Sans Serif", "Palatino Linotype", "System",
   "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");

  colorsArray = new Array("Black", "Sienna", "DarkOliveGreen", "DarkGreen",
   "DarkSlateBlue", "333366", "Navy", "666699", "Indigo", "DarkSlateGray", "DarkRed", "DarkOrange",
   "Olive", "Green", "Teal", "Blue", "SlateGray", "DimGray", "Red", "SandyBrown",
   "YellowGreen", "SeaGreen", "RoyalBlue", "Purple", "Gray",
   "Magenta", "Orange", "Yellow", "Lime", "Cyan", "DeepSkyBlue", "DarkOrchid",
   "Silver", "Pink", "Wheat", "LemonChiffon", "PaleGreen", "PaleTurquoise",
   "Plum", "White");

   function CColorPallete(id, current_color, width)
   {
      var ch = "";
      document.write("<select size='1' name='" + id + "' style='width:"+width+"'>");
      for(var iCounter = 0; iCounter < colorsArray.length; iCounter++)
      {
          if(current_color == colorsArray[iCounter]) ch = " selected"; else ch = "";
          document.write("<option value='" + colorsArray[iCounter] + "' "+ch+" style='BACKGROUND-COLOR:" + colorsArray[iCounter] + "'>&nbsp;&nbsp;&nbsp;</option>");
      }
      document.write("</select>");
   }

   function CFontPallete(id, current_font, width)
   {
      var ch = "";
      document.write("<select size='1' name='" + id + "' style='width:"+width+"'>");
      for(var iCounter = 0; iCounter < fontsArray.length; iCounter++)
      {
          if(current_font == fontsArray[iCounter]) ch = " selected"; else ch = "";
          document.write("<option value='" + fontsArray[iCounter] + "' "+ch+" style='font-family:" + fontsArray[iCounter] + "'>" + fontsArray[iCounter] + "</option>");
      }
      document.write("</select>");
   }

    var str_login = "Логин";
    var str_password = "Пароль";
    var str_search = "Введите строку";

    function LoginOnFocus(state)  // state = 1 - фокусировка
    {
        if(state) {
          if(auto.login.value == str_login) auto.login.value = "";
          }

        else {
          if(auto.login.value == "") auto.login.value = str_login; }
    }

    function PasswordOnFocus(state)  // state = 1 - фокусировка
    {
        if(state) {
          if(auto.password.value == str_password) auto.password.value = "";
          }

        else {
          if(auto.password.value == "") auto.password.value = str_password; }
    }
    function SearchOnFocus(state)  // state = 1 - фокусировка
    {
        if(state) {
          if(search_form.search_str.value == str_search) search_form.search_str.value = ""; }

        else {
          if(search_form.search_str.value == "") search_form.search_str.value = str_search; }
    }
  function edit_client()
  {
      window.location = "user.php?edit=1";
  }
    function exit()
    {
        window.location = "index.php?exit_user=1";
    }
    function fogot_passw()
    {
        var login_user = "";
        if(auto.login.value != str_login) login_user = auto.login.value;

        window.location = "user.php?fp=1&login=" + login_user;
    }
    function regis()
    {
        parent.ViewElement.path = "Регистрационная форма";
        parent.ViewElement.location = "regis.php";
        parent.ViewElement.locate();
    }
    function wscrn()
    {
        sw = screen.width;
        if(sw < 810)
        {
            midtab.width = 800;
            headtab.width = 800;
            bottab.width = 800;
        }
        else
        {
            midtab.width = 970;
            headtab.width = 970;
            bottab.width = 970;
        }
    }
