$(document).ready(function() {
	
	$('#mainslider').cycle({ 
    fx:    'fade', 
    speed:  2500 
 });
 
	$( ".datepicker" ).datepicker();
	
	function forum_insert_smile(obj, element_name) {
	if(!obj) return;
	var obj = obj.firstChild;
	if(!obj) return;

	var alt = obj.alt;
	if(!alt) return false;

	var obj = document.getElementById('message');
	if(!obj) obj = document.getElementById('forum_body');
	if(!obj) obj = document.getElementById(element_name);
	if(!obj) return false;

	obj.value += "[smile:" + alt + "] ";
	obj.focus();

	return true;
}
 
	 
});

$(window).load(function() {
  setHeight('.col');
});
 
// Глобальная переменная, хранящая максимальное значение высоты
var maxHeight = 0;
 
function setHeight(col) {
  //Получим все элементы с классом, указанным в переменной col
  col = $(col);
 
  //Для каждого элемента
  col.each(function() {        
 
    // Сохраним максимальное значение
    if ($(this).height() > maxHeight) {
      maxHeight = $(this).height();;
    }
  });
 
	// Установим высоту
  col.height(maxHeight);
}
$(document).ready(function() {    
	
    
    $("#photoalbum").click(function() {
$("#dialog-bottom span").children().hide().filter("#photo_album").show('slow',function() {
$(".photosgallery-vertical").sliderkit({
circular:true,
mousewheel:true,
shownavitems:4,
verticalnav:true,
navclipcenter:true,
auto:true
});  
});
        $("#overlay-photo").css({"width": $(window).width(), "height": $(window).height()}).fadeIn("slow");
        $("#overlay-photo>#modal-dialog").css({'top': ($("#overlay-photo>#modal-dialog").height()) / 2, 'margin-left': - $('#overlay-photo>#modal-dialog').width() / 2});
        $("#dialog-top span").text($("#photo_album").attr("title"));    

        return false;
    });
    
	$("#bron").click(function() {
        $("#dialog-bottom span").children().hide().filter("#bron_form").show();
        $("#overlay").css({"width": $(window).width(), "height": $(window).height()}).fadeIn("slow");
        $("#modal-dialog").css({'top': ($(window).height() - $('#modal-dialog').height()) / 2, 'margin-left': - $('#modal-dialog').width() / 2});
        $("#dialog-top span").text($("#bron_form").attr("title"));    

        return false;
    });

	$("#bronya").click(function() {
        $("#dialog-bottom span").children().hide().filter("#bron_form").show();
        $("#overlay").css({"width": $(window).width(), "height": $(window).height()}).fadeIn("slow");
        $("#modal-dialog").css({'top': ($(window).height() - $('#modal-dialog').height()) / 2, 'margin-left': - $('#modal-dialog').width() / 2});
        $("#dialog-top span").text($("#bron_form").attr("title"));    

        return false;
    });
	
	$("#korp").click(function() {
        $("#dialog-bottom span").children().hide().filter("#korp_form").show();
        $("#overlay").css({"width": $(window).width(), "height": $(window).height()}).fadeIn("slow");
        $("#modal-dialog").css({'top': ($(window).height() - $('#modal-dialog').height()) / 2, 'margin-left': - $('#modal-dialog').width() / 2});
        $("#dialog-top span").text($("#korp_form").attr("title"));    

        return false;
    });

    $("#dialog-close").click(function() {
        $("#overlay").fadeOut("fast");
        return false;
    });
	
    $("#overlay-photo #dialog-close").click(function() {
        $("#overlay-photo").fadeOut("fast");
        return false;
    });
	
});


