	//home page rotation functionality

	function Rotator()
	{
		this.count = 0;	//splash count
		this.currentID = 0;	//current ID (index) from collection
		this.move = 1;	//1 = go on, 2 = unpause or move next, 0 = stop, -1 = move back, 3 = go to
		this.defaultSpeed = 1400;	//fadeout and fadein speed
		this.defaultDelay = 3000;	//timer delay
		this.t = 0;	//timer
		
		//fadein and fadeout controls
		this.ControlPath = '';
		this.TitlePath = '';
		this.TextPath = '';
		this.HrefPath = '';
		this.ImagePath = '';
		this.ActiveLinkIdPrefix = '';
		this.ActiveLinkPath = '';
		
		//data
		this.Title = new Array();
		this.Text = new Array();
		this.Link = new Array();
		this.Image = new Array();
		
		//player buttons
		this.ButtonNextPath = '';
		this.ButtonPrevPath = '';
		this.ButtonPausePath = '';
	}
	
	Rotator.prototype.RotateView = function (id, speed) 
	{
		if (this.move == 0)
		{
			return;
		}
		if (this.move == 3)
		{
			this.move = 0;
		}
		if (this.Title.length != this.count || this.Text.length != this.count || this.Link.length != this.count || this.Image.length != this.count)
		{
			return;
		}
		var prevID = this.currentID;
		this.currentID = id;
		clearTimeout(this.t);
		
		var instance = this;
		
		//$('#main #sidebar').fadeOut(speed);	//problems with title in IE
		$(this.ControlPath).fadeOut(speed, function() 
		{		
			if (instance.Title)
			{
				$(instance.TitlePath).html(instance.Title[id]);
			}
			$(instance.TextPath).html(instance.Text[id]);
			$(instance.HrefPath).attr('href', instance.Link[id]);
			$(instance.ImagePath).attr('src', instance.Image[id] /*+ '?' + Math.random()*/);
			
			$('#' + instance.ActiveLinkIdPrefix + prevID).removeClass('active');
			$('#' + instance.ActiveLinkIdPrefix + id).addClass('active');
			$(instance.ControlPath).fadeIn(speed, function() 
			{
				instance.StartAnimation(id);
				//setTimeout("StartAnimation("+ id +")", rd);
				
			});
		});
	};
	
	Rotator.prototype.StartAnimation = function (id) 
	{
		if (this.count == 0)
		{
			return;
		}
		if (this.move == 0)	//pause
		{
			return;
		}
		
		if (this.move == -1)	//go back
		{
			id--;	
			
			if (id < 0)
			{
				id = this.count - 1;
			}
		}
		else if (this.move == 3)	//go to
		{
			//
		}
		else	//go next
		{
			id++;
		
			if (id + 1 > this.count) 
			{
				id = 0;
			}
		}
		
		var delay = this.defaultDelay;
		var speed = this.defaultSpeed;
		
		if (this.move == 2 || this.move == -1 || this.move == 3)
		{
			clearTimeout(this.t);
			delay = 1;
			speed = this.defaultSpeed / 2;
			if (this.move != 3)
			{
				this.move = 1;
			}
		}
		
		this.t = setTimeout('rotator.RotateView('+ id +', '+ speed +')', delay);
	};
	
	//rotator instance
	var rotator = new Rotator();
	
	//-----------------------------------------------------------------------
	//butons event init and rotation start
	$(document).ready(function()
	{	
		if (!rotator)
		{
			return;
		}
		$(rotator.ButtonPausePath).click(function(event)
		{ 
			event.preventDefault();
			if (rotator.move == 0)
			{
				rotator.move = 2;	//move again
			}
			else
			{
				rotator.move = 0;	//stop
			}
			clearTimeout(rotator.t);
			rotator.StartAnimation(rotator.currentID);
		});
		
		$(rotator.ButtonPrevPath).click(function(event)
		{ 
			event.preventDefault();
			rotator.move = -1;	//move back
			clearTimeout(rotator.t);
			rotator.StartAnimation(rotator.currentID);
		});
		
		$(rotator.ButtonNextPath).click(function(event)
		{ 
			event.preventDefault();
			rotator.move = 2;	//move next
			clearTimeout(rotator.t);
			rotator.StartAnimation(rotator.currentID);
		});
		$(rotator.ActiveLinkPath).mouseover(function(event)
		{
			event.preventDefault();
			rotator.move = 3;	//go to
			var index = $(this).attr('id').substring(rotator.ActiveLinkIdPrefix.length);
			clearTimeout(rotator.t);
			rotator.StartAnimation(index);
		});
		$(rotator.ActiveLinkPath).mouseout(function(event)
		{
			event.preventDefault();
			rotator.move = 1; //go on
			rotator.StartAnimation(rotator.currentID);
		});
		
		//first start of rotator
		rotator.StartAnimation(rotator.currentID);
	});
