/*
* modernlady.ru functions
* JQuery 1.2.1 required
* Author: www.topsitepro.ru
*/

$(document).ready(function(){
	/* ���������*/
	/*
	var heights = new Array ($("#editor").parent().parent().height(), $("#cite").parent().parent().height(), $("#logo").height() + 20);
	var max = heights[0];
	if (max != null) 
	{
		for (var i = 1; i < heights.length; i++ ) {
			if (heights[i] >= max) {
				max = heights[i];
			}
		}
		$("#editor").height((function(){
			var result = 0;
			if (heights[0] < max) 
			{
				result = $("#editor").height() + max - heights[0] + 5;
			}
			else 
			{
				result = $("#editor").height() + heights[0] - max;
			}
			return result;
		})());
		$("#cite").height((function(){
			var result = 0;
			if (heights[1] == max) return max-38;
			if (heights[1] < max) 
			{
				result = $("#cite").parent().height() + max - heights[1] - 23 + 5;
			}
			else 
			{
				result = $("#cite").parent().height() + heights[1] - max - 4;
			}
			return result;
		})());
		$("#logo").height((function(){
			var result = 0;
			if (heights[2] < max) 
			{
				result = $("#logo").height() + max - heights[2];
			}
			else 
			{
				result = $("#logo").height() + heights[2] - max;
			}
			return result;
		})());
	}
	*/
	/* ����*/
	var col = $('#center .column').length;
	var columns_code = '<ul class="columns clear"></ul>';
	if (col == 2) {
		$('#center .column').each(function(i) {
			var block = $(this).parent().parent();
			if ( i == 0 ) {
				block.before(columns_code);
			}
			var classname = block.attr('class');
			$('#center .columns').append('<li class="'+ classname +'" >' + block.html() + '</li>');
			block.remove();
		});
	}
	
	/* строка поиска */
	$('#search .string').focus(function(){
		$(this).val("");
	});
	$('#search .string').blur(function(){
		if ($(this).val() == ""){
			$(this).val("Поиск по сайту");
		}
	});
});

function Changer() {
    this.prev = "";
}

Changer.prototype.setId = function(id) {
    this.id = id;
}

Changer.prototype.setCount = function(count) {
    this.count = count;
}

Changer.prototype.getElemId = function() {
    var ne = "";
    do {
        ne = this.id + "_"+ Math.round(Math.random() * this.count);
        if (this.count < 2) return ne;
    } while (ne == this.prev);
    return ne;
}

Changer.prototype.next = function() {
    var elem_id = this.getElemId();
    if (this.prev != "") {
        document.getElementById(this.prev).style.display="none";
    }
    document.getElementById(elem_id).style.display="block";
    this.prev = elem_id;
}

function updateArchiveLink(year) {
    $.post('/archive.html', {'year':year},
                    function(data, status) {
                        document.getElementById('archive_div').innerHTML = data;
                        });
    return false;
}
