function toggleMovieInfo(mtype)
{
	//$('minfo_info').removeClassName('selected');
	//$('minfo_embed').removeClassName('selected');
	
	$('MovieInfos').style.display = 'none';
	$('MovieEmbed').style.display = 'none';
	$('MovieTheatre').style.display = 'none';
	if (mtype == 'info') 
	{
		if ($('minfo_info').hasClassName('selected')){$('minfo_info').removeClassName('selected');Effect.SlideUp('MovieInfos');}
		else{$('minfo_info').addClassName('selected');$('minfo_embed').removeClassName('selected');Effect.SlideDown('MovieInfos');}
	}else 
		{
			if ($('minfo_embed').hasClassName('selected')){$('minfo_embed').removeClassName('selected');Effect.SlideUp('MovieEmbed');}
			else{$('minfo_embed').addClassName('selected');$('minfo_info').removeClassName('selected');Effect.SlideDown('MovieEmbed');}
		}
}
function hideMovieInfo()
{
	$('MovieInfos').style.display = 'none';
	$('minfo_info').removeClassName('selected');
}
function hideMovieEmbed()
{
	$('MovieEmbed').style.display = 'none';
	$('minfo_embed').removeClassName('selected');
}

//-----------------------------------------------------------------------------------------------------------------------------------------
function hideTheatreInfo()
{
	//$('MovieTheatre').style.display = 'none';
	Effect.SlideUp('MovieTheatre');
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function requestTheatres(basePath)
{
	var rCity = '';
	var city = $('city_sel').value;
	if (city != 0) 
	{
		rCity = 'city=' + encodeURIComponent(city);
		new Ajax.Request(basePath + 'theatre/?' + rCity + '&action=gettheatres',
		{
			onSuccess: function(transport)
			{
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				if (json.Theatres)
				{
					
					var thSelect = $('theatre_sel');
					var selOptions = thSelect.childNodes;
					var selLength = selOptions.length;
					
					for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
					
					$H(json.Theatres).each(function(k){
						
						var opt = document.createElement('option');
						opt.text = k.value;opt.value = k.key;
						thSelect.options.add(opt);
					});
					thSelect.disabled = false;
				}
				pageTracker._trackPageview("/cinema_listing.html");
				Effect.SlideDown('MovieTheatre');
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=city&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');$('MovieTheatre').style.display = 'none';
			$('theatre_sel').disabled = true;
		}
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function requestMovies(basePath)
{
	var theatre = $('theatre_sel').value;
	if (theatre != 0) 
	{
		
		var rTheatre = 'theatre=' + encodeURIComponent($('theatre_sel').value);
		var rCity = '&city=' + encodeURIComponent($('city_sel').value);
		new Ajax.Request(basePath + 'theatre/?' + rTheatre + rCity + '&action=getmovies' ,
		{
			onSuccess: function(transport)
			{
				
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				if (json.Movies)
				{
					
					var thSelect = $('movie_sel');
					var selOptions = thSelect.childNodes;
					var selLength = selOptions.length;
					
					for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
					
					$H(json.Movies).each(function(k){
						
						var opt = document.createElement('option');
						opt.text = k.value;opt.value = k.key;
						thSelect.options.add(opt);
					});
					thSelect.disabled = false;
				}
				pageTracker._trackPageview("/cinema_listing.html");
				Effect.SlideDown('MovieTheatre');
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=theatre&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');$('MovieTheatre').style.display = 'none';
			$('movie_sel').disabled = true;
			requestTheatres(basePath);
		}
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function requestMovies2(basePath)
{
	$('theatre_sel').options[0].selected = true;
	$('theatre_sel').disabled = true;
	var city = $('city_sel').value;
	if (city != 0) 
	{
		
		var rCity = 'city=' + encodeURIComponent(city);
		new Ajax.Request(basePath + 'theatre/?' + rCity + '&action=getmovies2' ,
		{
			onSuccess: function(transport)
			{
				
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				
				if (json.Movies)
				{
					
					var thSelect = $('movie_sel');
					var selOptions = thSelect.childNodes;
					var selLength = selOptions.length;
					
					for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
					
					$H(json.Movies).each(function(k){
						
						var opt = document.createElement('option');
						opt.text = k.value;opt.value = k.key;
						thSelect.options.add(opt);
					});
					thSelect.disabled = false;
				}
				
				pageTracker._trackPageview("/cinema_listing.html");
				Effect.SlideDown('MovieTheatre');
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=theatre&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');$('MovieTheatre').style.display = 'none';
			$('movie_sel').options[0].selected = true;
			$('movie_sel').disabled = true;
			requestTheatres(basePath);
		}
}

//-----------------------------------------------------------------------------------------------------------------------------------------
function requestMovie(basePath)
{
	var movie = $('movie_sel').value;
	if (movie != 0) 
	{
		var rMovie = 'movie=' + encodeURIComponent(movie);
		var rTheatre = '&theatre=' + encodeURIComponent($('theatre_sel').value);
		var rCity = '&city=' + encodeURIComponent($('city_sel').value);
		new Ajax.Request(basePath + 'theatre/?' + rMovie + rTheatre + rCity + '&action=getmovie' ,
		{
			onSuccess: function(transport)
			{
				
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				Effect.SlideDown('MovieTheatre');
				
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=movie&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');
			requestMovies(basePath);
		}	
	pageTracker._trackPageview("/cinema_listing.html");	
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function setMovie2(basePath, mid)
{
	var thSelect = $('movie_sel');
	var selLength = thSelect.options.length;
	for (i = selLength - 1; i > 0; i--)
	{
		if (thSelect.options[i].value == mid) thSelect.options[i].selected = true;
	} 
	requestMovie2(basePath);
	return false;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function setTheatre2(basePath, mid, tid)
{
	var thSelect = $('movie_sel');
	var selLength = thSelect.options.length;
	for (i = selLength - 1; i > 0; i--)
	{
		if (thSelect.options[i].value == mid) thSelect.options[i].selected = true;
	} 
	
	var rMovie = 'movie=' + encodeURIComponent(mid);
	var rCity = '&city=' + encodeURIComponent($('city_sel').value);
	var rTheatre = '&theatre=' + encodeURIComponent(tid);
	new Ajax.Request(basePath + 'theatre/?' + rMovie + rCity + rTheatre + '&action=gettheatres2' ,
	{
		onSuccess: function(transport)
		{
			
			var json = transport.responseText.evalJSON();
			hideMovieInfo();hideMovieEmbed();
			$('MovieTheatre').update(json.responseHTML);
			Effect.SlideDown('MovieTheatre');
			if (json.Theatres)
			{
				var thSelect = $('theatre_sel');
				var selOptions = thSelect.childNodes;
				var selLength = selOptions.length;
				
				for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
				
				$H(json.Theatres).each(function(k){
					
					var opt = document.createElement('option');
					opt.text = k.value;opt.value = k.key;
					if (opt.value == tid) opt.selected = true;
					thSelect.options.add(opt);
				});
				thSelect.disabled = false;
			}
		}
	});
	
	return false;
}
//-----------------------------------------------------------------------------------------------------------------------------------------

function requestMovie2(basePath)
{
	var movie = $('movie_sel').value;
	if (movie != 0) 
	{
		var rMovie = 'movie=' + encodeURIComponent(movie);
		var rCity = '&city=' + encodeURIComponent($('city_sel').value);
		new Ajax.Request(basePath + 'theatre/?' + rMovie + rCity + '&action=gettheatres2' ,
		{
			onSuccess: function(transport)
			{
				
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				Effect.SlideDown('MovieTheatre');
				if (json.Theatres)
				{
					var thSelect = $('theatre_sel');
					var selOptions = thSelect.childNodes;
					var selLength = selOptions.length;
					
					for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
					
					$H(json.Theatres).each(function(k){
						
						var opt = document.createElement('option');
						opt.text = k.value;opt.value = k.key;
						thSelect.options.add(opt);
					});
					thSelect.disabled = false;
				}
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=movie&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');
			$('theatre_sel').disabled = true;
			requestMovies2(basePath);
		}	
	pageTracker._trackPageview("/cinema_listing.html");	
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function requestTheatre2(basePath)
{
	var theatre = $('theatre_sel').value;
	if (theatre != 0) 
	{
		var rMovie = 'movie=' + encodeURIComponent($('movie_sel').value);
		var rTheatre = '&theatre=' + encodeURIComponent($('theatre_sel').value);
		var rCity = '&city=' + encodeURIComponent($('city_sel').value);
		new Ajax.Request(basePath + 'theatre/?' + rMovie + rTheatre + rCity + '&action=gettheatre2' ,
		{
			onSuccess: function(transport)
			{
				
				var json = transport.responseText.evalJSON();
				hideMovieInfo();hideMovieEmbed();
				$('MovieTheatre').update(json.responseHTML);
				Effect.SlideDown('MovieTheatre');
				
			}
		});
	}else
		{
			new Ajax.Request(basePath + 'theatre/?p=movie&action=usess',{onSuccess: function(transport){}});
			$('MovieTheatre').update('');
			requestMovie2(basePath);
		}	
	pageTracker._trackPageview("/cinema_listing.html");	
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function showTheatre(basePath, theatre_id, movie_id)
{
	if ($('MovieTheatre').style.display == 'block') $('MovieTheatre').style.display = 'none';
	new Ajax.Request(basePath + 'theatre/?movie_id=' + movie_id + '&theatre=' + encodeURIComponent(theatre_id) + '&action=gettheatre',
	{
		onSuccess: function(transport)
		{
			var json = transport.responseText.evalJSON();
			hideMovieInfo();hideMovieEmbed();
			$('MovieTheatre').update(json.responseHTML);
			Effect.SlideDown('MovieTheatre');
		}
	});
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function requestCities(basePath, date, movie_id)
{
	if (date == 0) {$('city_sel').disabled = true;Effect.SlideUp('MovieTheatre');return;}
	$('city_sel').style.display = 'none';
	$('loading_bar').style.display = 'block';
	new Ajax.Request(basePath + 'theatre/?movie_id=' + movie_id + '&date=' + encodeURIComponent(date) + '&action=getcities',
	{
		onSuccess: function(transport)
		{
			var json = transport.responseText.evalJSON();
			if (json.Cities)
			{
				var thSelect = $('city_sel');
				var selOptions = thSelect.childNodes;
				var selLength = selOptions.length;
				
				for (i = selLength - 1; i > 0; i--) thSelect.removeChild(selOptions[i]);
				
				$A(json.Cities).each(function(k){
					
					var opt = document.createElement('option');
					opt.text = k;opt.value = k;
					thSelect.options.add(opt);
				});
				thSelect.disabled = false;
				
			}
			
			$('city_sel').style.display = 'block';
			$('city_sel').disabled = false;
			$('loading_bar').style.display = 'none';
			
			hideMovieInfo();hideMovieEmbed();
			$('MovieTheatre').update(json.responseHTML);
			Effect.SlideDown('MovieTheatre');
			//$('MovieTheatre').style.display = 'block';
		
			
		}
	});
	//alert(city);	
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function posters(basePath, direction, href)
{
	new Ajax.Request(href + '?ajax=1&action=posters',
	{
		onSuccess: function(transport)
		{
			var json = transport.responseText.evalJSON();
			if (json.prevLink) {$('posters_prev').parentNode.style.display = 'block'; $('posters_prev').href = json.prevLink;}
			else {$('posters_prev').parentNode.style.display = 'none'; $('posters_prev').href = '';}
			
			if (json.nextLink) {$('posters_next').parentNode.style.display = 'block'; $('posters_next').href = json.nextLink;}
			else {$('posters_next').parentNode.style.display = 'none'; $('posters_next').href = '';}
			
			$('posters_list').innerHTML = json.responsePosters;
		}
	});	
	return false;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function playerLoaded(){
    
}
