function animate_flyer_in(element) {
	var underlay = $(element.id+"_underlay");
	var overlay = $(element.id+"_overlay");

	new Effect.Parallel([
	  new Effect.Opacity(underlay, { sync: true, from: 1, to: 0.05 }),
	  new Effect.Opacity(overlay, { sync: true, from: 0.05, to: 1 })
	], { 
		duration: 1,
		afterFinish:function() {
			overlay.style.opacity=1;
			underlay.style.opacity=0.05;
		}
	});
}

function animate_flyer_out(element) {
	var underlay = $(element.id+"_underlay");
	var overlay = $(element.id+"_overlay");

 new Effect.Parallel([
	  new Effect.Opacity(underlay, { sync: true, from: 0.05, to: 1 }),
	  new Effect.Opacity(overlay, { sync: true, from: 1, to: 0.05 })
  ], { 
    	duration: 1	,
		afterFinish:function() {
			overlay.style.opacity=0.05;
			underlay.style.opacity=1;
		}
  });
}

function setup() {void(0);}

Date.prototype.toMysqlFormat = function() {
  return this.getFullYear() + '-' +
    (this.getMonth() + 1).toPaddedString(2) + '-' +
    this.getDate().toPaddedString(2);
};
var BPPlayerInstance;
var BPPlayer = Class.create({
	initialize: function(videoElement) {
    	this.videoWidth = videoElement.width;
    	this.videoHeight = videoElement.height;
		this.videoFile = videoElement.pathToMovie;
		this.id = "BPPlayer";
		this.destroy();
		this.DOMcreate();
  	},
	DOMcreate: function() {
   		var fullScreen = new Element("div");
        fullScreen.id = this.id;
        fullScreen.className = "curtain";
        fullScreen.setAttribute("style","position:absolute;top:0px;left:0px");

     // fullScreen.style.display='none';
        fullScreen.style.width = $('body').offsetWidth+"px";
		fullScreen.style.height = $('body').offsetHeight+"px";
		//Effect.toggle(fullScreen,'appear');
		

		var player = new Element("div");
		player.id = "playerContainer";
		var x = ( $('body').getWidth() - this.videoWidth ) / 2;
		player.style.position='absolute';
		player.style.left = x + "px";
        player.style.top = ($('body').scrollTop+120) + "px";

		var table = new Element('div');
		var topRow = new Element('div');
		topRow.className="playerTable";
		var topLeft = new Element('div');
		topLeft.id = "top-left";
		topLeft.appendChild(this.closeButton());
		var topMiddle = new Element('div');
		topMiddle.id = "top";
		topMiddle.style.width = ( this.videoWidth + 10 ) + "px";
		var topright = new Element('div');
		topright.id = "top-right";
		topRow.appendChild(topLeft);
		topRow.appendChild(topMiddle);
		topRow.appendChild(topright);
		table.appendChild(topRow);
		
		var middleRow = new Element('div');
		middleRow.className="playerTable";
		var middleLeft = new Element('div');
		middleLeft.id = "left";
		middleLeft.style.height = (this.videoHeight + 10) +"px";
		var mainPlayerDiv = new Element('div');
		mainPlayerDiv.id = "player1";
		mainPlayerDiv.style.height = (this.videoHeight + 5) +"px";
		mainPlayerDiv.style.width = ( this.videoWidth ) + "px";
		var middleRight = new Element('div');
		middleRight.id = "right";
		middleRight.style.height = (this.videoHeight + 10) +"px";
		middleRow.appendChild(middleLeft);
		middleRow.appendChild(mainPlayerDiv);
		middleRow.appendChild(middleRight);		
		table.appendChild(middleRow);		

		var logoRow = new Element('div');
		logoRow.className="playerTable";
		var logoLeft = new Element('div');
		logoLeft.id = "left";
		logoLeft.style.height = (35) +"px";
		var logo = new Element('div');
		logo.id = "player-logo";
		logo.style.width = ( this.videoWidth +10) + "px";
		logo.innerHTML = '<img src="./interface/images/player/logo.png" alt="" border=0 >';
		var logoRight = new Element('div');
		logoRight.id = "right";
		logoRight.style.height = (35) +"px";
		logoRow.appendChild(logoLeft);
		logoRow.appendChild(logo);
		logoRow.appendChild(logoRight);		
		table.appendChild(logoRow);
		
		var bottomRow = new Element('div');
		bottomRow.className="playerTable";
		var bottomLeft = new Element('div');
		bottomLeft.id = "bottom-left";
		var bottomMiddle = new Element('div');
		bottomMiddle.id = "bottom";
		bottomMiddle.style.width = ( this.videoWidth + 10 ) + "px";
		var bottomright = new Element('div');
		bottomright.id = "bottom-right";
		bottomRow.appendChild(bottomLeft);
		bottomRow.appendChild(bottomMiddle);
		bottomRow.appendChild(bottomright);
		table.appendChild(bottomRow);
/*
		var row = new Element('tr');
		var cell = new Element('td');
		cell.width = '30px';
		cell.id = 'left';
		row.appendChild(cell);
		var cell = new Element('td');
		cell.align='center'
		cell.id = 'player-logo';
		cell.innerHTML = '<img src="./interface/images/player/logo.png"/>';
		row.appendChild(cell);
		var cell = new Element('td');
		cell.id = 'right';
		cell.width = '30px';
		row.appendChild(cell);
		table.appendChild(row);

		var row = new Element('tr');
		row.height='30px';
		var cell = new Element('td');
		cell.height = '30px';
		cell.width = '30px';
		cell.id = 'bottom-left';
		row.appendChild(cell);
		var cell = new Element('td');
		cell.id = 'bottom';
		row.appendChild(cell);
		var cell = new Element('td');
		cell.width = '30px';
		cell.id = 'bottom-right';
		row.appendChild(cell);
		table.appendChild(row);
*/

		player.appendChild(table);
		fullScreen.appendChild(player);
		$('body').appendChild(fullScreen);
		
		var FO = {	movie:"./interface/flv_player/flvplayer.swf",width:(this.videoWidth-35),height:this.videoHeight,majorversion:"7",build:"0",bgcolor:"#FFFFFF",
						flashvars:"file="+this.videoFile+"&lightcolor=0xFFFFFF&showdigits=true&autostart=true&showfsbutton=false" };
		UFO.create(	FO, "player1");
		
  	},
	closeButton: function() {
		var button = new Element('a');
		var img = new Element('img');
		button.href='javascript:void(0)';
		button.onclick= function() {if($("BPPlayer")) {
			$("BPPlayer").remove();
		}} ;
		img.border=0
		img.style.position='relative';
		img.style.top='5px';
		img.style.left='5px';
		img.src='./interface/images/closebox.png';
		button.appendChild(img);
		return button;
	},
	destroy: function() {
        if($(this.id)) {
			$(this.id).remove();
		}
	},
	close: function() {
		this.destroy();
	}
	
});


function scrollingRight() {
	var name = new Array();
	name[0] = "zero";
	name[1] = "one";
	name[2] = "two";
	name[3] = "three";
	name[4] = "four";
	if($("scrollerContent").offsetLeft <= 0) 
		new Effect.Move($("scrollerContent"), { x: 390, y: 0, mode: "relative", duration:0.5 , 
		afterFinish : function() {
			 if ($("scrollerContent").offsetLeft >= 0) $("scrollerContent").style.left="-1560px";
			var activeIndex = ($("scrollerContent").offsetLeft / (-390) ) - 1;
			$('pageBrowser').select('li').each(function(e){
				if (e.id == name[activeIndex]) { e.addClassName("selectedPageBrowser"); }
				else { e.removeClassName("selectedPageBrowser");}
			})
			
			}
			
		});
		
}

function scrollingLeft() {
	var name = new Array();
	name[0] = "zero";
	name[1] = "one";
	name[2] = "two";
	name[3] = "three";
	name[4] = "four";
	if($("scrollerContent").offsetLeft >= -1950) 
		new Effect.Move($("scrollerContent"), { x: -390, y: 0, mode: "relative", duration:0.5, 
		afterFinish : function(){ 
			if ($("scrollerContent").offsetLeft <= -1950) $("scrollerContent").style.left="0px";
			var activeIndex = ($("scrollerContent").offsetLeft / (-390) ) - 1 ;
			if (activeIndex < 0) activeIndex = 4;
			$('pageBrowser').select('li').each(function(e){
				if (e.id == name[activeIndex]) { e.addClassName("selectedPageBrowser"); }
				else { e.removeClassName("selectedPageBrowser");}
			})
		}
			
		});
}

function BrowserScrollTo(targetIndex) {
	switch(targetIndex) {
		case "zero":
			targetIndex=0;
			break;
		case "one":
			targetIndex=1;
			break;
		case "two":
			targetIndex=2;
			break;
		case "three":
			targetIndex=3;
			break;
	}
	var name = new Array();
	name[0] = "zero";
	name[1] = "one";
	name[2] = "two";
	name[3] = "three";
	
	var activeIndex = ($("scrollerContent").offsetLeft / (-390) ) - 1 ;
	var target = (activeIndex - (targetIndex)) * 390 ;
	new Effect.Move($("scrollerContent"), { x: target, y: 0, mode: "relative", duration:0.5, 
	afterFinish : function(){ 
		if ($("scrollerContent").offsetLeft <= -1560) $("scrollerContent").style.left="0px";
		var activeIndex = ($("scrollerContent").offsetLeft / (-390) ) - 1 ;
		if (activeIndex < 0) activeIndex = 3;
		$('pageBrowser').select('li').each(function(e){
			if (e.id == name[activeIndex]) { e.addClassName("selectedPageBrowser"); }
            else { e.removeClassName("selectedPageBrowser");}
		})
	}
		
	});}