﻿$(document).ready(function() {
	$("a.MediaImage, a.PopupImg").lightBox();

	$("input[type='text']").focus(function() {
		if (this.value == this.defaultValue) this.value = "";
	});
	$("input[type='text']").blur(function() {
		if (this.value == "") this.value = (this.defaultValue ? this.defaultValue : "");
	});

	/*$(".baglistimg img").each(function() {
		var Height = $(this).height();
		var TotHeight = 90;
		if (Height != TotHeight) {
			var Margin = Math.round(TotHeight - Height) / 2;
			$(this).css("margin-top", Margin + "px");
		}
	});*/

	$("body").prepend("<div id=\"ScheduleBox\"></div>");
	$("#ScheduleBox").css("opacity", "0.8");
	$("ul.schedulelist li a").hover(function() {
		var toolText = $(this).attr("alt").replace("|-|", "<br />");
		$("#ScheduleBox").html(toolText);
		$("#ScheduleBox").show();
	}, function() { $("#ScheduleBox").hide(); });

	$().mousemove(function(e) {
		var thisTop = e.pageY + 15;
		var thisLeft = e.pageX - 15;
		$("#ScheduleBox").css("top", thisTop + "px");
		$("#ScheduleBox").css("left", thisLeft + "px");
	});

	SponsTimer = setInterval(function() { RotateSpons(); }, 5000);

	$(".questlist li div").hide();

	$(".questlist li a").click(function() {
		if ($(this).parent("li").children("div").css("display") == "none") {
			$(this).parent("li").parent("ul").children("li").children("div").slideUp(500);
			$(this).parent("li").children("div").slideDown(500);
		}
		else {
			$(this).parent("li").parent("ul").children("li").children("div").slideUp(500);
		}
	});

});


function RotateSpons() {
	var NewBig = $("#SponsSmall img:first").attr("src");
	var OldBig = $("#SponsBig img").attr("src");
	$("#SponsBig img").fadeOut(800, function() {
	$("#SponsSmall img:first").remove();
	$("#SponsBig img:first").remove();
	$("#SponsSmall").append("<img src=\"" + OldBig + "\" alt=\"\" />");
	$("#SponsBig").append("<img src=\"" + NewBig + "\" alt=\"\" />");
	$("#SponsBig img").hide();
	$("#SponsBig img").fadeIn(800);
	});
}

Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
Cufon.replace('span.entrydate');