﻿$(window).load(function() {
	$("#work-shade").fadeOut("fast");
});

$(document).ready(function() {
	hs.graphicsDir = '/App_Themes/Default/highslide/graphics/';
	hs.align = 'center';
	hs.targetY = 'middle -20px';
	hs.marginTop = 40;
	hs.allowSizeReduction = false;
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	hs.wrapperClassName = "ws";
	hs.dimmingOpacity = 0.4;
	hs.preserveContent = true;
	hs.cacheAjax = false;
	// hs.registerOverlay({ thumbnailId: null, overlayId: 'ws-nav', position: 'above', hideOnMouseOut: false });


	hs.Expander.prototype.onAfterExpand = function(sender) {
		var cont = this.wrapper;
		$(".zoomcontainer", cont).anythingZoomer({
			doDoubleClick: false
		});

		$("div.videoPane a[href*='youtube.com']").each(function() {
			var videoID = $(this).attr('href').match(/watch\?v=(.+)+/);
			if (videoID.length > 0) {
				videoID = videoID[1];
				$(this).replaceWith('<div id="youtube-embed-' + videoID + '">You need Flash player 8+ to view this video.</div>');
				var params = { allowScriptAccess: 'always', allowfullScreen: 'false' };
				var attrs = { id: 'youtube-video-' + videoID };
				// Embed the youtube video using SWFObject script
				swfobject.embedSWF('http://www.youtube.com/v/' + videoID + '&enablejsapi=1&rel=0&playerapiid=youtube-api-' + videoID, 'youtube-embed-' + videoID, '530', '319', '8', null, null, params, attrs);
			}
		});
	}

	moveFirstSlide();

});

function moveFirstSlide() {
	$(".highslide-gallery").each(function() {
	$("a:first", this).attr("href", $(".hidden-container a:first", $(this)).attr("href")).after("<div class='ws highslide-caption'>" + $(".hidden-container div.highslide-caption:first", $(this)).html() + "</div>");
		$(".hidden-container a:first", $(this)).remove();
		$(".hidden-container div.highslide-caption:first", $(this)).remove();
		//$("a:first", this).after($(".hidden-container div:first div:first", this).next("div"));
		//$("a:first", this).after($(".hidden-container div:first div:first", this).html());
		//$(".hidden-container div:first", this).remove();
	});
}
