 window.addEvent('load', function(){
	
	////////////////////////////////////////////////////////
	/// Grab flicker URLS and make gallery /////////////////
	////////////////////////////////////////////////////////
	
	flickrGalleries = $$("body")[0].getElements("a[href^=http:\/\/www.flickr.com\/photos\/newmardigras\/sets\/]")
	
	flickrGalleries.each(
		
		function (el) {
			if(el.get("class").indexOf("photo") == -1) {
				// If the target of the link is a new window (system replaces target="_blank" with onclick="window.open(this.href); return false;)"
				// then pop the image set into the mask
				if(el.getProperty("onclick") == "window.open(this.href); return false;") {

					el.addEvent("click", function (ev) {
						
						ev.stop();
						if (!$("site-mask")) {
						mask = new Mask({
								elementClass	: "flickr",
								title	: el.get("title"),
								type 	: "panel",
								size 	: "large",
								url 	: "flickr.cfm?" + escape(el.get("href")),
								buttons	: [{label:"Close",id: "close-mask"}]
								}).create();
							}
						
						}); 
					}
				else {
					var setid = el.get("href").split("/");
					setid = setid[setid.length-2];
					var w = 605;
					var h = 385;
					if (el.getParent("div[id=event-review]")) {
						w = 570;
						h = 360;
						}
					var html = "<object type=\"application/x-shockwave-flash\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + w + "\" height=\"" + h + "\">" + 
						"<param name=\"flashvars\" value=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\" /></param> " + 
						"<param name=\"movie\" value=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\"></param>" + 
						"<param name=\"allowFullScreen\" value=\"true\"></param>" + 
						"<embed 	type=\"application/x-shockwave-flash\" " + 
						"		src=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\" " + 
						"		allowFullScreen=\"true\" " + 
						"		flashvars=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\" " + 
						"		width=\"" + w + "\" height=\"" + h + "\">" + 
						"</embed>" + 
					"</object>";
					new Element("div").set("html", html).replaces(el);
					}
				}
			}
		
		)
	
	
	
	if($("video-menu-scroller")) {
	
		$("video-menu-scroller").getElements("a[class^=photo]").each(
	
			function (el) {
				el.addEvent("click", function (ev) {
					ev.stop();
					$("video").set("html", "");
					var setid = el.get("href").split("/");
					setid = setid[setid.length-2];
					var html = "<object type=\"application/x-shockwave-flash\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"443\" height=\"281\">" + 
						"<param name=\"flashvars\" value=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\"></param> " + 
						"<param name=\"movie\" value=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\"></param>" + 
						"<param name=\"allowFullScreen\" value=\"true\"></param>" + 
						"<embed 	type=\"application/x-shockwave-flash\" " + 
						"		src=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\" " + 
						"		allowFullScreen=\"true\" " + 
						"		flashvars=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\" " + 
						"		width=\"443\" height=\"281\">" + 
						"</embed>" + 
					"</object>";
					$("video").set("html", html);
					//$("video").getElement("object").setProperty("height", "281");
					//		$("video").getElement("object").setProperty("width", "443");
						
					}); // end event
				} // end function
			); // end each
	
	
		}
	if($("gallery-features")) {
	
		$("gallery-features").getElements("a[class^=photo]").each(
	
			function (el) {
				el.addEvent("click", function (ev) {
					ev.stop();
					$("video").inject(el.getParent("div").getPrevious(), "after");
					$("video").set("html", "");
					var setid = el.get("href").split("/");
					setid = setid[setid.length-2];
					var html = "<object width=\"605\" height=\"385\">" + 
						"<param name=\"flashvars\" value=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\"></param> " + 
						"<param name=\"movie\" value=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\"></param>" + 
						"<param name=\"allowFullScreen\" value=\"true\"></param>" + 
						"<embed 	type=\"application/x-shockwave-flash\" " + 
						"		src=\"http://www.flickr.com/apps/slideshow/show.swf?v=71649\" " + 
						"		allowFullScreen=\"true\" " + 
						"		flashvars=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fshow%2Fwith%2F3885114243%2F&page_show_back_url=%2Fphotos%2Fnewmardigras%2Fsets%2F" + setid + "%2Fwith%2F3885114243%2F&set_id=" + setid + "&jump_to=\" " + 
						"		width=\"605\" height=\"385\">" + 
						"</embed>" + 
					"</object>";
					$("video").set("html", html);
					//$("video").getElement("object").setProperty("height", "281");
					//		$("video").getElement("object").setProperty("width", "443");
						
					}); // end event
				} // end function
			); // end each
	
	
		}
	
	////////////////////////////////////////////////////////
	
	})
	