/*
	Copyright Code Computerlove Ltd 2009
	Build: 1.0.0.357
	Date: 06/10/2009 14:57:54
*/

(function($j) {

	Code.registerNamespace('Website');

	Website.Core = {

		_initClosePopupWindow: function() {

			$j('a.js-close').bind('click', function() {
				window.close();
			});

		},

		_applyPopupLinks: function(url) {

			var self = this;

			var width = 550;
			var height = 460;
			var leftPosition = (screen.width) ? (screen.width - width) / 2 : 100;
			var topPosition = (screen.height) ? (screen.height - height) / 2 : 100;

			settings = 'width=' + width + ',height=' + height + ',top=' + topPosition + ',left=' + leftPosition +
									',scrollbars=yes,location=no,directories=no,status=0,menubar=no,toolbar=no,resizable=no';

			self._applyExternalLinks(url, settings);
		},

		_applyExternalLinks: function(url, settings) {

			if (Code.Type.isNothing(settings)) {
				window.open(url);
			} else {
				window.open(url, '', settings);
			}

		},

		_initExternalLinks: function() {

			var self = this;

			$j('a.js-popup').bind('click', function() {
				self._applyPopupLinks($j(this).attr('href'));
				return false;
			});

			$j('li.js-popup a').bind('click', function() {
				self._applyPopupLinks($j(this).attr('href'));
				return false;
			});

			$j('li.js-external a').bind('click', function() {
				self._applyExternalLinks($j(this).attr('href'));
				return false;
			});

			$j('a.js-external').bind('click', function() {
				self._applyExternalLinks($j(this).attr('href'));
				return false;
			});

		},

		onReady: function() {

			var self = this;
			self._initExternalLinks();
			self._initClosePopupWindow();

		}

	};

	$j().ready(function() {
		Website.Core.onReady();
	});

})(jQuery);	
