// JavaScript Document

$(function() {
	
	/*$(".feed_item .feed_preview_date").each(function() {
		var thisDay = parseInt($(this).children(".day").text(), 10);
		var thisMonth = parseInt($(this).children(".month").text(), 10) - 1;
		var thisYear = parseInt($(this).children(".year").text(), 10) + 2000;
		$(this).text($.datepicker.formatDate('M dd, yy', new Date(thisYear,thisMonth,thisDay)));
	});
	
	$(".upcoming-event .upcoming-event-date").each(function() {
		var thisDay = parseInt($(this).children(".ued-day").text(), 10);
		var thisMonth = parseInt($(this).children(".ued-month").text(), 10) - 1;
		var thisYear = parseInt($(this).children(".ued-year").text(), 10);
		$(this).text($.datepicker.formatDate('M dd, yy', new Date(thisYear,thisMonth,thisDay)));
	});*/
		
	if($("#nav").outerHeight() < $("#content").outerHeight())
	{
		$("#nav").css("height",$("#content").outerHeight() - 30)
	}
	else
	{
		$("#content").css("height",$("#nav").outerHeight() - 20)
	}
	
	if($("#feeds-events").outerHeight() < $("#feeds").outerHeight())
	{
		$("#feeds-events").css("height",$("#feeds").outerHeight() - 80)
	}
	else
	{
		$("#feeds").css("height",$("#feeds-events").outerHeight() - 80)
	}

	/*$("img.hover, input.hover").hover(function() {
		$(this).attr("src", $(this).attr("src").split(".").join("-hover."));
	}, function() {
		$(this).attr("src", $(this).attr("src").split("-hover.").join("."));
	});*/

	if($("#main-image-rotate").length > 0)
	{
		$("#main-image-rotate").html("");
		
		$("#main-image-rotate").append('<div id="rotator"></div>')
		
		$.get("/media/slideshow.xml", function (xml) {
			$(xml).find("image-item").each(function(i) {
			
				output = '';
				output += '<img src="'+$(this).find("image-path").text()+'" alt="'+$(this).find("image-title").text()+'" width="580" height="300" />';
				$("#rotator").append(output);
			 
			});	
			
			var slideSpd = parseFloat($(xml).find("slideshow-speed").text()) * 1000;
			var transSpd = parseFloat($(xml).find("transition-speed").text()) * 1000;
			var transType = $(xml).find("transition-type").text();
			$("#rotator").cycle({
				fx: transType,
				timeout: slideSpd,
				speed: transSpd,
				cleartype: true,
				cleartypeNoBg: true
			});
					
		});
	}
		
	
});
