/**
  @author Kirk Ouimet Design
  @filename summit.js
  @website http://www.summitconf.org/
  Custom JavaScript for Summit
*/

/* Function Name
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
// AJAX Navigation
function changeContent(divToChange, liToChange, contentToLoad) {
	// Disable the link
	if(liToChange == "eventsLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"eventsLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">Events</a>";
	else if(document.getElementById("eventsLinkLI"))
		document.getElementById("eventsLinkLI").innerHTML = "<a id=\"eventsLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'eventsLinkLI', 'events.php'); return false;\">Events</a>";
	if(liToChange == "aboutLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"aboutLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">About</a>";
	else if(document.getElementById("aboutLinkLI"))
		document.getElementById("aboutLinkLI").innerHTML = "<a id=\"aboutLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'aboutLinkLI', 'about.php'); return false;\">About</a>";
	if(liToChange == "resourcesLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"resourcesLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">Resources</a>";
	else if(document.getElementById("resourcesLinkLI"))
		document.getElementById("resourcesLinkLI").innerHTML = "<a id=\"resourcesLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'resourcesLinkLI', 'resources.php'); return false;\">Resources</a>";
	if(liToChange == "sponsorsLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"sponsorsLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">Sponsors</a>";
	else if(document.getElementById("sponsorsLinkLI"))
		document.getElementById("sponsorsLinkLI").innerHTML = "<a id=\"sponsorsLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'sponsorsLinkLI', 'sponsors.php'); return false;\">Sponsors</a>";
	if(liToChange == "registerLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"registerLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">Register</a>";
	else if(document.getElementById("registerLinkLI"))
		document.getElementById("registerLinkLI").innerHTML = "<a id=\"registerLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'registerLinkLI', 'register.php'); return false;\">Register</a>";		
	if(liToChange == "contactLinkLI")
		document.getElementById(liToChange).innerHTML = "<a id=\"contactLink\" style=\"background: #FFF; font-weight: bold;\" href=\"javascript:void(0)\" onclick=\"return false;\">Contact</a>";
	else if(document.getElementById("contactLinkLI"))
		document.getElementById("contactLinkLI").innerHTML = "<a id=\"contactLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat !important; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'contactLinkLI', 'contact.php'); return false;\">Contact</a>";		

	// Update the div
	Effect.BlindUp(divToChange, {
		duration:.5,
		afterFinish:function() {
			document.getElementById(divToChange).innerHTML = "<img src=\"img/ajax-loader.gif\" alt=\"\" /><span style=\"font-size: 1.2em;\">&nbsp;Retrieving content...</span>";
			var target = divToChange;
			var url = contentToLoad;
			var changer = new Ajax.Updater(target, url, {
				method:'get',
				onComplete:function() {
					Effect.Appear(divToChange, {
						duration:.5,
						afterFinish:function() {
							if(contentToLoad == "events.php") {
								new Control.Tabs('summit_tabs');
							}
							document.getElementById(divToChange).style.height = "auto !important"; // Fix the height
						}
					});
				}
			});
		}
	});
}

function resetLinks() {
	document.getElementById("eventsLinkLI").innerHTML = "<a id=\"eventsLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'eventsLinkLI', 'events.php'); return false;\">Events</a>";
	document.getElementById("aboutLinkLI").innerHTML = "<a id=\"aboutLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'aboutLinkLI', 'about.php'); return false;\">About</a>";
	document.getElementById("resourcesLinkLI").innerHTML = "<a id=\"resourcesLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'resourcesLinkLI', 'resources.php'); return false;\">Resources</a>";
	document.getElementById("sponsorsLinkLI").innerHTML = "<a id=\"sponsorsLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'sponsorsLinkLI', 'sponsors.php'); return false;\">Sponsors</a>";
	document.getElementById("registerLinkLI").innerHTML = "<a id=\"registerLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'registerLinkLI', 'register.php'); return false;\">Register</a>";		
	document.getElementById("contactLinkLI").innerHTML = "<a id=\"contactLink\" style=\"background: #EDF1F8 url(\"/img/nav_bg.gif\") no-repeat; font-weight: normal;\" href=\"javascript:void(0)\" onclick=\"changeContent('contentContainer', 'contactLinkLI', 'contact.php'); return false;\">Contact</a>";		
}