function confirm_url(page,msg) 
{
	if (!msg)
		msg = 'Are you sure?';
	if (confirm(msg)) 
	{
		top.location = page;
	}
}

function nospam(user,domain)
{
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

function abuse(page)
{
	page = '/misc/abuse.php?' + page;
	winprops = 'height=250,width=400,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes'
	window.open(page, 'abuse', winprops);
}

function print_content(content)
{
	page = '/content/print.php?id=' + content;
	winprops = 'height=400,width=520,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes'
	window.open(page, 'print_content', winprops);
}

function textCounter(field,cntfield,maxlimit)
{
	if (field.value.length > maxlimit)
		field.value	= field.value.substring(0, maxlimit);
	else
		cntfield.value = field.value.length;
} 	

function Navigate(list) 
{
	location.href=list.options[list.selectedIndex].value;
}

function popup(page, Pname, Pwidth, Pheight)
{
	winprops = 'height='+Pheight+',width='+Pwidth+',toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no'
	window.open(page, Pname, winprops);
}

function popup2(page, Pname, Pwidth, Pheight)
{
	winprops = 'height='+Pheight+',width='+Pwidth+',toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes'
	window.open(page, Pname, winprops);
}

function createMark2(map,point) {
	map.clearOverlays();
	var marker = new GMarker(point, {draggable: true});
	map.addOverlay(marker);
	map.panTo(marker.getPoint());
	$("#map_lat").val(marker.getPoint().lat());
	$("#map_lng").val(marker.getPoint().lng());

	GEvent.addListener(marker,'dragend', function(){ 
		map.panTo(marker.getPoint());
		$("#map_lat").val(marker.getPoint().lat());
		$("#map_lng").val(marker.getPoint().lng());
	});
}

function newMarker(markerLocation, markerId, spotname, slug, markinfo, ic) {
	var marker=new GMarker(markerLocation, {title:spotname+' ('+markinfo+')', icon:ic});
	GEvent.addListener(marker, 'click', function() {
		window.location = slug+','+markerId+'.html';
	});
	return marker;
}

function createMarker(point, name, infowindow) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(name);
  });
  return marker;
}

function geocode(geocoder,map,address) {
  if (geocoder) {
		geocoder.getLatLng(address, function(point) {
      if (!point) {
        alert(address + " hittades inte/not found.");
      } else {
        map.setCenter(point, 13);
      }
		});
  }
}
