
function hideAll(id)
{
 els = document.getElementsByTagName('div');
 for (i=0; i< els.length; i++)
 {
 if (-1 != els[i].id.indexOf('lai'))
  {
  if (els[i].id == id)
  {
    if(els[i].style.display=='block')  
     els[i].style.display='none';
    else
     els[i].style.display='block';
  }
  else
    els[i].style.display='none';
   }
 }
}
function setbg(theRow, newColor)
{
    var theCells = null;

    if (typeof(document.getElementsByTagName) != 'undefined')
	{
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined')
	{
        theCells = theRow.cells;
    }
    else
	{
        return false;
    }

    var rowCellsCnt  = theCells.length;

	if (typeof(theCells[0].style) != 'undefined')
	{
		for (var c = 0; c < rowCellsCnt; c++)
		{
			theCells[c].style.backgroundColor = newColor;
		}
	}

	return true;
}

function ask(str){
return confirm("Вы действительно хотите удалить "+str+"?");
}

function gmap_show(map_id){
	window.open("/gmap/show/?id="+map_id,"gmap_prewie","width=600, height=360, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no");
	}
	
var preload=new Image();
preload.src="/images/preloader.gif";
	
function notepadadd(elntid,elnttype,elnt){
var div=$(elnt).parent();	
div.html('<img src="/images/preloader.gif"/>');
$.post('/notepad/add/',{id: elntid, type:elnttype},
function(data){
	if(data=="added"){
	var count=$('#notepad_counter').text();
	count++;
	$('#notepad_counter').text(count);
	div.html('<a href="" onclick="notepadremove('+elntid+','+elnttype+',this); return false;" title="удалить из блокнота"><img src="/images/notepad2.png" border="0"/></a>');
	}
},'text');
}

function notepadremove(elntid,elnttype,elnt){
var div=$(elnt).parent();	
div.html('<img src="/images/preloader.gif"/>');	
$.post('/notepad/remove/',{id: elntid, type:elnttype},
function(data){
	if(data=="removed"){
	var count=$('#notepad_counter').text();
	count--;
	$('#notepad_counter').text(count);
	div.html('<a href="" onclick="notepadadd('+elntid+','+elnttype+',this); return false;" title="добавить в блокнот"><img src="/images/notepad.png" border="0"/></a>');
	}
},'text');
}

var captchapicnum=1;
function changecaptcha(){
$("#captchasrc").attr('src',"/contacts/captcha/"+'?'+captchapicnum);
captchapicnum++;
}