var	_rotator_no	=new Array();

var	_rotator_timer	=new Array();
var	_rotator_imgs	=new Array();
var	_rotator_divs	=new Array();
var	_rotator_active	=new Array();

//------------------------------------------------------------------------------------------------ screenshot_rotator
function	screenshot_rotator	(id)
{
	var	o	=obj_id	('screenshots_'	+id);
	var	list	=o.getElementsByTagName('IMG');
	var	c	=list.length;
	
	if (c	<2)
	{
		return;
	}

	_rotator_no[id]		=c;
	_rotator_imgs[id]	=list;
	_rotator_divs[id]	=o.children;
	
	_rotator_active[id]	=true;

	var	s	=list[1].src;
	var	x	=s.lastIndexOf	('/');
	
	if (!_rotator_timer[id])
	{
		if (s.substr(x	+1)	=='empty.png')
		{
			var	i;
			
			for (	i	=1;
				i	<c;
				i	++
			)
			{
				list[i].src	='screenshot.php?application='	+id	+'&screenshot='	+i;
			}
		}

		_rotator_timer[id]	=setTimeout	('screenshot_display('	+id	+', 1)', 1000);
	}
}

//------------------------------------------------------------------------------------------------ screenshot_rotator_stop
function	screenshot_rotator_stop	(id)
{
	_rotator_active[id]	=false;
}

//------------------------------------------------------------------------------------------------ screenshot_display
function	screenshot_display	(id, no)
{
	if (_rotator_imgs[id][no].height	<=32)
	{
		_rotator_timer[id]	=setTimeout	('screenshot_display('	+id	+', '	+no	+')', 100);
		
		return;
	}
	
	if (!_rotator_active[id])
	{
		if (_rotator_divs[id][0].style.visibility	=='visible')
		{
			_rotator_timer[id]	=null;

			return;
		}

		no	=0;
	}
	
	for (	i	=0;
		i	<_rotator_no[id];
		i	++
	)
	{
		if (i	!=no)
		{
			_rotator_divs[id][i].style.zIndex	=1;
		}
	}

	screenshot_fade_start	(id, no, 2);
}

//------------------------------------------------------------------------------------------------ screenshot_fade_start
function	screenshot_fade_start	(id, no, z_index)
{
	var	o	=_rotator_divs[id][no];
	
	o.style.zIndex		=z_index;
	
	screenshot_fade	(id, no, 0);
	
	o.style.visibility	='visible';
}

//------------------------------------------------------------------------------------------------ screenshot_fade
function	screenshot_fade	(id, no, fade)
{
	var	o	=_rotator_divs[id][no].style;
	
	o.opacity	=fade	/100;
	o.MozOpacity	=fade	/100; 
	o.KhtmlOpacity	=fade	/100; 
//	o.filter = "alpha(opacity=" + fade + ")";
//	o.filter	='progid:DXImageTransform.Microsoft.Alpha(opacity='	+fade	+')';

	if (fade	<100)
	{
		fade	+=4;
		_rotator_timer[id]	=setTimeout	('screenshot_fade('	+id	+', '	+no	+', '	+fade	+')', 40);

		return;
	}

	var	i;
	for (	i	=0;
		i	<_rotator_no[id];
		i	++
	)
	{
		if (i	!=no)
		{
			_rotator_divs[id][i].style.visibility	='hidden';
		}
	}
	
	if (	(_rotator_active[id])
		||
		(no	!=0)
	)
	{
		_rotator_timer[id]	=setTimeout	('screenshot_display('	+id	+', '	+(no	+1)	%_rotator_no[id]	+')', 1000);
	}
	else
	{
		_rotator_timer[id]	=null;
	}
}

//------------------------------------------------------------------------------------------------ submit url
function	application_submit_url	()
{
	var	url	=obj_name_val	('submit_url');
	var	app_id	=obj_name_val	('application');
	
	if (!field_http	('submit_url')	)
	{
		window.alert	('Please enter valid URL.');
		
		return;
	}
	
	document.location	='application-'	+app_id	+'.html?doit=submit_url&url='	+escape	(url);
}

