
var mozrequest='';
var request='';
var vklrequest='';
function $(id){
	return document.getElementById(id);
}

function createRequestV() {
	try {
		vklrequest = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			vklrequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
		try {
			vklrequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			vklrequest = false;
		}
		}
	}

	if (!vklrequest)
		alert("Error initializing XMLHttpRequest!");
}


function close_open(id,id_img){
createRequestV();

var t=0;

		

	var dis = $(id).style.display;
	if (dis == 'none'){
	t=0;
		$(id).style.display = '';
		$(id_img).src = '/i/close.gif';
	}else{
		t=1;
		$(id).style.display = 'none';
		$(id_img).src = '/i/open.gif';
	}

var url = "/closeopen/?pageid="+pageid+"&name="+id+"&nnn="+Math.floor(Math.random()*1000000);
        vklrequest.open("GET", url, true);
        vklrequest.send(null);
}
function sost(){
if (vklrequest.readyState==4) {

        if (vklrequest.status==200){
   alert(vklrequest.responseText);
   }
 }
}
function rurl(url){
arr=url.split('http://cementnik.ru/');
url=arr.join('');
arr=url.split('http://www.cementnik.ru/');
url=arr.join('');
return url;
}
function torg_table_over(obj){
	obj.style.backgroundColor = '#5AB9FB';
}

function torg_table_out(obj){
	obj.style.backgroundColor = '#ffffff';
}

function zam(){
	var from = $('from').value;
	$('from').value = $('to').value;
	$('to').value = from;
}
function addcont(){
$('contactlabel').style.display='';
$('add_friend').style.display='';
$('svlabel').style.display='none';
$('sv').style.display='none';
$('kontlabel').style.display='none';
$('kont').style.display='none';
$('proflabel').style.display='none';
$('prof').style.display='none';
}
function otmcont(){
$('contactlabel').style.display='none';
$('add_friend').style.display='none';
$('svlabel').style.display='';
$('sv').style.display='';
$('kontlabel').style.display='';
$('kont').style.display='';
$('proflabel').style.display='';
$('prof').style.display='';
}
function createRequest() {
	try {
		request = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
		try {
			request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			request = false;
		}
		}
	}

	if (!request)
		alert("Error initializing XMLHttpRequest!");
}
function createRequestmoz() {
	try {
		mozrequest = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			mozrequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
		try {
			mozrequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			mozrequest = false;
		}
		}
	}

	if (!mozrequest)
		alert("Error initializing XMLHttpRequest!");
}


function getmessages() {
createRequest();


var url = "/newmessage/?nnn="+Math.floor(Math.random()*1000000);
		
        request.open("GET", url, true);
        request.onreadystatechange=vivod;
        request.send(null);
}	
function vivod(){
if (request.readyState==4) {

        if (request.status==200){
        var txt = request.responseText;
       
        arr=txt.split(';');
  
        
        
        if ((arr[0]-0)>0){
	   $('pochta').innerHTML=arr[0]+'  '+newsklon(arr[0]);
	   if (arr[3]=='0'){ $('pochtaadm').innerHTML=arr[0]+'  '+newsklon(arr[0]);
	   $('notadm').style.display="none";
	   $('adm').style.display="";
         } else {
       $('notadm').style.display="";
	   $('adm').style.display="none";
       }
           }
	   else  $('pochta').innerHTML='';
	 if ((arr[1]-0)>0){
	   $('guests').innerHTML=arr[1]+'  '+newsklon(arr[1]);
           }
	   else  $('guests').innerHTML='';
	 if ((arr[2]-0)>0){
	   $('zayav').innerHTML=arr[2]+'  '+newsklon(arr[2]);
           }
	   else  $('zayav').innerHTML='';    
     
  }            
 }



}
function getFilesServ(id) {

createRequestmoz();


var url = "/getfiles/"+id+"/?nnn="+Math.floor(Math.random()*1000000);
		
        mozrequest.open("GET", url, true);
        mozrequest.onreadystatechange=vivodfilesServ;
        mozrequest.send(null);
}	
function vivodfilesServ(){
var form='';

if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
        var txt = mozrequest.responseText;
        spisok=txt.split(';');
    form+='<ul>';
    for (i=0;i<spisok.length-1;i++){
   var a=spisok[i].split('+');

   form+='<li style="list-style:none;vertical-align:top;">';
   ras=a[0].split('.');
	if (ras[1] == 'doc'){
		form+='<div style="float:left;clear:left;margin-top:5px"><img src="/i/doc.gif" style="width:44px;height:49px" /></div>';
	}
	if (ras[1] == 'xls'){
		form+='<div style="float:left;clear:left;margin-top:5px"><img src="/i/xsl.gif" style="width:42px;height:49px"/></div>';
	}
	if (ras[1] == 'rar'){
		form+='<div style="float:left;clear:left;margin-top:5px"><img src="/i/rar.gif" style="width:32px;height:24px"/></div>';
	}
	if (ras[1] == 'pdf'){
		form+='<div style="float:left;clear:left;margin-top:5px"><img src="/i/pdf.gif" style="width:45px;height:46px"/></div>';
	}
	if (ras[1] == 'jpg' || ras[1] == 'jpeg'){
		form+='<div style="float:left;clear:left;margin-top:5px"><img src="/i/jpg.gif" style="width:37px;height:47px" /></div>';
	}
   form+='<div style="vertical-align:top;float:left;margin-top:15px"><a href="#" onClick="zapolndocs('+a[2]+',this.innerHTML,'+a[3]+');window.close();">'+a[0]+'</a><br/>';
   form+='<div style="margin-top:5px">'+Math.round(a[1])+'  '+'килобайта</div></div>';
form+='</li>';

    
    }
form+='</ul>';
document.getElementById('docsvivod').innerHTML='';
document.getElementById('docsvivod').innerHTML=form;

    
     
  }            
 }
}
function zapolndocs(user,file,idfile){

window.opener.document.getElementById('docserv').value='/docs/'+user+'/'+file;
window.opener.document.getElementById('docservid').value=idfile;



}

function getFiles(id) {

createRequestmoz();


var url = "/getfiles/"+id+"/?nnn="+Math.floor(Math.random()*1000000);
		
        mozrequest.open("GET", url, true);
        mozrequest.onreadystatechange=vivodfiles;
        mozrequest.send(null);
}	
function vivodfiles(){
var form='';

if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
        var txt = mozrequest.responseText;
        spisok=txt.split(';');
    form+='<ul>';
    for (i=0;i<spisok.length-1;i++){
   var a=spisok[i].split('+');

   form+='<li style="list-style:none;vertical-align:top;width:400px">';
   ras=a[0].split('.');
	if (ras[1] == 'doc'){
		form+='<div style="float:left;margin-left:20px;clear:left;margin-top:25px"><img src="/i/doc.gif" style="width:44px;height:49px" /></div>';
	}
	if (ras[1] == 'xls'){
		form+='<div style="float:left;margin-left:20px;clear:left;margin-top:5px"><img src="/i/xsl.gif" style="width:42px;height:49px"/></div>';
	}
	if (ras[1] == 'rar'){
		form+='<div style="float:left;margin-left:20px;clear:left;margin-top:5px"><img src="/i/rar.gif" style="width:32px;height:24px"/></div>';
	}
	if (ras[1] == 'pdf'){
		form+='<div style="float:left;margin-left:20px;clear:left;margin-top:5px"><img src="/i/pdf.gif" style="width:45px;height:46px"/></div>';
	}
	if (ras[1] == 'jpg' || ras[1] == 'jpeg'){
		form+='<div style="float:left;margin-left:20px;clear:left;margin-top:5px"><img src="/i/jpg.gif" style="width:37px;height:47px" /></div>';
	}
   form+='<div style="vertical-align:top;margin-left:20px;float:left;margin-top:15px;width:300px"><a href="/docs/'+a[2]+'/'+a[0]+'">'+a[0]+'</a><br/>';
   form+='<div style="margin-top:5px">'+Math.round(a[1])+'  '+'килобайта</div><div style="margin-top:5px;"><a href="/delfile/'+a[3]+'/">Удалить</a></div></div>';
form+='</li>';

    
    }
form+='</ul>';

document.getElementById('docsvivod').innerHTML='';
document.getElementById('docsvivod').innerHTML=form;

    
     
  }            
 }
} 
function reminder(){
if (confirm('Вы хотите восстановить пароль ?')){
createRequestmoz();

var email=$('loginauth1').value;
if (email==''){ alert('Введите логин в поле');} else {
var url = "/reminder/?email="+email+"&nnn="+Math.floor(Math.random()*1000000);


		
        mozrequest.open("GET", url, true);
        mozrequest.onreadystatechange=vivodreminder;
        mozrequest.send(null);
        }
  }
}	
function vivodreminder(){
var form='';

if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
        alert('Ваш новый пароль отправлен на электронную почту');
  

    
     
  }            
 }
}

function renFolders() {
id=document.getElementById('tekpapka').value;
nazv=document.getElementById('nazvfolderren').value;
createRequestmoz();

var url = "/renfolder/"+id+"/?nazv="+nazv+"&nnn="+Math.floor(Math.random()*1000000);

        mozrequest.open("GET", url, true);
     //   mozrequest.onreadystatechange=vivodadded;
        mozrequest.send(null);
}	
function renamefolders(objid) {
id=objid.split('nazv')[1];
nazv=document.getElementById(objid).value;
createRequestmoz();

var url = "/renfolder/"+id+"/?nazv="+nazv+"&nnn="+Math.floor(Math.random()*1000000);

        mozrequest.open("GET", url, true);
     //   mozrequest.onreadystatechange=vivodadded;
        mozrequest.send(null);
}
function addFolders() {
id=document.getElementById('tekpapka').value;
nazv=document.getElementById('nazvfolder').value;
createRequestmoz();

var url = "/addfolder/"+id+"/?nazv="+nazv+"&nnn="+Math.floor(Math.random()*1000000);

        mozrequest.open("GET", url, true);
        mozrequest.onreadystatechange=vivodadded;
        mozrequest.send(null);
}	
function delFolders(id) {
if (confirm('Вы действительно хотите удалить папку?')){

createRequestmoz();

var url = "/delfolder/"+id+"/?nnn="+Math.floor(Math.random()*1000000);

        mozrequest.open("GET", url, true);
       // mozrequest.onreadystatechange=vivodadded;
        mozrequest.send(null);
  //  document.getElementById('folder'+id).style.display='none';
 document.getElementById('doc_form').submit();
        }
}


function vivodadded(){
var form='';
if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
        var txt = mozrequest.responseText;
        
        spisok=txt.split(';');
        id=spisok[2];
        nazv=spisok[0];
        id_parent=spisok[1];
 form+='<LI>';
 form+='<SPAN  style="color:#000000;font-size:11px;margin-left:0px" class="folder" onClick="getFiles('+id+');getElementById(\'tekpapka\').value='+id+';"><SPAN style="margin-left:20px">'+nazv+'</SPAN></SPAN>';
 form+='<UL id="fold'+id+'">';
 form+=	'</UL>';
 form+= '</LI>';
	       
var str=document.getElementById('fold'+id_parent).innerHTML; 
if (id_parent==0) document.getElementById('example').innerHTML; else
document.getElementById('fold'+id_parent).innerHTML=str+form;	
     
  }            
 }
} 

var timerID = null;
var TimerRunning = false;
var x=0;
x=x-0;
var schet=0;
var usp=0;
var timertime=0;
function stopclock () {
if(TimerRunning) clearTimeout(timerID);
TimerRunning = false;
}
function startclock() {

stopclock();
getmessages();

otprav();
}
function otprav () {
timerID = setTimeout("startclock()",30000);
TimerRunning = true;
}
function newsklon(param){
if ((param==1)||((param%10==1)&&(param!=11))||((param%100!=11)&&(param%10==1))) var word='новое'; else
var word='новых';
return word;

}	
function poisk(){
createRequestmoz();
var family=$('family').value;
var imya=$('imya').value;
var nazv=$('nazv').value;
var url = "/poisktext/?family="+family+"&imya="+imya+"&nazv="+nazv+"&nnn="+Math.floor(Math.random()*1000000);
   mozrequest.open("GET", url, true);
      mozrequest.onreadystatechange=poiskfunc;
       mozrequest.send(null);
}	

function poiskfunc(){
var i=0;
var form='<div id="page1" name="p"><table style="width:100%;"><tr><td style="width:25%; text-align:center; vertical-align:bottom">';

if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
         var txt = mozrequest.responseText;

        
       var spisok=txt.split(';');
	   kol_page=1;
	   k=1;
       for (i=0;i<spisok.length-1;i++){
			var a=spisok[i].split('+');
			//alert(a);
			if (a[4]!='1'){
				if (a[3] != ''){
					form+='<div><a href="/profile/'+a[0]+'/"><img src="/i/'+a[3]+'" border="0"/></a></div>';
				}else{
					form+='<div><a href="/profile/'+a[0]+'/"><img src="/i/user_foto.gif" border="0"/></a></div>';
				}
			}else{
				form+='<div><a href="/profile/'+a[0]+'/"><img src="/i/block.jpg" border="0"/></a></div>';
			}
			if ((k)%4 == 0){
				form+='<div><a href="/profile/'+a[0]+'/" style="color:#515251;">'+a[1]+'  '+a[2]+' </a></div></td></tr><tr><td style="padding-top:30px; width:25%; text-align:center; vertical-align:bottom">';
			}else{
				form+='<div><a href="/profile/'+a[0]+'/" style="color:#515251;">'+a[1]+'  '+a[2]+' </a></div></td><td style="padding-top:30px; width:25%; text-align:center; vertical-align:bottom">';
			}
           
			k++;
			if ((i+1)%12 == 0 && (i+1) != spisok.length-1){
				page=((i+1)/12)+1;
				form+='</td></tr></table></div><div id="page'+page+'" style="display:none;" name="p"><table style="width:100%;"><tr><td style="width:25%; text-align:center; vertical-align:bottom">';
				kol_page++;
				k=1;
			}
           }
			form+='</td></tr></table></div>';
			if (kol_page > 1){
				form+='<div style="text-align:center; margin-top:15px;">';
				for (i=1;i<=kol_page;i++){
					if (i==1){
						form+='<span style=""><a id="page'+i+'_a" onClick="view_page(\'page'+i+'\',\''+kol_page+'\')" style="font-weight:normal; text-decoration:none; margin-left:20px;">'+i+'</a></span>';
					}else{
						form+='<span style=""><a id="page'+i+'_a" onClick="view_page(\'page'+i+'\',\''+kol_page+'\')" style="font-weight:normal; text-decoration:underline; cursor:pointer; margin-left:20px;">'+i+'</a></span>';		
					}
				}
				form+='</div>';
			}
			//alert(form);
		   $('vivodtd').style.display='';
           $('vivoddiv').innerHTML='';
           $('vivoddiv').innerHTML=form;
                 
         } 
         
      }
}

function getElementPosition(elemId){
	var elem = typeof elemId == 'object' ? elemId : $(elemId);
	var w = elem.offsetWidth;
	var h = elem.offsetHeight;
	var l = 0;
	var t = 0;
	while (elem){
		l += elem.offsetLeft;
		t += elem.offsetTop;
		elem = elem.offsetParent;
	}
	return {"left":l, "top":t, "width": w, "height":h};
}
function poiskreg(){
createRequestmoz();
var region=$('region').value;

var url = "/regions/?region="+encodeURI(region)+"&nnn="+Math.floor(Math.random()*1000000);

   mozrequest.open("GET", url, true);
      mozrequest.onreadystatechange=poiskregfunc;
       mozrequest.send(null);
  
}	

function poiskregfunc(){
var i=0;
var id='divsp';
if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
         var txt = mozrequest.responseText;
         var b = getElementPosition('region'); 
var form='<table cellspacing="0" cellpadding="0" style="border:1px solid #000000">'
        
       var spisok=txt.split(';');
for (i=0;i<spisok.length-1;i++){
a=spisok[i].split('+');
 	form+='<tr   style="background:#FFFFFF;" class="cp"   onmouseover=" this.style.background=\'#555555\'; this.style.color=\'#FFFFFF\';" onmouseout="this.style.background=\'#ffffff\'; this.style.color=\'#000000\';" onClick="$(\'divsp\').style.display=\'none\';$(\'region\').value=\''+a[1]+'\';GUnload();map_load(\''+a[0]+'\',\'all\',\'\');" ><td style="font-size:11px; width:127px;">'+a[1]+'</td>';
					


            }
     form+='</table>';              
         $(id).style.left=b.left+'px';
			$(id).style.top=b.top+b.height-1+'px';
			$(id).style.width=b.width-2+'px';
			$(id).style.borderTop='0px';
		
	
			//alert(res);
			$(id).style.position = 'absolute';
			$(id).style.display='';
			$(id).style.zIndex="110";
		    $(id).background='#FFFFFF';
			$(id).innerHTML = form;
         
         } 
         
      }
}
function poiskregfact(){
createRequestmoz();
var region=$('region').value;
if (region.length>0){
var url = "/regions/?region="+encodeURI(region)+"&nnn="+Math.floor(Math.random()*1000000);

   mozrequest.open("GET", url, true);
      mozrequest.onreadystatechange=poiskregfuncfact;
       mozrequest.send(null);
  }
}	

function poiskregfuncfact(){
var i=0;
var id='divsp';
if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
         var txt = mozrequest.responseText;
         
         var b = getElementPosition('region'); 
var form='<table cellspacing="0" cellpadding="0" style="border:1px solid #000000">'
        
       var spisok=txt.split(';');
for (i=0;i<spisok.length-1;i++){
a=spisok[i].split('+');
 	form+='<tr   style="background:#FFFFFF;" class="cp"   onmouseover=" this.style.background=\'#555555\'; this.style.color=\'#FFFFFF\';" onmouseout="this.style.background=\'#ffffff\'; this.style.color=\'#000000\';" onClick="$(\'divsp\').style.display=\'none\';$(\'region\').value=\''+a[1]+'\';GUnload();map_load(\''+a[0]+'\',\'factories\',\'\',\''+tid+'\');" ><td style="font-size:11px; width:127px;">'+a[1]+'</td>';
					


            }
     form+='</table>';              
         $(id).style.left=b.left+'px';
			$(id).style.top=b.top+b.height-1+'px';
			$(id).style.width=b.width-2+'px';
			$(id).style.borderTop='0px';
		
	
			//alert(res);
			$(id).style.position = 'absolute';
			$(id).style.display='';
			$(id).style.zIndex="110";
		    $(id).background='#FFFFFF';
			$(id).innerHTML = form;
         
         } 
         
      }
}

function poiskregyafact(){
createRequestmoz();
var region=$('region').value;
if (region.length>0){
var url = "/regions/?region="+encodeURI(region)+"&nnn="+Math.floor(Math.random()*1000000);

   mozrequest.open("GET", url, true);
      mozrequest.onreadystatechange=poiskregfuncyafact;
       mozrequest.send(null);
  }
}	

function poiskregfuncyafact(){
var i=0;
var id='divsp';
if (mozrequest.readyState==4) {

        if (mozrequest.status==200){
         var txt = mozrequest.responseText;
         var b = getElementPosition('region'); 
var form='<table cellspacing="0" cellpadding="0" style="border:1px solid #000000">'
        
       var spisok=txt.split(';');
for (i=0;i<spisok.length-1;i++){
a=spisok[i].split('+');
 	form+='<tr   style="background:#FFFFFF;" class="cp"   onmouseover=" this.style.background=\'#555555\'; this.style.color=\'#FFFFFF\';" onmouseout="this.style.background=\'#ffffff\'; this.style.color=\'#000000\';" onClick="$(\'divsp\').style.display=\'none\';$(\'region\').value=\''+a[1]+'\';map_load(\'\',\'factories\',\''+a[0]+'\',\''+tid+'\');" ><td style="font-size:11px; width:127px;">'+a[1]+'</td>';
					


            }
     form+='</table>';              
         $(id).style.left=b.left+'px';
			$(id).style.top=b.top+b.height-1+'px';
			$(id).style.width=b.width-2+'px';
			$(id).style.borderTop='0px';
		
	
			//alert(res);
			$(id).style.position = 'absolute';
			$(id).style.display='';
			$(id).style.zIndex="110";
		    $(id).background='#FFFFFF';
			$(id).innerHTML = form;
         
         } 
         
      }
}


function view_page(id,kol){
	for (i=1;i<=kol;i++){
		$('page'+i).style.display='none';
		$('page'+i+'_a').style.textDecoration='underline';
		$('page'+i+'_a').style.cursor='pointer';
	}
	$(id).style.display='';
	$(id+'_a').style.textDecoration='none';
	$(id+'_a').style.cursor='text';
}

function select_naim(){
	sec = $('section').value;
	$('nach_naim').style.display='none';
	naim = document.getElementsByName('naim');
	for (i=0; i<naim.length; i++){
		id = naim[i].id.split('_');
		if (id[1] == sec){
			naim[i].style.display='';
		}else{
			naim[i].style.display='none';
		}
	}
}

function select_spec(id){
	naim = $(id).value;
	$('nach_spec').style.display='none';
	spec = document.getElementsByName('spec');
	for (i=0; i<spec.length; i++){
		id_s = spec[i].id.split('_');
		if (id_s[1] == naim){
			spec[i].style.display='';
		}else{
			spec[i].style.display='none';
		}
	}
	$('id2').value=$(id).value;
}

function select_id3(id){
	$('id3').value=$(id).value;
}

function select_usl(){
	usl = document.getElementsByName('usl');
	for (i=0; i<usl.length; i++){
		check = usl[i].checked;
		if (check){
			$('id9').value = usl[i].value;
		}
	}
}

function select_type(){	
	type=$('type').value;
	if (type == 'Предложение'){
		$('operation_type').value = type;
		$('spros').style.display='none';
	}else{
		$('spros').style.display='';
	}
	/*type = document.getElementsByName('type');
	for (i=0; i<type.length; i++){
		check = type[i].checked;
		if (check){
			if (type[i].value == 'Предложение'){
				$('operation_type').value = type[i].value;
				$('spros').style.display='none';
			}else{
				$('spros').style.display='';
			}
		}
	}*/
}

function select_spros(){
	$('operation_type').value = $('s_spros').value;
}

function quote(id,uid){

if (uid){
	str = $(id).innerHTML;
	//
	//$('msg').focus();
	//$('msg').style.display='';
	$('newmessage').style.display='none';
	if ($('cit'))  $('cit').value='<<<'+str+'>>>';
	//$('newmessage').style.display='';
	//$('msg').innerHTML='666666666';
	//$('msg').value='6666666';
	//alert('2222223');
}else{
	alert('Авторизуйтесь!');
	return false;
}
}

function newforumm(uid){
	if (uid){
	document.getElementById('newmessage').style.display='inline';
	document.getElementById('msg').focus();
	}else{
		alert('Авторизуйтесь!');
		return false;
	}
}

function newtema(uid){
	if (uid){
	document.getElementById('newmessage').style.display='';
		return false;
	}else{
		alert('Авторизуйтесь!');
	}
}

function newssectionsave(){
arr=new Array();
var nameparam='';
arr=document.getElementsByTagName('input');

for (i=0;i<arr.length;i++){

if ((document.getElementsByTagName('input')[i].type=="checkbox")&&(document.getElementsByTagName('input')[i].id.split('_').length>1)&&(document.getElementsByTagName('input')[i].checked)){

nameparam+=document.getElementsByTagName('input')[i].id+';';
}
}

$('newshid').value=nameparam;
}
function regionsave(){
arr=new Array();
var nameparam='';
arr=document.getElementsByTagName('input');

for (i=0;i<arr.length;i++){

if ((document.getElementsByTagName('input')[i].type=="checkbox")&&(document.getElementsByTagName('input')[i].id.split('_').length>1)&&(document.getElementsByTagName('input')[i].checked)){

nameparam+=document.getElementsByTagName('input')[i].id+';';
}
}

$('regions').value=nameparam;
}

function  delmessage(id){
if (confirm('Хотите удалить сообщение?')) {

createRequestmoz();

var url = "/delmessage/"+id+"/?nnn="+Math.floor(Math.random()*1000000);

        mozrequest.open("GET", url, true);
       // mozrequest.onreadystatechange=vivodadded;
        mozrequest.send(null);
        $('tr'+id).style.display='none';
        }

}

function open_param(){
	d=$('dop').style.display;
	if (d == 'none'){
		$('dop').style.display='';
	}else{
		$('dop').style.display='none';
	}
}

function add2(){
	v=$('operation_type').value;
	if (v==''){
		$('operation_type').value=$('s_spros').value;
	} 
}
function funcdop(){
if ($('pred1').style.display=='none'){
$('pred1').style.display='';
$('dolg1').style.display='';
$('vr1').style.display='';
$('vrpo1').style.display='';
} else { if ($('pred2').style.display=='none'){
$('pred2').style.display='';
$('dolg2').style.display='';
$('vr2').style.display='';
$('vrpo2').style.display='';
}  else { if ($('pred3').style.display=='none'){
$('pred3').style.display='';
$('dolg3').style.display='';
$('vr3').style.display='';
$('vrpo3').style.display='';
$('addcomp').style.display='none';
  } 
 }
}

}
function vspldiv(typenum){
	var body_tag = document.getElementsByTagName("body")[0];
	var child_div = document.getElementById("link_div");
	
    if (child_div != null) {
		removeElement(1);
	} else {  
		child_div = document.createElement('div'); 
		child_div.setAttribute('id','link_div'); 
		child_div.style.position = "absolute";
		child_div.style.left = "502px";
		child_div.style.top = "329px";
		//child_div.style.border = "1px solid black";
		//child_div.style.backgroundColor = "white";
		child_div.style.width = "225px";
		child_div.innerHTML = "<table width='100%' cellpadding='0' cellspacing='0'><tr><td class='pr_t_l'></td><td class='pr_t' style='background-color:#ffffff;'><img src='/i/0.gif' style='width:1px; height:1px;'/></td><td class='pr_t_r'></td></tr><tr><td class='pr_l' style='background-color:#ffffff;'><img src='/i/0.gif' style='width:1px; height:1px;'/></td><td class='pr_c' style='background-color:#ffffff;'><span style='float:left;margin:0px 0px 0px 3px;'><a href='/lotsmap/"+typenum+"/' style='color:#515251;'>Перейти на большую карту</a> </span><a onClick='getElementById(\"link_div\").style.display=\"none\";' style='float:right;'><img src='/i/close_add.gif'/></a><br/></span></td><td class='pr_r' style='background-color:#ffffff;'><img src='/i/0.gif' style='width:1px; height:1px;'/></td></tr><tr><td class='pr_b_l'></td><td class='pr_b' style='background-color:#ffffff;'><img src='/i/0.gif' style='width:1px; height:1px;'/></td><td class='pr_b_r'></td></tr></table>"; 
		body_tag.appendChild(child_div); 

 }
}

function add_favorite(a){
	title=document.title; url=document.location; 
	try { // Internet Explorer 
		window.external.AddFavorite(url, title); 
	} catch (e) { 
		try { // Mozilla 
			window.sidebar.addPanel(title, url, ""); 
		} catch (e) { // Opera 
			if (typeof(opera)=="object"){ 
				a.rel="sidebar"; 
				a.title=title; 
				a.url=url; 
				return true; 
			} else { // Unknown 
				alert('Нажмите Ctrl-D чтобы добавить страницу в закладки'); 
				} 
			} 
		} 
	return false; 
} 

function showPassInput(){
	$('passT').style.display='none';
	$('pass').style.display='';
	$('pass').focus();
}

function lotP(p,kol){
	id='page'+(p-1);
	id_a='page'+(p-1)+'_a'
	for (i=0; i<kol; i++){
		if (p-1 == i){
			$(id).style.display='';
			$(id_a).style.textDecoration='none';
			$(id_a).style.cursor='text';
		}else{
			r='page'+i;
			r_a='page'+i+'_a';
			$(r).style.display='none';
			$(r_a).style.textDecoration='underline';
			$(r_a).style.cursor='pointer';
		}
	}
}

function openImport(){
	im=$('import').style.display;
	if (im=='none'){
		$('import').style.display='';
	}else{
		$('import').style.display='none';
	}
}

function vidAll(){
	f=document.getElementsByTagName('input');
	all=$('all').checked;
	if (all==true){
		for (i=0; i<f.length; i++){
			f[i].checked=true;
		}
	}else{
		for (i=0; i<f.length; i++){
			f[i].checked=false;
		}
	}
}

function delVid(){
	f=document.getElementsById('friend');
	for (i=0; i<f.length; i++){
		if (f[i].checked){
			itemid=f[i].name;
			id=itemid.split('item');
		}
	}
}
function newaddress(){
var st=$('polyadiv').innerHTML;
var index=$('polyadiv').getElementsByTagName('input').length+1
var form='<br/><div><input type="text" name="userprig'+index+'" style="width:160px; font-size:12px; font-family:Tahoma; border:2px solid #ff0000; color:#999999;" value="Введите имя получателя" onFocus="if (pol'+index+'==0) ;this.value=\'\';pol'+index+'=1;this.style.color=\'#000000\';" onBlur="this.style.border=\'1px solid #000000\';" /></div>';
	form+='<div style="clear:both;"><input type="text" name="mailprig'+index+'" style="width:160px; font-size:12px; font-family:Tahoma; border:2px solid #ff0000; color:#999999;" value="E-mail получателя" onFocus="if (email'+index+'==0) this.value=\'\';email'+index+'=1;this.style.color=\'#000000\';" onBlur="this.style.border=\'1px solid #000000\';" /></div>';
$('polyadiv').innerHTML=st+form;	
}					
function zamtext(){
var cemtext=$('txt').innerHTML;
var arr=cemtext.split('*Фамилия имя*');
var nnn=arr.join(' '+$('pol').value+' ');

$('txt').innerHTML=nnn;


}
