				$(document).ready(
								
					function()
					{

						$('div#version_html').css("display", "none");
						$('div#version_flash').css("display", "block");
						$('div#version_flash div#flashcontent').css("display", "block");
						$('div#version_flash div#flashcontent').css("width", "100%");
						$('div#version_flash div#flashcontent').css("height", "100%");
						$('div#version_flash div#flashcontent').css("position", "absolute");
						$('div#version_flash div#flashcontent').css("left", "0");
						$('div#version_flash div#flashcontent').css("top", "0");
						
						$('#dock').Fisheye(
							{
								maxWidth: 10,
								items: 'a',
								itemsText: 'span',
								container: '.dock-container',
								itemWidth: 110,
								proximity: 90,
								alignment : 'left',
								valign: 'bottom',
								halign : 'center'
							}
						)
						
						
						$('#dock').css("margin", "160px auto 0 auto");
						$('a.dock-item').css("position", "absolute");
						$('a.dock-item').css("bottom", "0");
						$('a.dock-item').css("width", "40px");

					 /* bez title na hover - nowa wersja (03/10)
						$('.dock-item').mouseover(function(){
						//var title = $(this).attr("title");
						var title = $(this).find('span').html();
						$('#title').text(title);
					}).mouseout(function(){
						$('#title').text('');
					});
					*/

					$('#ticker').bxSlider({
						mode: 'ticker',
						speed: 7000,
						width: 252, //tyle ma najdluzsze logo
						wrapper_class: 'ticker_container'
					});	

					$('a.ticker').mouseover(
						function(){
							var curImgSrc = $(this).find('img.current').attr('src');
							$(this).find('img.current').attr('src', $(this).find("img.current").attr("alt"));
							$(this).find('img.current').attr('alt', curImgSrc);
							}
					)
				
					$('a.ticker').mouseout(
						function(){
							var curImgSrc = $(this).find('img.current').attr('src');
							$(this).find('img.current').attr('src', $(this).find("img.current").attr("alt"));
							$(this).find('img.current').attr('alt', curImgSrc);
							}
					)
					
					if($.cookie('confin_clock_help') != 1)
					{
						$('div#clock_help').fadeIn('slow');
					}
					
					$('div#clock_help').mouseover(
						function(){
							$('div#clock_help').fadeOut('slow');
							$.cookie('confin_clock_help', '1', {path: '/', expires: 10});
							}
					)
					
					$('.scrollable-area').jScrollPane();
					
					$('.maptoggle').toggle(
						function(){
						if($('img#map').attr('src') != 'images/map_zoomed.png')
								{
									$('img#map').fadeIn('slow');
									$('img#map').attr('src','images/map_zoomed.png');
								}
						}, function() {
								if($('img#map').attr('src') != 'images/map_normal.png')
								{
									$('img#map').fadeIn('slow');
									$('img#map').attr('src','images/map_normal.png');
								}
						});
						
					$("#slider").easySlider({
						prevText:'Poprzednie',
						nextText:'Następne',
						orientation:'vertical'
					});

					$('#show_contact').click(
						function(){
							$('div#contact_wrapper').fadeIn('slow');
							}
					)
					
					$('#close_contact').click(
						function(){
							$('div#contact_wrapper').fadeOut('slow');
							}
					)
					
					$('#close_offer').click(
						function(){
							$('div#offerlay_wrapper').fadeOut('slow');
							}
					)
					
					/*
					$('a.dock-item').click(
						function(){
							$('div#offerlay_wrapper').fadeIn('slow');
							}
					)
					*/
					
					$('a.send').click(
						function(){
							$('#contact_form').submit();
							$('a.send').preventDefault();
							}
					)
					
					$('a.clear').click(
						function(){
							$('#contact_form').find(':input').val("");
							}
					)
					
					$('#newsitems ul.newsmenu li.news a').click(
						function(){
							$('div#news-content').text('Wczytywanie...');
							}
					)
					
					setInterval("play()", 1200);

					$("#submit").click(
						function(){
							send_mail();
						}
					)

					}
					
					
				);
				
function CheckNIP(input_string)
{
	if (!input_string.match( /^[0-9]{3}-[0-9]{2}-[0-9]{2}-[0-9]{3}$/ ) && !input_string.match( /^[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/ ) && !input_string.match( /^[0-9]{10}$/ ))
	{
		return false;
	}
	
	var my_nums = input_string.replace(/-/g,'');
	var valid_nums = "657234567";
	var sum = 0;
	for (var temp=8;temp>=0;temp--)
	sum += (parseInt(valid_nums.charAt(temp)) * parseInt(my_nums.charAt(temp)));
	if ( (sum % 11) == 10 ? false : ((sum % 11) == parseInt(my_nums.charAt(9))) )
		return true;
	else
		return false;
}

//alert(sprawdzNIP("657-008-22-74"));

function CheckEmail(input_string)
{
	var validMail= /^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+)*(\.[a-zA-Z]{2,4})$/;

	if (validMail.exec(input_string) == null)
		return false

	return true;
}

function CheckPhone(input_string)
{
	var validMail= /^[0-9]+$/;

	if (validMail.exec(input_string) == null)
		return false

	return true;
}

function play()
{
	$('#clock').css({backgroundPosition: '70px 45px'}).animate({'background-position': '100px 45px'}).animate({backgroundPosition: '70px 45px'});
}

function send_mail()
{


		var allInputs = $("#contact_form :input");
		var specialInputs = new Array("in_nip", "in_tel", "in_ema"); //nip, tel, email
		var errors = 0;
		var err_nip_str = "", err_phone_str = "", err_email_str = "";
		

		for (var x = 0; x <= 7; x++)
		 {
				if ($(allInputs[x]).val() == "" && jQuery.inArray(allInputs[x].id, specialInputs) < 0)
				{
					errors++;
				}

				if (jQuery.inArray(allInputs[x].id, specialInputs) >= 0)
				{
					
					if(allInputs[x].id == "in_nip" && CheckNIP(allInputs[x].value) != true)
					{
						errors++;
						err_nip_str = "Podany NIP jest nieprawidłowy. "
					}

					if(allInputs[x].id == "in_tel" && CheckPhone(allInputs[x].value) != true)
					{
						errors++;
						err_phone_str = "Podany Telefon jest nieprawidłowy (powinien zawierać jedynie cyfry). "
					}
					
					if(allInputs[x].id == "in_ema" && CheckEmail(allInputs[x].value) != true)
					{
						errors++;
						err_email_str = "Podany adres E-Mail jest nieprawidłowy. "
					}
				}
		 }
		 
		 if(errors > 0)
		 {
			$("#form_result").text("Błąd. Jedno lub więcej pól zostało nieprawidłowo wypełnione. " + err_nip_str + err_phone_str + err_email_str);
			return false;
		 }
		 else
		 {
				$.post( 
					 "html/ajax_mail.php",
					 { 
						 ajx: 1,
						 usl: $('#ta_usl').val(),
						 ocz: $('#ta_ocz').val(),
						 dzi: $('#in_dzi').val(),
						 nip: $('#in_nip').val(),
						 naz: $('#in_naz').val(),
						 oso: $('#in_oso').val(),
						 tel: $('#in_tel').val(),
						 ema: $('#in_ema').val()
					 },
					 function(data) {
					 
							var response = data;
							
							if(response == 1)
							{
								$('#contact_wrapper div.left_col').fadeOut("fast");
								$('#contact_wrapper div.right_col').fadeOut("fast");
								$('#contact_wrapper div.footer img.send').fadeOut("fast");
								$('#contact_wrapper div.footer a.clear').fadeOut("fast");
								$('#form_result').html("Wiadomość została wysłana pomyślnie.");
							}
							else
							{
								$('#form_result').html("Nie wysłano wiadomości. Wystąpił problem podczas wysyłania. Proszę spróbować ponownie.");
							}
							
					 }

          );
			return true;

		 }

}
