$(document).ready(function () {
	$("#hotelsList > li").each(function () {
		var p = document.createElement('p');
		var a = document.createElement('a');
		a.href = '#';
		a.className = 'alternate';
		a.containerElem = this;
		a.onclick = function () {
			useAlternate(this,this.containerElem);
			return false;
		}
		a.appendChild(document.createTextNode('use Google Maps instead?'));
		p.appendChild(a);
		$(this).find('.maps_directions').addClass('yahoo').append(p);
	});
	$('#sortForm input[@type="submit"]').hide();
	$('#sortOptions').bind('change', function () {
		window.location.href='?sort='+$(this).val();
	});
});
function useAlternate(caller,container) {
	$('.maps_directions').toggleClass('google').toggleClass('yahoo'); // adds google if not present, removes if present; same for yahoo
	if ($(caller).html().match('Google')) $('.maps_directions a.alternate').html('use Yahoo! Maps instead?');
	else $('.maps_directions a.alternate').html('use Google Maps instead?');
}

