$(document).ready(function(){

	if($('.auctions-subnav').length > 0) {
		
		$('.auctions-subnav a').click(function(){
			
			var sel = $(this).attr('href').replace('#','');
			$('.auctions-subnav .current').removeClass('current');

			if(sel == 'all') {
				$('.auction').show();
			} else {
				$('.auction:not(.'+sel+')').hide();
				$('.'+sel).show();
			}
			$(this).parent().addClass('current');
			return false;
		});
	}
	
	if($('.showgallery').length > 0) {
		
		$('.showgallery').click(function(){
			$(this).hide().parents('.auction-item').find('.gallery').slideDown();
			$(this).parent().find('.hidegallery').show();
			return false;
		})
		
		$('.hidegallery').click(function(){
			$(this).hide().parents('.auction-item').find('.gallery').slideUp();
			$(this).parent().find('.showgallery').show();
			return false;
		})
		
	}
	
	if($('.gallery').length > 0) {
		$('.gallery a').lightBox();
	}
	
	if($('#contactform').length > 0) {
		$('#contactform').validate();
	}
	
	if($('#proxybid').length > 0) {
		$('#proxybid').dialog({
			modal:true,
			autoOpen: false
		});
		
		$('#proxybid #cancelbutton').click(function(){
			$('#proxybid').dialog("close");
		});
		
		$('.placebid').click(function(){
			var item = $(this).parent().parent().parent().find('.auction-item-name').text();
			$('#proxybid #item-name').text(item);
			$('#auction-item-name').val(item);
			$('#proxybid').dialog('open');
		});
		
		$('#proxybid form').validate();
	}
	
});
