﻿/// <reference path="jquery-1.6.2.js" />

/*
*	Code Dependencies:
*	- "jquery-1.6.2.js"
*	- "dc.global.js"
*/

$(document).ready(function () {
	dc.site.Init();
});

// This is a Self-Executing Anonymous Function
// "dc" is the namespace for all of our code
// There should be no global "window" variables,
// they should all be created under the "dc" namespace. 
(function (dc, $, undefined) {
	// Hook jQuery Selector Caching Function to "$$"
	var $$ = dc.$$;
	
	// Create the "dc.site" namespace if it does not exist
	dc.site = (function (site) {
		
		site.Init = function () {
			var $CurrentNavLink = $$('#' + dc.CurrentNavLinkId);
			var $NavLinks = $$('li.NavLink', '#Nav');

			/* Remove Nav Link Text */
			$('a', $NavLinks).text('');

			/* Set "Current" class on this pages corresponding Nav Link */
			if ($CurrentNavLink != null || $CurrentNavLink != undefined) {
				$CurrentNavLink.addClass('Current').find('img.NavPointer').css('top', '4px');
			}

			/* Hookup NavMenu Actions*/
			$NavLinks.each(function() {
				var $NavLink = $(this);
				/* Change Pointers to ".gif" for IE6 png problems */
				var $NavPointer = $('img.NavPointer', $NavLink)
				if (dc.BrowserIsIE6) {
					var src = $NavPointer.attr('src');
					src = src.replace('.png', '.gif');
					$NavPointer.attr('src', src);
				}
				if (!$NavLink.hasClass('Current')) {
					$NavLink.hover(function() {
						$NavLink.addClass('Current');
						$NavPointer.stop().animate({ 'top': '0px' }, 200);
					}, function() {
						$NavLink.removeClass('Current');
						$NavPointer.stop().animate({ 'top': '26px' }, 200);
					}).click(function() {
						document.location = $(this).find('a').attr('href')
					});
				}
			});
			/* IE6 and IPhone/IPad Fix */
			if (dc.BrowserIsIE6) {
				$$('img', '#PagePeel').attr('src', 'Images/PagePeelCorner.gif');
				$$('#FooterContainer, #MainContentBottom').addClass('IE6');
			}
			if (dc.BrowserIsIPhone) {
				$$('#FooterContainer, #FooterContent, #MainContentBottom').addClass('IPhone');
			}
			/* PagePeel */
			$$('#PagePeel').hover(function() { //On hover...
				/* Animate and expand the image and the msg_block (Width + height) */
				$('img, span', this).stop().animate({ width: '307px', height: '319px' }, 400);
			}, function() {
				/* On hover out, go back to original size 50x52 */
				$('img', this).stop().animate({ width: '58px', height: '60px' }, 220);
				/* On hover out, go back to original size 50x50 */
				$('span', this).stop().animate({ width: '58px', height: '58px' }, 200); // Note: this one retracts a bit faster (to prevent glitching in IE)
			});
		}

		// Return this instance of site
		return site;
	})(window.dc.site = window.dc.site || {});

})(window.dc = window.dc || {}, jQuery);
