Function.prototype.bind = function(obj)
{
	var method = this;
	var args = [];
	for(var i = 1; i < arguments.length; i++)
	{
		args.push(arguments[i]);
	}
	temp = function()
	{
		return method.apply(obj, args);
	}
	return temp;
}


var StartVideo = function(parameters)
{
	this.videoLinks = parameters.videoLinks;
	this.setBehavior();
	this.containerId = parameters.containerId;
	this.container = document.getElementById(this.containerId);

	this._Eingine = new VE;
}

StartVideo.prototype.setBehavior = function()
{
	for(var i = 0; i < this.videoLinks.length; i++)
	{
		this.videoLinks[i].onclick = this.showVideo.bind(this, this.videoLinks[i].href);
	}
}

StartVideo.prototype.showVideo = function(location)
{
	if(parseInt(this.container.style.height) > 10)
	{
		this.writeVideo(location);
		return false;
	}

	this._Eingine.stop();
	var _this = this;

	this._Eingine.init(0, 230, Easing.expoOut, 1);
	this._Eingine.onChange = function(position)
	{
		_this.container.style.height = position + 'px';
	}

	this._Eingine.onFinish = this.writeVideo.bind(this, location);

	this._Eingine.start();

	return false;
}

StartVideo.prototype.writeVideo = function(location)
{
	var vd = new SWFObject('/swf/mediaplayer.swf', 'mediaplayer',  320, 210, 8);
	vd.addParam('allowfullscreen', 'true');
	vd.addVariable('file', location);
	vd.addVariable('width', 320);
	vd.addVariable('height', 210);
	vd.addVariable('autostart', 'true');
	vd.addVariable('backcolor', '0x99FF99');
	vd.write(this.containerId);
}

new StartVideo({
	videoLinks: document.getElementById('VideoLinks').getElementsByTagName('A'),
	containerId: 'video_container'
});


