function show_help_content()
{
	$("#modal_background").show();
	$("#modal_background").css("opacity","0.8");
	$("#modal_background").css("backgroundColor","#b2e5ff");
	
	
	$("#help_content").html("");
	$("#help_content").show();
}

function hide_help_content()
{
	$("#help_content").hide();
	$("#modal_background").hide();
	$("#modal_background").css("opacity","0.0");
}

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function drop_down_menu(element)
{
	new Effect.SlideDown(element);
}

function loadHomeTestimonial()
{
	new Ajax.Updater({success:'home_testimonial'}, '/home/testimonial', {asynchronous:true, evalScripts:true, method:'get', onSuccess:function(request){homeTestimonialLoadedOK();}, parameters:'authenticity_token=' + encodeURIComponent('4e4a15824686cb3cd3ff83866bda1c8159dbd469')})	
}

function homeTestimonialLoadedOK()
{
//	new Effect.SlideDown('home_testimonial');
	new Effect.Appear($('home_testimonial'));
}

var CImageDescription = Class.create(
{
	initialize: function(element, imageElement, height)
	{
		this.imageHeight=height;
		this.element=element;
		this.y=height;
		this.alpha=0.0;
		this.imageElement=imageElement;
		this.imageElement.setOpacity(this.alpha);
		this.timer=null;
		this.isExpanding=false;
		this.isContracting=false;
		this.isExpanded=false;
		this.isContracted=true;
		this.updateStyle();
		this.mouseOverEvent=Event.observe(element,"mouseover", this.expand.bind(this));
		this.mouseOutEvent=Event.observe(element,"mouseout", this.contract.bind(this));
		this.keepExpanded=false;
		this.keepContracted=false;
	},
	startTimer: function()
	{
		if (this.timer)
		{
			clearInterval(this.timer);
		}
		this.timer=setInterval(this.update.bind(this),10);
	},
	stopTimer: function()
	{
		if (this.timer)
		{
			clearInterval(this.timer);
		}
		this.timer=null;
	},
	update: function()
	{
		var loop;
		for (loop=0; loop<7; loop++)
		{
			if (this.isExpanding)
			{
				if (this.y>0)
				{
					this.isExpanding=true;
					this.y--;
					if (this.alpha<1)
						this.alpha+=0.005;
					this.imageElement.setOpacity(this.alpha);
					this.imageElement.style.top=this.y + 'px';
				}
				else
				{
					this.stopTimer();
					this.isExpanded=true;
					this.isExpanding=false;
				}
			}
			if (this.isContracting)
			{
				if (this.y<this.imageHeight)
				{
					this.isContracting=true;
					this.y++;
					if (this.alpha>0)
						this.alpha-=0.005;
					this.imageElement.setOpacity(this.alpha);
					this.imageElement.style.top=this.y + 'px';
				}
				else
				{
					this.stopTimer();
					this.isContracted=true;
					this.isContracting=false;
				}
			}
		}
	},
	
	updateStyle: function()
	{
	},
	expand: function()
	{
		if ((this.isExpanding) || (this.isExpanded) || (this.keepContracted))
		{
			return;
		}
		this.isExpanding=true;
		this.isExpanded=false;
		this.isContracted=false;
		this.isContracting=false;
		if (!this.timer)
		{
			this.startTimer();
		}
	},
	contract: function()
	{
		if ((this.isContracting) || (this.isContracted) || (this.keepExpanded))
		{
			return;
		}
		this.isExpanding=false;
		this.isExpanded=false;
		this.isContracted=false;
		this.isContracting=true;
		if (!this.timer)
		{
			this.startTimer();
		}
	},
	fullyExpand: function(keepExpanded)
	{
		this.keepExpanded=keepExpanded;
		this.padding=this.maxPadding;
		this.isExpanding=false;
		this.isExpanded=true;
		this.isContracted=false;
		this.isContracting=false;
		this.updateStyle();
	},
	fullyContract: function(keepContracted)
	{
		this.keepContracted=keepContracted;
		this.padding=this.minPadding;
		this.isExpanding=false;
		this.isExpanded=false;
		this.isContracted=true;
		this.isContracting=false;
		this.updateStyle();
	}
});

var CImageDescriptions = Class.create(
{
	initialize: function()
	{
		this.images=new Array();
	},
	addImage: function(element,imageElement,height)
	{
		imageDescription=new CImageDescription(element,imageElement,height);
		this.images.push(imageDescription);
		return imageDescription;
	},
	findImageByElement: function(element)
	{
		var loop;
		for (loop=0; loop<this.images.length; loop++)
		{
			if (this.images[loop].element==element)
			{
				return this.images[loop];
			}
		}
		return null;
	}
});

var ImageDescriptions=new CImageDescriptions();















var CDropDown = Class.create(
{
	initialize: function(element, minY, maxY)
	{
		this.element=element;
		this.y=minY;
		this.minY=minY;
		this.maxY=maxY;
		this.timer=null;
		this.isExpanding=false;
		this.isContracting=false;
		this.isExpanded=false;
		this.isContracted=true;
		this.updateStyle();
		this.mouseOverEvent=Event.observe(element,"mouseover", this.expand.bind(this));
		this.mouseOutEvent=Event.observe(element,"mouseout", this.contract.bind(this));
		this.keepExpanded=false;
		this.keepContracted=false;
	},
	startTimer: function()
	{
		if (this.timer)
		{
			clearInterval(this.timer);
		}
		this.timer=setInterval(this.update.bind(this),10);
	},
	stopTimer: function()
	{
		if (this.timer)
		{
			clearInterval(this.timer);
		}
		this.timer=null;
	},
	update: function()
	{
		var loop;
		for (loop=0; loop<7; loop++)
		{
			if (this.isExpanding)
			{
				if (this.y<this.maxY)
				{
					this.isExpanding=true;
					this.y++;
					this.element.style.top=this.y + 'px';
				}
				else
				{
					this.stopTimer();
					this.isExpanded=true;
					this.isExpanding=false;
				}
			}
			if (this.isContracting)
			{
				if (this.y>this.minY)
				{
					this.isContracting=true;
					this.y--;
					this.element.style.top=this.y + 'px';
				}
				else
				{
					this.stopTimer();
					this.isContracted=true;
					this.isContracting=false;
				}
			}
		}
	},
	
	updateStyle: function()
	{
	},
	expand: function()
	{
		if ((this.isExpanding) || (this.isExpanded) || (this.keepContracted))
		{
			return;
		}
		this.isExpanding=true;
		this.isExpanded=false;
		this.isContracted=false;
		this.isContracting=false;
		if (!this.timer)
		{
			this.startTimer();
		}
	},
	contract: function()
	{
		if ((this.isContracting) || (this.isContracted) || (this.keepExpanded))
		{
			return;
		}
		this.isExpanding=false;
		this.isExpanded=false;
		this.isContracted=false;
		this.isContracting=true;
		if (!this.timer)
		{
			this.startTimer();
		}
	},
	fullyExpand: function(keepExpanded)
	{
		this.keepExpanded=keepExpanded;
		this.padding=this.maxPadding;
		this.isExpanding=false;
		this.isExpanded=true;
		this.isContracted=false;
		this.isContracting=false;
		this.updateStyle();
	},
	fullyContract: function(keepContracted)
	{
		this.keepContracted=keepContracted;
		this.padding=this.minPadding;
		this.isExpanding=false;
		this.isExpanded=false;
		this.isContracted=true;
		this.isContracting=false;
		this.updateStyle();
	}
});

var CDropDowns = Class.create(
{
	initialize: function()
	{
		this.images=new Array();
	},
	addImage: function(element,minY,maxY)
	{
		dropDown=new CDropDown(element,minY,maxY);
		this.images.push(dropDown);
		return dropDown;
	},
	findImageByElement: function(element)
	{
		var loop;
		for (loop=0; loop<this.images.length; loop++)
		{
			if (this.images[loop].element==element)
			{
				return this.images[loop];
			}
		}
		return null;
	}
});

var DropDowns=new CDropDowns();

