var navSet;

if (thisPage == "shows") {
	$("#navShows").addClass("navSelected");
	$("#upcomingShows").css("top", "12px");
	$("#upcomingShows").show();
	$("#mailingList").css("top", "12px");
	$("#mailingList").show();
}

if (thisPage == "proximity") {
	$("#navMailingList").addClass("navSelected");
	$("#mailingList2").css("top", "12px");
	$("#mailingList2").show();
	$("#twitter").css("top", "12px");
	$("#twitter").show();
	$("#facebook").css("top", "12px");
	$("#facebook").show();
}

if (thisPage == "cd" || thisPage == "itunes") {
	$("#navCD").addClass("navSelected");
	$("#cd").css("top", "12px");
	$("#cd").show();
	$("#iTunes").css("top", "12px");
	$("#iTunes").show();
}

if (thisPage == "audio" || thisPage == "video") {
	$("#navAV").addClass("navSelected");
	$("#audio").css("top", "12px");
	$("#audio").show();
	$("#video").css("top", "12px");
	$("#video").show();
}

if (thisPage == "pictures") {
	$("#navImages").addClass("navSelected");
	$("#renderings").css("top", "12px");
	$("#renderings").show();
	$("#photos").css("top", "12px");
	$("#photos").show();
}

if (thisPage == "writings" || thisPage == "emocopia" || thisPage == "industry") {
	$("#navVarious").addClass("navSelected");
	$("#writings").css("top", "12px");
	$("#writings").show();
	$("#emocopia").css("top", "12px");
	$("#emocopia").show();
	$("#industry").css("top", "12px");
	$("#industry").show();
}

switch(thisPage) {
	case "shows":
		document.title = "Emo Philips - Shows";
	break;
	case "proximity":
		document.title = "Emo Philips - Proximity";
	break;
	case "cd":
		document.title = "Emo Philips - CD";
	break;
	case "itunes":
		document.title = "Emo Philips - iTunes";
	break;
	case "audio":
		document.title = "Emo Philips - Audio";
	break;
	case "video":
		document.title = "Emo Philips - Video";
	break;
	case "pictures":
		document.title = "Emo Philips - Images";
	break;
	case "writings":
		document.title = "Emo Philips - Writings";
	break;
	case "emocopia":
		document.title = "Emo Philips - Emocopia";
	break;
	case "industry":
		document.title = "Emo Philips - Industry";
	break;
}

$(".navBtn").mouseenter(
	function(){ $(this).css({ "background-color": "#fbc729", "color": "#006699" });}
);

$(".navBtn").mouseleave(
	function(){
		if (!$(this).hasClass("navSelected")) {
			$(this).css({ "background-color": "#006699", "color": "#fbc729" });
		}
	}
);

//moveFooter();

//swfobject.createCSS("#navFlotsam", "position: absolute;top: 0px;left: 330px;width: 650px;height: 180px;z-index: 0;");
//swfobject.embedSWF(siteURL + "themes/site_themes/emo/flash/flotsams.swf", "navFlotsam", "650", "180", "10.0.0", "", {}, {wmode: "transparent"}, {});

$("#navShows").click(showNavShows);
$("#navCD").click(showNavCD);
$("#navAV").click(showNavAV);
$("#navImages").click(showNavImages);
$("#navMailingList").click(showNavMailingList);
$("#navVarious").click(showNavVarious);

function unHighlightNavs() {
	$("#navShows,#navCD,#navAV,#navImages,#navMailingList,#navVarious").each(
		function(i){
			if (!$(this).hasClass("navSelected")) {
				$(this).css({ "background-color": "#006699", "color": "#fbc729" });
			}
		});
}

function showNavShows() {
	showNavs();
	$("#navShows").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#upcomingShows");
	showNavItem("#mailingList");
}

function showNavCD() {
	showNavs();
	$("#navCD").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#cd");
	showNavItem("#iTunes");
}

function showNavAV() {
	showNavs();
	$("#navAV").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#audio");
	showNavItem("#video");
}

function showNavImages() {
	showNavs();
	$("#navImages").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#renderings");
	showNavItem("#photos");
}

function showNavMailingList() {
	showNavs();
	$("#navMailingList").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#mailingList2");
	showNavItem("#twitter");
	showNavItem("#facebook");
}

function showNavVarious() {
	showNavs();
	$("#navVarious").addClass("navSelected");
	unHighlightNavs();
	showNavItem("#writings");
	showNavItem("#emocopia");
	showNavItem("#industry");
}

function showNavItem(theItem) {
	$(theItem).css("top", "-200px");
	$(theItem).show();
	$(theItem).animate( { top: "12px" }, { queue:true, duration:700 + randInt(600), easing:"bounceEaseOut" });
}

function showNavs() {
	$("#navShows,#navCD,#navAV,#navImages,#navMailingList,#navVarious").removeClass("navSelected");
	$("#upcomingShows,#mailingList,#cd,#iTunes,#audio,#video,#renderings,#photos,#mailingList2,#twitter,#facebook,#writings,#emocopia,#industry").animate( {top: "-200px"}, {queue:true, duration:300, easing:"circEaseIn"});
}

function randInt(topRange) {
	return Math.round(Math.random() * topRange);
}



$(".show-table-row").mouseenter(
	function(){ $(this).css({ "background-color": "#004477" }); }
);
$(".show-table-row").mouseleave(
	function(){ $(this).css({ "background-color": "transparent" }); }
);

function moveFooter() {
return;
	$("#footer").css("top", ($("#contents").height() - 20) + "px");
	$("#footer").css("left", ($("#contents").width() - 140) + "px");
	$("#footer").show();
}


jQuery.extend({
    
    easing: 
    {

		linear: function( p, n, firstNum, diff ) {
			return firstNum + diff * p;
		},
		swing: function( p, n, firstNum, diff ) {
			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
		},
        // ******* back
        backEaseIn:function(p, n, firstNum, diff) {

            var c=firstNum+diff;
            
            var s = 1.70158; // default overshoot value, can be adjusted to suit
            return c*(p/=1)*p*((s+1)*p - s) + firstNum;
        },
        
        backEaseOut:function(p, n, firstNum, diff) {

            var c=firstNum+diff;
            
            var s = 1.70158; // default overshoot value, can be adjusted to suit
            return c*((p=p/1-1)*p*((s+1)*p + s) + 1) + firstNum;
        },
        
        backEaseInOut:function(p, n, firstNum, diff) {

            var c=firstNum+diff;
            
            var s = 1.70158; // default overshoot value, can be adjusted to suit
            if ((p/=0.5) < 1) 
                return c/2*(p*p*(((s*=(1.525))+1)*p - s)) + firstNum;
            else
                return c/2*((p-=2)*p*(((s*=(1.525))+1)*p + s) + 2) + firstNum;
        },
        
        // ******* bounce
        bounceEaseIn:function(p, n, firstNum, diff) {
            
            var c=firstNum+diff;
            var inv = this.bounceEaseOut (1-p, 1, 0, diff);
            return c - inv + firstNum;
        },
        
        bounceEaseOut:function(p, n, firstNum, diff) {

            var c=firstNum+diff;

            if (p < (1/2.75))
            {
                return c*(7.5625*p*p) + firstNum;
            }
            else if (p < (2/2.75))
            {
                return c*(7.5625*(p-=(1.5/2.75))*p + .75) + firstNum;
            }
            else if (p < (2.5/2.75))
            {
                return c*(7.5625*(p-=(2.25/2.75))*p + .9375) + firstNum;
            }
            else
            {
                return c*(7.5625*(p-=(2.625/2.75))*p + .984375) + firstNum;
            }
        },
        
        
        // ******* circ
        circEaseIn:function(p, n, firstNum, diff) {

            var c=firstNum+diff;
            
            return -c * (Math.sqrt(1 - (p/=1)*p) - 1) + firstNum;
        },
        
        circEaseOut:function(p, n, firstNum, diff) {

            var c=firstNum+diff;
            
            return c * Math.sqrt(1 - (p=p/1-1)*p) + firstNum;
        }
    }
});