$(document).ready(function() {
	if ($("#search #map").length) {
		var top = $("#search #map").offset().top - 30;
		$(window).scroll(function () {
			var $scrollingCart = $("#search #map");
			var y = $(this).scrollTop();
			if (y >= top) {
				$scrollingCart
					.stop()
					.animate({"marginTop": ($(window).scrollTop() - top) + "px"}, "slow" );
			} else {
				$scrollingCart
					.stop()
					.animate({"marginTop": "0px"}, "slow" );
			}
		});
	} else if ($("#place-menu.tab #ordercart").length) {
		$("#place-menu.tab #ordercart").addClass('fixed');
		var top = $("#place-menu.tab #ordercart").offset().top - 10;
		$(window).scroll(function () {
			var $scrollingCart = $("#place-menu.tab #ordercart");
			var y = $(this).scrollTop();
			if (y >= top) {
				$scrollingCart
					.stop()
					.animate({"marginTop": ($(window).scrollTop() - top) + "px"}, "slow" );
			} else {
				$scrollingCart
					.stop()
					.animate({"marginTop": "0px"}, "slow" );
			}
		});
	}
});

$(document).ready(function() {
	$('input.default-value').each(function() {
		if ($(this).attr('title') != $(this).attr('value')) {
			$(this).removeClass('default-value');
		}
		$(this).focus(function() {
			if ($(this).attr('title') == $(this).attr('value')) {
				$(this).attr('value', '');
				$(this).removeClass('default-value');
			}
		});
		$(this).blur(function() {
			if (!$(this).attr('value')) {
				$(this).attr('value', $(this).attr('title'));
				$(this).addClass('default-value');
			}
		});
	});
	
	$("a[rel*='external']").click(function(){
		this.target = "_blank";
	});
	
	$('a[rel*=facebox]').facebox({overlay:true, opacity: 0.3});
});
