var __FlickrCallbacks = {};
//var strApiKey As String = "8d9519088d3c85441d0d1e24ceadf3eb"
var Flickr = (function() {

	var iCallCount = 0;

	var strAPIKey = "";

	function sendRequest(strMethod, oContent, fncCallback) {
		iCallCount++;

		var strURL = "http://www.flickr.com/services/rest/"
			+ "?method=" + strMethod
			+ "&format=json"
			+ "&api_key=" + strAPIKey
			+ "&jsoncallback=__FlickrCallbacks.fn_" + iCallCount
			+ "&time=" + new Date().getTime();

		if (oContent) {
			for (var a in oContent) {
				if (oContent.hasOwnProperty(a)) {
					strURL += "&" + a + "=" + encodeURIComponent(oContent[a]);
				}
			}
		}

		var oScript = document.createElement("script");

		var fncFlickr = function(oResponse) {
			document.body.removeChild(oScript);
			if (fncCallback)
				fncCallback(oResponse);
		}

		__FlickrCallbacks["fn_" + iCallCount] = fncFlickr;

		oScript.setAttribute("type", "text/javascript");
		document.body.appendChild(oScript);
		oScript.src = strURL;
	}

	return {

		setAPIKey : function(strKey) {
			strAPIKey = strKey;
		},

		callMethod : function(strMethod, oContent, fncCallback) {
			sendRequest(strMethod, oContent, fncCallback);
		}

	}


})();


