﻿function tabs() {    
    $('.itemsPerPage a:last-child').addClass('last');
};

function mouseOver() {
	
	$('area').mouseover(function() {
		swapImage( getLocationMapImage($(this).attr('location')));
		$('#hoodList li').removeClass('selected');
		$('.'+$(this).attr('location')).addClass('selected');	
   	});
	
	$('area').mouseout(function() {
		swapImage( getLocationMapImage($('.map').attr('defaultLocation')) );
		$('.'+$(this).attr('location')).removeClass('selected');
		$('.'+$('.map').attr('defaultLocation')).addClass('selected');
   	});
   	
   	$('#hoodList').find('li').mouseover(function() {
   	   	$('#hoodList li').removeClass('selected');
   	    swapImage( getLocationMapImage($(this).attr('class')) );
		$(this).addClass('selected');
   	});
   	
   	$('#hoodList').find('li').mouseout(function() {
   	    swapImage( getLocationMapImage($('.map').attr('defaultLocation')) );
   	    $(this).removeClass('selected');
		$('.'+$('.map').attr('defaultLocation')).addClass('selected');
   	});

};

function swapImage(image)
{
	$('img.map').attr('src',image);
}

$(document).ready(function(){
    tabs();
    mouseOver();
    setDisabledClass();
    swapImage( getLocationMapImage($('.map').attr('defaultLocation')) );   
});

function getLocationMapImage(location)
{
    if (location == 'fashion')
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/fashion.gif';       
    else if (location == 'sport')
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/sport.gif';
    else if (location == 'entertainment')
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/entertainment.gif';
    else if (location == 'ranch')
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/ranch.gif';
    else if (location == "resources")
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/resources.gif';
    else if (location == "happy-trails-food-court")
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/happy-trails.gif';
    else if (location == "fossils")
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/fossils.gif';
    else
        return RM_AUTHORITY + RM_BASEURL +'images/shopping/image-map/default.gif';
}

function setDisabledClass()
{
    $('#letters').find('a').each(function() {
        if ($(this).attr('disabled') == 'disabled')
            $(this).addClass('disabled');
    });
}
