
function SliderFix(name, pos)
{
	var p = AbsolutePosition(document.getElementById("blog_st0"));
	$("#slider_" + name).css("position","absolute"); 
	if(name == "left") {
		$("#slider_" + name).css("left",(p.x + pos) + "px"); 
		$("#slider_middle").css("left",(p.x + pos) + "px"); 
		$("#slider_middle").css("position","absolute"); 
		$("#slider_middle").css("height","362px"); 
	}
	else {
		$("#slider_" + name).css("left", (p.x + pos) + "px");
	}
}

function ShowPad(cmd)
{
	$("#blog_writer").css("height", "0px");
	$("#tab2").css("display", cmd==0 ? "none" : "");
	$("#tab3").css("display", cmd==0 ? "" : "none");
	$("#blog_writer").animate({height:150}, "slow");
}

function ShowWriter() { ShowPad(1); }

function Project2Department(obj,id)
{
	$.get("/Utility/ProjectOpr.aspx", { rnd : Math.random(), id : id, opr : "depart", md5 : "undefined" }, function(result) {
		obj.innerHTML = "";
		$("#department_name").html(result);
	});
}

var bar_x0 = 0;
var bar_x0p = 0;
var bar_y0 = 0;
var bar_x1 = 0;
var bar_x1p = 0;
var bar_y1 = 0;
var bar_w0 = 100;

var show = false;

$(document).ready(function()  
{  
	var offset = $("#slider_left").offset();
	bar_x0 = offset.left;
	bar_y0 = offset.top; 
	bar_x0p = bar_x0;

	var offset = $("#slider_right").offset();
	bar_x1 = offset.left;
	bar_y1 = offset.top; 
	bar_x1p = bar_x1;

	$("#slider_middle").css("width", (bar_x1p-bar_x0p) + "px"); 

	$("#slider_left").mousedown(function(e)
	{  
		$(this).css("position","absolute"); 
		$("#slider_middle").css("position","absolute"); 
		$("#slider_middle").css("height","362px"); 
		var offset = $(this).offset(); 
		var x = e.pageX - offset.left; 
		var y = e.pageY - offset.top;

		$(document).bind("mousemove",function(e)
		{  
			$("#slider_left").stop();

			var _x = e.pageX - x;
			if(_x < bar_x0) _x = bar_x0;
			if(_x > (bar_x1p)) _x = bar_x1p;
			var _y = bar_y0;
			  
			var dn1 = new Date();
			dn1.setTime( bar_start.getTime() + (_x-bar_x0)*24.0*60.0*60.0*1000.0/bar_scale );
			$("#slider_left").html(dn1.getFullYear() + "-" + I2(dn1.getMonth()+1) + "-" + I2(dn1.getDate()));

			$("#slider_left").animate({left:_x+"px",top:_y+"px"},10); 
			bar_x0p = _x;

			$("#slider_middle").css("left", (bar_x0p) + "px");
			$("#slider_middle").css("width", (bar_x1p-bar_x0p) + "px");
			if(bar_x1p-bar_x0p > 110) {
				if(bar_scale < 10) {
					$("#slider_middle").html("<a href=\"javascript:void(0)\" onclick=\"Reshow();return false;\">点击刷新</a>" );
				}
				else {
					$("#slider_middle").html("<a href=\"javascript:void(0)\" onclick=\"window.location='/Computer/Project.aspx?id=" + bar_index + "';return false;\">RESET</a>");
				}
			}
			else {
				$("#slider_middle").html("" +  parseInt((bar_x1p-bar_x0p)/bar_scale, 10) + "");
			}
		});  
		  
	});  

	$("#slider_right").mousedown(function(e) 
	{  
		$(this).css("position","absolute"); 
		$("#slider_middle").css("position","absolute"); 
		$("#slider_middle").css("height","362px"); 
		var offset = $(this).offset();
		var x = e.pageX - offset.left;
		var y = e.pageY - offset.top;

		$(document).bind("mousemove",function(e)
		{  
			$("#slider_right").stop();

			var _x = e.pageX - x;
			if(_x < (bar_x0)) _x = bar_x0;
			if(_x < (bar_x0p)) _x = bar_x0p;
			if(_x > bar_x1) _x = bar_x1;
			var _y = bar_y1;

			var dn1 = new Date();
			dn1.setTime( bar_start.getTime() + (_x-bar_x0)*24.0*60.0*60.0*1000.0/bar_scale );
			$("#slider_right").html(dn1.getFullYear() + "-" + I2(dn1.getMonth()+1) + "-" + I2(dn1.getDate()));
		  
			$("#slider_right").animate({left:_x+"px",top:_y+"px"},10);  
			bar_x1p = _x;

			$("#slider_middle").css("left", (bar_x0p) + "px");
			$("#slider_middle").css("width", (bar_x1p-bar_x0p) + "px");
			if(bar_x1p-bar_x0p > 110) {
				if(bar_scale < 10) {
					$("#slider_middle").html("<a href=\"javascript:void(0)\" onclick=\"Reshow();return false;\">点击刷新</a>" );
				}
				else {
					$("#slider_middle").html("<a href=\"javascript:void(0)\" onclick=\"window.location='/Computer/Project.aspx?id=" + bar_index + "';return false;\">RESET</a>");
				}
			}
			else {
				$("#slider_middle").html("" +  parseInt((bar_x1p-bar_x0p)/bar_scale, 10) + "" );
			}
		});  
		  
	});  
	  
	$(document).mouseup(function()  
	{  
		$("#slider_left").css("cursor","pointer");  
		$("#slider_right").css("cursor","pointer");  
		$(this).unbind("mousemove");  
	})  
})

function Reshow()
{
	var t1 = $("#slider_left").html();
	var t2 = $("#slider_right").html();
	window.location = "/Computer/Project.aspx?id=" + bar_index + "&t1=" + t1 + "&t2=" + t2;
}
