﻿var last = "";
var $j = jQuery.noConflict();

$j(document).ready(function () {
	var load_url = document.location.toString();

	if (load_url.match("#")) {
		last = setToLC(load_url.split("#")[1]);
		document.getElementById("SponsorsDiv").style.display = "inline";
		if (last == "Sponsors") document.getElementById("SponsorsDiv").style.display = "none";
		if (last != "Sponsors" && last != "ContactUs") {
			var src = $j("#" + last + "Img").attr("src").replace(".gif", "-over.gif");
			$j("#" + last + "Img").attr("src", src);
		}
		document.title = "RBC 2010 | Cardinal Health";
	} else {
		last = "Home";
		var src = $j("#" + last + "Img").attr("src").replace(".gif", "-over.gif");
		$j("#" + last + "Img").attr("src", src);
		$j("#MainAreaDiv").load(last + "/content.aspx");
	}

	$j("#MainAreaDiv").load(last + "/content.aspx");

	$j("#NavigationDiv img")
	.click(function () {
		setNavigation(this, "-over.gif", ".gif");
	})
	.mouseover(function () {
		setNavigation(this, ".gif", "-over.gif");
	})
	.mouseout(function () {
		setNavigation(this, "-over.gif", ".gif");
	});

	$j("#NavigationDiv a").click(function () {
		setMainAreaDiv(this);
		return false;
	});

	$j("#SponsorsViewAllLink").click(function () {
		setMainAreaDiv(this);
		return false;
	});

	$j("#FooterHomeLink").click(function () {
		setMainAreaDiv(this);
		return false;
	});

	$j("#FooterContactUsLink").click(function () {
		setMainAreaDiv(this);
		return false;
	});

	function setNavigation(value, oldP, newP) {
		var next = $j(value).attr("id").split("Img")[0];
		if (last != next) {
			var src = $j(value).attr("src").replace(oldP, newP);
			$j(value).attr("src", src);
		}
	}

	function setMainAreaDiv(value) {
		var next = $j(value).attr("href").split("#")[1];
		if (last == "Sponsors") document.getElementById("SponsorsDiv").style.display = "inline";
		if (next == "Sponsors") document.getElementById("SponsorsDiv").style.display = "none";
		if (last != next) {
			if (last != "Sponsors" && last != "ContactUs") {
				var src = $j("#" + last + "Img").attr("src").replace("-over.gif", ".gif");
				$j("#" + last + "Img").attr("src", src);
			}
			if (next != "Sponsors" && next != "ContactUs") {
				var src = $j("#" + next + "Img").attr("src").replace(".gif", "-over.gif");
				$j("#" + next + "Img").attr("src", src);
			}
			last = next;
			$j("#MainAreaDiv").load(last + "/content.aspx");
		}
	}

	function setToLC(value) {
		value = value.toLowerCase();
		if (value == "home") {
			return "Home"
		}
		if (value == "scheduleofevents") {
			return "ScheduleOfEvents"
		}
		if (value == "generalinformation") {
			return "GeneralInformation"
		}
		if (value == "entertainmentandevents") {
			return "EntertainmentAndEvents"
		}
		if (value == "continuingeducation") {
			return "ContinuingEducation"
		}
		if (value == "campcardinalhealth") {
			return "CampCardinalHealth"
		}
		if (value == "informationforexhibitors") {
			return "InformationForExhibitors"
		}
		if (value == "followusontwitter") {
			return "FollowUsOnTwitter"
		}
		if (value == "rbc2011") {
			return "RBC2011"
		}
		if (value == "sponsors") {
			return "Sponsors"
		}
		if (value == "contactus") {
			return "ContactUs"
		}
	}
});