
jQuery.gspreadsheets={
	returnFunc:null,
	data:{
		shop:"entry.0.single",
		lat:"entry.1.single",
		lng:"entry.2.single",
		address:"entry.3.single",
		explanation:"entry.4.single"
	},
	loadJSON:function(json){
		if(typeof(returnFunc)=='function'){
			var SPNAME='gsx$'
			var spEntries=json['feed']['entry'];
			var spList=[];
			for(var i=0;i<spEntries.length;i++){
				var obj={};
				for(var j in spEntries[i]){
					var ft = j.substring(SPNAME.length);
					obj[j.substring(SPNAME.length)]=spEntries[i][j]["$t"];
				}
				spList.push(obj);
			}
			returnFunc.call(this,spList);
		}
	},
	load:function(spid,spse,rfunc){
		if(!spse || typeof(spse)!="string" || spse==""){
			spse="default";
		}
		returnFunc=rfunc;
		var src="http://spreadsheets.google.com/feeds/list/"+spid+"/"+spse+"/public/values?";
		src+="alt=json-in-script&callback=$.gspreadsheets.loadJSON&rand="+(new Date()).getTime();
	
		var scriptElement = document.createElement('script');
		scriptElement.setAttribute('type', 'text/javascript');
		scriptElement.setAttribute('src', src);
		scriptElement.setAttribute('class', 'sploader');
		document.documentElement.firstChild.appendChild(scriptElement);  
	},
	post:function(spid,send,func){
		var sendData={};
		for(var i in send){
			if(this.data[i] && this.data[i]!=""){
				sendData[this.data[i]]=send[i];
			}
		}
		$.post("http://spreadsheets.google.com/formResponse?key="+spid,
			sendData,
			func
		);
	}
}