function ScoopIcon(latlng, destination, hasBlog, hasPhotoAlbum, hasVideo) {
  this.latlng_ = latlng;
  this.destination_ = destination;
  this.hasBlog_ = hasBlog||false;
  this.hasPhotoAlbum_ = hasPhotoAlbum||false;
  this.hasVideo_ = hasVideo||false;
}
ScoopIcon.prototype = new GOverlay();

ScoopIcon.prototype.initialize = function(map) {
  this.map_ = map;
  this.tabs_ = new Array();
	var plot_wrap = document.createElement("div");
  var pin_marker = document.createElement("img");


	var destination_tab = document.getElementById("destination_tab-"+this.destination_);
	if(destination_tab != null) {
		destination_tab = destination_tab.cloneNode(true);
		destination_tab.className = "";
		var selected_index = this.tabs_.push(new GInfoWindowTab('Location', destination_tab))-1;

		GEvent.bindDom(pin_marker, "click", this, function() {
			this.map_.openInfoWindowTabs(this.latlng_, this.tabs_, {
				maxWidth: 500,
				selectedTab: selected_index
			});
		});
	}

	if((this.hasBlog_ == false) && (this.hasPhotoAlbum_ == false) && (this.hasVideo_ == false)) {
		pin_marker.setAttribute("src", "/img/icon_flag_blue.gif");
	} else {
		pin_marker.setAttribute("src", "/img/icon_flag_red.gif");

		plot_wrap.setAttribute("class", "plot_wrap");
		plot_wrap.style.textAlign = "center";

		var plot_table = document.createElement("table");
		plot_table.style.borderCollapse = "collapse";
		plot_wrap.appendChild(plot_table);

		var plot_bubble = document.createElement("tbody");
		plot_bubble.setAttribute("class", "plot_bubble");
		plot_bubble.style.borderCollapse = "collapse";
		plot_bubble.style.display = "inline";
		plot_table.appendChild(plot_bubble);

		var corner_td = document.createElement("td");
		corner_td.setAttribute("class", "rounded_edge");
		corner_td.style.cssFloat = "left"
		corner_td.setAttribute("style", "float:left;");

		var in_td = document.createElement("td");
		in_td.setAttribute("class", "in");


		// Top Row
		var plot_bubble_tr_top = document.createElement("tr");
		plot_bubble_tr_top.setAttribute("class", "plot_bubble_top");
		var top_left_corner = corner_td.cloneNode(false);
		var top_left_corner_img = document.createElement("img");
		top_left_corner_img.setAttribute("src", "/img/map_bubble_corner_top_left.gif");
		top_left_corner.appendChild(top_left_corner_img);

		var top_in_td = in_td.cloneNode(true);
		top_in_td.style.backgroundColor = "white";
		top_in_td.style.backgroundImage = "url(/img/map_bubble_edge_top.gif)";
		top_in_td.style.backgroundRepeat = "repeat-x";

		var top_right_corner = corner_td.cloneNode(false);
		var top_right_corner_img = document.createElement("img");
		top_right_corner_img.setAttribute("src", "/img/map_bubble_corner_top_right.gif");
		top_right_corner.appendChild(top_right_corner_img);

		plot_bubble_tr_top.appendChild(top_left_corner);
		plot_bubble_tr_top.appendChild(top_in_td);
		plot_bubble_tr_top.appendChild(top_right_corner);
		plot_bubble.appendChild(plot_bubble_tr_top);


		// Bottom Row
		var plot_bubble_tr_bottom = document.createElement("tr");
		plot_bubble_tr_bottom.setAttribute("class", "plot_bubble_bottom");

		var bottom_left_corner = corner_td.cloneNode(false);
		var bottom_left_corner_img = document.createElement("img");
		bottom_left_corner_img.setAttribute("src", "/img/map_bubble_corner_bottom_left.gif");
		bottom_left_corner.appendChild(bottom_left_corner_img);

		var bottom_in_td = in_td.cloneNode(true);
		bottom_in_td.style.backgroundColor = "white";
		bottom_in_td.style.backgroundImage = "url(/img/map_bubble_edge_bottom.gif)";
		bottom_in_td.style.backgroundRepeat = "repeat-x";

		var bottom_right_corner = corner_td.cloneNode(false);
		var bottom_right_corner_img = document.createElement("img");
		bottom_right_corner_img.setAttribute("src", "/img/map_bubble_corner_bottom_right.gif");
		bottom_right_corner.appendChild(bottom_right_corner_img);

		plot_bubble_tr_bottom.appendChild(bottom_left_corner);
		plot_bubble_tr_bottom.appendChild(bottom_in_td);
		plot_bubble_tr_bottom.appendChild(bottom_right_corner);


		// Bottom Point
		var plot_bubble_point_down_tr = document.createElement("tr");
		var plot_bubble_point_down_td = document.createElement("td");
		plot_bubble_point_down_td.setAttribute("colSpan", "3");
		plot_bubble_point_down_td.setAttribute("class", "bottom_point");
		plot_bubble_point_down_td.style.textAlign = "center";
		plot_bubble_point_down_tr.appendChild(plot_bubble_point_down_td);

		var plot_bubble_point_down_tr_img = document.createElement("img");
		plot_bubble_point_down_tr_img.setAttribute("src", "/img/map_bubble_point_down.gif");
		plot_bubble_point_down_tr_img.style.position = "relative";
		plot_bubble_point_down_tr_img.style.top = -1+"px";
		plot_bubble_point_down_td.appendChild(plot_bubble_point_down_tr_img);
		this.point_down_ = plot_bubble_point_down_tr;


		// Side padding
		var pad_td = document.createElement("td");
		pad_td.setAttribute("class", "pad");
		pad_td.style.backgroundColor = "white";

  	if(this.hasBlog_ == true) {
			var blog_tr = document.createElement("tr");
			var left_pad = pad_td.cloneNode(false);
			var blog_td = document.createElement("td");
			blog_td.style.backgroundColor = "white";
			var right_pad = pad_td.cloneNode(false);

  		var blog_img = document.createElement("img");
		  blog_img.setAttribute("class", "scoop scoop_blog");
		  blog_img.setAttribute("src", "/img/icon_Blog.gif");
			blog_img.style.margin = "5px auto";
			blog_td.appendChild(blog_img);

	  	blog_tr.appendChild(left_pad);
	  	blog_tr.appendChild(blog_td);
	  	blog_tr.appendChild(right_pad);
	  	plot_bubble.appendChild(blog_tr);

			var blog_tab = document.getElementById("blog_tab-"+this.destination_);
			if(blog_tab != null) {
				blog_tab = blog_tab.cloneNode(true);
				blog_tab.className = "";
				var selected_index = this.tabs_.push(new GInfoWindowTab('Blogs', blog_tab))-1;

	  		GEvent.bindDom(blog_img, "click", this, function() {
					this.map_.openInfoWindowTabs(this.latlng_, this.tabs_, {
						maxWidth: 500,
						selectedTab: selected_index
					});
	  		});
	  	}
		}

  	if(this.hasPhotoAlbum_ == true) {
			var photoalbum_tr = document.createElement("tr");
			var left_pad = pad_td.cloneNode(false);
			var photoalbum_td = document.createElement("td");
			photoalbum_td.style.backgroundColor = "white";
			var right_pad = pad_td.cloneNode(false);

		  var photoalbum_img = document.createElement("img");
		  photoalbum_img.setAttribute("class", "scoop scoop_photoalbum");
		  photoalbum_img.setAttribute("src", "/img/icon_PhotoAlbum.gif");
			photoalbum_img.style.margin = "5px auto";
			photoalbum_td.appendChild(photoalbum_img);

	  	photoalbum_tr.appendChild(left_pad);
	  	photoalbum_tr.appendChild(photoalbum_td);
	  	photoalbum_tr.appendChild(right_pad);
	  	plot_bubble.appendChild(photoalbum_tr);

			var photo_tab = document.getElementById("photo_tab-"+this.destination_);
			if(photo_tab != null) {
				photo_tab = photo_tab.cloneNode(true);
				photo_tab.className = "";
				var selected_index = this.tabs_.push(new GInfoWindowTab('Photo Albums', photo_tab))-1;

	  		GEvent.bindDom(photoalbum_img, "click", this, function() {
					this.map_.openInfoWindowTabs(this.latlng_, this.tabs_, {
						maxWidth: 500,
						selectedTab: selected_index
					});
	  		});
	  	}
  	}

  	if(this.hasVideo_ == true) {
			var video_tr = document.createElement("tr");
			var left_pad = pad_td.cloneNode(false);
			var video_td = document.createElement("td");
			video_td.style.backgroundColor = "white";
			var right_pad = pad_td.cloneNode(false);

		  var video_img = document.createElement("img");
		  video_img.setAttribute("class", "scoop scoop_video");
		  video_img.setAttribute("src", "/img/icon_Video.gif");
			video_img.style.margin = "5px auto";
			video_td.appendChild(video_img);

	  	plot_bubble.appendChild(left_pad);
	  	plot_bubble.appendChild(video_tr);
	  	plot_bubble.appendChild(right_pad);

	  	video_tr.appendChild(left_pad);
	  	video_tr.appendChild(video_td);
	  	video_tr.appendChild(right_pad);
	  	plot_bubble.appendChild(video_tr);

			var video_tab = document.getElementById("video_tab-"+this.destination_);
			if(video_tab != null) {
				video_tab = video_tab.cloneNode(true);
				video_tab.className = "";
				var selected_index = this.tabs_.push(new GInfoWindowTab('Videos', video_tab))-1;

	  		GEvent.bindDom(video_img, "click", this, function() {
					this.map_.openInfoWindowTabs(this.latlng_, this.tabs_, {
						maxWidth: 500,
						selectedTab: selected_index
					});
	  		});
	  	}
		}

	  plot_bubble.appendChild(plot_bubble_tr_bottom);
	  plot_bubble.appendChild(plot_bubble_point_down_tr);
	}


	var point = this.map_.fromLatLngToDivPixel(this.latlng_);
  var left = (point.x / 2);

  plot_wrap.style.display = "none";
  plot_wrap.style.position = "absolute";
  plot_wrap.style.left = left + "px";
  plot_wrap.style.top = point.y - (plot_wrap.offsetHeight) + "px";

  pin_marker.style.display = "none";
  pin_marker.style.position = "absolute";
  pin_marker.style.left = left + "px";
  pin_marker.style.top = point.y - (pin_marker.offsetHeight) + "px";

  this.plot_wrap_ = plot_wrap;
  this.pin_marker_ = pin_marker;

  map.getPane(G_MAP_MARKER_PANE).appendChild(this.plot_wrap_);
  map.getPane(G_MAP_MARKER_PANE).appendChild(this.pin_marker_);
}

ScoopIcon.prototype.remove = function() {
  this.plot_wrap_.parentNode.removeChild(this.plot_wrap_);
  this.pin_marker_.parentNode.removeChild(this.pin_marker_);
}

ScoopIcon.prototype.copy = function() {
  return new ScoopIcon(this.latlng_);
}

ScoopIcon.prototype.redraw = function(force) {
	var point = this.map_.fromLatLngToDivPixel(this.latlng_);

	// if we're zoomed out, show the pin, else show the bubble and date
  if((this.map_.getZoom() < 6) || ((this.hasBlog_ == false) && (this.hasPhotoAlbum_ == false) && (this.hasVideo_ == false))) {
  	this.plot_wrap_.style.display = "none";
  	this.pin_marker_.style.display = "block";
	  this.pin_marker_.style.left = point.x - (this.pin_marker_.offsetWidth / 2) + "px";
	  this.pin_marker_.style.top = point.y - (this.pin_marker_.offsetHeight) + "px"
  } else {
  	this.pin_marker_.style.display = "none";
  	this.plot_wrap_.style.display = "block";
	  this.plot_wrap_.style.left = point.x - (this.plot_wrap_.offsetWidth / 2) + "px";
	  this.plot_wrap_.style.top = point.y - (this.plot_wrap_.offsetHeight) + "px";
	}
}

