function checkAllCheckBox(classname)
{
	$("."+classname).attr("checked","checked");
}
function uncheckAllCheckBox(classname)
{
	$("."+classname).attr("checked","");
}
function checkAll(classname)
{
	$("."+classname).attr("checked","checked");
}
function uncheckAll(classname)
{
	$(".cb_order").attr("checked","");
}
function recordOutboundLink(that, category, action)
{
  try {
    var pageTracker=_gat._getTracker("UA-286387-8");
    pageTracker._trackEvent(category, action);
    setTimeout('document.location = "' + this.href + '"', 100)
  }catch(err){}
}
function recordOutboundLinkAsync(that, category, action)
{
  try {
    var pageTracker=_gat._getTracker("UA-286387-8");
    pageTracker._trackEvent(category, action);
    setTimeout('document.location = "' + this.href + '"', 100)
  }catch(err){}
}
$(document).ready(function() {
    $('.dialog').scrollTop(100000);
});
$(document).ready(function(){
    var i = 0, mouse_is_inside = false;

    $('#cityListContainer').hover(function(){
        mouse_is_inside = true;
    }, function(){
        mouse_is_inside = false;
    });

    $('#citySelector').hover(function(){
        mouse_is_inside = true;
    }, function(){
        mouse_is_inside = false;
    });

    $("body").mouseup(function(){
        if(! mouse_is_inside) $('#cityListContainer').hide();
    });


    $('#citySelector').click(function(){
        if(i == 0){
            $('#cityListContainer').empty().html('<img src="pic/spinner.gif" />');
            //setTimeout($('#cityListContainer').load('/ajax/list_city.php'), 10000);
            $('#cityListContainer').load('/ajax/list_city.php');
            i++;
        } else {
            if($('#cityListContainer').is(":visible")){
                $('#cityListContainer').hide("slow");
            } else {
                $('#cityListContainer').show("slow");
            }
        }
    })
});

$(document).ready(function(){
    $('.flag').click(function(){
        var userNum = $(this).attr('id');
        userNum = userNum.substr(userNum.length - 1, 1);
        if($(this).attr('class') == 'flag flagged'){
            $(this).removeClass("flagged").addClass("not-flagged");
            $.get("/ajax/favorite_dialogs.php", { flag: "0", mdid: $(this).attr('id'), user: userNum } );
        } else {
            $(this).removeClass("not-flagged").addClass("flagged");
            $.get("/ajax/favorite_dialogs.php", { flag: "1", mdid: $(this).attr('id'), user: userNum } );
        }
    })
});

$(document).ready(function(){              // по окончанию загрузки страницы
    $('#category-selector').click(function(){      // вешаем на клик по элементу с id = example-1
        $('#category_dropdown').show(0);
    })
});

$(document).ready(function(){
	$("#selectAllCheckBoxes").click(function(){
        if(!$('input[type=checkbox]').is(':checked')){
            $('input[type=checkbox]').attr('checked', true);
        } else {
            $('input[type=checkbox]').attr('checked', false);
        }
	});
});

/* Russian (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Andrew Stromnov (stromnov@gmail.com). */
jQuery(function($){
	$.datepicker.regional['ru'] = {
		closeText: 'Закрыть',
		prevText: '&#x3c;Пред',
		nextText: 'След&#x3e;',
		currentText: 'Сегодня',
		monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
		'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
		monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
		'Июл','Авг','Сен','Окт','Ноя','Дек'],
		dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
		dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
		dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
		weekHeader: 'Не',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['ru']);
});

$(function() {
	$(".datepicker").datepicker();
});

$(document).ready(function(){
    $(".sizes_orders .order").hover(
        function () {
            $(".sizes_orders .order .odc").hide();
            if($(this).children('.odc').size()) {
                $(this).children('.odc').show();
            } else {
                $(this).append($("<div class='odc'></div>"));
                $(this).children('.odc').load('/ajax/order_comment.php?oid=' + $(this).attr('id'));
            }
        },
        function() {
            //$(this).children('.odc').hide();
        }
    );
});
