function newWin(URL) {

	okno=window.open(URL,'blank');
	//okno.document.close();
	okno.focus();

}

function zoom(URL,winName,features) {
	okno=window.open('',winName,features);
	okno.document.write('<HTML><TITLE>Mapka // M.L.C. - Medical Laser Centre</TITLE><BODY style="margin:0; padding:0; font-family: Arial, Helvetica, sans-serif; color: white;">');
	okno.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" style="font-size: 75%;">');
	okno.document.write('<a href="javascript:window.close()"><IMG SRC="'+URL+'" border="0" alt="close" title="close" style="border: 5px solid #FCF4DD"></a><br>');
	okno.document.write('<td><tr></table></BODY></HTML>');
	okno.document.close();
	okno.focus();
	okno.document.bgColor="255D6E";
}

(function($, window, document, _undefined)
{
	/**
	 * Contact form
	 */
	I4App.ContactForm = {};
	$.extend(I4App.ContactForm,
	{
		formSubmit: function($form)
		{
			$form.submit(function(e){
				e.preventDefault();
				$('label.error').remove();

				var valid = true,
					submitButton = $form.find('input[type="submit"]').attr('disabled', 'disabled');

				$form.find('.required').each(function()
				{
					var elm = $(this),
						errLabel = elm.parent().find('label.error');

					if (errLabel.length > 0)
					{
						errLabel.remove();
					}

					if (elm.attr('id') == 'ctrl_email')
					{
						var val = jQuery.trim(elm.val());
						if (val == '')
						{
							valid = false;
							elm.parent().append('<label class="error">' + I4App.phrases.field_cannot_be_empty + '</label>');
						} else {
							if (!I4App.form.validateEmail(val))
							{
								valid = false;
								elm.parent().append('<label class="error">' + I4App.phrases.bad_email_format + '</label>');
							}
						}

					} else {
						if (jQuery.trim(elm.val()) == '')
						{
							valid = false;
							elm.parent().append('<label class="error">' + I4App.phrases.field_cannot_be_empty + '</label>');
						}
					}
				});

				if (valid)
				{
					$.post(
						$form.attr('action'),
						$form.serialize(),
						function(data){
							I4App.overlayWindow.showWindow('', data);
							I4App.activate('#I4AppInfoWindow .content');
							submitButton.attr('disabled', '');
						}
					);
				}
				submitButton.attr('disabled', '');
			});
		}
	});

	I4App.register('#contactForm', 'I4App.ContactForm.formSubmit');

}(jQuery, this, document));

// news cycling
$(document).ready(
	function() {
		list = new Array();
		$('.nwsitem.rotate').each(function(i) {
			list[i] = this;
		});

		function rotateNews(i) {
			$('.nwsitem.rotate').hide();
			$('.nwsitem.rotate:eq('+i+')').show().animate({ opacity: 0 }, 0).animate({ opacity: 1 }, 500);

			delay = 1000 + ($('.nwsitem.rotate:eq('+i+')').html().length * 15);
			
			i++;

			if(i < $('.nwsitem.rotate').length) {
				window.setTimeout(rotateNews, delay, i);
			} else {
				window.setTimeout(rotateNews, delay, 0);
			}
		}
		
		rotateNews(0);
	}
);

