jQuery.fn.extend({
    check: function() {
	return this.each(function() { this.checked = true; });
    },
    uncheck: function() {
	return this.each(function() { this.checked = false; });
    }
});

function init_item_map(div_id,item,zoom) {
    if (!zoom) {
        zoom = 13;
    }
    if (GBrowserIsCompatible()) {
	var icon = new GIcon();
	icon.image = "/images/markers/marker-red.png";
	icon.shadow = "/images/shadow.png";
	icon.iconSize = new GSize(16, 26);
	icon.shadowSize = new GSize(29, 26);
	icon.iconAnchor = new GPoint(7.0, 26.0);
	icon.infoWindowAnchor = new GPoint(9, 2);
	icon.infoShadowAnchor = new GPoint(18, 25);
	var markerOptions = { icon:icon };
        var map = new GMap2(document.getElementById(div_id));
	var point = new GLatLng(item.lat, item.lng);
	if ($('#location_lat').val() && $('#location_lng').val()) {
	  markerOptions["draggable"] = true;
	}
	var marker = new GMarker(point, markerOptions);

	GEvent.addListener(marker, "dragend", function(latlng) {
	  $('#location_lat').val(latlng.lat());
	  $('#location_lng').val(latlng.lng());
	});
	map.addControl(new GSmallMapControl());
        map.setCenter(point, zoom);
	map.addOverlay(marker);
    }
}

function set_rating(rating_type_id, rating) {
  for (var i = 1; i <= 5; i++) {
    if (i <= rating) {
	$('#rating_star_' + rating_type_id + '_' + i).attr({src: '/images/rating-star.png'});
    } else {
	$('#rating_star_' + rating_type_id + '_' + i).attr({src: '/images/rating-no-star.png'});
    }
  }
}
