
/* ===== Sliding DIV ======== */
var Slider = function ()
{
	this.ms          = 50;
	this.intv        = null;
	this.origin      = 0;
	this.height      = 0;
	this.num_steps   = 1;
	this.endpos      = 0;
	this.step_height = 0;
	this.increment   = 0;
	this.speed       = 1.25;
	this.element     = null;
}

Slider.prototype.init = function(ele) 
{
	window['Slider_'+ele.id] = this; // self reference 
	this.element              = ele;
	this.height               = this.step_height*this.num_steps;
	Element.setStyle(this.element,{'height':this.height+'px'});
}

Slider.prototype.slideUp = function() {
	this.step(-1);
}

Slider.prototype.slideDown = function() {
	this.step(1);
}

Slider.prototype.step = function(n) 
{
	if(n==1 && this.intv==null)
	{
		if(this.origin < 0 ) // ok to move down?
		{
			this.increment = 1;
			this.endpos   += this.step_height;
			this.intv      = window.setInterval("window['Slider_"+this.element.id+"'].move()",this.ms);
		}
	}
	else if(n==-1 && this.intv==null)
	{
		if(this.origin >= -(this.height-this.step_height)) // ok to move up?
		{
			this.increment = -1;
			this.endpos   += -(this.step_height);
			this.intv      = window.setInterval("window['Slider_"+this.element.id+"'].move()",this.ms);
		}
	}
}

Slider.prototype.move = function() 
{
	if( this.increment<0 && this.origin>this.endpos || 
		this.increment>0 && this.origin<this.endpos  ) 
	{
		var absDistance = Math.floor( (Math.abs(this.endpos-this.origin)/2) * this.speed );
		absDistance = (absDistance<1)? 1 : absDistance ;
		this.origin += (this.increment>0)? absDistance : -(absDistance) ;
		Element.setStyle(this.element,{'margin-top':this.origin+'px'});
	}
	else // clear interval
	{
		window.clearInterval(this.intv);
		this.intv = null;
	}
}


/* ===== Misc ======== */

function chkf(obj)
{
	var ferror = new Array();
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
	if(obj.sender_name.value=='Enter Your Name' || obj.sender_name.value=='')
		ferror.push('Please enter your name');

	if(re.test(obj.sender_email.value)!=true)
		ferror.push('Please enter your email address');
		
	if(obj.recip_name.value=='Enter Recipient Name' || obj.recip_name.value=='')
		ferror.push('Please enter recipients name');
	
	if(re.test(obj.recip_email.value)!=true)
		ferror.push('Please enter recipients email address');
		
	if(ferror.length==0)
		return true;
	else
	{
		alert(ferror.join("\n"));
		return false;
	}
}

function jsGetURL(url)
{
	var win;hasOpener=false;
	if(window.opener)
	{
		hasOpener=true;
		try // buggy return value for IE window.opener.closed, so...
		{
			hasOpener = !window.opener.closed; // if we are not closed, we have an opener
		} 
		catch(errorObject) 
		{
			// window.opener.closed is not working correctly
			// assume no opener
			hasOpener = false;
		}
	}
	if(!hasOpener) 
		win=window.open(url,'Peabody');
	else 
	{	
		win=window.opener;
		win.location=url;
	}
	win.focus();
}