$(document).ready(function(){
	$('div.select span').click(function(){
		var curPosition = $(this).parents('div.select').css('position');
		$(this).parents('div.select').css('position', (curPosition=='static')? 'relative':'static' );
		$(this).parents('div.select').find('ul').toggle();
	});
	$("div.select ul li").hover(
	function(){ $(this).addClass('hover'); },
	function(){ $(this).removeClass('hover');}
	);
	$('div.select a').click(function(e){
		e.preventDefault();
		var curValue = $(this).text();
		$(this).parents('div.select').css('position','static');
		$(this).parents('div.select').find('input').attr('value',curValue);
		$(this).parents('div.select').find('span b').html(curValue);
		$(this).parents('div.select').find('ul').hide();
	});

	$(".gallery li").hover(
	function(){ $(this).addClass('hover'); },
	function(){ $(this).removeClass('hover');}
	);
	$(".left-coll tr").hover(
	function(){ $(this).addClass('hover'); },
	function(){ $(this).removeClass('hover');}
	);

	$('div.selectdate span').click(function(){
		var curPosition = $(this).parents('div.selectdate').css('position');
		$(this).parents('div.selectdate').css('position', (curPosition=='static')? 'relative':'static' );
		$(this).parents('div.selectdate').find('ul').toggle();
	});
	$("div.selectdate ul li").hover(
	function(){ $(this).addClass('hover'); },
	function(){ $(this).removeClass('hover');}
	);
	$('div.selectdate a').click(function(e){
		e.preventDefault();
		var curValue = $(this).text();
		$(this).parents('div.selectdate').css('position','static');
		$(this).parents('div.selectdate').find('input').attr('value',curValue);
		$(this).parents('div.selectdate').find('span b').html(curValue);
		$(this).parents('div.selectdate').find('ul').hide();

		$.post('lib/loadtickets.php', {'dat':curValue}, function(res){
			$("div.select ul").html(res);
		}, 'html');
		$("div.select ul li").livequery(function(event) { });
		$("div.select a").livequery('click', function(event) {
			e.preventDefault();
			var curValue = $(this).text();
			$(this).parents('div.select').css('position','static');
			$(this).parents('div.select').find('input').attr('value',curValue);
			$(this).parents('div.select').find('span b').html(curValue);
			$(this).parents('div.select').find('ul').hide();
			return false; 
		});

	});

});