var navArr;
var contentArr;
var objNum;

function eventInfoInit()
{
	//currTheme = $jq("#pageTheme").html();
	currTheme = '';
	/* Event Info Summary Display */
	$jq("h3").filter(".titleHide").hide();
	$jq("caption").filter(".titleHide").hide();
	
	navArr = $jq("#eventInfoNav").children("dd").children();
	contentArr = $jq("div").filter(".eventInfoContent");
				
	$jq("#eventInfoNav_0").addClass("active");
				
	navArr.mousedown(toggleEventInfo);
	
	
	/* Calender slide */
	if (document.getElementById("calendar_Event"))
	{
		$jq("#calendar").children("table").children("tbody").children("tr").children("td").children("a").click(function(){
			activeDay = $jq("#calendar").children("table").children("tbody").children("tr").children("td").children("a");
			activeDay.removeClass("active");
			for (i=0; i < activeDay.length; i++)
			{
				if (activeDay[i].innerHTML == this.innerHTML)
				{
					$jq(activeDay[i]).addClass("active");
					toggleDay(i);
				}
			}
		});
		
		$jq("#calendar_Event").children(".btn-arrow-r").hide();
		$jq("#calendar_Event").hide();
	}
	
	/* Image Hover in Nav */
	$jq("#eventInfoNav").children("dd").children("a").click(toggleImgNav);
	
	$jq("img").filter(".navhover").hover(function(){
		if (this.className != "active") this.src = hoverURL(this.src);
	}, function(){ 
		if (this.className != "active") this.src = hoverURL(this.src);
	});
	
	resetImgNav();
	
	$jq("div").filter(".eventInfoContent").each(function(i){
		if (i == 0)
		{
			$jq(this).show();
		}
		else
		{
			$jq(this).hide();
		}
	});
	
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
	$jq("div").filter(".eventdate").css("display","inline");
	
	$jq("div").filter(".eventdate").each(function(i){
		monthno = $jq(this).children("span").html().split("-")[1];
		dayno	= $jq(this).children("span").html().split("-")[2];
		
		if (monthno.charAt(0) == '0')
		{
			monthno = monthno.split("0")[1];
		}
		
		$jq(this).children("span").html(dayno+" "+months[monthno-1]);
	});
	
    fromDate = $jq("div").filter(".eventdate")[0];
    if ( $jq("div").filter(".eventdate").length > 1 )$jq(fromDate).append("&#160;-&#160;");
}

function resetImgNav()
{
	$jq("img").filter(".navhover").attr("src", function(){
		currSrc = this.src;
		newSrc = currSrc.split("img/")[0] + "App_Themes/" + currTheme + "/img/" + currSrc.split("img/")[1];
		return newSrc;
	});
}

function toggleImgNav()
{
	$jq("#eventInfoNav").children("dd").children("a").children("img").attr("class", "navhover");
	$jq("#eventInfoNav").children("dd").children("a").children("img").attr("src", function(){
		var newSrc = this.src;
		if (newSrc.indexOf("App_Themes") == -1)	newSrc = this.src.split("img/")[0] + "App_Themes/" + currTheme + "/img/" + this.src.split("img/")[1];
		return newSrc;
	});
	
	$jq(this).children("img").attr("class","active");
	$jq(this).children("img").attr("src", function(){
		currSrc = this.src;
		this.src = currSrc.split('App_Themes/')[0]  + 'img/' + currSrc.split('img/')[1];
	});
}

function toggleDay(sessions)
{
	activeSession = $jq("#calendar_Event").children("div");
	for (i=0; i < activeSession.length; i++)
	{
		if (i == parseInt(sessions))
		{
			if (!sessionBG) 
			{
				$jq("#calendar_Event").fadeIn("slow");
				$jq(activeSession[i]).slideDown("slow", function(){ $jq("#calendar_Event").children(".btn-arrow-r").fadeIn("slow");});
				sessionBG = true;
			}
			else
			{
				$jq(activeSession[i]).fadeIn("slow");
			}
			
		}
		else
		{
			$jq(activeSession[i]).hide();
		}
	}
}

function toggleEventInfo()
{
	$jq("#eventInfoContent").children("div").children("h3").hide();
	$jq("#eventInfoContent").children("table").children("caption").hide();
	
	navArr.removeClass("active");
	objNum = parseInt($jq(this).attr("id").split("_")[1]);
	
	$jq("div").filter(".eventInfoContent").hide();
	$jq("#eventInfoContent_"+[objNum]).fadeIn("fast");
//	for (var i=0; i < contentArr.length; i++)
//	{
//		//contentArr[i].style.display = (objNum == i) ? 'block' : 'none';
//		if(objNum == i)
//		{
//			$jq("#eventInfoContent_"+[i]).fadeIn("fast");
//		}
//		else
//		{
//			$jq("#eventInfoContent_"+[i]).hide();
//		}
//	}
	
	$jq(this).attr("href","javascript://");
	$jq(this).addClass("active");
}

$jq(document).ready(eventInfoInit);
