	var swfu;
	var ga = false;
function sendUserForm() {
		if(document.user_form.reg_accept.checked == false) {
			if(ga) {
				try {
					var pageTracker = _gat._getTracker("UA-3146697-1");
					pageTracker._trackPageview(ga.replace('dane-kontaktowe', 'blad'));
				} catch(err) {}
			}
			alert('Musisz zaakceptować regulamin aby móc skorzystać z naszych usług.');
			return false;
		}
		if (document.user_form.payment_id.value == 0) {
			if(ga) {
				try {
					var pageTracker = _gat._getTracker("UA-3146697-1");
					pageTracker._trackPageview(ga.replace('dane-kontaktowe', 'blad'));
				} catch(err) {}
			}
			alert('Proszę wybrać sposób płatności.');
			return false;
		}
		if(document.user_form.payment_id.options[document.user_form.payment_id.selectedIndex].className == 'needDest' && document.user_form.destination_id.value == 0) {
			if(ga) {
				try {
					var pageTracker = _gat._getTracker("UA-3146697-1");
					pageTracker._trackPageview(ga.replace('dane-kontaktowe', 'blad'));
				} catch(err) {}
			}
			alert('Wskaż miejsce odbioru zamówienia.');
			return false;
		}
		return true;
	}
$(document).ready(function(){
	$('#user_form').submit(function() {
		return sendUserForm();
	});
	$('#payment_id').change(function() {
		$('#payment_id option').eq($(this).get(0).selectedIndex).click();
	});
	$('#dalej').hide();
	$(".small a").click(function(){
		var largePath=$(this).attr("href");
		$("#largeImg").attr({src:largePath});
		$("#largeImg").fadeIn("fast");
		return false;
	});
	var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
		if(playerVersion.major < 9) {
			$('<div class="errors"><a href="http://get.adobe.com/flashplayer/">Pobierz i zainstaluj</a> najnowszą wersję Flash Player\'a aby uzyskać pełną funkcjonalność strony.</div>').prependTo('#zamow');
		}
	
	$("#szczegoly .text").eq(1).hide();
	$("#szczegoly .text").eq(2).hide();
	
	$("#menu ul li a").click(function(){
		var index = $("#menu ul li a").index(this);
		$("#menu ul li a").removeClass('active');
		$("#menu ul li a").addClass('button');
		$(this).removeClass('button');
		$(this).addClass('active');
		$("#szczegoly .text").hide();
		$("#szczegoly .text").eq(index).fadeIn("slow");
		return false;
	});
});
function shipmentCost(price) {
	if(document.getElementById('shipmentCost')) {
		price = price.toString();
		if (price.indexOf('.') == 0 || price.indexOf('.') == -1) {
			price += '.00';
		}
		else if (price.indexOf('.') == price.length -2)
			price += '0';
		$('#shipmentCost').html(price + ' PLN');
		var totalPrice = parseFloat($('#cartValue').html().replace(' PLN','')) + parseFloat(price);
		totalPrice = totalPrice.toString();
		if (totalPrice.indexOf('.') == 0 || totalPrice.indexOf('.') == -1) {
			totalPrice += '.00';
		}
		else if (totalPrice.indexOf('.') == totalPrice.length -2)
			totalPrice += '0';	
		$('#totalPrice').html(totalPrice+' PLN');
	}
}
	var gFiles = 1;
	function addFile(e) {
		if(e.value.length > 0) {
			$('<tr id="file-'+gFiles+'"><td>'+(gFiles+1)+'.</td><td><input id="ilosc--'+gFiles+'" type="text" name="ilosc--'+gFiles+'" value="1" /></td><td id="price'+gFiles+'>'+$('#productPrice').val()+' zł</td><td><input type="file" name="file' + gFiles + '" onchange="addFile(this)" /><input type="button" onclick="removeFile(\'file-' + gFiles + '\')" value="Usuń" /></td></tr>').appendTo('#fileList'); 
			gFiles++;
		}
	}
	function removeFile(aId) {
		if($('#fileList > tr').length < 2) return false;
	    $('#file-'+aId).remove();
		swfu.cancelUpload(swfu.getFile(aId).id, false);
		return false;
	}

		window.onload = function() {
			if($.cookie('PHPSESSID')) {
				var settings = {
					flash_url : "../img/swfupload/swfupload.swf",
					upload_url: "../../fotoupload.php",	// Relative to the SWF file
					post_params: {"PHPSESSID" : $.cookie('PHPSESSID'),
								"priceListCode" : $('#priceListCode').val(),
								"productId" : $('#productId').val()},
					file_size_limit : "100 MB",
					file_types : "*.*",
					file_types_description : "All Files",
					file_upload_limit : 100,
					file_queue_limit : 0,
					debug: false,

					// Button settings
					// Relative to the Flash file
					button_image_url: "http://www.crazyfoto.pl/img/bytton_dodaj.jpg",
					button_width: "185",
					button_height: "28",
					button_placeholder_id: "wybierzPliki",
					button_text_style: ".theFont { font-size: 16; color: #f93; }",
					button_text_left_padding: 12,
					button_text_top_padding: 3,	
					button_action : SWFUpload.BUTTON_ACTION.SELECT_FILE, 
					
					file_queued_handler : fileQueued,
					file_queue_error_handler : fileQueueError,
					file_dialog_complete_handler : fileDialogComplete,
					upload_start_handler : uploadStart,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete,
					queue_complete_handler : queueComplete
				};

				swfu = new SWFUpload(settings);
			}
	     };
