(function eorisis_info()
{
	jQuery(function($,undefined)
	{
		var srv_ver = $('#srv-ver');
		var dl_update = $('#eo-dl-upd');
		var latest = $('#eo-latest');
		var rel_date = $('#eo-rel-date');
		var rel_notes = $('#eo-rel-notes');
		var ver_no = $('#eo-ver-no');
		var upd_chk = $('#eo-upd-chk');

		srv_ver.hide();
		dl_update.hide();
		latest.hide();
		rel_date.hide();
		rel_notes.hide();

		$('#eo-upd-chk a').fadeIn(1500);

		function check_for_update()
		{
			upd_chk.fadeOut(500).hide();
			srv_ver.fadeIn(500);

			ver_no.text('|EO_UPDATE_CHECKING| ..').fadeIn(500, function()
			{
				timer = setTimeout(function()
				{
					clearTimeout(timer);
					$.ajax(
					{
						url				: '|UPDATE_SITE_URI|/|APP_URI|/version',
						type			: 'GET',
						data			: {'update':'|APP_TYPE|', 'software':'|APP_URI|'},
						dataType		: 'jsonp',
						jsonpCallback	: 'callback',
						contentType		: 'application/javascript; charset=utf-8',
						cache			: false,
						timeout			: 10000,
						success:function(response)
						{
							if ((typeof response['server_version'] !== 'undefined') &&
								(typeof response['infourl'] !== 'undefined') &&
								(typeof response['download_url'] !== 'undefined') &&
								(typeof response['release_date'] !== 'undefined') &&
								(typeof response['release_notes'] !== 'undefined'))
							{
								var server_version	= response['server_version'];
								var infourl			= response['infourl'];
								var download_url	= response['download_url'];
								var release_date	= response['release_date'];
								var release_notes	= response['release_notes'];

								var eo_infourl = $('#eo-infourl');

								eo_infourl.wrap(function()
								{
									var link = $('<a/>');
									link.attr('href', infourl);
									link.attr('target', '_blank');
									link.attr('title', '|EO_OPEN_IN_NEW_WINDOW|');
									link.text($(this).text());
									return link;
								});

								ver_no.fadeOut(300, function()
								{
									var rel = $('#eo-release');

									ver_no.html('|EO_LATEST_VERSION|:&nbsp;'+server_version).fadeIn(500);
									rel.fadeIn(800);
									srv_ver.animate({ height:"55px" }, 200, 'linear');

									if (server_version <= installed_ver)
									{
										rel.animate({ height:"40px" }, 200, 'linear');
										latest.text('|EO_LATEST|').fadeIn();
										rel_date.html('|EO_RELEASE_DATE|:&nbsp;'+release_date).fadeIn();
										eo_infourl.html('|EO_VIEW_CHANGELOG_ONLINE|').fadeIn();
									}
									else if (server_version > installed_ver)
									{
										dl_update.wrap(function()
										{
											var link = $('<a/>');
											link.attr('href', download_url);
											link.attr('target', '_blank');
											link.attr('title', '|EO_OPEN_IN_NEW_WINDOW|');
											link.text($(this).text());
											return link;
										});

										rel.animate({ height:"60px" }, 200, 'linear');
										dl_update.fadeIn(150).fadeOut(150).fadeIn().fadeOut(150).fadeIn().text('|EO_NEW_VERSION_AVAILABLE|');
										rel_date.html('|EO_RELEASE_DATE|:&nbsp;'+release_date).fadeIn();
										rel_notes.html('|EO_RELEASE_NOTES|:&nbsp;'+release_notes).fadeIn();
										eo_infourl.html('|EO_VIEW_CHANGELOG_ONLINE|').fadeIn();

										rel.addClass('new-update');
										$('span#eo-dl-upd').addClass('blue');
									}
								});
							}
							else
							{
								conn_err();
							}
						},
						error:function()
						{
							conn_err();
						}
					});

					return false;
				}, 550);
			});
		}

		function conn_err()
		{
			ver_no.fadeOut(function()
			{
				var title = '|EO_CONN_ERROR|';
				var dsc = '|EO_CONN_ERROR_DSC|';

				srv_ver.animate({ height:'120px' }, 300, 'linear');
				ver_no.addClass('error');
				dl_update.addClass('error');
				ver_no.text(title).fadeIn();
				dl_update.text(dsc).fadeIn();
			});
		}

		upd_chk.click(function()
		{
			check_for_update(this.href);
			return false;
		});
	});
})();
