/*
SEO DHTML by Fabio Sutto
http://www.seos.it/
Utilizzabile liberamente se non si cancellano queste righe
*/

function toggleDiv(toggleConfig, idOuter)
{
    this.config = toggleConfig;

    this.stepW = 0;
    this.stepH = 0;
    this.paceW = this.config.maxWidth / this.config.step;
    this.paceH = this.config.maxHeight / this.config.step;

    this.outerObj = document.getElementById(idOuter);
		
    this.outerObj.style.width = this.config.minWidth + 'px';
    this.outerObj.style.height = this.config.minHeight + 'px';

    this.opening = false;

    this.openInterval = 1;
    this.closeInterval = 1;
}

function expandW()
{
    this.stepW += this.paceW;
    this.outerObj.style.width = this.stepW + 'px';

    var currW = parseInt(this.outerObj.style.width);

    if (currW >= this.config.maxWidth)
        clearInterval(this.openInterval);
} 

toggleDiv.prototype.expandW = expandW;

function expandH()
{
    this.stepH += this.paceH;
    this.outerObj.style.height = this.stepH + 'px';

    var currH = parseInt(this.outerObj.style.height);

    if (currH >= this.config.maxHeight)
        clearInterval(this.openInterval);
} 

toggleDiv.prototype.expandH = expandH;

function expandB()
{
   this.expandW();
   this.expandH();
} 

toggleDiv.prototype.expandB = expandB;

function closeW()
{
    this.stepW -= this.paceW;
    this.outerObj.style.width = this.stepW + 'px';

    if (parseInt(this.outerObj.style.width) <= this.config.minWidth)
    {
        clearInterval(this.closeInterval) ;
        this.outerObj.style.width = this.config.minWidth + 'px';
    }
} 

toggleDiv.prototype.closeW = closeW;

function closeH()
{
    this.stepH -= this.paceH;
    this.outerObj.style.height = this.stepH + 'px';
    
    if (parseInt(this.outerObj.style.height) <= this.config.minHeight)
    {
        clearInterval(this.closeInterval);
        this.outerObj.style.height = this.config.minHeight + 'px';
    }
} 

toggleDiv.prototype.closeH = closeH;

function closeB()
{
   this.closeW();
   this.closeH();
} 

toggleDiv.prototype.closeB = closeB;

function toggle()
{	
	globalObj = this;
	
	if (this.opening)
	{
	   clearInterval(this.openInterval);
	   this.opening = false ;
	   
	   if (this.config.direction == 'right')
	       this.closeInterval = setInterval('globalObj.closeW()', this.config.speed);
	   else if (this.config.direction == 'down')
	      this.closeInterval = setInterval('globalObj.closeH()', this.config.speed);
	   else	
	      this.closeInterval = setInterval('globalObj.closeB()', this.config.speed);
		  
	   var outerObj1 = document.getElementById('wmr_act_lnk');
	   outerObj1.innerHTML = this.config.continues;/*'Continues..';*/
	}
	else
	{
	   clearInterval(this.closeInterval);
	   this.opening = true;
	   
	   if (this.config.direction == 'right')
	      this.openInterval = setInterval('globalObj.expandW()', this.config.speed);
	   else if (this.config.direction == 'down')
	      this.openInterval = setInterval('globalObj.expandH()', this.config.speed);
	   else
	      this.openInterval = setInterval('globalObj.expandB()', this.config.speed);
		  
	   var outerObj1 = document.getElementById('wmr_act_lnk');
	   outerObj1.innerHTML = this.config.xclose;/*'[X] Close';*/
	}
} 

toggleDiv.prototype.toggle = toggle;