
//var currentFileBox = 0;
	var maxFileBoxes = 4;
	var filledDate = '';
	var startpriceChanged = false;
  
    var mhAuctionEditorFormular = {
        handleKnownUser: function() {
            $("#UserIsKnownSwitch").click(function(){
                $(this).parent("label").addClass("inline").removeClass("text");
                $("#UserIsUnknownSwitch").parent("label").addClass("text").removeClass("inline");
                $(".userIsUnknown").hide();
                $(".userIsKnown").show();
            });
        },
        handleUnknownUser: function() {
            $("#UserIsUnknownSwitch").click(function(){
                $(this).parent("label").removeClass("text");
                $("#UserIsKnownSwitch").parent("label").addClass("text");
                $(".userIsKnown").hide();
                $(".userIsUnknown").show();
            });
        },
        init: function() {
            this.handleKnownUser();
            this.handleUnknownUser();
        }
    };

    $(document).ready(function(){
        mhAuctionEditorFormular.init();
    })

	function prefillTargetDate()
	{
		if ($('#targetDate').val() == filledDate)
		{
			time = new Date();
			newTimestamp = time.getTime() + ((parseInt($('#daysRunning').val()) + 14) *24*60*60*1000);
			time.setTime(newTimestamp);
			newDate = 'ab ca. ' + time.getDate() + '.' + (time.getMonth()+1) + '.' + time.getFullYear();
			$('#targetDate').val(newDate);
			filledDate = newDate;
		}
	}

	var nextToShow = 1;
		
	function removeUploadField(fieldNumber)
	{
		$('#boxFile'+fieldNumber).hide();
		UploadFieldArray[fieldNumber] = 0;
		
		if(UploadFieldArray[0] == 2 && (UploadFieldArray[1] == 1 || UploadFieldArray[1] == 2) && (UploadFieldArray[2] == 1 || UploadFieldArray[2] == 2) && (UploadFieldArray[3] == 1 || UploadFieldArray[3] == 2))
		{
			$('#showMoreFileButton').hide();
		}
		else
		{
			$('#showMoreFileButton').show();
		}
	}

	$().ready(function() {
	
		$("#fileInfo").hover(
			function ()
			{
				showBubble("fileInfo", "info-fileInfo", "left", -5);
			},
			function()
			{
				$("#info-fileInfo").hide();
			}
			
			);
	
		$('#showMoreFileButton').click(function() {
			var i = 1;
			var found = 0;
			
			while(i < maxFileBoxes && found != 1)
			{
				if(UploadFieldArray[i] == 0)
				{
					found = 1;
					$('#boxFile'+i).show();
					UploadFieldArray[i] = 1;
					nextToShow = i + 1;
				}
				
				i++;
			}
			
			if((UploadFieldArray[1] == 1 || UploadFieldArray[1] == 2) && (UploadFieldArray[2] == 1 || UploadFieldArray[2] == 2) && (UploadFieldArray[3] == 1 || UploadFieldArray[3] == 2))
			{
				$('#showMoreFileButton').hide();
			}
			else
			{
				$('#showMoreFileButton').show();
			}
		});

		$('#preSelectStartprice').change(function() {
			startpriceChanged = true;
		});


		$('#unittype').change(function() {
			selectedOption = $(this).children('option:selected');

			// change unittype
			$('.priceUnit').html(selectedOption.attr('unitLabel'));

			// decide showing countUnitsContainer
			if (selectedOption.attr('requiresCountUnits') == true) {
				$('#countUnitsContainer .countUnitsLabel').html(selectedOption.attr('countUnitsLabel'));
				$('#countUnitsContainer .countUnitsUnitLabel').html(selectedOption.attr('countUnitsUnitLabel'));
				$('#countUnitsContainer').css('display','inline-block');

				// kopiert aus alter version
//				$(".ContentHolderRight").css("height","587px");
//				$("#profiles div.container").css("height","587px");
//				$("#lastbox").hide();
//				$("#lc").hide();
//				$("#rc").hide();
			} else {
				$('#countUnitsContainer').css('display','none');
			}

			if(!startpriceChanged) {
				if (($(this).val() == '1') || ($(this).val() == '4')) {
					$('#startprice').val('1000');
				} else {
					$('#startprice').val('10');
				}
			}			
		});
		$('#unittype').change();

		// prefill form
		if ($('#startprice').val() == '')
		{
			$('#preSelectStartprice').val('1000');
			$('#startprice').val('1000');
			startpriceChanged = false;
		}
		prefillTargetDate();
	});

	// verification notice
	$("#closeVerificationNotice").click(function() { 
		$("#verificationNotice").hide();
		return false;
	});

