if(typeof(Default) === 'undefined')
{
	var Default = new function ()
	{
		this.init = function ()
		{
			$('#hero-images').cycle(
		{
			fx: 'scrollHorz',
			pause: 1,
			prev: '.hero-navigation-prev',
			next: '.hero-navigation-next'
		});

			$('.department-cards.active_').cycle(
		{
			fx: 'scrollHorz',
			timeout: 0,
			prev: '.card-navigation-prev',
			next: '.card-navigation-next'
		});

			$('#must-have-items').cycle(
		{
			fx: 'scrollHorz',
			timeout: 0,
			prev: '.must-have-navigation-prev',
			next: '.must-have-navigation-next'
		});

			$('#values-arrow').data('home', { offset: $('#values-arrow').position() });

			$('#values-navigation').mouseleave(function (e)
			{
				var a = $('#values-arrow');
				var b = a.data('home').offset;
				a.animate({ left: b.left + 'px' }, { queue: false });
			});
			$('#values-navigation li a').mouseenter(function (e)
			{
				$('#values-arrow').animate({ left: $(this).position().left + $(this).width() / 2 + 'px' }, { queue: false });
			}).click(function (e)
			{
				var p = $(this).position().left + $(this).width() / 2;
				$('#values-arrow').data('home', { offset: { left: p} });
			});
			FB = FB || { init: function () { } };
			FB.init({
				appId: '100795819977922',
				status: true, // check login status
				cookie: true // enable cookies to allow the server to access the session
			});

			if ($.browser.msie)
				setTimeout(function () { $('.content-navigation').hide(); $('.content-container').hover(function () { $('.content-navigation', this).show(); }, function () { $('.content-navigation', this).hide(); }); }, 200);
			else
				setTimeout(function () { $('.content-navigation').fadeOut(); $('.content-container').hover(function () { $('.content-navigation', this).fadeIn(); }, function () { $('.content-navigation', this).fadeOut(); }); }, 200);

			$.subscribe('/profile/tab', show_profile_tab);
			$.subscribe('/values/swap', show_value_tab);
			$.subscribe('/publish/facebook', fb_publish);
			$.subscribe('/publish/twitter', twitter_publish)

			setTimeout(function () { $('.content-card-control, .hero-item-control').hover(function () { $('.content-share-callout', this).show(); }, function () { $('.content-share-callout', this).hide(); }); }, 200);
		}

		function show_profile_tab(id, link_id)
		{
			$('#profile-data .profile-section.active_').removeClass('active_').fadeOut('fast', function () { $('#' + id).addClass('active_').fadeIn('fast'); });

			$('#profile-navigation .active_').removeClass('active').removeClass('selected');
			$('#' + link_id).addClass('active_').addClass('selected');
		}

		function show_value_tab(id, link_id)
		{
			$('#values-navigation .active_').removeClass('active_').removeClass('values-navigation-selected');
			$('#' + link_id).addClass('active_').addClass('values-navigation-selected');
			$('#values-content .active_').removeClass('active_').removeClass('values-statement-selected');
			var l = $('#' + id).addClass('active_').addClass('values-statement-selected');
		}

		function fb_publish(t, d, l, i)
		{
			if ($find('CurrentUser').get_IsLoggedIn() && $find('CurrentUser').get_FacebookToken())
			{
				$.get('post.aspx', { FacebookMessage: t + ':' + d });
				/*$.post(
				{
				'Post.aspx',
				{
				title: t,
				description: d,
				image: i,
				link: l
				}
				});*/
			}
			else
			{
				FB.ui(
		{
			method: 'stream.publish',
			attachment:
			{
				name: t,
				description: d,
				href: l,
				media: [{ type: 'image', src: i, href: l}]
			}
		});
			}
		}

		function fb_authorize(aid, url)
		{
			if ($find('CurrentUser').get_FacebookToken())
			{
				$.post('post.aspx?RevokeFacebook=true');
			}
			else
			{
				window.open("https://graph.facebook.com/oauth/authorize?client_id=" + '100795819977922' + "&redirect_uri=" + 'http://www.zellers.com' + "&scope=publish_stream,offline_access");
			}
		}

		function twitter_publish(t, d, l)
		{
			var url = ['http://twitter.com/home?status=', escape(t), escape(':'), escape(d), escape(':'), escape(l)].join();
			if ($find('CurrentUser').get_IsLoggedIn() && $find('CurrentUser').get_TwitterToken())
			{
				//$.get('post.aspx', { TwitterMessage: t + ':' + d });
			}
			else
			{
				//window.open(url);
			}
			window.open(url);
		}

		this.twitter_authorize = function (url)
		{
			window.location = url;
		}
	}

$(Default.init);
}

