$(document).ready(function(){

	$('img#nick, #page h1, #page, #navmask, #topmask').hide();

 	if($.browser.msie) {
	
		// fix menu in ie
		$('ul.dd').css({ "padding-bottom": "0px", "background-color": "#fff" });	
		$('ul.dd li').css({ "margin-top": "0px", "padding": "7px 0 7px 0", "background-color": "#fff" });
		
		// fix pages background in ie
		
 	} 

	l();
	
	if($.browser.webkit) {
		repos();
		repos();
	}
	else
	{
		repos();		
	}
	
	// do dropdowns
	$('ul.dd').hide();
	$('ul#bottomnav li').hoverIntent(function(){
		$('ul.dd', $(this)).slideDown(100);
	},function(){
		$('ul.dd', $(this)).slideUp(100);
	});

	$(window).resize(function(){
		repos();
	});	
	
	// load
	function l()
	{	
		if($('#page').hasClass('home'))
		{
			$('img#nick, #page h1, #page').fadeIn();
			$('div#nav').removeClass('pages');			
		}
		else
		{
			$('img#nick, #page h1, #navmask, #topmask, #page').fadeIn();			
		}
	}
	
	// reposition
	function repos()
	{
		$('#page h1').offset({ left: $('#page').offset().left-100 });	
		$('img#nick').offset({ left: $('#container').offset().left-130 });	
		$('p.copyright').offset({ left: $('#container').offset().left });	
		$('img#prudential').offset({ left: $('#container').offset().left });			
		$('#nav').offset({ left: $('#page').offset().left-11 });
		$('#navmask').offset({ left: $('#page').offset().left });
		$('#topmask').offset({ left: $('#page').offset().left });
		if(!$('#page').hasClass('home'))
		{		
			$('img#minisiggy').offset({ left: $('#content').offset().left+669-188 });
		}
		$('#page').height($(document).height());	
		
		// may need to deal with nav being 25px to the right on ie7	
	}

	// fade listings in and out on hover
	$('div.listing').fadeTo(0, 0.6);
	$('div.listing').hover(function(){
		$(this).fadeTo(300, 1);
	}, function(){
		$(this).fadeTo(300, 0.6);
	});

	$('img#down').hide(); // this is broken, hiding it temporarily
	
	$('a.big, div.thumbs a').click(function(){
		return false;
	});
	
	// turned off the slideshow in IE
	if(!$.browser.msie){	// !$.browser.msie
		$('#listings').css({ "position": "relative" });
		$('img#down').show();
		
		// fade in the slideshow link
		$('div.show').hide();
		$('div.big').hoverIntent(function(){
			$('div.show', $(this)).fadeIn(300);
		}, function(){
			$('div.show', $(this)).fadeOut(300);
		});
		
	}
	else
	{		
		// if ie9, don't show fade out bars on content area top / bottom
		if($.browser.version.slice(0,1) == "9" || $.browser.version.slice(0,1) == "8") 
		{
			$('#topmask img').remove();
			$('#navmask img').remove();
		}		
		
		// fade in the slideshow link
		$('div.show').hide();
		$('div.big').hoverIntent(function(){
			$('div.show', $(this)).fadeIn(300);
		}, function(){
			$('div.show', $(this)).fadeOut(300);
		});		
		
		$('div.show').hide();
		$('.testimonials div').css({ "background-color": "transparent" });
	}
	
});
