$(document).ready(function () {
	$('#wpadminbar').remove();
});
function eventsTypeJump() {
	var theUrl = $('#eventjumpmenu').val();
	if (theUrl != "#") {
		window.location.href = theUrl;
	}
}
$(document).ready(function () {
	var theTitle = "";
	$(".tooltip").hover(function (e) {
		$("body").append("<p id='tooltip'>" + $(this).attr('title') + "</p>");
		thePos = 0 - (($('#tooltip').width() / 2) + 10);
		theTitle = $(this).attr('title');
		$(this).attr('title', "");
		$("#tooltip").css("top", (e.pageY - 40) + "px").css("left", (e.pageX + thePos) + "px").css("display", "block");
	}, function () {
		$("#tooltip").remove();
		$(this).attr('title', theTitle);
		theTitle = "";
	});
	$(".tooltip").mousemove(function (e) {
		thePos = 0 - (($('#tooltip').width() / 2) + 10);
		$("#tooltip").css("top", (e.pageY - 40) + "px").css("left", (e.pageX + thePos) + "px");
	});
});
$(document).ready(function () {
	if ($('#findus_tabs').length) {
		findus_hideall();
		$('#findus_tabs li.car a').attr('class', 'on');
		$('#findus_car').css('display', 'block');
	}
});
function findus_hideall() {
	$('#findus_car').css('display', 'none');
	$('#findus_bike').css('display', 'none');
	$('#findus_bus').css('display', 'none');
}
function switchTab(goto) {
	if ($('#findus_car').css('display') == 'block') {
		$('#findus_car').fadeOut('slow', function () {
			$('#findus_' + goto).fadeIn('slow');
		});
	} else if ($('#findus_bike').css('display') == 'block') {
		$('#findus_bike').fadeOut('slow', function () {
			$('#findus_' + goto).fadeIn('slow');
		});
	} else if ($('#findus_bus').css('display') == 'block') {
		$('#findus_bus').fadeOut('slow', function () {
			$('#findus_' + goto).fadeIn('slow');
		});
	}
	$('#findus_tabs li.car a').attr('class', '');
	$('#findus_tabs li.bike a').attr('class', '');
	$('#findus_tabs li.bus a').attr('class', '');
	$('#findus_tabs li.' + goto + ' a').attr('class', 'on');
	return false;
}
function sb_toggle(theContent) {
	theContent = "sb_" + theContent;
	if ($('#' + theContent).is(':hidden')) {
		$('#' + theContent).slideDown("slow");
	} else {
		$('#' + theContent).slideUp("slow");
	}
}
$(document).ready(function () {
	if ($('#infopage_hub_slides').length) {
		infopage_slides_initalise();
	}
});
function infopage_slides_initalise() {
	infopage_slides_on_before_load();
	$('#infopage_hub_slides').cycle({
		fx: 'scrollVert',
		after: infopage_slides_on_after_scroll,
		next: '#infopage_slides_up',
		prev: '#infopage_slides_down',
		timeout: 0,
		cleartypeNoBg: true
	});
	infopage_slides_on_after_load();
}
function infopage_slides_on_after_scroll(curr, next, opts) {}
function infopage_slides_on_before_load() {}
function infopage_slides_on_after_load() {}
function pressYearJump() {
	var theUrl = $('#pressjump').val();
	if (theUrl != "#") {
		window.location.href = theUrl;
	}
}
$(document).ready(function () {
	if ($('div.pi-galleryoverview').length) {
		numRows = $('.pi-thumb-row').length;
		if (numRows > 0) {
			for (i = 1; i <= numRows; i++) {
				var highestItem = 0;
				$(".pi-row" + i + ' .pi-gallery-thumbnail').each(function (x) {
					if ($(this).height() > highestItem) {
						highestItem = $(this).height();
					}
				});
				$(".pi-row" + i + ' .pi-gallery-thumbnail').each(function (x) {
				//	$(this).css('height', highestItem + 'px');
				});
			}
		}
	}
});
function rangersJump() {
	var theUrl = $('#rangersjumpmenu').val();
	if (theUrl != "#") {
		window.location.href = theUrl;
	}
}
$(document).ready(function () {
	if ($('#mttd_slides').length) {
		ttd_initalise();
	}
});
function ttd_initalise() {
	ttd_on_before_load();
	$('#mttd_slides').cycle({
		fx: 'scrollVert',
		after: ttd_on_after_scroll,
		next: '#mttd_up',
		prev: '#mttd_down',
		timeout: 0,
		cleartypeNoBg: true
	});
	ttd_on_after_load();
}
function ttd_on_after_scroll(curr, next, opts) {}
function ttd_on_before_load() {}
function ttd_on_after_load() {}
$(document).ready(function () {
	var theTitle = "";
	$(".kidshover").hover(function (e) {
		var theContent = "kidshover_" + $(this).attr('id');
		theContent = $('#' + theContent).html();
		$("body").append("<p id='kidshover'>" + theContent + "</p>");
		thePos = 0 - (($('#kidshover').width() / 2) + 20);
		$("#kidshover").css("top", (e.pageY + 20) + "px").css("left", (e.pageX + thePos) + "px").css("display", "block");
	}, function () {
		$("#kidshover").remove();
	});
	$(".kidshover").mousemove(function (e) {
		thePos = 0 - (($('#kidshover').width() / 2) + 20);
		$("#kidshover").css("top", (e.pageY + 20) + "px").css("left", (e.pageX + thePos) + "px");
	});
});

function eventIconInfo(iconid) {
	$.ajax({
		type: "GET",
		url: "/wp-content/themes/moorsvalley/ajax/eventiconinfo.php",
		data: "iconid=" + iconid,
		success: function (thereturn) {
			if (thereturn != "failed") {
				$.fancybox(thereturn, {
					'padding': 0,
					'margin': 20,
					'cyclic': false,
					'scrolling': 'auto',
					'autoDimensions': true,
					'autoscale': false,
					'centerOnScroll': true,
					'hideOnOverlayClick': false,
					'hideOnContentClick': false,
					'overlayShow': true,
					'overlayOpacity': 0.8,
					'overlayColor': '#000',
					'titleShow': false,
					'transitionIn': 'fade',
					'transitionOut': 'fade',
					'speedIn': 300,
					'speedOut': 300,
					'showCloseButton': true,
					'showNavArrows': false,
					'enableEscapeButton': true
				});
			}
		}
	});
}
$(document).ready(function () {
	if ($('#press_list').length) {
		$('div.article').each(function (index) {
			if ($(this).height() < 123) {} else if ($(this).height() == 136) {
				$("div.article:nth-child(" + (index + 1) + ") div.article_link").css('height', '136px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a").css('height', '136px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a img").attr('src', '/wp-content/themes/moorsvalley/images/press/list-more-136.jpg').css('height', '136px');
			} else if ($(this).height() == 134) {
				$("div.article:nth-child(" + (index + 1) + ") div.article_link").css('height', '134px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a").css('height', '134px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a img").attr('src', '/wp-content/themes/moorsvalley/images/press/list-more-136.jpg').css('height', '134px');
			} else if ($(this).height() == 155) {
				$("div.article:nth-child(" + (index + 1) + ") div.article_link").css('height', '155px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a").css('height', '155px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a img").attr('src', '/wp-content/themes/moorsvalley/images/press/list-more-155.jpg').css('height', '155px');
			} else if ($(this).height() > 155) {
				$("div.article:nth-child(" + (index + 1) + ") div.article_link").css('height', $(this).height() + 'px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a").css('height', $(this).height() + 'px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a img").attr('src', '/wp-content/themes/moorsvalley/images/press/list-more-155.jpg').css('height', $(this).height() + 'px');
			} else {
				$("div.article:nth-child(" + (index + 1) + ") div.article_link").css('height', $(this).height() + 'px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a").css('height', $(this).height() + 'px');
				$("div.article:nth-child(" + (index + 1) + ") div.article_link a img").attr('src', '/wp-content/themes/moorsvalley/images/press/list-more-136.jpg').css('height', $(this).height() + 'px');
			}
		});
	}
});
$(document).ready(function () {
	if ($('#events_list').length) {
		var ii = 1;
		for (ii = 1; ii <= eventcount; ii++) {
			$("#event_" + ii + " event_link").css('height', $("#event_" + ii).height() + 'px');
			$("#event_" + ii + " div.event_link a").css('height', $("#event_" + ii).height() + 'px');
			$("#event_" + ii + " div.event_link a img").css('height', $("#event_" + ii).height() + 'px');
		}
	}
});
$(document).ready(function(){
	if($('body').height()<$(window).height()) {
		var fixheight = $(window).height() - $('body').height();
		$('#footer_back').after('<div id="heightfix"></div>');
		$('#heightfix').css('height', fixheight + 'px');
	}
});
