// jQuery fadeIn/fadeOut IE cleartype glitch
// http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute("filter");
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute("filter");
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);



$(document).ready(function() {
	flickrShow = $.flash.create({
		swf: "http://www.flickr.com/apps/slideshow/show.swf?v=71649",
		width: "100%",
		height: "100%",
		params: {
			menu: "false",
			quality: "high",
			allowScriptAccess: "sameDomain",
			allowFullScreen: "true",
			bgcolor: "#000000"
		},
		flashvars: {
			offsite: true,
			lang: "en-us",
			page_show_url: "/photos/coda/sets/72157622807506662/show/", // %2F
			page_show_back_url: "/photos/coda/sets/72157622807506662/",
			set_id: "72157622807506662", //"8753",
			jump_to: "",
			speed: "slow"
		}
	});

	// add flash to container (replace fallback content)
	$("#slideshow").html(flickrShow);

	$("a", "#toggler").hover(function() {
		$(this).css("background-position", "right bottom");
	}, function() {
		$(this).css("background-position", "right 0");
	});

	$("a", "#toggler").click(function() {
		if ($(this).parent().hasClass("close")) {
			//clearTimeout(t);
			$("#description").customFadeOut(1000, function() {
				$("#toggler").removeClass("close").addClass("open");
				$("a", "#toggler").html("show info"); // attr("title", "show information")
			});
		}
		else {
			$("#description").customFadeIn(500, function() {
				$("#toggler").removeClass("open").addClass("close");
				$("a", "#toggler").html("hide info"); // .attr("title", "hide information")
			});
		}

		return false;
	});

	/*window.t = setTimeout(function() {
		$("#description").customFadeOut(1000, function() {
			$("#toggler").removeClass("close").addClass("open");
			$("a", "#toggler").html("show info"); // .attr("title", "show information")
		});
	}, 20000);*/
});


// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-11612376-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();