/* main recalc */
var sec=0;
var t;
jQuery(document).ready(function(){
// get alls dialogs and mark hide
	var dialogs = jQuery("#dialogs");

	dialogs.find("div").css("display","none");
//	dialogs.find("div").slideUp(0);
	dialogs.css("display","block");

	timedCount();
/*
		jQuery("#clientchoose li").click(function(){
			$("#clientchoose").slideUp(600);

			var aform = $("#areform");
			var cid = $(this).attr("title");
			aform.slideDown(600);
			aform.html("<span class='load'>Загрузка...</span>");

			var postdata = "action=add&cid="+cid;

			$.ajax({
				type: "POST",
				url: "/alarms/index.p3",
				data: postdata,
				success: function(done){
					aform.html(done);
					jQuery("button[@name='retorntoclients']").click(function(){
						$("#clientchoose").slideDown(600);
						aform.slideUp(600);
					});
					toalarm();
				}
			});
		});
*/
});

function timedCount(){
	var slower = sec-5;
	var cdiv = jQuery("#dialogs > div[@title="+slower+"]");
	if(cdiv.html()){
//		jQuery("#dialogs").find("div").slideUp(300);
		jQuery("#dialogs").find("div").css("display","none");
//		cdiv.slideDown(600);
		cdiv.css("display","block");
	}
	if(sec==45){
		jQuery("#dialogs").find("div").css("display","none");
	}
	if(sec==60){
		stopCount();
		sec=0;
	} else {
		sec=sec+1;
	}
	t=setTimeout("timedCount()",1000);
}

function stopCount(){
	clearTimeout(t);
}

