﻿

var iecaca = false;
if ( navigator.userAgent.indexOf('MSIE',0) != -1 ) iecaca = true;
//alert(iecaca);

var Marquee=new Class({
	timeout:2500,
	height:0,
	count:0,
	container:null,
	effect:null,
	period:null,
	initialize: function(id) {
		this.container=$(id);
		this.container.setStyle('display','none');
		/*
		this.container.setStyle('width','470');
		this.container.setStyle('height','160');
		this.container.setProperty('width','470px');
		this.container.setProperty('height','160px');
		*/
		this.hideAll();
		this.height=this.container.getHeight();
		this.container.setStyle('display','block');
		this.anim();
		this.period=new PeriodicalExecuter(this.anim.bind(this),8);
	},
	anim: function() {
		this.hideAll();
		var div=this.getNext();
		var top=this.getHeightPix();
		var left=this.getWidthPix();
		
		if ( !iecaca ) {
			div.setStyle('top',top);
			div.setStyle('display','block');
			
			this.effect = new Fx.Tween(div,{transition: Fx.Transitions.Sine.easeOut});
			this.effect.start('top',top,'0px');
		}
		else {
			
			div.setStyle('top','0px');
			div.setStyle('display','block');
			
			this.effect = new Fx.Tween(div,{transition: Fx.Transitions.Sine.easeOut, duration: 1500});
			this.effect.start('opacity',0,1);
			
			/*
			div.setStyle('left',top);
			div.setStyle('display','block');
			
			this.effect = new Fx.Tween(div,{transition: Fx.Transitions.Sine.easeOut});
			this.effect.start('left',left,'0px');
			*/
			
			
		}
	},
	getNext: function() {
		var actual=this.count;
		this.count++
		this.count=(this.count<this.getLength())?this.count:0;
		return this.getChild(actual);
	},
	hideAll: function() {
		this.container.getChildren().each(function(e){
			e.setStyle('display',"none");
			e.setStyle('position',"relative");
			e.setStyle('zIndex','200');
		});
	},
	getLength: function() {
		return this.getChildren().length;
	},
	getChild: function(index) {
		return this.getChildren()[index];
	},
	getChildren: function() {
		return this.container.getChildren();
	},
	getHeightPix: function(n) {
		return this.container.getSize().y+'px';
	},
	getWidthPix: function(n) {
		return '-'+this.container.getSize().x+'px';
	}
});


var container;
window.addEvent("domready", function() {
	container=new Marquee('marquesina');
});




/*
function showAlert ()
{
	this.counter = this.counter ? this.counter + 1 : 1;
	alert(this.counter);
}
var pe = new PeriodicalExecuter(showAlert, 10);
.getHeight()
*/





