function toggleResidentalRequestForm()
{
    var message = (messages.watcher_notify) ? messages.watcher_notify : '';
    bubble.overlay('show')
        .show()
        .size(500, 175)
        .text(message);
}

function toggleLowRatingForm()
{
    var message = (messages.watcher_lowrating) ? messages.watcher_lowrating : '';
    bubble.overlay('show')
        .show()
        .size(500, 175)
        .text(message);
}

function send_watcher_request()
{
    var field = document.getElementById('watcher_info');
    JsHttpRequest.query(
        DIR_WEB_ROOT+'/include/ajax/residentRequestAdd.php',
        { watcherDesc: field.value },
        function(result, errors) 
        {
			if (result.bStateError)
			{
			    bubble.height(350);
			    $('watcher_message').setStyle('padding-bottom', '10px');
				$('watcher_message').innerHTML = '<span class="error">' + result.sMsg + '</span>'; 
			}
			else
			{
	            var text = '<p style="padding-bottom: 5px;"><strong>Спасибо!</strong></p>';
    	        text += '<p>Ваша заявка будет рассмотрена в течение 2—3 дней.</p>';
    	        bubble.height(320);

	            bubble
    	            .height(95)
        	        .text(text);
            }
        },
        true
    );

    return false;
}

function edit_comment_test_allowed(idComment, link)
{
    JsHttpRequest.query(
        DIR_WEB_ROOT+'/include/ajax/testCommentEditAllowed.php', {
            idComment: idComment
        },
    
        function(result, errors) 
        {
        	if (result.bStateError)
        	{
        		msgErrorBox.alert(result.sMsgTitle,result.sMsg); 
        	}
        	else
        	{
                var comment_div = $(link).getParent().getNext().getNext();
                comment_div.setStyle('padding-bottom', 0);
                //var slide = new Fx.Slide('comment_content_id_' + idComment).toggle();
                $('comment_content_id_' + idComment).toggle();
                comment_div.setStyle('margin-top', '-2px');
        		lsCmtTree.toggleEditCommentForm(idComment, result.sText);
                //document.getElementById('comment_textarea_div_id_'+idComment).style.display='none';
        	}
        },
        true
    );
}

function edit_comment(idComment, content, link)
{
    JsHttpRequest.query(
        DIR_WEB_ROOT+'/include/ajax/commentEdit.php',{
            idComment: idComment, 
            content: content
        },
    
        function(result, errors)
        {
        	if (result.bStateError)
        	{
        		msgErrorBox.alert(result.sMsgTitle,result.sMsg);
        	}
        	else
        	{
        		lsCmtTree.enableFormComment();
        		lsCmtTree.toggleEditCommentForm(idComment, '');
                //document.getElementById('comment_textarea_div_id_'+idComment).style.display='block';
        		document.getElementById('comment_content_for_edit_'+idComment).innerHTML = result.sText;

                var comment_div = $(link).getParent().getNext().getNext();
                comment_div.setStyle('padding-bottom', '7px');
                //var slide = new Fx.Slide('comment_content_id_' + idComment).toggle();
                $('comment_content_id_' + idComment).toggle();
                comment_div.setStyle('margin-top', 0);
        	}
        },
        true
    );

    $('form_comment_text').addClass('loader');
}

function open_radio()
{
    window.open('/radio.php', 'radio', 'width=295,height=205,resizable=1,location=1,scrollbars=0,menubar=0,status=0');
    return false;
}

var indexes_block = {
    init: function() 
    {
        // click
        $('indexes_block')
            .addEvent('mouseover', function() { $(this).addClass('ov');})
            .addEvent('mouseout', function() { $(this).removeClass('ov'); })
            .addEvent('click', function(event) 
            {
                $('indexes_block_pop').setStyle('display', 'block');
                indexesBlockPopVisible = true;
                event.stop();
            }
        );

        // popup click
        $('indexes_block_pop').addEvent('click', function(event) { event.stop(); });

        // close buttons
        $$('#indexes_block_pop .cb').addEvent('click', function() {
            $('indexes_block_pop').setStyle('display', 'none');
            indexesBlockPopVisible = false;
        });

        // document handler
        document.addEvent('click', function() {
            $('indexes_block_pop').setStyle('display', 'none');
            indexesBlockPopVisible = false;
        });
    }
}
