if (typeof _contentDelay == 'undefined')
	_contentDelay = 0;
	
if (typeof _contentFadeIn == 'undefined')
	_contentFadeIn = 800;	

if (typeof _fadeFooter == 'undefined')
	_fadeFooter = false;

var printing = false;

window.onload = animateContent;

//for mozilla - which caches pages
window.onpageshow = function(evt) {
	if (evt.persisted) window.onload();
}

function animateContent()
{	
  sniffBrowser();
	
	if (printing)
		return;
		
	$('#content').hide();
	setTimeout("loadContent()", _contentDelay);
	if (_fadeFooter)
	{
		$('#footer').hide();
		setTimeout("loadFooter()", _contentDelay);
	}
};

function loadContent()
{
	reveal('#content');

	
	//$('#nav').css({border: '1px solid red', display: 'block', zIndex : '1000', opacity : '1.0' });
	//$('#content').css({border: '1px solid red', display: 'block', zIndex : '9', opacity : '.5'});
	//document.getElementById('content').style.opacity = '1.0';
}

function loadFooter()
{	
	reveal('#footer');
}

function reveal(element)
{
	if (isMacXFF())
	  $(element).show();
	else
	  $(element).fadeIn(_contentFadeIn,
		function() {
			//doing nothing at this tiem
		}											
	);
}

function sniffBrowser()
{
	if (isMacXFF())
		$('body').addClass('firefox-mac');
}

function isMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}

/* Pricing filters */

$(function() {
  var selectPricing = function(link, loc) {
    $('.select-pricing').removeClass('selected');
    $(link).addClass('selected');
    $('.rates').show();
    $('.pricing').hide().filter('.' + loc).show();
    $.cookie("select-pricing", loc);
  };
  
  if ($('.rates').length) {
    $('.rates td.x-label, .rates').hide();
    // var $p = $('<p/>').text('Show pricing for: ');
    // $('<a/>').attr('href', '#').text("Darien").appendTo($p);
    // $p.append(" | ");
    // $("h2:first").after($p);
    var html = '<p>Show pricing for: <a href="#" class="select-pricing" id="select-pricing-darien">Darien</a> | <a href="#" class="select-pricing" id="select-pricing-north-haven">North Haven</a></p>';
    $('h2:first').after(html);
    //$('#content').append(html); 
    $("#select-pricing-darien").click(function() { selectPricing(this, 'darien'); });
    $("#select-pricing-north-haven").click(function() { selectPricing(this, 'north-haven'); });
    
    var loc =  $.cookie('select-pricing');
    if (loc) {
      $('#select-pricing-' + loc).click();
    }
  }
});

