/**
 * Checks/unchecks all objects
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *                  
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check) {
    var elts = document.forms[the_form].elements['id[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
    	if (elts[0].checked == do_check) do_check=!do_check;
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function

/* Подтвердить удаление */
function confirmLink(theLink, confirmMsg, hrefadd)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += hrefadd; // добавляем подтверждение удаления
    }

    return is_confirmed;
} // end of the 'confirmLink()' function /* */

function expand(id) 
{ 
    whichEl = document.getElementById(id);
    if (whichEl.style.display == "none" || whichEl.style.display=="") 
    {
                whichEl.style.display = "block";
    }
    else 
    {
                whichEl.style.display = "none";
    }
}

function wopen(src, wtitle, width, height){
  myWin= window.open(src, 'big', 'width=550, height=450, toolbar=0, menubar=0, location=0, scrollbars=0, resizable=1');

  // открыть объект document для последующей печати 
  myWin.document.open();
  
  // генерировать новый документ 
  myWin.document.write("<html><head><title>"+ wtitle);
  myWin.document.write("</title></head><body bgcolor=#FFFFC8>\n");
  myWin.document.write("<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%><tr><td valign=middle align=center>");
  myWin.document.write("<a href=\"javascript:close();\"><img border=0 title='Закрыть окно' alt='Закрыть окно' src='"+src+"'><br></a>");
  myWin.document.write("</td></tr></table>");
  myWin.document.write("</body></html>");

  // закрыть документ - (но не окно!)
  myWin.document.close();  
  myWin.focus();
  void(0);
}
