$(function(){
	$('a').click(function(){
		this.blur();
	});

	var at = 350; // animation time

	// ie fuckers
	if($.browser.msie){

	}

	// bikes
	if($('body').hasClass('bikesLayout')){
		$('#bikes .show_detail').css('display','block');
		$('#bikes .detail .close').show();
		$('#bikes .detail').each(function(){
			$(this).hide();
		});
		if($.browser.msie){
			$('#bikes .detail').css('background','#fff'); // because ie sux when displaying png
		}

		$('.show_detail').click(function(){
			var id = $(this).attr('href');
			var left = '12px';
			$('.close').click(); // hide existing
			if($(id).hasClass('first')){
				left = '0';
			}else if($(id).hasClass('fifth')){
				left = '-124px';
			}
			$(id+' .detail')
				.css({
					'position':'absolute',
					'top':'28px',
					'left' : left,
					'width':'280px',
					'border':'solid 1px #d2232a',
					'padding':'2px 8px 8px 8px'
				})
				.fadeIn(at)
				.parent().css('z-index','50'); // needed by IE
			$(id+' .show_detail').hide();

			$('.close').click(function(e){
				$('#bikes .bike').css('z-index','1');
				$('.detail').not(':hidden').hide();
				$('.show_detail:hidden').css('display','block');
			});
		});

		var hash = window.location.hash ? window.location.hash : false;
		if(hash){
			$.fx.off = true;
			$(hash+' > .show_detail').click();
			$.fx.off = false;
		}
	}

	// trips
	if($('body').hasClass('tripsLayout') || $('body').hasClass('czTripsLayout')){
		
		if($.browser.msie && parseInt($.browser.version) < 9){
			$.fx.off = true;
		}

		$('.city0, .city1, .city').click(function(){
			$('.city0, .city1').removeClass('active');
			var id = $(this).attr('href');
			$('a[href='+id+']').addClass('active');
			$('.detail:not(:hidden)').hide();
			$(id+'.detail').fadeIn(at)
		});


		//var hash = window.location.hash ? window.location.hash : false;
		var hash = window.location.hash ? window.location.hash : '#praha';
		if(hash){
			$.fx.off = true;
			$('a[href="'+hash+'"]').click();
			if($.browser.msie && parseInt($.browser.version) < 9){
				//$.fx.off = false;
			}else{
				$.fx.off = false;
			}
		}
	}



});

