var firstTimePhotos = true;
var volume = 0;
var initTimerID = null;
var playTimerID = null;

var hasVideos = false;
var hasPhotos = false;
var gallery = '';

function mediaGalleryInit(gal, hasV, hasP)
{
	firstTimePhotos = true;
	gallery = gal;
	hasVideos = hasV;
	hasPhotos = hasP;
}

function initPhotos()
{
	try
	{
		showPhotos();
	}
	catch (err)
	{
		//alert(err);
		//initTimerID = self.setTimeout("initPhotos()", 1000);
	}
}

function showPhotos()
{
	if (firstTimePhotos)
	{
		firstTimePhotos = false;
		UFO.create(FOphoto, 'image_rotator');
	}

	var videosBlock = document.getElementById('video_player');
	if (videosBlock != null)
	{
		videosBlock.style.height = '0px';
		videosBlock.style.left = '-10000px';
		videosBlock.style.visibility = 'hidden';
		videosBlock.style.display = 'none';
	}

	var photosBlock = document.getElementById('image_rotator');
	if (photosBlock != null)
	{
		photosBlock.style.height = '320px';
		photosBlock.style.left = '0px';
		photosBlock.style.visibility = 'visible';
		photosBlock.style.display = 'block';
		var result = sendEvent('image_rotator_swf', 'playitem', 0);
	}
	
	var videosLinkOn = document.getElementById('videos_link_on');
	var videosLinkOff = document.getElementById('videos_link_off');

	if (videosLinkOn != null)
	{
		videosLinkOn.style.display = 'inline';
		videosLinkOff.style.display = 'none';
	}

	var photosLinkOn = document.getElementById('photos_link_on');
	var photosLinkOff = document.getElementById('photos_link_off');

	if (photosLinkOn != null)
	{
		photosLinkOn.style.display = 'none';
		photosLinkOff.style.display = 'inline';
	}
}

function initVideos()
{
	clearTimeout(initTimerID);

	try
	{
		showVideos();
	}
	catch (err)
	{
		initTimerID = self.setTimeout("initVideos()", 1000);
	}
}

function showVideos()
{
	var photosBlock = document.getElementById('image_rotator');
	if (photosBlock != null)
	{
		photosBlock.style.left = '-10000px';
		photosBlock.style.height = '0px';
		photosBlock.style.visibility = 'hidden';
		photosBlock.style.display = 'none';
	}

	var videosBlock = document.getElementById('video_player');
	if (videosBlock != null)
	{
		videosBlock.style.left = '0px';
		videosBlock.style.height = '320px';
		videosBlock.style.visibility = 'visible';
		videosBlock.style.display = 'block';
	}

	var photosLinkOn = document.getElementById('photos_link_on');
	var photosLinkOff = document.getElementById('photos_link_off');

	if (photosLinkOn != null)
	{
		photosLinkOn.style.display = 'inline';
		photosLinkOff.style.display = 'none';
	}

	var videosLinkOn = document.getElementById('videos_link_on');
	var videosLinkOff = document.getElementById('videos_link_off');

	if (videosLinkOn != null)
	{
		videosLinkOn.style.display = 'none';
		videosLinkOff.style.display = 'inline';
	}
}

function sendEvent(id, typ, prm)
{
	try
	{
		thisMovie(id).sendEvent(typ, prm);
	}
	catch (err)
	{
		//alert(err);
	}
}

function thisMovie(movieName)
{
    if (navigator.appName.indexOf("Microsoft") != -1)
    {
		return window[movieName];
	}
	else
	{
		return document[movieName];
	}
}

// NOT IN USE
function getUpdate(typ, pr1, pr2)
{
	if (typ == "volume" && pr1 > 0)
	{
		volume = pr1;
	}
}