﻿$(document).ready(function () {
	//Cache proxy object of slide show (Use to activate link of slide show)
	var $proxySlide = $(".collectionMask");
	
    $('#jContainer').show();	
    $('.slideshow').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 6000,
		before: function(currSlide, nextSlide, options, forwardFlag) {
			$("div.bgImage").css("height", $(currSlide).height());
		},
		pager: ".pagingContainer",
		activePagerClass: "current",
		pagerAnchorBuilder: function(index, el) {
			return "<a href='#'><img src='/images/s.gif' width='10' height='20' /></a>"
		},
		after: function(currEl, nextEl, options, fwd) {
			var $link = $(this).filter("a:first");			
			if ($link.length > 0) {
				var $newLink = $("<a />").attr("href", $link.attr("href"));
				$proxySlide.wrap($newLink);
			} else {
				if ($proxySlide.parent("a").length > 0) $proxySlide.unwrap();
			}
		}		
    });
	
	
	$.address.externalChange(function(e) {
		if (e.pathNames.length && (e.pathNames[0] == "subscription")) {
			window.setTimeout(function() { window.subscribe.showMe(); }, 500);
		}
	});	
});
