﻿(function($j) {

	Code.registerNamespace('Website');

	Website.Core = {

		/*
		* function onReady 
		*/

		mapLink: '#ContentSecondary .zoo-map',

		onReady: function() {
			var self = this;
			self.initShowMap();
			self.clearFields($j('.text', '#SiteSearch'));

			$j('#SiteSearch input').click(function() {
				if ($j('#SiteSearch input.text').val() == "Enter keyword") {
					$j('#SiteSearch input.text').val("");
				}
			});
		},

		initShowMap: function() {

			var self = this;

			$j('p a', self.mapLink).text(Website.Core.Resources.MapCopy);

			$j(self.mapLink).click(function(e) {
				e.preventDefault();
				self.showModalWindow();
			});
		},

		showModalWindow: function() {

			var self = this;

			$j.leModal.show({
				clickBackgroundToHide: true,
				overlayOpacity: 0.3,
				modalTopAdjustment: 100,
				showAnimationSpeed: 'fast',
				setContentCallBack: function(jModalWin) {
					jModalWin.css({ 'background': 'transparent', 'width': '940px', 'height': '545px' });

					setTimeout(function() {
						
						if (!$j('#FlashContainer', jModalWin).size())
							jModalWin.append($j('<div id="FlashContainer"><div id="FlashMap">You don\'t have flash player 10</div></div>'));

						swfobject.embedSWF(
							Code.resolveUrl("~/_Client/Flash/Map/Preloader.swf"), "FlashMap", "980", "585", "10",
							false, Website.Flash.flashvars, Website.Flash.params, {}
						);
					}, 500);

				}
			});
		},

		closeOverlay: function() {
			$j.leModal.hide();
		},

		clearFields: function(fields) {

			$j(fields).focus(function() {
				$j(this).val('');
			});

		}

	};

	$j().ready(function() {
		Website.Core.onReady();
	});

})(jQuery);	


