/***** The Following is for the theater_info sub_menu *****/

function turnoffHighlight() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("nav2")) return false;
  var nav = document.getElementById("nav2");
  var links = nav.getElementsByTagName("a");
  for (var i=0; i<links.length; i++) {
      links[i].className = "";
      //var linktext = links[i].lastChild.nodeValue.toLowerCase();
      //document.body.setAttribute("id",linktext);
    }
}

function turnonHighlight(id) {
	var navOn = document.getElementById(id);
	navOn.className = "active";
}

/********************************/
/*      Show Ticket Prices      */
/********************************/
function showTicketPrices() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'block';
	turnonHighlight("li_ticketprices");
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*       Show Showtimes         */
/********************************/
function showShowtimes() {
	turnoffHighlight();
	$('showtimes').style.display = 'block';
	turnonHighlight("li_showtimes");
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*         Show Parties         */
/********************************/
function showParties() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'block';
	turnonHighlight("li_parties");
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*        Show Specials         */
/********************************/
function showSpecials() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'block';
	turnonHighlight("li_specials");
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*        Show Rewards          */
/********************************/
function showRewards() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'block';
	turnonHighlight("li_rewards");
	$('pictures').style.display = 'none';
}

/********************************/
/*        Show Reviews          */
/********************************/
function showReviews() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'block';
	turnonHighlight("li_reviews");
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*         Show Groups          */
/********************************/
function showGroups() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'block';
	turnonHighlight("li_groups");
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'none';
}

/********************************/
/*        Show Pictures         */
/********************************/
function showPictures() {
	turnoffHighlight();
	$('showtimes').style.display = 'none';
	$('parties').style.display = 'none';
	$('ticketprices').style.display = 'none';
	$('specials').style.display = 'none';
	$('groups').style.display = 'none';
	$('reviews').style.display = 'none';
	$('rewards').style.display = 'none';
	$('pictures').style.display = 'block';
	turnonHighlight("li_pictures");
}

/********************************/
/*        Weather Info          */
/********************************/
function ShowWeather() {
	if ($('weather_div').style.display == 'block') {
		$('weather_div').style.display = 'none';
		$('show_weather').innerHTML = '<a onclick="ShowWeather();">Show Local Weather<br /></a><img src="images/weather.gif" border="0" />';
	} else {
		$('weather_div').style.display = 'block';
		$('show_weather').innerHTML = '<a onclick="ShowWeather();">Hide Local Weather</a>';
	}
}


/**********************************************************/

/***** The Following is for the Guestbook area *****/

function addGuestbook() {
	$('content_guestbook').style.display = 'none';
	$('content_guestbook_add').style.display = 'block';
}

function CanceladdGuestbook() {
	$('content_guestbook').style.display = 'block';
	$('content_guestbook_add').style.display = 'none';
}

/**********************************************************/

/********************************/
/*    Yahoo! Movie Search       */
/********************************/
function YahooMovieSearch() {
	var string = $F('inputtext3');
	window.open ("http://movies.yahoo.com/mv/search?p="+string);
}


/********************************/
/* Check Theater on page load   */
/********************************/
function checkTheater() {
	
	var Tcookie = readCookie('theater');
	
	if (Tcookie == null) {
		//$('theater_status').innerHTML = ''; //No Theater Chosen
	}
	else {
		$('ajax_loading').style.display='block';
		$('theater_status').style.display='none';
		var rtsID = 'rtsID=' + Tcookie;
		pars = 'rtsID=' + Tcookie + '&home=Y';
		//retrieveInfo(pars);
		get_theater_name(rtsID);
	}
}

/********************************/
/*      Get Theater Name        */
/********************************/
function get_theater_name(rtsID) {
	var myAjax = new Ajax.Request('get_theater_name.php', 
	          {method: 'get', parameters: rtsID, onComplete:setTheaterStatus});
}
/********************************/


/********************************/
/*  Retrieve Theater Name and   */
/*  set it in 'theater-status'  */
/********************************/
function setTheaterStatus(response) {
	$('theater_status').innerHTML = '';
	//$('theater_status').innerHTML = '<br>Click Here For<br>' + response.responseText + '<br>Showtimes';
	$('theater_status').innerHTML = '<img style=\"padding-bottom: 0px;\" border=\"0\" src=\"images/icons/theater.png\" height=\"32\" width=\"32\">&nbsp;' + response.responseText;
	$('ajax_loading').style.display='none';
	$('theater_status').style.display='block';
	correctPNG();
}
/********************************/

/********************************/
/*    Retrieve Theater Info     */
/********************************/
function retrieveInfo(pars) {
	//alert(pars);
	var myAjax = new Ajax.Request('theater_info.php', 
	          {method: 'get', parameters: pars, onComplete:dosetTheaterResponse});
}
/********************************/


/********************************/
/*   Populate 'content-div'     */
/*      with theater data       */
/********************************/
function dosetTheaterResponse(response) {
	
	//a return visitor?
	//var x = pars.split("=");
	//home = x[2];
	
	//if (home == 'Y') {
		//($('content_home').style.display = 'block');
		//($('content_theater').style.display = 'none');
		
	//} else {
		//($('content_home').style.display = 'none');
		//($('content_theater').style.display = 'block');
		
	//}

	/* Check for errors ... a response of '-1' indicates that the text below was NOT found */
	IsResponseError = response.responseText.indexOf('Error');

	if (IsResponseError == '-1') { //no error reported
		//populate Theater Info div
		$('content_theater').innerHTML = response.responseText;
		
		//hide loading
		$('ajax_loading').style.display='none';
		$('theater_status').style.display='block';

		var Tcookie = readCookie('theater');
		var rtsID = 'rtsID=' + Tcookie;
		//get_theater_name(rtsID);
	} else {
		//populate Theater Info div
		$('content_theater').innerHTML = response.responseText;
		
		//hide loading
		$('ajax_loading').style.display='none';
		$('ajax_loading2').style.display='none';
		$('theater_status').style.display='block';
	}
}
/********************************/

function update_theater_info(url,rtsID) {
	$('ajax_loading2').style.display='block';
	pars = 'UPDATE=' + url + '&rtsID=' + rtsID;
	var myAjax = new Ajax.Request('theater_info.php', 
	          {method: 'get', parameters: pars, onComplete:dosetTheaterResponse});
}

/****************************************************/
/*   Set cookie based on theater select box         */
/****************************************************/
function setTheater(rtsID) {
	//show loading
	$('ajax_loading').style.display='block';
	//$('theater_status').style.display='none';
	
	var URL = "theater.php?rtsID=";
	
	//get rtsID
	if (rtsID=='none') { // select_drop_down combo box
	var rtsID = $F('select_theater_drop_down');

		if (rtsID=='000' || rtsID=='001') {
			alert("Invalid Choice");
			$('ajax_loading').style.display='none';
			$('theater_status').style.display='block';
			location.href="theaters.php";
		} else {

			//set cookie
			eraseCookie('theater');
			createCookie('theater',rtsID,31);
			
			location.href="theater.php?rtsID="+rtsID;
			
			//Now retrieve the info
			//pars = 'rtsID=' + rtsID;
			//retrieveInfo(pars);

			//$('content_theater').style.display = 'block';
			//$('content_select_theaters').style.display = 'none';
		}
	} else { 
	
		//set cookie
		eraseCookie('theater');
		createCookie('theater',rtsID,31);
		
		//send to theater information page
		location.href="theater.php?rtsID="+rtsID;
	}
}
/********************************/

function GoTo(url) {
	location.href=url;
}

/********************************/
/*           Content            */
/********************************/
function ShowContent(id) {
	if ($(id).style.display=='none') {
		//new Effect.BlindDown(id,{duration:.3});
		($(id).style.display='block')
	} else {
		HideContent(id);
	}
}

function HideContent(id) {
	//new Effect.BlindUp(id,{duration:.3});
	($(id).style.display='none')

}

/********************************/
/*     Event/Sotries/News       */
/********************************/

function getEvent(SID) {
	$('event_loading').style.display='block';
	pars = 'SID=' + SID;
	var myAjax2 = new Ajax.Request('get_event.php', 
	          {method: 'get', parameters: pars, onComplete:ShowEventContent});
	//alert(SID);
}
/********************************/

function ShowEventContent(response) {

	new Effect.BlindUp('event_content',{duration:.3});
	
	$('event_content2').innerHTML = '';
	//$('theater_status').innerHTML = '<br>Click Here For<br>' + response.responseText + '<br>Showtimes';
	$('event_content2').innerHTML = '<div align="center" style="width:100%;"><a onclick=\"CloseEventContent(\'event_content2\',\'event_content\');\">Return to News and Events</a></div>' + response.responseText + '<br><div align="center" style="width:100%;"><a onclick=\"CloseEventContent(\'event_content2\',\'event_content\');\">Return to News and Events</a></div>';
	$('event_content2').style.display='block';
	new Effect.BlindDown('event_content2',{duration:.3});
	$('event_loading').style.display='none';
	correctPNG();
}

function CloseEventContent(id1,id2) {
	new Effect.BlindUp(id1,{duration:.3});
	new Effect.BlindDown(id2,{duration:.3});
}

/********************************/

function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}