function jsDisplayStoreById(id)
{
	//first find the index of the store
	var currentIndex = jsFindStoreIndex(id);
	
	jsDisplayStore(currentIndex);
}

function jsFindStoreIndex(id)
{
	for (var i=0; i < jsStores.stores.length; i++)
	{
		if (jsStores.stores[i].id == id)
		{
			return i; 
		}
	}
}

function jsDisplayStore(index)
{
	//hide the intro gallery and show the store details
	$("#introgallery1").hide();
	$("#introgallery2").hide();
	$("#introgallery3").hide();
	$("#storedetails").show();


	var store = jsStores.stores[index];
	if (store.mainPhotoRegular == "")
	{
		$("#storedetails-image").html(""); 
	}
	else
	{
		$("#storedetails-image").html("<img src='" + store.mainPhotoRegular + "' />");
	}
	
	if (store.name == "")
	{
		$("#storedetails-name").hide();
	}
	else
	{
		$("#storedetails-name").show();
		$("#storedetails-name").html(store.name);
	}

	if (store.description == "")
	{
		$("#storedetails-description").hide();
	}
	else
	{
		$("#storedetails-description").show();
		$("#storedetails-description").html(store.description);
	}
	
	if (store.phone == "")
	{
		$("#storedetails-phone-container").hide();
	}
	else
	{
		$("#storedetails-phone-container").show();
		$("#storedetails-phone").html(store.phone);
	}
	
	if (store.fax == "")
	{
		$("#storedetails-fax-container").hide();
	}
	else
	{
		$("#storedetails-fax-container").show();
		$("#storedetails-fax").html(store.fax);
	}
	
	if (store.hours == "")
	{
		$("#storedetails-hours-container").hide();
	}
	else
	{
		$("#storedetails-hours-container").show();
		$("#storedetails-hours").html(store.hours);
	}

	if (store.email == "")
	{
		$("#storedetails-email-container").hide();
	}
	else
	{
		$("#storedetails-email-container").show();
		$("#storedetails-email").html("<a href='mailto:" + store.email + "'>" + store.email + "</a>");
	}

	if (store.website == "")
	{
		$("#storedetails-website-container").hide();
	}
	else
	{
		$("#storedetails-website-container").show();
		$("#storedetails-website").html("<a href='http://" + store.website + "' target='_blank'>" + store.website + "</a>");
	}


	jsCurrentStoreIndex = index;	

	jsShowHidePrevNextButton();
}

function jsDisplayNextStore()
{
	if (jsCurrentStoreIndex == "")
	{
		jsDisplayStore(1);
	}
	else
	{
		jsDisplayStore(jsCurrentStoreIndex + 1);
	}
	
	jsShowHidePrevNextButton();
}

function jsDisplayPrevStore()
{
	jsDisplayStore(jsCurrentStoreIndex - 1);
	
	jsShowHidePrevNextButton();
}

function jsShowHidePrevNextButton()
{
	var numOfStores = jsStores.stores.length - 1; 

	if (jsCurrentStoreIndex == 1)
	{
		$("#introgallery-prev").hide();
	}
	else
	{
		$("#introgallery-prev").show();
	}

	if (jsCurrentStoreIndex < numOfStores)
	{
		$("#introgallery-next").show();
	}
	else
	{
		$("#introgallery-next").hide();
	}
}