function moveItem(targetId, position, elementId){
	$(document).ready(function(){
		var table = $('#prices');
		var tableOffset = table.offset();
		var target = $('#'+targetId);
		var element = $('#'+elementId);
		var elementOffset = element.offset();
		var elementWidth = element.width();
		var elementHeight = element.height();
		var targetWidth = target.width();
		var targetHeight = target.height();
		if(position=='down'){
			var bottomLine = elementOffset.top+elementHeight;
			var leftPx = elementOffset.left + ((elementWidth+32 - targetWidth)/2);
			target.css('left', leftPx);
			target.css('top', bottomLine);
		}
		if(position=='up'){
			var bottomLine = elementOffset.top-22;
			var leftPx = elementOffset.left + ((elementWidth+32 - targetWidth)/2);
			target.css('left', leftPx);
			target.css('top', bottomLine);
		}
		if(position=='upMiddle'){
			var bottomLine = elementOffset.top-22;
			var leftPx = elementOffset.left + ((elementWidth-16)/2);
			target.css('left', leftPx);
			target.css('top', bottomLine);
		}
		if(position=='tdown'){
			var bottomLine = elementOffset.top+27;
			var leftPx = elementOffset.left + ((elementWidth+32 - targetWidth)/2);
			target.css('left', leftPx);
			target.css('top', bottomLine);
		}
	});
}

function publicConfigurator(){
	$('.quantity').keyup(function(){
		var quantity = $(this).val();
		quantity = Number(quantity);
		var id = $(this).attr('id');
		var onePrice = $('#'+id+'_price').html();
		onePrice = Number(onePrice);
		if(isNaN(onePrice) || isNaN(quantity)){
			alert('Моля, въведете число.');
		}else{
			var total = quantity*onePrice;
			var total = total.toFixed(2);
			$('#'+id+'_total').val(total);
			publicConfiguratorCalculateTotal();
		}
	});
}

function publicConfiguratorCalculateTotal(){
	var total = 0;
	$('.total').each(function(){
		var currentTotal = $(this).val();
		var currentTotal = Number(currentTotal);
		total = total + currentTotal;	
	});
	total = total.toFixed(2);
	$('#total').val(total);
}

function poll(){
	$(document).ready(function(){
		$('.pollButtons li a').click(function(e){
			e.preventDefault();
			$(this).blur();
			var number = 'one';
			$('#havewebsite').val('0');
			if($(this).hasClass('two')){
				number = 'two';
				$('#havewebsite').val('1');
			}
			if(!$(this).hasClass('active')){
				$('.pollButtons li a.active').removeClass('active');
				$(this).addClass('active');
				var targetQuestions = $('.questions'+number);
				var height = targetQuestions.height();
				$('#boxContent').animate({height: height+'px'}, 300, function(){
					$('.questions.active').fadeOut(300, function(){
						$(this).removeClass('active');
						targetQuestions.fadeIn(400).addClass('active');
					});
				});
			}
		});
	});
}

function initSeminars(){
	$(document).ready(function(){
		
	});
	
	$('#seminarId').change(function(){
		$('.seminarDates').css('display', 'none');
		$('.seminarLinks').css('display', 'none');
		var id = $(this).val();
		$('#seminarLinks'+id).css('display', 'block');
		$('#seminarDates'+id).css('display', 'block');
	});
	
	$('#quantity').change(function(){
		var people = $(this).val();
		var amount = people*150;
		$('#amount').val(amount+ ' лв.');
	});	
	
	$('#seminarId').change();
	$('#quantity').change();	
}
