function del_item(where)
{
	if (confirm("Вы уверены, что хотите удалить данную запись?")){
		document.location.replace(where);
	}
	return false;
}
function truncate(where)
{
	if (confirm("Вы уверены, что хотите переместить все статьи из данной катагории?")){
		document.location.replace(where);
	}
	return false;
}

function setCheckboxes(the_form, the_element, do_check)
{
    var elts      = document.forms[the_form].elements[the_element];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        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;
}

function tableFlashRows(_node, _color)
{
    _node.onmouseover=function()	{}
    list = _node.rows;
    for (var i = 0; i < list.length; i++) {
	list[i].onmouseover=function()	{	this.style["backgroundColor"]= _color;	}
	list[i].onmouseout=function()	{	this.style["backgroundColor"]="";	}
    }
}
/* Внешние ссылки с атрибутом rel="external" */
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		if (anchors[i].getAttribute("href") &&

		anchors[i].getAttribute("rel") == "external") {
			anchors[i].target = "_blank";
		}
	}
}
window.onload = externalLinks;
/* Поле input с исчезающим текстом внутри него */
function InputPlaceholder (input, value, cssFilled, cssEmpty)
{
	var thisCopy = this

	this.Input = input
	this.Value = value
	this.SaveOriginal = (input.value == value)
	this.CssFilled = cssFilled
	this.CssEmpty = cssEmpty

	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keydown', function() {return thisCopy.onKeyDown()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder.prototype.setupEvent = function (elem, eventType, handler)
{
	if (elem.attachEvent)
	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener)
	{
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder.prototype.onFocus = function()
{
	if (!this.SaveOriginal &&  this.Input.value == this.Value)
	{
		this.Input.value = ''
	}
	else
	{
			this.Input.className = this.CssFilled
	}
}

InputPlaceholder.prototype.onKeyDown = function()
{
	this.Input.className = this.CssFilled
}

InputPlaceholder.prototype.onBlur = function()
{
	if (this.Input.value == '' || this.Input.value == this.Value)
	{
		this.Input.value = this.Value
		this.Input.className = this.CssEmpty
	}
	else
	{
		this.Input.className = this.CssFilled
	}
}
function redirect(uri){
	document.location = uri;
}

String.prototype.printAddr =
function (_hamper,_prefix,_postfix,_face)
{
  _hamper=
  _prefix+
  "@"+
  this+
  (_postfix || '')
  document.write((_face||_hamper).link("mailto:"+_hamper));
}
