var intTotalEventHeight = 0;
var intBoxTopMargin = 0;
var x = 0;

$(document).ready(function(){
	$(".imgscrollup").mousedown(function(){
		if (intBoxTopMargin < 0 ) {
			scrolly("up",10);
		}
	});
	$(".imgscrolldown").mousedown(function(){
		if (intBoxTopMargin >= -intTotalEventHeight + 450 ) {
			scrolly("down",10);
		}
	});
	$(document).mouseup(function(){
		clearTimeout(x);
	});
	$(".imgscrollup").mouseout(function(){
		clearTimeout(x);
	});
	$(".imgscrolldown").mouseout(function(){
		clearTimeout(x);
	});
	$("#month1").show();

	$(".activemonth .eventbox").each(function(){
		intTotalEventHeight = intTotalEventHeight + $(this).height() + 20;
	});
	$(".monthtext").click(function() {
		href = $(this).attr("href");
		href = href.substr(1);
		$(".eventsscrollcontainer").hide();
		$("#"+href).show();
		$(".eventsscrollcontainer").removeClass("activemonth");
		$("#"+href).addClass("activemonth");
		$(".monthtext").removeClass("active");
		$(this).addClass("active");
		intTotalEventHeight = 0;
		$(".activemonth .eventbox").each(function(){
			intTotalEventHeight = intTotalEventHeight + $(this).height() + 20;
		});
		return false;
	});
	$(".mapdonyngs").click(function() {
		DisplayShadowboxHTML(51.245154427683886,-0.17852783203125);
		return false;
	});
	$(".mapleatherhead").click(function() {
		DisplayShadowboxHTML(51.29207627533849,-0.33679962158203125);
		return false;
	});
	$(".mappavillion").click(function() {
		DisplayShadowboxHTML(51.40348936856666,0.0171661376953125);
		return false;
	});
	
	$(".partytooltip").qtip(
   {
      content: "All new venues are subject to a site inspection to assess suitability and safety prior to any party arrangements being made. If you have a venue in mind please call Paul on 07795 486959 for more information.",
		position: {
			corner: {
				target: 'bottomMiddle',
				tooltip: 'topMiddle'
			}
		},
		style: { 
			name: 'blue',
			tip: 'topMiddle'
		}
   });

	
});	

contactSuccess = function(){
	pageTracker._trackPageview("/contact-us-sent.php");
}

scrolly = function(direction,directionval) {
	strDirection = direction;
	intScroll = parseInt(directionval);
	if (direction == "up") {
		intScroll = intScroll;
	} else {
		intScroll = -intScroll;
	}
	var topmargin = $(".activemonth ").css("top");
	topmargin = topmargin.substr(0,topmargin.length - 2)
	topmargin = parseInt(topmargin);
	intBoxTopMargin = topmargin;
	topmargin = topmargin + intScroll;
	$(".activemonth ").css({"top":topmargin+"px"});
	if (direction == "up") {
		intScroll = intScroll;
	} else {
		intScroll = -1 * intScroll;
	}
	if (direction == "up") {
		if (intBoxTopMargin < 0 ) {
			x = setTimeout("scrolly(strDirection,intScroll)", 50);
		}
	} else {
		if (intBoxTopMargin >= -intTotalEventHeight + 450 ) {
			x = setTimeout("scrolly(strDirection,intScroll)", 50);
		}
	}
}