function initGallery(){
	var _len = $('#carusel .gallery-scroll li').length;
	
	if ( _len == 1) {
		_len == 2;
		var $list = $('#carusel .gallery-scroll ul');
		$list.css('visibility', 'hidden').find('li:last').clone(true).appendTo($list);
	}
	
	var _active = 1;
    var _activeTimeCounter = null;
    var _activePriceCounter = null;
	setActiveInfo();
		
	$('#carusel a.prev').click(function(){
		if(_active>0) {
			_active--;
		}
		else {
			_active = _len-1;
		}

		var $list = $('#carusel .gallery-scroll ul');
		$list.find('li:last').insertBefore($list.find('li:first'));
		
		setActiveInfo();
		return false;
	});
	
	$('#carusel a.next').click(function(){
		
		if(_active<_len-1){
			_active++;
		}
		else{
			_active = 0;
		}

		var $list = $('#carusel .gallery-scroll ul');
		$list.find('li:first').insertAfter($list.find('li:last'));
		
		setActiveInfo();
		return false;
	});
		
	function setActiveInfo(){
        if (_activeTimeCounter != null) {
            _activeTimeCounter.stop();
        }
        if (_activePriceCounter != null) {
            _activePriceCounter.stop();
        }
		$('#carusel .gallery-scroll li').removeClass('active');
		$('#carusel .gallery-scroll li:nth-child(2)').addClass('active');

		$('#carusel div.auto-info').html($('#carusel .gallery-scroll ul > li.active .info').html());

		try {
		    _activeTimeCounter = $('#carusel div.auto-info div.auto .time-counter').pricecounter({ is_timecountdown: true }).data('counter');
		    _activePriceCounter = $('#carusel div.auto-info div.frame-auto .frame-digit').pricecounter().data('counter');
		}
		catch (err) { }
		
		// Remove all click event handlers for main img
        $("#carusel .auto-info .frame-auto .holder > img").unbind("click");

        // Add hand cursor so users should know it is a link
        $('#carusel .auto-info .frame-auto .holder > img').css('cursor','pointer');
        
        // Add click event on main img
        $('#carusel .auto-info .frame-auto .holder > img').click(function() {
         var linkToReservationPage = $('#carusel .auto-info .koop a#details').attr('href');
         document.location = linkToReservationPage;
        });
	}
	
}
$(function(){
	initGallery();
});

function Clickbutton(e, targetButton) {
    if (e.keyCode == 13) {
        targetButton.click();
        return false;
    }
    return true;
}

$(function(){
   $('a.expiredAuctionImageLnk').css('position', 'relative').append('<img src="/style/images/holder_overlay_1.png" style="position:absolute; top:5px; left:0px">');
   $('a.soldAuctionImageLnk').css('position', 'relative').append('<img src="/style/images/holder_overlay_2.png" style="position:absolute; top:5px; left:0px">');
   $('a.reservedAuctionImageLng').css('position', 'relative').append('<img src="/style/images/holder_overlay_3.png" style="position:absolute; top:5px; left:0px">');
});

$(function() {
    $('div.row-auto').css('cursor', 'pointer');
    $('div.row-auto').each(function() {
        $(this).click(function() {
            var link = $(this).find('.frame-auto a').attr('href');
            document.location.href = link;
        });
        $(this).hover(function() {
        var link = $(this).find('.holder-auto h2 a');
            link.css('color', '#FF9C00');
        }, function() {
        var link = $(this).find('.holder-auto h2 a');
            link.css('color', '#336EA4');
        });

    });
});


$(document).ready(function() {
    try {
        $('div.content.lister div.frame-digit').pricecounter().data('counter');
        $('div.content.lister div.time-counter').pricecounter({ is_timecountdown: true }).data('counter');
        $('div.sidebar div.frame-digit').pricecounter().data('counter');
        $('div.holder div.time-counter').pricecounter({ is_timecountdown: true }).data('counter');
        $('div.holder div.holder div.frame-digit').pricecounter().data('counter');
    }
    catch (err) { }
});