var animationSpeed = 500;				// Speed of animation

// Don't touch anything below this line!
var animationStyle = "easeInOutCirc";	// Type of animation
var boxWidth = 602;						// Width of each image container. This will ONLY change if the layout changes.

// For IE hover flicker bug
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

// Hello jQuery!
$(document).ready(function(){

// Gallery Nav Hover
	$("#nav_drop_topic").mouseover(function() {$(this).addClass("sfhover")});
	$("#nav_drop_topic").mouseout(function() {$(this).removeClass("sfhover")});
	$("#nav_drop_gall").mouseover(function() {$(this).addClass("sfhover")});
	$("#nav_drop_gall").mouseout(function() {$(this).removeClass("sfhover")});


// Easing animation
	var counter = 0;
	$("#nav_slideshow div.th a").each(function(){
		var move = -boxWidth*counter; // Equation to calculate how far the slideshow container should move.
		var imgNum = "th_"+counter
		$(this).addClass(imgNum);
		$(this).click(function(){
			$("#slideshow").animate({ left:move }, animationSpeed, animationStyle); // Animate
			$("#nav_slideshow div.th a").removeClass("active");
			$(this).addClass("active")
			return false;
		});
		counter++;
	});

// Captions hide/show
	$("#nav_slideshow div.th a").click(function() {$("#captions .caption").removeClass("show")});
	$("#nav_slideshow div.th a.th_0").click(function() {$("#captions .c_0").addClass("show")});
	$("#nav_slideshow div.th a.th_1").click(function() {$("#captions .c_1").addClass("show")});
	$("#nav_slideshow div.th a.th_2").click(function() {$("#captions .c_2").addClass("show")});
	$("#nav_slideshow div.th a.th_3").click(function() {$("#captions .c_3").addClass("show")});
	$("#nav_slideshow div.th a.th_4").click(function() {$("#captions .c_4").addClass("show")});

// Share show/hide
	$("li.option_share .share").click(function() {
		$("li.option_share").toggleClass("active");
		$("li.option_share a").toggleClass("active");
		$("li.option_share ul").toggle();
	});

}); // Bye-bye jQuery!



//Used for PageOption Web 2.0
function pageOptionPopUp(site) {
    var url = self.location.href;
    var facebook = 'http://www.facebook.com/sharer.php?u=';
    var delicious = 'http://del.icio.us/post?v=4&partner=nyt&noui&jump=close&url=';
    var sharelink = 'x652.xml?link=';
    if(site=='facebook') {
       var win = window.open(facebook + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
    else if(site=='delicious')
    {
       var win = window.open(delicious + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
    else if(site == 'sharelink')
    {
         var win = window.open(sharelink + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
}