var delicious_callbacks = {};
var tempsDarreraResposta = 0;

function jsonp(nurl, nparams, callback_function, fix,e) {
	missatgeMapa = "";
	nurl += "?";
	nparams.each(function(item) {
		nurl += item.key + "=" + escape(item.value) + "&";
	});
	var n_uid = (new Date()).getTime();
	delicious_callbacks[n_uid] = function (content) 
	{
	 if (n_uid > tempsDarreraResposta)
	    {
	       tempsDarreraResposta=n_uid;	       
	    	var nt = "" + callback_function + "(content)";
	       eval(nt);
	    }
		delete delicious_callbacks[n_uid];
     };
    if (fix){
    	nurl += "jsonp=" +  encodeURIComponent(callback_function);
    }else{
    	nurl += "jsonp=" +  encodeURIComponent("delicious_callbacks[" + n_uid + "]");
	}
	//nurl += "jsonp=" +  encodeURIComponent(callback_function);
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('Id', callback_function);
	scriptElem.setAttribute('src', nurl);
	scriptElem.setAttribute('type', 'text/javascript');
    scriptElem.setAttribute('charset', 'UTF-8');
	tag = document.getElementById(callback_function);
	if(!tag) {
	  tag = document.getElementsByTagName('head')[0].appendChild(scriptElem);
	} else {
	  document.getElementsByTagName('head')[0].replaceChild(scriptElem, tag);
	}
	eval(callback_function);
} 

