var lastSlide = null;

//var sliders = new Array();

function slider(obj, obj2)
{
	if (!obj)
		return;		
	
//	sliders[sliders.length] = { menu:obj, activator:obj2 } ;
//	
//	$(obj2).click(function () 
//	    { 
//	        for (x = 0; x < sliders.length; x++)
//            {
//                if (sliders[x].activator != this)
//                    $(sliders[x].menu).slideUp("normal")
//            }

//	        $(obj).slideToggle("normal"); 
//	        $(obj).css("border-bottom", "1px solid #999");
//	    });
	
		
	this.control = obj;
	this.activator = obj2 || obj; 
	this.Min_Height = 0;
	this.Max_Height = 153;

	this.initHeight = 0;
	this.targetHeight = 0;
	this.startTime = 0;
	this.maxTime = 0;
	
	this.expanded = false
	this.busy = false;

	this.init();

	this.Timer = null;
	

}

slider.prototype.init = function () 
{
	var oThis = this;
	
	this.control.style.height = this.Min_Height + 'px';
	this.activator.onmousedown = function() 
	{ 
			if (lastSlide && lastSlide.expanded == true)
			{
				lastSlide.slide();
			}
				
				
			oThis.slide();
			lastSlide = oThis;
	};
	
}

slider.prototype.slide = function () 
{
	this.busy = false;
	var oThis = this;
	var position = parseInt(this.control.style.height);
	
	if ( window.hideUnscrollingDivs )
	hideUnscrollingDivs();  // This should be included in the page specific js
	
	
	if ( position <= 0 )
	{
		this.initHeight = this.Min_Height;
		this.targetHeight = this.Max_Height;
		this.startTime = Number(new Date());
		this.maxTime = 1000;

		this.control.style.display = 'block';
	}
	else
	{
		this.initHeight = this.Max_Height;
		this.targetHeight = this.Min_Height;
		this.startTime = Number(new Date());
		this.maxTime = 1000;
	}

	this.Timer = window.setInterval(function () { oThis.move() }, 1);
	
}

slider.prototype.move = function ()
{
	var timeElapsed = (new Date() - this.startTime);
		
	if (this.maxTime < timeElapsed)
	{
		this.control.style.height = this.targetHeight + 'px';
	
		window.clearInterval(this.Timer);
	}
	else
	{
		if(this.busy)
			return;
		
		this.busy = true;
		
		var slideDistance = this.targetHeight - this.initHeight;
			
		this.control.style.height = Math.ceil(Math.pow((timeElapsed / this.maxTime), 0.6) * slideDistance + this.initHeight) + 'px';
	}
		
	this.busy = false;


	if (parseInt(this.control.style.height) != this.Min_Height)
	{
		this.control.style.borderBottom = "1px solid #999";
		this.expanded = true;
	}
	else
	{
		this.control.style.borderBottom = "";
		this.expanded = false;		
	}

	if ( window.resizer )
		resizer();

}

function hide(objName)
{
   var obj = document.getElementById(objName)

   obj.style.display = "none";
}


function check(value)
{
  var fmobj = document.getElementById("Form1")

  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ( (e.type=='checkbox') && (!e.disabled) ) {
      e.checked = value;
    }
  }
}

