function timer()
{
	var date = new Date();
	var minutes = (date.getMinutes() < 10)? '0' + date.getMinutes() : date.getMinutes();
	var secounds = (date.getSeconds() < 10)? '0' + date.getSeconds() : date.getSeconds();
	document.getElementById('date').innerHTML= 'dziś jest: '+ date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear() + ', godz. ' + date.getHours() + ':' + minutes + ':' + secounds;
	setTimeout('timer()', 1000);
}

function subscribe_form_response(status)
{
	status = status.charAt(0);
	var subscribe_status_array = new Array();
	subscribe_status_array[0] = 'Adres dodany do bazy - dziekujemy!';
	subscribe_status_array[1] = 'Niepoprawny adres e-mail!';
	subscribe_status_array[2] = 'Adres email już istnieje w bazie!';
	subscribe_status_array[100] = 'Blad zapisu adresu do bazy prosimy sprobowac ponownie!';
	$('note').innerHTML = (subscribe_status_array[status] != undefined) ? subscribe_status_array[status] : subscribe_status_array[100];
}

function subscribe_form_send()
{
	var req = mint.Request();
	req.retryNum = 0;
	req.OnSuccess = function () {subscribe_form_response(this.responseText);}
	//req.OnLoading = function () {$('note').innerHTML = '<img border="0" src="/application/images/layout/loading.gif">';}
	req.OnError = function () {$("note").innerHTML = "Błąd połączenia...";}
	req.OnAbort = function () {$("note").innerHTML = "Błąd połączenia...";}
	req.SendForm("email_form");
	
}

function subscribe_form_swap_message(action)
{
	if(action == 'hide')
	{
		$("email").value = ($("email").value == 'Wpisz swój e-mail')? '' : $("email").value;
	}
	else if(action == 'check')
	{
		$("email").value = ($("email").value != '')? $("email").value : 'Wpisz swój e-mail';
	}
}

	function count_array(array)
	{
		var count = 0; 
		for(key in array){count++;}
		return count;
	}

	var imagesSiteArray = new Array();
	imagesSiteArray[0] = 'foto_01.jpg';
	imagesSiteArray[1] = 'foto_02.jpg';
	imagesSiteArray[2] = 'foto_03.jpg';
	imagesSiteArray[3] = 'foto_04.jpg';
	imagesSiteArray[4] = 'foto_05.jpg';
	imagesSiteArray[5] = 'foto_06.jpg';
	imagesSiteArray[6] = 'foto_07.jpg';
	imagesSiteArray[7] = 'foto_08.jpg';

	function imagesPreloader()
	{
		if (document.images)
		{
			var imagesSiteUrl = '/application/images/layout/';
			var imagesSiteObject = new Array();
			for(var i = 0; i < count_array(imagesSiteArray); i++)
			{
				imagesSiteObject[i] = new Image();
				imagesSiteObject[i].src = imagesSiteUrl + imagesSiteArray[i];
			}
		}
	}

	function swapMiniGalleryPlay(index)
	{
		swapMiniGallery(index);
		index = (index < (count_array(imagesSiteArray) - 1))? (index + 1) : 0;
		setTimeout("swapMiniGalleryPlay(" + index + ")", 3000);
	}
	
	function swapMiniGallery(index)
	{
		var imagesSiteUrl = '/application/images/layout/';
		$('mini_gallery_img').src = imagesSiteUrl + imagesSiteArray[index];
		miniGalleryLinks(index);
	}

	function miniGalleryLinks(selected_index)
	{
		var links_string = '';
		var count_elements = count_array(imagesSiteArray);
		links_string += '<a href="javascript:void(0);" onclick="swapMiniGallery(' + ((selected_index > 0)? (selected_index - 1) : (count_elements - 1)) + ');"><img src="/application/images/layout/p_gallery_left.png" border="0" alt="p" title="" /></a>';
		for(var i = 0; i < count_elements; i++)
		{
			links_string += '<span' + ((selected_index == i)? ' class="active"' : '') + '>[<a href="javascript:void(0);" onclick="swapMiniGallery(' + i + ');">' + (i + 1) + '</a>]</span>';	
		}
		links_string += '<a href="javascript:void(0);" onclick="swapMiniGallery(' + ((selected_index < (count_elements - 1))? (selected_index + 1) : 0) + ');"><img src="/application/images/layout/p_gallery_right.png" border="0" alt="p" title="" /></a>';
		$('mini_gallery_links').innerHTML = links_string;
	}

