$(document).ready(function () {
    //.sidebar_pollen_tracker input, .games_tool_pollen_input_wrapper input
    $('.sidebar_pollen_tracker_input, .games_tool_pollen_input_wrapper input').each(function () {
        $(this).val('Enter ZIP Code');
    });
    //.sidebar_pollen_tracker input, .games_tool_pollen_input_wrapper input
    $('.sidebar_pollen_tracker_input, .games_tool_pollen_input_wrapper input').click(function () {
        if ($(this).val() == 'Enter ZIP Code') {
            $(this).val('');
        }
    });
    //.sidebar_pollen_tracker input, .games_tool_pollen_input_wrapper input
    $('.sidebar_pollen_tracker_input, .games_tool_pollen_input_wrapper input').blur(function () {
        if ($(this).val() == '') {
            $(this).val('Enter ZIP Code');
        }
    });
    $('.games_tool_pollen_input_wrapper a').click(function () {
        document.getElementById("PollenForecasterLink").href = document.getElementById("PollenForecasterLink").href + "?ZipCode="+ document.getElementById("ZipCode").value;
    });


            function preload(arrayOfImages) {
                $(arrayOfImages).each(function () {
                    $("<img>")[0].src = this;
                    // Alternatively you could use:
                    // (new Image()).src = this;
                });
            }
            preload([
	    'Images/purple_8x_icon.png',
		'Images/purple_flowe.png',
		'Images/purple_head_icon.png',
		'Images/purple_plane_icon.png',
		'Images/purple_pollen.png',
		'Images/purple_question_mark.png',
		'Images/purple_tissue.png',
		'Images/purple_tv.png',
		'Images/purple_two_way_arrow.png',
		'Images/purple_vs_icon.png',
		'Images/purple_zz_icon.png'
      ]);




            $('.ad_list_item').click(function () {
                return false;
            });

        });
        $(document).ready(function () {
            $('section').each(function () {
                var offset = $(this).offset();
                // console.log(offset);
                $(this).scrollspy({
                    min: offset.top,
                    max: offset.top + $(this).height(),
                    onEnter: function (element, position) {
                        _gaq.push(['_trackEvent', 'Section tracking - products', 'Entering ' + element.id]);
                        // window.location.hash = '';
                        // History.pushState(null, null, '#' + element.id);
                    },
                    onLeave: function (element, position) {
                        _gaq.push(['_trackEvent', 'Section tracking - products', 'Leaving ' + element.id]);

                    }
                });
            });

            var $link_section = window.location.href;
            var $trimmed_link_section = $link_section.split('#');
            var $trimmed_parts = $trimmed_link_section[1];
            if ($trimmed_parts == 'pollen-count') {
                var $tier_two = $('#pollen-count').offset();
                $.scrollTo($tier_two.top, 1000);
                location.hash = '';
            }
            if ($trimmed_parts == 'myths') {
                var $tier_myth = $('#myths').offset();
                $.scrollTo($tier_myth.top, 1000);
                location.hash = '';
            }
            if ($trimmed_parts == 'games') {
                var $help_myth = $('#games').offset();
                $.scrollTo($help_myth.top, 1000);
                location.hash = '';
            }
            if ($trimmed_parts == 'tv-commercials') {
                var $help_myth = $('#tv-commercials').offset();
                $.scrollTo($help_myth.top, 1000);
                location.hash = '';
            }

            $('.allegra_games_sub_menu .column_one a, .footer_top_menu_one .pollen').click(function () {
                var $tier_two = $('#pollen-count').offset();
                $.scrollTo($tier_two.top, 1000);
            });
            $('.allegra_games_sub_menu .column_two a, .footer_top_menu_one .tissue, .footer_top_menu_one .bop').click(function () {
                var $tier_two = $('#games').offset();
                $.scrollTo($tier_two.top, 1000);
            });
            $('.allegra_games_sub_menu .column_three a').click(function () {
                var $tier_two = $('#games').offset();
                $.scrollTo($tier_two.top, 1000);
            });
            $('.allegra_games_sub_menu .column_four a, .footer_top_menu_one .tv').click(function () {
                var $tier_two = $('#tv-commercials').offset();
                $.scrollTo($tier_two.top, 1000);
            });
});

