$(document).ready(function(){
	
	//setTimeout("pngFix()",3000);
	
	$('#topNav #sectionBtns a:not("a.currentPage"):not("a#tripBuilder"):not("a#rockcenter")').hover(
		function() {
			var prefixRemoved = $(this).attr('id').substring(4);
			$('img.label',this).attr('src','/img/topNav/'+ prefixRemoved +'_on.gif');
			$('img.black_on',this).stop().stop().animate({top:'0px'},{duration:400, easing:"easeOutQuart"});
			$('img.colorTab',this).stop().stop().animate({top:'0px'},{duration:400, easing:"easeOutQuart"});
			
		},
		function() {
			var prefixRemoved = $(this).attr('id').substring(4);
			$('img.label',this).attr('src','/img/topNav/'+ prefixRemoved +'_off.png').ifixpng();
			$('img.black_on',this).stop().stop().animate({top:'68px'},'fast');
			$('img.colorTab',this).stop().stop().animate({top:'-33px'},'fast');
		}	
	);
	
	// Trip Builder Rollover
	$('#tripBuilder_off').hover(
		function() {
			$(this).stop().stop().animate({opacity:'0'},{duration:800, easing:"easeOutQuart"});
		},
		function() {
			$(this).stop().stop().animate({opacity:'1'},{duration:1200, easing:"easeOutQuart"});
		}
	);
	
	// Conditional for moving footer down if content goes past 880px
	if ($('table#content').height() > 630) {
		$('#footer').css('top', function() {return 880 + ($('table#content').height()-630)});
	}
	
	// Current Page Selection in Top Nav
	if ($('#topNav a').hasClass('currentPage')) {
		$('#topNav a.currentPage > img').attr('src','/img/topNav/' + $('#topNav a.currentPage').attr('id').substring(4) + '_on.gif');
		$('#topNav a.currentPage img.black_on').css('top','0px');
		$('#topNav a.currentPage img.colorTab').css('top','0px');
	}
	
	// jQuery scrollbar initialize
	scrollInit();
	
	if ($.browser.msie) {
		$('#topNav #sectionBtns a > .black_mask').click(
			function(){window.location=$(this).parent().attr('href')});
		$('#topNav #sectionBtns a > .colorTab_mask').click(
			function(){window.location=$(this).parent().attr('href')});
	}
});

function pngFix() {
	//alert("tttt");
	$('.png').ifixpng();
	$('#sectionBtns a').ifixpng();
	$('#sectionBtns a img').ifixpng();
	$('#whitePanel').ifixpng();
	$('#bottombar').ifixpng();
	$('#titlebar').ifixpng();
}

function scrollInit() {
	if ($('div').hasClass('outerScrollContainerShort')) {
		$('.outerScrollContainerShort .scroll-pane').jScrollPane({scrollbarWidth:8, dragMaxHeight:19, dragMinHeight:19, scrollbarMargin:10});
		$(".jScrollPaneContainer").css({width:"625px"})
	} 
	if ($('div').hasClass('outerScrollContainerTall')) {
		$('.outerScrollContainerTall .scroll-pane').jScrollPane({scrollbarWidth:8, dragMaxHeight:58, dragMinHeight:58, scrollbarMargin:10});
		$(".jScrollPaneContainer").css({width:"625px"})
	}
}

// Global ajax function
function getContent(page) {
	 //alert(page);
	$("#contentPanel").load(page, function(){
		scrollInit();
		$(this).fadeIn("slow");
	}).not("#contentPanel:has('#look')").fadeOut("fast", function(){$(this).fadeIn("slow", function(){$('.png').ifixpng();})});
};

function printPage() {
	window.print();
}

function getSection(sectionID) {
	window.location.href = "/index.php/section/" + sectionID;
}

function thickbox(id) {
	if (id == "pc") {
		tb_show('ss', '#TB_inline?inlineId=privCard&width=607&height=571', null);
	} else if (id == "rl_in") {
		//alert("rl_in");
		tb_show('ss', '/index.php/rockListContainerIn?KeepThis=true&#TB_iframe=true&width=607&height=571', null);
		
	} else if (id == "rl_out") {
		tb_show('ss', '/index.php/rockListContainerOut?KeepThis=true&#TB_iframe=true&width=607&height=571', null);
	} else if (id == "rl_login") {
		tb_show('ss', '/index.php/rockListContainerLogin?KeepThis=true&#TB_iframe=true&width=607&height=571', null);
	}
	
}

function setRockListBtn(loginStatus) {
	//alert(loginStatus);
	setTimeout("setRockListBtnInternal('"+loginStatus+"')", 300);
}

function setRockListBtnInternal(loginStatus) {
	if (document.getElementById("menuSWF")) {
		
		if (loginStatus == "loggedIn") {
			document.getElementById("menuSWF").rockListLogin('in');
		} else if (loginStatus == "loggedOut") {
			//alert("logout");
			document.getElementById("menuSWF").rockListLogin('out');
		}
	}
}

function showPrivCardFromRockList() {
	setTimeout("tb_show('ss', '#TB_inline?inlineId=privCard&width=607&height=571', null);",500);
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(dynamicRockListBtn);
addLoadEvent(pngFix);