
$(function() {
clickPrepare();
infoSaver();
infoChanger();

//addTag();

});

function infoSaver() {
$("#textSave").click( function() {
	textInput = $("#textInput");
	var newText = textInput.val();
	var bodega_id = $(".single").attr("id");
	textInput.focus();
	$(this).attr("disabled","disabled");
	$(this).val("Saving...");
	var button = $(this);
	//alert("newText="+newText+"&bodega_id="+bodega_id);
	$.ajax({
	type: "POST",
	url: "../ajax.php",
	data: "newText="+escape(newText)+"&bodega_id="+bodega_id,
	success: function(msg){
	//alert(msg);
	button.attr("disabled",false);
	button.val("Save");
	}
	});


});




}

function infoChanger() {
	$(".bodBusinessAdd").click( function() {
		$(this).replaceWith("<div class='newSign'><input type='text' id='newSignName'><input type='submit' value='Save' id='newSignNameSubmit'></div>");
		$("#newSignName").focus();
		$("#newSignNameSubmit").click( function() {
			newSignNameInput = $("#newSignName");
			var newSignName = newSignNameInput.val();
			var bodega_id = $(".single").attr("id");
			$(this).attr("disabled","disabled");
			$(this).val("Saving...");
			var signbutton = $(this);
			//alert("newSign="+newSignName+"&bodega_id="+bodega_id);
			$.ajax({
			type: "POST",
			url: "../ajax.php",
			data: "newSign="+escape(newSignName)+"&bodega_id="+bodega_id,
			success: function(signmsg){
			//alert(signmsg);
			$(".newSign").replaceWith("/<span class='bodBusiness'> "+newSignName+"</span>");
			}
			});
		});
		
	});
}



function clickPrepare() {

		var thisid = $(".single").attr("id");
		var fullid = 'bod' + thisid;
		//alert(fullid);
		//alert(jsonstring[fullid].gmaps_lat+'AND'+jsonstring[fullid].gmaps_long+'AND'+jsonstring[fullid].gmaps_pitch+'AND'+jsonstring[fullid].gmaps_yaw+'AND'+jsonstring[fullid].gmaps_zoom);	
		initialize(jsonstring[fullid].gmaps_lat,jsonstring[fullid].gmaps_long,jsonstring[fullid].gmaps_pitch,jsonstring[fullid].gmaps_yaw,jsonstring[fullid].gmaps_zoom);
		
}


//initialize();
