$(function(){
	
	// remove empty list items
	$('.left-content > ul > li').filter(':empty').remove();
	
	$('.left-content > ul > li')
		.click(function(){
			var i = 1, t = this;
			$('.left-content > ul > li')
				.removeClass('active')
				.each(function(){
					if (t == this) {
						return false;
					}
					i = i + 1;
				});
			$('.img-placeholder > div').hide();
			$('.img-placeholder > div:nth-child(' + i + ')').show();
			$(this).addClass('active');
			return false;
		})
		.filter(':first').addClass('active');
	
	$('.img-placeholder > div').not(':first').hide();
		
	$('.L23 input[name$=tboxPlace]')
		.bind('keypress', function(e) {
			// check for ENTER
			if ( e.keyCode == 13 ) {
				var submitButton = $('.L23 a[id$=lnkSearchButton]');
				window.location = submitButton.attr('href');
			}
    });

    $('.L23 input[name$=txtL23L26StreetZip]')
		.bind('keypress', function(e) {
		    // check for ENTER
		    if (e.keyCode == 13) {
		        var submitButton = $('.L23 a[id$=lbtnSearchAddress]');
		        window.location = submitButton.attr('href');
		    }
	});

	$('.L23 input[name$=txtL23L26HouseNumber]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.L23 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});

	$('.L23 input[name$=txtL23L26NumberAddition]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.L23 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});

	$('.L23 input[name$=txtL23L26Place]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.L23 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});

	$('.l26 input[name$=txtL26WidgetStreetZip]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.l26 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});

	$('.l26 input[name$=txtL26WidgetHouseNumber]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.l26 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});

	$('.l26 input[name$=txtL26WidgetPlace]')
	.bind('keypress', function(e) {
	    // check for ENTER
	    if (e.keyCode == 13) {
	        var submitButton = $('.l26 a[id$=lbtnSearchAddress]');
	        window.location = submitButton.attr('href');
	    }
	});
	
	$.ajax({
        type: 'POST',
        url: '/_vti_bin/PortalSearchService.asmx/GetPlaceNames',
        contentType: "application/json; charset=utf-8",
        data: "{}",
        dataType: 'json',
        success: function(cities) {
	        $(".autocomplete-place").autocomplete(cities.d);
        }
    });
	
	
	
});