// JavaScript Document

/*   JavaScript Snap, version 1.2
 *  (c) 2006 rckr software <bimaldas@rckr.com;mileesh@rckr.com>
/*--------------------------------------------------------------------------*/

function snapManager(SnapDivID,ContentID,Opt)
{
	this.myDivheight=1;	
	this.shiftDiv=20;
	this.toggle=1;
	this.expandHeight=0;
	this.snapid=SnapDivID;
	this.contentid=ContentID;
	this.opt=Opt;
	
	
	
	
}

snapManager.prototype.getHeight = function ()
{
   var obj = $(this.contentid);
   var height=obj.offsetHeight;
   this.expandHeight=height;
   
};

snapManager.prototype.expandMe=function ()
{
		var SnapObj=$(this.snapid);
		if(this.myDivheight<=this.expandHeight)
		{
			SnapObj.style.visibility='visible';
			SnapObj.style.height=this.myDivheight +"px";
			this.myDivheight=this.myDivheight+this.shiftDiv;			
			setTimeout(this.expandMe.bindAsEventListener(this),1);
			
		}
		else
		{
		this.toggle=0;
		//SnapObj.style.height=this.myDivheight+"px";
		SnapObj.style.height="auto";
		SnapObj.style.overflow="visible";
					
		}
				

}

snapManager.prototype.collapseMe=function()
{
    	
	   
	   	var SnapObj=$(this.snapid);
		SnapObj.style.overflow="hidden";
		
		if(this.myDivheight>=this.shiftDiv)
		{
		SnapObj.style.height=this.myDivheight +"px";
		this.myDivheight=this.myDivheight-this.shiftDiv;
		setTimeout(this.collapseMe.bindAsEventListener(this),1);
		}
		else
		{
		SnapObj.style.height=1 +"px";
		this.toggle=1;
		}
		
}
snapManager.prototype.speedControl=function()
{
this.shiftDiv=this.expandHeight/10;
}

snapManager.prototype.OpenSnap=function()
{

var SnapObj=$(this.snapid);
this.toggle=0;
SnapObj.style.visibility='visible';
SnapObj.style.height="auto";
SnapObj.style.overflow="visible";

this.getHeight();
this.myDivheight=this.expandHeight;


}



snapManager.prototype.Snap=function () 
{
	this.getHeight();
	
	if (this.opt==1)
	{
	this.expandMe();
	}
	else if(this.opt==0)
	{
	this.collapseMe();
	}	
	else if(this.opt==3)
	{
			if(this.toggle==1)
			{
			this.expandMe();
			}
			else 
			{
			this.collapseMe();
			
			}
	}

	
};



