// view content methods

var selectedSection;
var innerAdHidden = false;
var gameChoiceHidden = true;
var isGameSelected = false;

function playVideo() {
	$('viewflash').playVideo();
}

function pauseVideo() {
	$('viewflash').pauseVideo();
}

function gotoSection(n) {
	try
	{
		n = n.toLowerCase();
		if($('viewflash') != null)
			$('viewflash').gotoSectionID(n);		
	}
	catch(e)
	{
		//
	}
	return false;
}

function ResetSeatsDropDowns()
{
	if(document.getElementById('DynamicSeatSelector1_cboSection') != null)
		document.getElementById('DynamicSeatSelector1_cboSection').selectedIndex = 0;

	if(document.getElementById('DynamicSeatSelector1_cboRows') != null)
	{
		document.getElementById('DynamicSeatSelector1_cboRows').selectedIndex = 0;
		document.getElementById('DynamicSeatSelector1_cboRows').disabled = true;
	}

	if(document.getElementById('DynamicSeatSelector1_cboSeats') != null)
	{
		document.getElementById('DynamicSeatSelector1_cboSeats').selectedIndex = 0;
		document.getElementById('DynamicSeatSelector1_cboSeats').disabled = true;
	}
}

function SetSeat(n)
{
	if( document.getElementById('DynamicSeatSelector1_idSeat') != null)
		document.getElementById('DynamicSeatSelector1_idSeat').value = n;
	
	if( document.getElementById('DynamicSectionInfo1_seatId') != null)
		document.getElementById('DynamicSectionInfo1_seatId').value = n;
}

function gotoMap(which) {
	$('viewflash').ExternalConnection(which);
	
	if(which == 0) {
		$('flashtitle').innerHTML = 'Seating Chart - Arena Bowl';
	}
	
	if(which == 1) {
		$('flashtitle').innerHTML = 'Seating Chart - Floor Seating';
	}
	
	if($('DynamicCalendar1_view_gamechoice') != null &&  isGameSelected)
	{
		Element.show('DynamicCalendar1_view_gamechoice');
	}
	
	if(selectedSection) {
		Element.show('menu1');
		Element.show('menu2');
		$('menu1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
		$('qmim1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
	} else {
		Element.hide('menu1');
		Element.hide('menu2');
	}
	return false;
}

function gotoCenterCourt() {
	$('viewflash').ExternalConnection(2);
	$('flashtitle').innerHTML = '360&deg; View';
	if(selectedSection) {
		Element.show('menu2');
		$('menu1').innerHTML = '<img src="Images/filmIcon.gif" alt="Center Court" align="bottom" /> Section ' + selectedSection;
		$('qmim1').innerHTML = '<img src="Images/filmIcon.gif" alt="Center Court" align="bottom" /> Section ' + selectedSection;
	} else {
		Element.hide('menu1');
		Element.hide('menu2');
	}
	return false;
}

function gotoAmenities() {
	$('viewflash').showAmenities();
	$('flashtitle').innerHTML = 'Section ' + selectedSection + " Amenities";
	if(selectedSection) {
		Element.show('menu2');
		$('menu1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
		$('qmim1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
	} else {
		Element.hide('menu1');
		Element.hide('menu2');
	}
	return false;
}

function BlindUpCalendar(callback)
{
	if(gameChoiceHidden)
	{
		if(innerAdHidden)
		{
			BlindDownCalendar();
		}
		else
		{
			innerAdHidden = true;
			new Effect.BlindUp('innerad', {duration:0.5, afterFinish:callback});
		}
	}
	else
	{
		if(document.getElementById('DynamicCalendar1_view_gamechoice') != null)
		{
			new Effect.BlindUp('DynamicCalendar1_view_gamechoice', {duration:0.5, afterFinish:callback});	
		}
		else
		{
		    callback();
		}
	}
}		  

function BlindDownCalendar()
{
	gameChoiceHidden = false;
	isGameSelected = true;
	if(document.getElementById('DynamicCalendar1_view_gamechoice') != null)
	{
		new Effect.BlindDown('DynamicCalendar1_view_gamechoice', {duration:0.5});
		closeSectionInfo();
		closeCalendar();
	}
}

function showInput(n) {
	if(n != "undefined" && n != null) {		
		selectedSection = n.toLowerCase();
		var ctrlName = 'DynamicSectionInfo1_sectionId';		
		if(document.getElementById(ctrlName).value == null || document.getElementById(ctrlName).value != selectedSection)
		{
			document.getElementById(ctrlName).value = selectedSection;
			if (!$("view_seatinfo") || $("view_seatinfo").style.display == "none")
			{
				__DK_DoCallBack('DynamicSectionInfo1$sectionId', '', 'DynamicSectionInfo1$AjaxPanel1', false, '', true, null, ShowInputEffect, null);
			}
			else
			{
				new Effect.BlindUp('view_seatinfo', {duration:0.5, afterFinish: function() {__DK_DoCallBack('DynamicSectionInfo1$sectionId', '', 'DynamicSectionInfo1$AjaxPanel1', false, '', true, null, ShowInputEffect, null);}});
			}
        }
        else
        {
			Element.show('menu1');
			Element.show('menu2');
        }
		if(!gameChoiceHidden)
		{
			if(document.getElementById('DynamicCalendar1_view_gamechoice') != null)
			{
				new Effect.BlindUp('DynamicCalendar1_view_gamechoice', {duration:0.5});	
			}
		}
		ResetSeatsDropDowns();
	}
}

function ShowDirections2()
{
   	Element.show('dir_ad1');
	Element.hide('custom_address');
}


function ShowInputEffect()
{    	
	if(!innerAdHidden) {
		innerAdHidden = true;
		new Effect.BlindUp('innerad', {duration:0.5});
	}
	new Effect.BlindUp('view_seatinfo', {queue: {position:'front', scope: 'contentScope'} });
	new Effect.BlindDown('view_seatinfo', {queue: {position:'end', scope: 'contentScope'} });
	Element.show('menu1');
	Element.show('menu2');
	$('menu1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
	$('qmim1').innerHTML = '<img src="Images/filmIcon.gif" align="bottom" /> Section ' + selectedSection + "&raquo;";
	$('flashtitle').innerHTML = 'Seat View - Section ' + selectedSection;
	closeCalendar();
	if(!gameChoiceHidden) {
		closeCalendarDetail();
	}
}

function getSelectedSection() {
	if(selectedSection) {
		gotoSection(selectedSection);
	} else {
		gotoMap();	
	}
}

function openCalendar()
{
	new Effect.BlindDown('calendarmodule', {duration:0.5});
	Element.show('view_calendar_close');
	Element.hide('view_calendar_open');
}

function closeCalendar()
{
	new Effect.BlindUp('calendarmodule', {duration:0.5, afterFinish:nd});
	Element.hide('view_calendar_close');
	Element.show('view_calendar_open');
}

function openCalendarDetail()
{
	new Effect.BlindDown('calendarDetail', {duration:0.5});
	Element.show('view_calendardetail_close');
	Element.hide('view_calendardetail_open');
}

function closeCalendarDetail()
{
	new Effect.BlindUp('calendarDetail', {duration:0.5});
	Element.hide('view_calendardetail_close');
	Element.show('view_calendardetail_open');
}

function openSectionInfo()
{
	new Effect.BlindDown('sectionInfo', {duration:0.5});
	Element.show('view_section_close');
	Element.hide('view_section_open');
}

function closeSectionInfo()
{
	new Effect.BlindUp('sectionInfo', {duration:0.5});
	Element.hide('view_section_close');
	Element.show('view_section_open');
}

function PageQuery(q)
{
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}

	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}

	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++)
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}

	this.getLength = function() { return this.keyValuePairs.length; }
}

function queryString(key)
{
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key));
}