
var now_comenting_in=0;var last_comment_shown=0;var comment_allow=0;var names_random=new Array("Прохожий","Домовой","Участковый","Сосед","Домовенок","Сантехник","Монтажник","Знакомый","Зевака","Строитель","Читатель","Писатель","ЖЖшник","Робот","Бабушки","Студент","Проффесор","Ученый","Ламер","Байкер","НЛО","Депутат","Иностранец","Алкоголик");function clearcommenttext(a)
{return"(<a href='javascript:spawn_cament("+a+")'>ответить</a>)";}
function spawn_cament(id)
{comment_allow=aCurrentUser.id>0;$("CommTd_"+last_comment_shown).innerHTML=clearcommenttext(last_comment_shown);last_comment_shown=id;t="<div style='width:100%;padding:5px'>";{teid="MyCommentBy_"+id;t+="<table width=100%><tr valign=top><td ><textarea onfocus='habr_selecttarget(\""+teid+"\")' Id="+teid+" rows=7 style='width:100%;bgcolor:#F0F0F0'></textarea></td>"+"<td align=center width='60px'>"+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_b();          return false;" class="buttn"><img src="editors/img/bold_ru.gif" width="20" height="20" alt=" " title="жирный"></a>'+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_i();          return false;" class="buttn"><img src="editors/img/italic_ru.gif" width="20" height="20" alt=" " title="курсив"></a><BR>'+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_u();          return false;" class="buttn"><img src="editors/img/underline_ru.gif" width="20" height="20" alt=" " title="подчеркнутый"></a>'+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_s();          return false;" class="buttn"><img src="editors/img/strikethrough.gif" width="20" height="20" alt=" " title="зачеркнуть"></a><BR>'+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_link();       return false;" class="buttn"><img src="editors/img/link.gif" width="20" height="20" alt=" " title="вставить ссылку"></a>'+'<a href="javascript:void(0)" onclick="hab_edit_insert_text_blockquote(); return false;" class="buttn"><img src="editors/img/indent.gif" width="20" height="20" alt=" " title="отступ"></a><BR>'+'<a href="javascript:void(0)" onclick="hab_edit_text_undo();              return false;" class="buttn"><img src="editors/img/undo_grey.gif" width="20" height="20" alt=" " title="отменить" id="undoimg"></a>'+"</td>"+"</tr></table>"+"<BR><input Id=MyCommentBy_"+id+"_submit type=button Value='Высказаться' style='font-size:16px' onclick=addcoment("+id+")>";t+="<font style='font-size:9px'></font>";}
if(!comment_allow)
{BN='Строитель';t+=' Представьтесь пожалуйста <input type=text Id=SAnyName Name=SAnyName Value="'+BN+'"> из <u>'+aCurrentUser.fromnaa+'</u>';t+='<BR><table><tr valign=middle><td>и я повторю надпись:</td><td><img src="SECUREKEY.php?rndfor&preBG=F0F0F0"></td><td> ==> </td><td><input maxlength=4 style="width:70px;font-size:18px" Name=SCheck Id=SCheck type=text></td></tr></table>';}
else
{t+="Настроить свое отображаемое имя Вы можете через <a href='http://www.i-stroy.ru/pannel/index.html'>панель управления</a>";t+='<input type=hidden Id=SAnyName Name=SAnyName Value=""><input type=hidden Id=SCheck Name=SCheck Value="">';}
t+='</div>';{$("CommTd_"+id).innerHTML=t;if($("yandex_comments"))
{$("yandex_comments").style.left=getRealOffsetX($("here_def_goes"))+'px';$("yandex_comments").style.top=getRealOffsetY($("here_def_goes"))+'px';$("yandex_comments").style.width=$("here_def_goes").clientWidth+'px';$("yandex_comments").show();}}}
function addcoment(id)
{if(!comment_allow)
{if(!$("SAnyName").value){alert("Назовитесь оригинальнее");return;}
if(!$("SCheck").value){alert("Повторите капчу");return;}}
v=$("MyCommentBy_"+id).value;if(!v)return;if($("yandex_comments"))
$("yandex_comments").hide();$("MyCommentBy_"+id+"_submit").enabled=false;new Ajax.Updater("coment_party",DRR+"loader/coment_updater.php?obj="+now_comenting_in+"&cid="+id,{method:'post',parameters:{'message':v,'Naming':$("SAnyName").value,'secure':$("SCheck").value},encoding:"windows-1251",asynchronous:true,evalScripts:true,onComplete:function(transport){$("CommTd_"+id).innerHTML=clearcommenttext(id);}});$("CommTd_"+id).innerHTML='<img src=imgs/icon/load.gif><BR>...еще секунду и Вас услышат...';}
function make_mapia_text_editor(mid,sec)
{H=parseInt($("content_holder").clientHeight);if(H<200)H=200;H+=20;$("content_holder").innerHTML="<div id=content_target style='padding-bottom:30px;min-height:"+H+"px'>...Идет загрузка редактора...</div>";new Ajax.Updater("content_target",DRR+"editors/mapia_text_editor.php?mid="+mid+"&seq="+sec,{encoding:"windows-1251",asynchronous:true});}
function make_mapia_text_load(mid,seq)
{new Ajax.Updater("content_target",DRR+"loader/mapia_text_show.php?mid="+mid+"&seq="+seq,{encoding:"windows-1251",asynchronous:true});}
function wish_to_add_place()
{if(!aCurrentUser.id)
{alert("Вы должны быть соседом для совершения этой операции");return;}
if(typeof(SubmitEditRectangle)!='undefined')SubmitEditRectangle();else
{fRet=confirm('Активировать режим редактора?');if(fRet)
{var center=geo_map_center;zoom=10;try
{center=geo_map.getCenter();zoom=geo_map.getZoom();}catch(e){}
lat=Math.round(center.y*1000000);lng=Math.round(center.x*1000000);goloc="lat="+lat+"&lng="+lng+"&z="+zoom;window.location.href=DRR+"add/place/index.html#"+goloc;}}}
function nav_add_image(mid)
{if(!aCurrentUser.id)
{alert("Вы должны быть соседом для совершения этой операции");return;}
var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif>';new Ajax.Updater("darkdotinner",DRR+"editors/mapia_image_upload.php?mid="+mid,{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function storm_done()
{$("storm_tag").innerHTML='Зарубленно';$("storm_tag").className='nav_a_S';dark_off();}
function save_this_page()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif><BR>Идет загрузка...';lat=0;lng=0;zoom=0;try
{var center=GetMap().getCenter();lat=Math.round(center.y*1000000);lng=Math.round(center.x*1000000);zoom=GetMap().getZoom();}catch(e){}
yahoo={'class':aCurrentUser.headerInClass,'code':aCurrentUser.headerInObject,'lat':lat,'lng':lng,'zoom':zoom,'title':document.title};new Ajax.Updater("darkdotinner",DRR+"editors/storm_tag.php",{method:'post',parameters:yahoo,encoding:"windows-1251",evalScripts:true,asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function news_rewritescanspore()
{for(i=1;;++i)
{obj=$("newspore"+i);if(!obj)return;obj.href='javascript:popup_newspore('+obj.name.substring(4)+');';}}
function popup_newspore(id)
{if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif><BR>в данный момент я гружу новость :)<BR>';new Ajax.Updater("darkdotinner","loader/newspore.php?content_id="+id,{encoding:"windows-1251",asynchronous:true,evalScripts:true});}
function blog_add_open()
{if(dark_panel_on==0)
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif><BR>Идет загрузка...';new Ajax.Updater("darkdotinner",DRR+"editors/spot_blog.php",{method:'get',encoding:"windows-1251",evalScripts:true,asynchronous:true,onFail:function(){dark_off();alert("непроперло");}});}
else
{if(!window.open(DRR+"editors/spot_blog.php?alone",'Add_Blog_Open','width=450,height=370,toolbar=0,location=0'))
alert('Окошко не открывается :(');}}
function OneAddNewBlog(value,name)
{if(typeof(mycaller)!='undefined'&&typeof(mycaller.OneAddNewBlog)!='undefined'&&this!=mycaller)
mycaller.OneAddNewBlog(value,name);else
{if($("BlogPost"))
{$("BlogPost").options[$("BlogPost").options.length]=new Option(name,value);$("BlogPost").selectedIndex=$("BlogPost").options.length-1;}
else alert("no blogpost");}}
function get_me_in_blog(blogid)
{new Ajax.Request(DRR+"editors/getinblog.php?blogid="+blogid,{evalScripts:true,asynchronous:true});}
function my_favorites(how)
{how=how||0;mpr=$("my_places_ref");mfd=$("my_favorites");if(mfd.style.display==''&&!how)
{mfd.hide();return;}
mfd.style.top=getRealOffsetY(mpr);mfd.style.left=(parseInt(getRealOffsetX(mpr))-60)+'px';mfd.style.width=(parseInt(document.body.clientWidth-getRealOffsetX(mpr))+50)+'px';if(!how)
mfd.innerHTML='<center>Найдется все, со временем</center>'
new Ajax.Updater("my_favorites",DRR+"loader/my_favorites.php",{parameters:{rq:how},method:'post',asynchronous:true,encoding:"windows-1251"});mfd.style.display='';}
function emote_on(id)
{new Ajax.Request(DRR+"loader/emoteon.php?nav_id="+now_comenting_in+"&emote="+id,{evalScripts:true,asynchronous:true,encoding:"windows-1251"})}<!--
var script_comm="// редактор просто взят с харба, потому что хабра - зе бест :)";var mouseY;var textarea_height;var undo='';var quote=false;var habr_selectedtarget="htmlarea";function habr_selecttarget(a){habr_selectedtarget=a;}
function hab_edit_text_undo(){if(undo)$(habr_selectedtarget).value=undo;$("undoimg").src="editors/img/undo_grey.gif";}
function hab_edit_text_save_undo(){undo=$(habr_selectedtarget).value;$("undoimg").src="editors/img/undo.gif";}
function hab_edit_text_clear_undo(){undo='';$("undoimg").src="editors/img/undo_grey.gif";}
function hab_edit_getCursor(input)
{var result={start:0,end:0};if(input.setSelectionRange)
{result.start=input.selectionStart;result.end=input.selectionEnd;}
else if(!document.selection){return 0;}
else if(document.selection&&document.selection.createRange)
{var range=document.selection.createRange();var stored_range=range.duplicate();stored_range.moveToElementText(input);stored_range.setEndPoint('EndToEnd',range);result.start=stored_range.text.length-range.text.length;result.end=result.start+range.text.length;}
return result;}
function hab_edit_setCursor(txtarea,start,end){if(txtarea.createTextRange){var range=txtarea.createTextRange();range.move("character",start);range.select();}else if(txtarea.selectionStart){txtarea.setSelectionRange(start,end);}}
function hab_edit_insert_tag(starttag,endtag){hab_edit_text_save_undo();var txtarea=$(habr_selectedtarget);txtarea.focus();var scrtop=txtarea.scrollTop;var cursorPos=hab_edit_getCursor(txtarea);if(cursorPos.start==cursorPos.end)
{var nuCursorPos=cursorPos.start+starttag.length;txtarea.value=txtarea.value.substring(0,cursorPos.start)+starttag+endtag+txtarea.value.substr(cursorPos.start);hab_edit_setCursor(txtarea,nuCursorPos,nuCursorPos);}
else{var txt_pre=txtarea.value.substring(0,cursorPos.start);var txt_sel=txtarea.value.substring(cursorPos.start,cursorPos.end);var txt_aft=txtarea.value.substring(cursorPos.end);txtarea.value=txt_pre+starttag+txt_sel+endtag+txt_aft;var nuCursorPos=String(txt_pre+starttag+txt_sel+endtag).length;hab_edit_setCursor(txtarea,nuCursorPos,nuCursorPos);}
if(scrtop)txtarea.scrollTop=scrtop;}
function hab_edit_insert_text_quote(){var txtarea=$(habr_selectedtarget);var cur=hab_edit_getCursor(txtarea);if(cur.start!=cur.end){hab_edit_insert_tag("<quote>","</quote>");}
else
{$("quoteimg").src=quote?"http://habrahabr.ru/i/ta/raquo.gif":"http://habrahabr.ru/i/ta/laquo.gif";hab_edit_insert_tag("",quote?"&laquo;":"&raquo;");quote=!quote;}}
function hab_edit_insert_text_mdash(){hab_edit_insert_tag("","&mdash;");}
function hab_edit_insert_text_blockquote(){hab_edit_insert_tag("<blockquote>","</blockquote>");}
function hab_edit_insert_text_b(){hab_edit_insert_tag("<strong>","</strong>");}
function hab_edit_insert_text_img(){$("addimgdiv").style.display="block";}
function hab_edit_insert_text_img_close(){$("addimgdiv").style.display="none";}
function hab_edit_insert_text_i(){hab_edit_insert_tag("<em>","</em>");}
function hab_edit_insert_text_user(){var txtarea=$(habr_selectedtarget);var cur=hab_edit_getCursor(txtarea);var username=window.prompt("Кто?",'');if(username){if(cur.start!=cur.end){hab_edit_insert_tag('<hh user="'+username+'">','</hh>');}
else
{hab_edit_insert_tag('','<hh user="'+username+'" />');}}}
function hab_edit_insert_text_u(){hab_edit_insert_tag("<u>","</u>");}
function hab_edit_insert_text_s(){hab_edit_insert_tag("<s>","</s>");}
function hab_edit_insert_text_link(){var txtarea=$(habr_selectedtarget);var cur=hab_edit_getCursor(txtarea);if(cur.start!=cur.end){var hreff=window.prompt("Введите URL ссылки",'');var regexx=new RegExp('([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/](([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)');if(hreff&&hreff.match(regexx)){hab_edit_insert_tag('<a href=\''+hreff+'\' target=_blank>',"</a>");}
else alert("Это не URL");}
else{alert("Сначала выделите текст, который вы желаете сделать ссылкой");}}
function hab_edit_resize_mousemove(evt){if(!evt)evt=this.event;if(evt.pageY)
var newheight=evt.pageY-mouseY;else
var newheight=evt.clientY-mouseY;if(newheight>=50){$(habr_selectedtarget).style.height=newheight+"px";textarea_height=newheight;}}
function hab_edit_resize_start(evt){if(!evt)evt=this.event;if(!textarea_height)textarea_height=100;if(evt.pageY)
mouseY=evt.pageY-textarea_height;else
mouseY=evt.clientY-textarea_height;if(document.addEventListener){document.addEventListener('mousemove',hab_edit_resize_mousemove,false);}
else{document.attachEvent('onmousemove',hab_edit_resize_mousemove);}}
function hab_edit_resize_stop(){if(document.addEventListener){document.removeEventListener('mousemove',hab_edit_resize_mousemove,false);}
else{document.detachEvent('onmousemove',hab_edit_resize_mousemove);}}
if(document.addEventListener){document.addEventListener('mouseup',hab_edit_resize_stop,false);}
else{document.attachEvent('onmouseup',hab_edit_resize_stop);}
function hab_edit_open_help()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif>';new Ajax.Updater("darkdotinner","editors/help.php",{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function hab_edit_showpicuploadform()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif>';new Ajax.Updater("darkdotinner","editors/upload.php",{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function hab_edit_insert_text_loc()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif>';new Ajax.Updater("darkdotinner","editors/locality.php",{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function hab_edit_videoform()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif>';new Ajax.Updater("darkdotinner","editors/video.php",{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function hab_edit_preview()
{var showW=0;if(!dark_panel_on)showW=1;dark_on();if(showW)
$("darkdotinner").innerHTML='<img src=imgs/icon/load.gif><BR>....Предпросмотр грузиться....';new Ajax.Updater("darkdotinner","editors/preview.php",{encoding:"windows-1251",asynchronous:true,evalScripts:true,onFail:function(){dark_off();alert("непроперло");}});}
function hab_edit_get_content()
{return $(habr_selectedtarget).value;}