// JavaScript Document

function pinLocator(lat,longitude) {	// for location of pin within Inspirator - Our Favourites - map veil
	// 85 = from top side of mapVeil to London. [REMOVED]    
	// 170 = height difference in new and old png [REMOVED]
	
	// 94 = from top side of mapVeil to London.
	// 51.533 London's latitude
	// 14.264 number of pixels that one degree of latitude occupies
	var pinTop=Math.round(94 - ((lat-51.533)*14.264));
	
	// 363 = from left side of mapVeil to London. [REMOVED]
	
	// 98 = from left side of mapVeil to London.   
	// 0.083 London's longitude
	// 7.023 number of pixels that one degree of longitude occupies
	var fiddleFactor=9.55-(2.527*((lat-50.067)/4.317));
	var pinLeft=0;
	if (longitude<0) {pinLeft=Math.round(98 + ((longitude-0.083)*fiddleFactor)); }
	else {pinLeft=Math.round(98 + ((longitude+0.083)*fiddleFactor)); }
	
	$("img.mapPin").css({"left":pinLeft,"top":pinTop});
}

function latLongLocator(coordsRecieved){
	// Discern what part of map to show - pick up co-ords from title attribute of anchor
	// Co-ords also used to locate the pin on the overlay map
	var coords=coordsRecieved;
	var commaPosition=coords.indexOf(',');
	lat=parseFloat(coords.substring(0,commaPosition));
	commaPosition++;
	longitude=parseFloat(coords.substring(commaPosition));
}

function pinLocatorBC() {	// for location of pin within the Big Carousel - non-Flash HTML/JS version
	var coords=$(".moduleCarouselBig").find("a.last").attr("title");
	latLongLocator(coords);

	// 283 = from top side of mapVeil to London.    
	// 51.533 London's latitude
	// 18.150 number of pixels that one degree of latitude occupies
	var pinTop=Math.round(283 - ((lat-51.533)*18.15));
	
	// 869 = from left side of mapVeil to London.    
	// 0.083 London's longitude
	// 12.26 number of pixels that one degree of longitude occupies
	var fiddleFactor=((lat-50.056)*2);
	var pinLeft=0;
	if (longitude<0) {pinLeft=Math.round(869 + ((longitude-0.083)*12.26)+fiddleFactor); }
	else {pinLeft=Math.round(869 + ((longitude+0.083)*12.26)+fiddleFactor); }
	
	$("img#carouselMapPin").css({"left":pinLeft,"top":pinTop});
}

function pinLocatorSC() {	// for location of pin within the Small Carousel - non-Flash HTML/JS version
	var coords=$(".moduleCarouselBig").find("a.last").attr("title");
	latLongLocator(coords);

	// 283 = from top side of mapVeil to London.    
	// 51.533 London's latitude
	// 13.438 number of pixels that one degree of latitude occupies
	var pinTop=Math.round(283 - ((lat-51.533)*13.438));
	
	// 546 = from left side of mapVeil to London.    
	// 0.083 London's longitude
	// 9.2395 number of pixels that one degree of longitude occupies
	var fiddleFactor=((lat-50.056)*1.5);
	var pinLeft=0;
	if (longitude<0) {pinLeft=Math.round(546 + ((longitude-0.083)*9.2395)+fiddleFactor); }
	else {pinLeft=Math.round(546 + ((longitude+0.083)*9.2395)+fiddleFactor); }
	
	$("img#carouselMapPin").css({"left":pinLeft,"top":pinTop});
}

