//<![CDATA[
/* */
function updateRowSum(index) {
	// Get the amount of working time
	var amount = $('#price-calculator tbody .amount').eq(index).val();
	amount = amount.replace(',', '.');
	amount = parseFloat(amount);
	if (isNaN(amount)) {
		amount = 0;
	}
	// Get the multiplier (1 h or 8 h)
	var unit = $('#price-calculator tbody .unit').eq(index).val();
	var multiplier = 1;
	if (unit == 'htp') {
		multiplier = 8;
	}
	// Get the rate
	var rate = $('#price-calculator tbody .rate').eq(index).html();
	rate = rate.replace(',', '.');
	rate = parseFloat(rate);
	// Calculate the sum
	var sum = amount * multiplier * rate;
	// Update the sum field
	//sum = sum.toFixed(0);
	sum = (sum + '').replace('.', ',');
	$('#price-calculator tbody .sum').eq(index).html(sum);
	updateTotalSum();
}
/* */
function updateTotalSum() {
	// Get the number of rows
	var rows = $('#price-calculator tbody .sum').size();
	// Update rows and count the total sum
	var total = 0;
	for (i = 0; i < rows; i++) {
		var sum = $('#price-calculator tbody .sum').eq(i).html();
		sum = sum.replace(',', '.');
		sum = parseFloat(sum);
		total += sum;
	}
	// Update the total sum field
	//total = total.toFixed(0);
	total = (total + '').replace('.', ',');
	$('#price-calculator tfoot .number').html(total);
}
// Add functionality on page load
$(function() {
	// Apply the logo crossfade effect
	$('#logo img').dumbCrossFade({
		index: 0,
		showTime: 8000, 
		transitionTime: 1000, 
		doHoverPause: true,
		maxZIndex: 10
	});
	// Apply the smooth navigation scroll effect
	$.localScroll({
		duration: 250
	});
	// Apply the picture zoom functionality
	$('#introduction a.zoom, #works a.zoom, #blog a.zoom, #contact-us a.zoom').fancybox({
		imageScale: true,
		centerOnScroll: false,
		padding: 0,
		overlayColor: '#333333',
		overlayOpacity: 0.5
	});
	$('#process a.zoom').fancybox({
		imageScale: false,
		centerOnScroll: false,
		padding: 0,
		overlayColor: '#333333',
		overlayOpacity: 0.5
	});
	// Add event handles to price calculator fields
	$('#price-calculator tbody .amount').bind('change keyup mouseup', function() {
		updateRowSum($("#price-calculator .amount").index(this));
	});
	$('#price-calculator tbody .unit').bind('change keyup mouseup', function() {
		updateRowSum($("#price-calculator .unit").index(this));
	});
	// Enable the price calculator fields (we wish to keep them disabled if javascript is disabled)
	$('#price-calculator tbody .amount').attr('disabled', '');
	// Calculate the price calculator sums (in case the browser fills in previous values on refresh)
	$('#price-calculator .amount').trigger('change');
	// Apply blog archive functionality
	$('#blog #col-2 .archive .button').click(function () {
		var url = $('#archive-selection').val();
		if (url != '') {
			window.location = url;
		}
		return false;
	});
	// Apply the tab functionality
	$('#contact-us .tabs .labels a').click(function() {
		$(this).parent().parent().parent().children('.tab').hide().filter(this.hash).show();
		$(this).parent().parent().children('li').removeClass('active');
		$(this).parent().addClass('active');
		return false;
	});
	// Display the tabs (only if javascript is available)
	$('#contact-us .tabs .labels').show();
	// Hide the spam honeypot field
	$('#t7969').hide();
	// Apply the contact form functionality
	var contactForm = $('#contact-form');
	var contactFormSubject = contactForm.children('#contact-form .subject');
	$('#contact-form .subject .meeting').change(function() {
		$('#contact-form .message').show();
		$('#contact-form .project-description').hide();
		$('#contact-form .url').hide();
		$('#contact-form .attachments').hide();
		$('#contact-form .self-description').hide();
		$('#contact-form .cv').hide();
		$('#contact-form .time').show();
		$('#contact-form .contact-info').show();
	});
	$('#contact-form .subject .estimation').change(function() {
		$('#contact-form .message').show();
		$('#contact-form .project-description').show();
		$('#contact-form .url').show();
		$('#contact-form .attachments').show();
		$('#contact-form .self-description').hide();
		$('#contact-form .cv').hide();
		$('#contact-form .time').hide();
		$('#contact-form .contact-info').show();
	});
	$('#contact-form .subject .employment').change(function() {
		$('#contact-form .message').show();
		$('#contact-form .project-description').hide();
		$('#contact-form .url').hide();
		$('#contact-form .attachments').hide();
		$('#contact-form .self-description').show();
		$('#contact-form .cv').show();
		$('#contact-form .time').hide();
		$('#contact-form .contact-info').show();
	});
	$('#contact-form .subject .question, #contact-form .subject .feedback, #contact-form .subject .other').change(function() {
		$('#contact-form .message').show();
		$('#contact-form .project-description').hide();
		$('#contact-form .url').hide();
		$('#contact-form .attachments').hide();
		$('#contact-form .self-description').hide();
		$('#contact-form .cv').hide();
		$('#contact-form .time').hide();
		$('#contact-form .contact-info').show();
	});
	// Update the contact form (in case the browser fills in previous values on refresh)
	$('#contact-form .subject input:radio:checked').change();
	// Apply the contact link functionality
	$('#contact-us .showContactForm').click(function() {
		$('.tabs a:last').click();
	});
	$('#contact-us .showMeetingForm').click(function() {
		$('.tabs a:last').click();
		$('#contact-form .subject .meeting').attr('checked', 'checked');
		$('#contact-form .subject .meeting').change();
	});
	$('#contact-us .showEstimationForm').click(function() {
		$('.tabs a:last').click();
		$('#contact-form .subject .estimation').attr('checked', 'checked');
		$('#contact-form .subject .estimation').change();
	});
});
//]]>