var imageID = null;
var setID = null;

function process(newSetID, newImageID, x, y) {

	
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setMapType(G_HYBRID_MAP);
        map.setCenter(new GLatLng(x, y), 15);
        map.addControl(new GSmallMapControl());


		var point = new GLatLng(x, y);
		map.addOverlay(new GMarker(point));

	   // document.getElementById('image').style.background="url('"+ im +"') no-repeat";
	   // var linkId = '_1_'+ newSetID+'_'+newImageID;
	   // setFb2(linkId);
	   // setPermalink(linkId);
	   // var t = 'track.htm?id='+newImageID;
	   // window.frames['track'].location = t;
      }
    }

	function setPermalink(id) {

		var url ='<a href="http://www.locativelondon.com/index.html';
		url += '?i='+id;
		url += '" target="_blank">';
		url += 'Permalink (Use this url to link to this pic)</a>';
		document.getElementById('permalink').innerHTML = url;
	}

	function setFb2(id) {

		var url = '<a href="http://www.facebook.com/sharer.php?u=';
		url +='http://www.locativelondon.com/fbpages/';
		url += id;
		url += '.htm?i='+id;
		url += '" target="_blank">';
		url += 'Share this picture with Facebook</a>';
		document.getElementById('fburl').innerHTML = url;
	}


function getParameter(parameterName) {

   var queryString = location.search.substring(1);

   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return "null";
   }
}

function loaderx() {
	if (getParameter('i') == undefined) {
		process(45,30905226,51.513562,-0.127957);
	} else {
		var i = getParameter('i');

		if(navigator.appName == "Microsoft Internet Explorer") {
			window.frames['feed'].document.getElementById(eval(i)[1]).focus();
		} else {
			document.getElementById('feed').contentDocument.getElementById(eval(i)[1]).focus();
		}
		process(eval(i)[0], eval(i)[1], eval(i)[2], eval(i)[3]);
	}
}
