// JavaScript Document


var vDay = 0;
var vFlier = 0;

$(document).ready(function()
{
	$(".popup, .popupContact").hide();
	
	$("#restaurant").mouseenter(function()
	{
		$("a#food-enter").fadeIn(700);
	});
	
	$("#nightclub").mouseenter(function()
	{
		$("a#club-enter").fadeIn(700);
	});
	
	$("#nightclub").mouseleave(function()
	{
		$("a#club-enter").fadeOut(500);
	});
	$("#restaurant").mouseleave(function()
	{
		$("a#food-enter").fadeOut(500);
	});

	// Additional information animation.
	$(".navbar2").hide();
	$("#flyerSlideshow").hide();
	$("#eventsPanel").hide();
	$("#eventHeading").hide();
	//$("#galleries").hide();
	$("#eventGallery").hide();
	$("#gallery-title").hide();
	$("#gallery-shadow").hide();
	$("#galleryArchive").hide();
	$("#backtolist").hide();

	$(".panelActivate a").click(function()
	{
		$("#eventsPanel").animate({
			top: "60px"
		}, 800);

		$(".panelActivate").fadeOut("fast");
		$("#panelClose").fadeIn("slow");
		
	});

	$("#home").click(function()
	{
		GoFromGallery();
		GoFromGalleryList();
		GoToHome();
	});


	$("#panelClose a").click(function()
	{
		$("#eventsPanel").animate({
			top: "650px"
		}, 800);

		$(".panelActivate").fadeIn("slow");
		$("#panelClose").fadeOut("fast");

	});



	$("a#events, .link").click(function(){
										
		GoFromGalleryList();
		GoFromGallery();
		//$("#WedMenu").click();
		SetWed();
		$(".navbar").fadeOut(700);
		$(".navbar2").fadeIn(1500);
		$("#backlink").fadeIn(1000);
		$("#backtodash").fadeOut(500);
		
		$("#logo").pause(750).fadeOut(500);
		
		$("#eventsPanel").pause(1000).fadeIn(1000);
		$("#flyerSlideshow").pause(1250).fadeIn(750);
		$("#eventHeading").pause(1250).fadeIn(500);
	});
	
	$("a#gallery").click(function(){
		

		
		//$("#eventsPanel").pause(1000).fadeIn(1000);
		//$("#flyerSlideshow").pause(1250).fadeIn(750);
		
		GoFromGallery();
		GoToGalleryList();
	});
	

	$("a#backlink").click(function()
	{
		$(".navbar2").fadeOut(700);

		$(".navbar").fadeIn(1500);
		$("#backlink").fadeOut(500);
		$("#backtodash").fadeIn(1000);
		$("#thisweek").pause(1250).fadeIn(250);

		$("#mainBanner").pause(1250).fadeIn(500);
		
		$("#logo").pause(750).fadeIn(500);
		$("#footer").pause(750).fadeIn(500);

		$("#eventsPanel").pause(250).fadeOut(250);
		$("#flyerSlideshow").pause(250).fadeOut(250);
		$("#eventHeading").fadeOut(500);

	});
	
	
	
	

	//Module Clicks that set the top menu and header and contents.
	$(".WedLink").click(function()
	{
		$("#WedMenu").click();
		SetWed();
	});
	$(".ThursLink").click(function()
	{
		$("#ThursMenu").click();
		SetThurs();
	});
	$(".FriLink").click(function()
	{
		$("#FriMenu").click();
		SetFri();
	});
	$(".SatLink").click(function()
	{
		$("#SatMenu").click();
		SetSat();
	});
	$(".SunLink").click(function()
	{
		$("#SunMenu").click();
		SetSun();
	});
	
	//Top Menu's don't set things right.
	$("#WedMenu").click(function()
	{
		SetWed();
	});
	$("#ThursMenu").click(function()
	{
		SetThurs();
	});
	$("#FriMenu").click(function()
	{
		SetFri();
	});
	$("#SatMenu").click(function()
	{
		SetSat();
	});
	$("#SunMenu").click(function()
	{
		SetSun();
	});
	$("#SpecMenu").click(function()
	{
		SetSpecial();
	});

	/* Modules fade out on events button click
	-------------------------------------------------------------------------- */
	$("a#events, .link, a#gallery").click(function()
	{
		GoFromHome();
	});



	/* Modules fade out on backlink button click
	-------------------------------------------------------------------------- */
	$("a#backlink").click(function()
	{
		//GoToHome();
		$("#home").click();
	});


	/* Gallery Listings
	-------------------------------------------------------------------------- */
		
		
	$("a#backtolist").click(function(){
		GoFromGallery();
		GoToGalleryList();
	});	
	
	$("#listing a").click(function(){
		$(".listing2").pause(75).fadeOut(125);
		$(".listing3").pause(250).fadeOut(250);
		$(".listing1").fadeOut(375);
		$("#listingShadow").pause(250).fadeOut(250);
		$("#galleryArchive").pause(375).fadeOut(250);
		$("#backtolist").fadeIn(1000);
	});
});

function SetWed()
{
	$("#DayHeader").attr("src", "images/wednesday-hdr.png");
	vDay = 2;
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=2");
}
function SetThurs()
{
	$("#DayHeader").attr("src", "images/thursday-hdr.png");
	vDay = 3;
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=3");
}
function SetFri()
{
	$("#DayHeader").attr("src", "images/friday-hdr.png");
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=4");
	vDay = 4;
}
function SetSat()
{
	$("#DayHeader").attr("src", "images/saturday-hdr.png");
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=5");
	vDay = 5;
}
function SetSun()
{
	$("#DayHeader").attr("src", "images/sunday-hdr.png");
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=6");
	vDay = 6;
}
function SetSpecial()
{
	$("#DayHeader").attr("src", "images/specialEvents-hdr.png");
	$("#flyerSlideshow").load("ViewEntries.php?What=Fliers&Day=7");
	vDay = 7;
}
function ParseFlier(tFlier)
{
	SetFlier(tFlier.substring(5));
}
function LoadFlierSummaries()
{
	$("#columnLeft").load("ViewEntries.php?Day="+vDay+"&What=Summaries");
}
function LoadFlierDetails()
{
	$("#panelFlyer").load("ViewEntry.php?Day="+vDay+"&EventID="+vFlier+"&What=Image");
	$("#columnRight").load("ViewEntry.php?Day="+vDay+"&EventID="+vFlier);
}
function SetFlier($tValue)
{
	vTemp = "#Summary" + vFlier;
	$(vTemp).removeClass("active");
	vFlier = $tValue;
	vTemp = "#Summary" + vFlier;
	$(vTemp).addClass("active");
}
function SetSummary()
{
	vTemp = "#Summary" + vFlier;
	$(vTemp).addClass("active");
}

//Gallery Functions
function GoToGalleryList()
{
	//We need to fade in and get the listing
	$("#galleries").pause(500).fadeIn(500);
	$("#listingShadow").pause(500).fadeIn(250);
	$("#galleryArchive").pause(500).fadeIn(250);
	$("#listing").load("gallerylisting.php");
	$(".listContainer").load("gallerypreview.php");
	$("#eventHeading").pause(500).fadeIn(500);
	$("#DayHeader").attr("src", "images/gallery-hdr.png");
	//We need to fade in and get the (up to ) 9 images
}
function GoFromGalleryList(tListing)
{
	switch(tListing)
	{
		case 1:
			$(".listing2").fadeOut(375);
			$(".listing3").pause(75).fadeOut(125);
			$(".listing1").pause(250).fadeOut(250);
			break;
		case 2:
			$(".listing1").fadeOut(375);
			$(".listing3").pause(250).fadeOut(250);
			$(".listing2").pause(75).fadeOut(125);
			break;
		case 3:
			$(".listing2").pause(75).fadeOut(125);
			$(".listing3").pause(250).fadeOut(250);
			$(".listing1").fadeOut(375);
			break;
		default:
			$(".listing2").fadeOut(375);
			$(".listing3").fadeOut(375);
			$(".listing1").fadeOut(375);
			break;
	}

	//$("#galleries").hide();
	$("#listingShadow").pause(250).fadeOut(250);
	$("#galleryArchive").pause(375).fadeOut(250);
	$("#eventHeading").fadeOut(250);
}
function GoToGallery(tEventID)
{
	$("#eventGallery").fadeIn(500);
	$("#gallery-title").pause(500).fadeIn(750);
	$("#gallery-shadow").pause(500).fadeIn(500);
	$("#eventHeading").pause(500).fadeIn(250);
	$("#DayHeader").attr("src", "images/gallery-hdr.png");
	$("#gallery_wrap").load("galleryitem.php?EventID="+tEventID);
	$("#backtolist").pause(500).fadeIn(1000);
	$("#backtodash").fadeOut(500);
}
function GoFromGallery()
{
	$("#eventGallery").fadeOut(500);
	$("#gallery-title").fadeOut(750);
	$("#gallery-shadow").fadeOut(500);
	$("#eventHeading").fadeOut(250);
	$("#backtolist").fadeOut(500);
	$("#backtodash").fadeIn(1000);
}

function GoToHome()
{
		$("#lineup li.wed").fadeIn("slow");
		$("#lineup li.thurs").pause(250).fadeIn("slow");
		$("#lineup li.fri").pause(550).fadeIn("slow");
		$("#lineup li.sat").pause(250).fadeIn("slow");
		$("#lineup li.sun").fadeIn("slow");
		$("#thisweek").pause(750).fadeIn(500);
		$("#logo-body").fadeIn(500);
		$("#mainBanner").pause(750).fadeIn(500);
}

function GoFromHome()
{
		$("#lineup li.wed").fadeOut("slow");
		$("#lineup li.sun").fadeOut("slow");
		$("#lineup li.thurs").pause(500).fadeOut("slow");
		$("#lineup li.sat").pause(500).fadeOut("slow");
		$("#lineup li.fri").pause(750).fadeOut("slow");
		$("#thisweek").pause(750).fadeOut(500);
		$("#logo-body").fadeOut(500);
		$("#mainBanner").pause(750).fadeOut(500);
}
