jQuery.fn.executeSignup = function() {
    return $(this).css({ top: ($(window).scrollTop() + 60) + "px" });
}

jQuery.fn.defaultVal = function(value) {
    $(this).val(value);
    return $(this).focus(
		function() { if ($(this).val() == value) $(this).val(''); }
	).blur(
		function() { if ($(this).val() == '') $(this).val(value); }
	);
}

$(function() {
    Cufon.replace('h2');
    //Cufon.replace('h3:not(.no-cufon)');
    Cufon.replace('h4');
    Cufon.replace('#menu-nav a');
    Cufon.replace('label');
    Cufon.replace('legend');

    $('input.defaulttext').each(function(i) {
        /*if ($(this).val() == '') {
        $(this).val($(this).attr('title'));
        }*/
        $(this).defaultVal($(this).attr('title'));

    });

    $('.gototop').click(function() {
        $('html,body').animate({ scrollTop: 0 }, 1000); 
    });

    /* Allows the modal to fit to the viewport's height if the viewport is too short */
    $('.modal').bind('show', function() {
      if ($(window).height() < $(this).height()+200) {
          $(this).css({ height: ($(window).height() * .745) + 'px' });
      }
      $(this).css({ top: ($(window).height() * .025) + 'px' }).show();
    });
    $('.modal').bind('hide', function() { $(this).css({ height: 'auto' }); $(this).hide(); });

    $('#current-location .button').click(function() { $('#location-modal').show(); $('#overlay').show(); LoadMap(); return false; });
    $('#overlay, .cancel').click(function() { $('.modal').hide(); $('#overlay').hide(); return false; });

    $('.offer').hover(
    function() { $(this).find('.hud').animate({ height: '70px' }); $(this).find('p').animate({ marginTop: '-0.4em' }); $(this).find('.hud h3').css('background-image', 'url(/content/images/up-arrow.png)'); },
    function() { $(this).find('.hud').animate({ height: '44px' }); $(this).find('p').animate({ marginTop: '0' }); $(this).find('.hud h3').css('background-image', 'url(/content/images/right-arrow.png)'); }
  );


    $('#content .change-location input').defaultVal('ZIP or City, State');
    $('#location-modal .change-location input').defaultVal('ZIP or City, State');


});

$.pmgGoogleMap = {};
$.pmgGoogleMap.isIncluded = false;
$.pmgGoogleMap.isModalOpened = false;
$.pmgGoogleMap.defaultShow = 4;

jQuery.fn.moveIntoView = function() {
  return $(this).css({top:($(window).scrollTop()+60)+"px" });
}

jQuery.fn.fitToViewport = function() {
  if ($(window).height() < $(this).height()) {
    return $(this).css({height: '80%'});
  } else {
    return $(this).css({height: 'auto'});
  }
}

  

    /*SET DEFAULT BUTTONS LOCATION MODAL*/
    if ($.browser.mozilla) {
        $("#zipCode").keypress(checkForEnterLocationModal);

    } else {
    $("#zipCode").keydown(checkForEnterLocationModal);
    }


    function checkForEnterLocationModal(event) {
        if (event.keyCode == 13) {
            $('#SubmitZipButton').click();
            event.preventDefault();
            return false;
        }
    }

    


