$(document).ready(function() {

	var locacion = $('body').attr('id');


    $('.locacion h3').hover(
		function() { $(this).addClass('hover').css({ cursor: 'pointer' }) },
		function() { $(this).removeClass('hover') }
	);

    function growStore(loc) {
        if (loc.find('.map').hasClass('open')) {
            loc.find('.map').removeClass('open').slideToggle(500, function() {
                loc.slideToggle();
            });
        }
        else {
            loc.slideToggle(500, function() {
                $(this).find('.map').slideToggle().addClass('open');
            });
        }
        loc.prev().toggleClass('active');
    }


    $('.locacion h3').click(function() {
        //$(this).next().slideToggle();
        var loc = $(this).next().not(':animated');
        growStore(loc);
    });

    var LOCS = $('.locacion h3').length;

    if (LOCS == 1) {
        setTimeout(function() { growStore($('.locacion h3').next()) }, 1000); //IF only one listing on page, animate opening and unbind
        //$('.locacion h3').unbind('click');
    }

    $('#ES-locations')
	.change(function() { $(this).parent('form').submit(); })
	.find('option').click(function() { $(this).parent('form').submit(); })
	;

    $('img.map')
		.click(function() {
		    var googloc = $.trim($(this).parent().prev('h3').html().replace(/<\/?[^>]+(>|$)/g, " ")).replace(/\s+/g, '+');
		    googloc = 'http://maps.google.com/maps?q=' + googloc + '+Food+Lion';
		    window.open(googloc);
		})
		.hover(function() { $(this).css({ cursor: 'pointer' }) })
	; // end img.map functions
	
	
	if (locacion == 'futbol-slideshow') {
        new projector('#futbol-slides', {
            postClickDelay: 60000,
            delay: 10000,
            slideValue: 600,
            speed: 400,
            orientation: "lateral",
            circular: true,
            navLinkSelector: $('#controls span'),
            slideSelector: $('.strip div'),
            slideEasing: "swing"
        });
        if (ie6) {
            $('#controls span').hover(
						function() { $(this).addClass('hover') },
						function() { $(this).removeClass('hover') }
					)
        }
        
    }
});
