var uvmap_disableddates = Array();
var uvmap_monthschecked = Array();
var itemTerms_arr = new Array();
var itemDescr_arr = new Array();
var itemOff_arr = new Array();
var colorcoding = new Array();
var stateValues = new Array(2, 3, 4, 7);
var gtimezone = 0;
var UV2hidePrices = new Array(1105345, 70862547, 704385761, 704068012, 3601327489, 3601381909, 3601321553, 3601321559, 1609292441, 704822650, 704822731, 709647002, 3601321533, 3601321539, 3601321549, 1609254938, 709011268, 709011270, 1505805077, 709011272, 709438321, 44051337, 44051343, 709182313, 1505911156, 1505790580, 705020730, 47010742012, 16010168426, 16010687168, 705663498, 1505718056, 1305111780);
var UVtablercart = new Array();
var UVtablercqtys = new Array();
var UVtablercprices = new Array();
var gb_ticketsurl = "";
var items_all_parsed = "";
var uvmapMapMobCacheIds = [];
var uvmapMapMobCacheCont = [];
var uvmapMapMobCacheRoom = [];
var wploaded = 0;

var reservationformurl = uv_mapurl + "reservation.form.pop.php";
var reservationformparams = "";

if (uv_venueid == "705147808") {
	reservationformurl = "//uvtix.com/websites/templesf/map/reservation.form.pop.php";
}

//Variables needed for pich/zoom
var uvmapPinchCurrentLocation = { x: 0, y: 0, zoom: 1 };
var uvmapPinchDistOld = 0;
var uvmapPinchScaleFactor = 0;
var uvmapPinchNewZoom = 1;
var uvmapPinchAllowMapMove = false;
var uvmapPinchContainer = "";
var uvmapPinchStartMapX = 0;
var uvmapPinchStartMapY = 0;
var uvmapPinchMouseMapX = 0;
var uvmapPinchMouseMapY = 0;
//ENDVariables needed for pich/zoom

if (typeof (allowcartsingletable) == "undefined")
	allowcartsingletable = false;
if (typeof (calendarevents) == "undefined")
	calendarevents = "";
if (typeof (mobilemapbuttontitle) == "undefined" || mobilemapbuttontitle == "")
	mobilemapbuttontitle = "View Map"
if (typeof (mobilemappulldowntitle) == "undefined")
	mobilemappulldowntitle = "";
if (typeof (custom_payatlabel) == "undefined")
	custom_payatlabel = "";
if (typeof (uvtixleads) == "undefined")
	uvtixleads = false;
if (typeof (tablepop_customtext) == "undefined")
	tablepop_customtext = "";
if (typeof (reservationcaptcha) == "undefined")
	reservationcaptcha = false;
if (typeof (uvmapclientid) == "undefined")
	uvmapclientid = 0;
if (typeof (uvmapGlobalTypeId) == "undefined")
	uvmapGlobalTypeId = 0;
if (typeof (uvmapCustomItemLeads) == "undefined")
	uvmapCustomItemLeads = '';
if (typeof (uvmapRedirectLayoutOptions) == "undefined")
	uvmapRedirectLayoutOptions = '';
if (typeof (openMapPopup) == 'undefined')
	openMapPopup = 0;
if (typeof (uvmapPerspectives) == 'undefined') {
	uvmapPerspectives = '';
}

reservationcaptcha = false;
if (typeof eventid == "undefined") {
	var eventid = "";
}

var tapedTwice = false;
var tapedClicks = 0;
var itemClick = "click";

if (mapismobile)
	itemClick = "click, touchstart";

if (uv_venueid == 709182313)
	show_purchase_inquiry = 1;
console.log("uv_venueid = " + uv_venueid);
let uvstardatecustom = new Date();
console.log("uvstardatecustom " + uvstardatecustom);
if (uv_venueid == 1305318461) {
	uvstardatecustom.setDate(uvstardatecustom.getDate() - 1);
}

if (uvmapCustomItemLeads)
	uvmapCustomItemLeads = JSON.parse(uvmapCustomItemLeads);

jQuery(document).ready(function () {
	if (allowcartsingletable == true)
		updateCart();

	pop_mapcal = jQuery("#map-shadow");
	jQuery(".uv-mapcont").addClass("uv-room-" + map_floor.replace(/([0-9]+\.)|(\.)/g, ''));

	if (jQuery("#uv-mapdate").length > 0) {
		jQuery("#uv-mapdate").datetimepicker({
			inline: true,
			format: "YYYY-MM-DD",
			minDate: uvstardatecustom
		});

		if (jQuery("#uv-mapdate").siblings("input[name='mapdate']").val().length > 0) {
			cleanCache();

			if (shortdate != "") {
				loaddate = "20" + shortdate[0] + shortdate[1] + "-" + shortdate[2] + shortdate[3] + "-" + shortdate[4] + shortdate[5];
				jQuery("#uv-mapdate").data("DateTimePicker").date(loaddate);

				loadItems(loaddate, map_floor);
			}
			else {
				jQuery("#uv-mapdate").data("DateTimePicker").date(jQuery("#uv-mapdate").siblings("input[name='mapdate']").val());
				loadItems(jQuery("#uv-mapdate").siblings("input[name='mapdate']").val(), map_floor);
			}
		}
		else
			jQuery("#uv-mapdate").data("DateTimePicker").date(null);

		var uvmapcalfirstdate = jQuery("#uv-mapdate").data("DateTimePicker").viewDate();
		uvmapcalfirstdate = moment(uvmapcalfirstdate._d).format("YYYY-MM-01");
		uvMapBlockDays(uvmapcalfirstdate, backend_url, uv_venueid, request3dtable_restypeid);

		jQuery("#uv-mapdate").on("dp.change", function (e) {
			if (e.date) {
				jQuery("#uv-mapdate").siblings("input[name='mapdate']").val(e.date.format("YYYY-MM-DD"));
				jQuery(".uv-putmapddate").html(e.date.format("ddd, MMM D, YYYY"));
				jQuery(".uv-putmapday").html(e.date.format("DD"));
				jQuery(".uv-putmapmon").html(e.date.format("MMM"));

				//MAP.loadItems(e.date.format("YYYY-MM-DD"));
				pop_mapcal.hide();
				shortdate = e.date.format("YYMMDD");
				token_globalstring = token_globalstring.replace(/dt[0-9]+/, "dt" + shortdate);


				//for felt nye
				if (uv_venueid == "1505718056" && shortdate == "171231" || uv_venueid == "1305364766")
					location.href = '/event/uv' + uv_venueid + 'dt' + shortdate + '/';
				//for season the brook 
				if (uv_venueid == "1305364766")
					location.href = '/map/uv' + uv_venueid + 'dt' + shortdate + '/seasons-at-the-brook';

				cleanCache();
				loadItems(jQuery("#uv-mapdate").siblings("input[name='mapdate']").val(), map_floor);
			}
		});

		jQuery("#uv-mapdate").on("dp.update", function (e) {
			uvMapBlockDays(moment(e.viewDate._d).format("YYYY-MM-01"), backend_url, uv_venueid, request3dtable_restypeid);
		});

		jQuery(".section-map").on("click", function () {
			var itemName = jQuery(this).attr("nameshow");

			var itemid = jQuery(this).attr("id").replace("T", "");
			var caldate = jQuery(this).attr("caldate");
			var dateString = jQuery(this).attr("date-show");
			var itemCapacity = jQuery(this).attr("capacity");
			var minCapacity = jQuery(this).attr("min");
			var maxCapacity = jQuery(this).attr("max")
			var sold = jQuery(this).attr("sold");
			var status = jQuery(this).attr("status");

			if (status != "Closed") {
				pop_up.addClass("uv-popmap");

				loadPop(uv_coreurl + "table.pop.php?itemid=" + itemid + "&caldate=" + caldate, function () {
					jQuery(".item-title").html(itemName);
					jQuery(".item-capacity span").html(minCapacity + "-" + maxCapacity);
					jQuery(".item-date span").html(dateString);

					//Redirect to external tickets for felt mgm
					if (uv_venueid == 1505718056 && caldate == "2016-12-31")
						replace_purchase_button(gb_ticketsurl, pop_up);

					jQuery(pop_up).fadeIn(0);
					fadePop();
				});
			}

		});
	}

	if (typeof (shortdate) != "undefined" && shortdate == "") {
		jQuery(".uv-mapchangedate").trigger("click");
	}
	if (jQuery("#uv-maproomselection").length > 0) {
		if (uvmapRedirectLayoutOptions)
			uvmapRedirectLayoutOptions = JSON.parse(uvmapRedirectLayoutOptions);

		jQuery(document).on("click", "#uv-maproomselection a, .uv-maproomselection a", function () {

			if (uvmapRedirectLayoutOptions && typeof (uvmapRedirectLayoutOptions[jQuery(this).data('value')]) != 'undefined') {
				redirectLayouUrl(uvmapRedirectLayoutOptions[jQuery(this).data('value')]);
				return;
			}

			pop_loader.show();
			jQuery("#uv-maproomselection a, .uv-maproomselection a").each(function () {
				jQuery(".uv-mapcont").removeClass("uv-room-" + jQuery(this).data("value").replace(/([0-9]+\.)|(\.)/g, ''));
			});

			if (typeof (window.history) != "undefined") {
				if (typeof (window.history.pushState != "undefined")) {
					var currentUrl = location.href;
					var regexUrl = /ly+([a-z]+)0/ig;
					var matches = regexUrl.exec(currentUrl);
					var layout = jQuery(this).data("value").replace(/[^a-z]/ig, '');

					if (matches != null) {
						var newUrl = currentUrl.replace(matches[1], layout);
						window.history.pushState({}, "", newUrl);
					}
				}
			}

			jQuery(".uv-putmaproomname").html(jQuery(this).html());
			jQuery(".uv-mapcont").addClass("uv-room-" + jQuery(this).data("value").replace(/([0-9]+\.)|(\.)/g, ''));
			map = jQuery(this).data("value");

			uvmapPinchNewZoom = 1;
			loadItems(jQuery("#uv-mapdate").siblings("input[name='mapdate']").val(), map, true);
			/*
jQuery(".uv-map").load(uv_mapurl + "/svg.map.html?map_floor=" + map, function(){
				loadItems(jQuery("#uv-mapdate").siblings("input[name='mapdate']").val());
				pop_loader.hide();
			});
*/
		});
	}
});

jQuery(document).on("click", ".uv-mapopentable[status='optional']", function (e) {
	e.stopPropagation();



	//jQuery(this).tooltip("show");
	$(".tooltip").tooltip("hide");
	pop_up.addClass("uv-popmap");
	expandPop(400);



	caldate = jQuery(this).attr('caldate');
	section_id = jQuery(this).attr("item_sectionid");

	if (uv_venueid == 1305111780 || uv_venueid == 1305112235) {

		const catname = jQuery(this).attr('item_globalcatname');
		const item_id = jQuery(this).attr("item_id");
		const item_section_capacity = jQuery(this).attr("item_section_capacity");
		const item_image = jQuery(this).attr("item_image");
		const date = moment(caldate, ['YYYY-MM-DD']).format('MMM D, YYYY');
		let item_descr = itemDescr_arr[item_id];
		let item_terms = itemTerms_arr[item_id];


		item_image_small = item_image_big = "";
		if (item_image) {
			item_image_small = item_image.replace("raw", "390SC260");
			item_image_big = item_image.replace("raw", "975SC650");
		}

		if (item_image == 0 || item_image == null) {
			item_image_small = "http://placehold.it/390x260";
			item_image_big = "http://placehold.it/975x650";
		}

		item_descr_short = "";
		item_descr_temporal = item_descr;

		if (item_descr_temporal)
			item_descr_temporal = item_descr_temporal.replace(/(\<br\/>)|(\<br\s\/>)/g, "");

		if (item_descr_temporal) {
			limit = 400;
			if (item_descr_temporal[limit] == "<")
				limit--;
			else if (item_descr_temporal[limit] == ">")
				limit++;

			//item_descr_short = item_descr_temporal.substring(0, limit)+"...";			
			item_descr_short_more = item_descr_temporal.substring(0, limit) + "...<a href='javascript:;' class='uv-showinfo' data-target='.uv-fulltabledescr-purchase' data-title='Description'>more</a>";
			item_descr_short = (item_descr_temporal.length < limit) ? item_descr_temporal : item_descr_short_more;
		}

		if (item_espoffer != "" && item_espoffer != null) {
			if (item_descr != "")
				item_descr += "<br/><br/>";

			// item_descr += "<b>Special Offer:</b><br/>"+item_espoffer;
		}

		loadPop(uv_mapurl + "sectionmultiitem.1305111780.php?caldate=" + caldate + "&flyer=" + item_image_small, function () {

			items = items_all_parsed["C" + section_id];
			first_item = items[0];

			content = pop_up.find('.pop-charge').html();

			content = content.replace(/\[\[uv-itemname\]\]/g, unescape(catname));
			content = content.replace(/\[\[uv-date\]\]/g, unescape(date));

			if (typeof (first_item) != 'undefined') {
				if (first_item.item_customurl != null && first_item.item_customurl != 'null') {
					content = content.replace(/\[\[uv-customviewurl\]\]/, first_item.item_customurl);
					content = content.replace(/\[\[uv-if-customviewurl\]\]/, "");
					content = content.replace(/\[\[uv-endif-customviewurl\]\]/, "");
					content = content.replace(/(\[\[uv-if-notcustomviewurl\]\])+(.|\n)*(\[\[uv-endif-notcustomviewurl\]\])/, "");
				}
				else {
					content = content.replace(/\[\[uv-if-notcustomviewurl\]\]/, "");
					content = content.replace(/\[\[uv-endif-notcustomviewurl\]\]/, "");
					content = content.replace(/(\[\[uv-if-customviewurl\]\])+(.|\n)*(\[\[uv-endif-customviewurl\]\])/, "");
				}

				content = content.replace(/\[\[uv-itemimage-small\]\]/g, unescape(item_image_small));
				content = content.replace(/\[\[uv-itemimage-big\]\]/g, unescape(item_image_big));
				content = content.replace("[[uv-descr-short]]", unescape(item_descr_short));
				content = content.replace("[[uv-descr-full]]", unescape(item_descr));
				content = content.replace("[[uv-terms]]", unescape(item_terms));


			}
			else {
				content = content.replace(/\[\[uv-if-notcustomviewurl\]\]/, "");
				content = content.replace(/\[\[uv-endif-notcustomviewurl\]\]/, "");
				content = content.replace(/(\[\[uv-if-customviewurl\]\])+(.|\n)*(\[\[uv-endif-customviewurl\]\])/, "");
				content = content.replace(/\[\[uv-itemimage-small\]\]/g, '');
				content = content.replace(/\[\[uv-itemimage-big\]\]/g, '');
				content = content.replace("[[uv-descr-short]]", '');
				content = content.replace("[[uv-descr-full]]", '');
				content = content.replace("[[uv-terms]]", '');

			}

			allPrepay = true;
			ulItems = '<ul>';
			if (typeof (items) != "undefined") {
				for (item of items) {
					itemid = item["item_id"];
					itemname = unescape(item["item_name"]);
					itemselect = item["item_selecttable"];
					itembaseprice = item["item_baseprice"];
					item_minimum = item["item_minimum"];
					item_deposit = item["item_deposit"];
					item_prepay = item["item_deposit"];
					item_paynow = item["item_paynow"];
					item_allowlead = item["item_allowlead"];
					item_state = item["item_state"];
					section_checkoutdep_state = item["checkoutdep_state"];

					if (item_state == "7") {

						itemname = itemname.replace(catname + " - ", '');

						// if(section_checkoutdep_state == 1)									
						// 	item_price = itempaynow;
						// else
						item_price = itembaseprice;

						if (item['checkoutdep_state'] == 1 && allPrepay == true) {
							allPrepay = false;
						}

						let label1 = '';
						let amount2 = '';

						if (item_minimum) {
							amount1 = 'Minimum Spend:<br /> <b>' + item_minimum + '</b>';
						} else {
							amount1 = 'Price:<br /> <b>' + itembaseprice + '</b>';
						}

						if (item['checkoutdep_state'] == 1) {
							amount2 = 'Deposit:<br />  <b>' + item_deposit + '</b>';
						} else {
							amount2 = 'Prepay:<br /> <b>' + itembaseprice + '</b>';
						}

						ulItems += '<li><button type="button" class="stadium-optional-item" item-id="' + itemid + '" item-allowlead="' + item_allowlead + '">' + itemname + ' <br /> ' + amount1 + ' <hr style="margin-top: 10px; margin-bottom: 10px; width: 70%; border-color: #c7cdd6" /> ' + amount2 + '</button></li>';

					}
				}
			}
			ulItems += '</ul>';


			content = content.replace(/\[\[uv-stadium-optional-items\]\]/, ulItems);

			jQuery(".uv-popmap").removeClass('closeover-pop');
			pop_up.find('.pop-charge').html(content);

			jQuery(".uv-popmap .pop-charge").css("left", "auto");
			jQuery(".uv-popmap .pop-charge").css("top", "auto");

			if (allPrepay == false && uv_venueid != 1305112235) {
				jQuery(document).find('.stadium-add-cart-optitem').remove();
			}

			jQuery(document).on('click', '.stadium-optional-item', function (e) {
				const itid = jQuery(this).attr('item-id');
				jQuery(document).find('.stadium-optional-item').removeClass('active');
				jQuery(this).addClass('active');
				jQuery(document).find('#uvtix_tablecart').attr('data-cart-ref', section_id);
				jQuery(document).find('#uvtix_tablepurchase, #uvtix_tablecart').attr('data-uvtix-item', itid);
				jQuery(document).find('#uvtix_tablepurchase').attr('data-uvtix-capacity', item_section_capacity);
				jQuery(document).find('#uvtix_tablepurchase').prop('disabled', false);

				if (jQuery(this).attr('item-allowlead') == '1') {
					if (pop_up.find('.uv-poptableoptions .stadium-buttons .inquire-btn').size() == 0) {
						pop_up.find('.uv-poptableoptions .stadium-buttons').append("<button type='button' style='padding: 8px 12px;border: 1px solid #161E4D;background: #161E4D;border-color: #161E4D;color: #fff;width: 100%;margin-top:10px;' itemid='" + itid + "' class='inquire-btn'>Inquire</button>");
					}
				} else {
					pop_up.find('.leads-form').addClass('uv-hidden');
					pop_up.find('.leads-form').html('');
					pop_up.find('.uv-poptableoptions .stadium-buttons .inquire-btn').remove();
				}

				if (allPrepay == true) {
					jQuery(document).find('#uvtix_tablecart').prop('disabled', false);
				}
				if (uv_venueid == 1305112235)
					jQuery(document).find('#uvtix_tablecart').prop('disabled', false);
			});

			jQuery(document).on('click', '.uv-poptableoptions .stadium-buttons .inquire-btn', function (e) {
				var itemid = jQuery(this).attr('itemid');

				if (!itemid) {
					return;
				}

				pop_loader.show();
				var tokenparam = 'uv' + uv_venueid + 'dt' + caldate[2] + caldate[3] + caldate[5] + caldate[6] + caldate[8] + caldate[9];

				if (uvveavenueid)
					tokenparam += 've' + uvveavenueid;

				if (roomid)
					tokenparam += 'rm' + roomid;

				tokenparam += 'it' + itemid;

				pop_up.find(".leads-form").load("//uvtix.com/websites/ln_core/uvcore/uvinquiry.php?token=" + tokenparam + "&formid=inline-leadsform&urvenueid=" + uv_venueid + "&resdate=" + caldate + "&clientid=" + uvmapclientid + "&leadtypeid=" + uvmapGlobalTypeId + "&stadiuminline=1", function () {
					pop_up.find(".leads-form .uv-popheader").remove();

					setTimeout(function () {
						pop_up.find(".leads-form").removeClass('uv-hidden');
						pop_loader.hide();
					}, 500);
				});
			});

			expandPop(850);
			fadePop();
		});
	}
	else {
		loadPop(uv_mapurl + "sectionmultiitem.php?caldate=" + caldate, function () {

			items = items_all_parsed["C" + section_id];

			item_buttons = "";

			if (typeof (items) != "undefined") {
				for (i in items) {
					itemid = items[i]["item_id"];
					itemname = items[i]["item_name"];
					itemselect = items[i]["item_selecttable"];
					itembaseprice = items[i]["item_baseprice"];
					itempaynow = items[i]["item_paynow"];
					itemdescr = items[i]["item_descr"];
					section_checkoutdep_state = items[i]["checkoutdep_state"];
					item_statename = items[i]["item_statename"];


					if (section_checkoutdep_state == 1 && uv_venueid != 1505807117)
						item_price = itempaynow;
					else
						item_price = itembaseprice;

					/** added by gabo **/
					/*
						Just for the venue of wynn in multiples items show the item base instead of pay now
						XS = 11066556
						Intrigue = 406544126
						EBC = 701133708
						EBC night : 405660315
						Eyecandylvwp : 47010734904
						Alibi: 1609407559
						
					*/
					if (uv_venueid == 11066556 || uv_venueid == 406544126 || uv_venueid == 701133708 || uv_venueid == 405660315 || uv_venueid == 47010734904 || uv_venueid == 49061111 || uv_venueid == 1305112235 || uv_venueid == 47010754609 || uv_venueid == 1609407559) {
						item_price = itembaseprice;
					}
					//hide price in XS inquiries only
					if (uv_venueid == 11066556 && item_statename == 'Inquiries Only') {
						item_price = "";
					}
					///////

					if (itemselect > 0) {
						var button_descr = '';

						if (uv_venueid == 705020694 || uv_venueid == 705020730) {
							button_descr = `<tr><td colspan='2' style='white-space: normal'><div style="font-size: 11px;text-align: left;margin-top: 2px;color: #9a9a9a;">${itemdescr}</div></td></tr>`;
						}

						item_buttons += '<button class="btn btn-block uv-btngrad item-option" data-itemid="' + itemid + '" ><table style="width:100%"><tr><td align="left">' + itemname + '</td><td align="right">' + item_price + '</td></tr>' + button_descr + '</table></button>';
					}
				}

				if (item_buttons == "") {
					item_buttons = "<div class='text-center' style='padding-bottom:20px;'><span class='text-danger' style='font-style:italic;font-size:18px;'>No items available</span></div>";
					jQuery(".section-multi-item-title").fadeOut(0);
				}
				else
					jQuery(".section-multi-item-title").fadeIn(0);

				jQuery(".section-multi-item").html(item_buttons);
			}
			fadePop();

			//Clear the Left and Top position
			if (uv_venueid == 1505908617)
				jQuery(".uv-popmap .pop-charge").prop("style", "");
		});
	}
});

jQuery(document).on("click", ".layout-view", function (e) {
	layout_id = jQuery(this).attr("id");
	layout_id = layout_id.replace(/^V/g, "");
	layout_id = layout_id.replace(/L$/g, "");
	if (uvmapRedirectLayoutOptions && typeof (uvmapRedirectLayoutOptions[layout_id + '.']) != 'undefined') {
		redirectLayouUrl(uvmapRedirectLayoutOptions[layout_id + '.']);
		return;
	}

	jQuery(this).tooltip("hide");

	if (jQuery(this).parents(".mapmobile-svg").size() <= 0) {
		bkwidth = jQuery(".uv-map svg").css("width");
		bkheight = jQuery(".uv-map svg").css("height");

		jQuery(".uv-map svg").css("width", bkwidth);
		jQuery(".uv-map svg").css("height", bkheight);
		jQuery(".uv-map svg").css("position", "fixed");
		jQuery(".uv-map svg").css("z-index", "100");

		jQuery(".uv-map svg").animate({
			width: "35px",
			height: "35px",
			opacity: 0,
			left: jQuery(".uv-mapoptions .uv-roomdropdown").offset().left + jQuery(".uv-mapoptions .uv-roomdropdown").width() + 35,
			top: jQuery(".uv-mapoptions .uv-roomdropdown").offset().top
		}, 500, function () {
			jQuery("#uv-maproomselection").find("li a[data-value='" + layout_id + ".']").trigger("click");
		});
	}
	else {
		jQuery("#uv-maproomselection").find("li a[data-value='" + layout_id + ".']").trigger("click");
	}
});

jQuery(document).on("click", ".item-option", function (e) {
	itemid = jQuery(this).data("itemid");

	jQuery(".uv-maplistcontainer .list-items li.uv-mapopentable[item_id='" + itemid + "'].uv-mapopentable-list .uv-listitemview").trigger("click");
});

jQuery(document).on("click", ".uv-showlistitems", function () {
	jQuery(".uv-maplistcontainer").fadeIn("fast");

	if (jQuery(this).attr("scrolltoitems") != undefined)
		jQuery('html, body').animate({ scrollTop: jQuery(".uv-maplistcontainer").offset().top - 60 }, 700);

	var _auxtmp = 1;
	if (typeof uv_venueid != "undefined" && uv_venueid == 49061105 && _auxtmp == 1) {
		_auxtmp = 0;
		$(".uv-mapcust").sort(sort_itm).appendTo('.list-items');
		$(".uv-mapcustpatio").sort(sort_itm).appendTo('.list-items');

		function sort_itm(a, b) {
			return (parseInt($(b).attr('item_custcorep'))) < (parseInt($(a).attr('item_custcorep'))) ? 1 : -1;
		}
	}

});
jQuery(document).on("click", ".uv-mapcompareclose", function () {
	jQuery(".uv-maplistcontainer").hide();
});
jQuery(document).on("click", ".uv-mapchangedate", function () {
	//jQuery('.uv-mapinfo, .uv-maptablet').hide();
	pop_mapcal.fadeIn("fast");

	if (jQuery("#uv-mapdate").siblings("input[name='mapdate']").val().length > 0)
		jQuery(".uv-mapdatecont").addClass("uv-mapallowclosemap");
});
jQuery(document).on("click", ".uv-mapshowmap", function () {
	pop_mapcal.hide();
	//jQuery(".uv-mapinfo, .uv-maptablet").show();
	jQuery(".uv-mapinfo, .uv-maptablet").removeClass("uv-hidden");
});
jQuery(document).on("click", ".uv-mapfloorplan", function () {
	var uvimageurl = jQuery(this).attr('data-image');
	pop_loader.show();
	pop_error.addClass('uv-popimgcont');
	pop_error.addClass('uv-mapfloorplan-container');

	clearPopError('<img src="' + uvimageurl + '" onload="pop_loader.hide(); fadePopError();">');
});
jQuery(document).on("click", ".uvtix_tableinquiry", function (e) {
	e.stopPropagation();
	e.preventDefault();
	pop_up.addClass("uv-popmap");
	expandPop(850);

	loadForm(jQuery(this), wploaded);
});
jQuery(document).on("click", ".uvmap-lbl-promocode", function () {
	jQuery(this).parents(".uvmap-promocode").find("#uvcart_promo").removeClass("hidden");
	jQuery(this).parents(".uv-poptableoptions").find(".uvmap-spoffer").addClass("hidden");
});

jQuery(document).on("click", "#uvtix_tablecart", function (e) {
	e.preventDefault();

	var itemid = jQuery(this).data("uvtix-item");
	var cartref = jQuery(this).data("cart-ref");

	if (cartref) {
		const element = jQuery(document).find('#S' + cartref + 'I')[0];

		if (element && element.classList) {
			element.classList.add('item-section-in-cart');
		}
	}

	if (UVtablercart.indexOf(itemid) == -1) {
		UVtablercart.push(itemid);

		if (jQuery(this).closest(".uv-poptableoptions").find(".uv-tableguests #uvtix_tableguests").length > 0)
			var uvtablecartqty = jQuery(this).closest(".uv-poptableoptions").find(".uv-tableguests #uvtix_tableguests").val();
		else
			var uvtablecartqty = 1;

		var uvtablecartprice = jQuery(this).closest(".uv-poptableoptions").find("#uvtix_baseprice").html();
		uvtablecartprice = uvtablecartprice.replace("$", "");
		uvtablecartprice = uvtablecartprice.replace(".", "");
		uvtablecartprice = uvtablecartprice.replace(",", "");
		uvtablecartprice = uvtablecartprice.replace("<span>", "");
		uvtablecartprice = uvtablecartprice.replace("</span>", "");

		UVtablercqtys.push(uvtablecartqty);
		UVtablercprices.push(uvtablecartprice);
	}

	animateCart();
});

jQuery(document).on("click", ".uv-map-cart-info, .uv-map-cart-list-close", function () {
	jQuery(".uv-map-cart-info").removeClass("animate-item-added");

	if (jQuery(".uv-map-cart-list").hasClass("uv-hide"))
		jQuery(".uv-map-cart-list").removeClass("uv-hide");
	else
		jQuery(".uv-map-cart-list").addClass("uv-hide");
});

jQuery(document).on("click", ".uv-map-cart-list-inc li:not(.uv-maplistths) .uv-listitemview button", function () {
	itemid = jQuery(this).data("itemid");
	cartref = jQuery(this).data("cart-ref");

	var index = UVtablercart.indexOf(itemid);

	if (cartref) {
		const element = jQuery(document).find('#' + cartref)[0];

		if (element) {
			jQuery(document).find('#' + cartref)[0].classList.remove('item-section-in-cart');
		}
	}

	UVtablercart.splice(index, 1);
	UVtablercqtys.splice(index, 1);
	UVtablercprices.splice(index, 1);

	updateCart();
});

jQuery(document).on("click", ".mapmobile-svg .uvmap-map-reset", function () {
	uvmapPinchNewZoom = 1;
	uvmapPinchCurrentLocation = { x: 0, y: 0, zoom: 1 };

	jQuery(".mapmobile-svg #uvmap-map").css("transform", "scale(1)");
	jQuery(".mapmobile-svg #uvmap-map").css("top", "0px");
	jQuery(".mapmobile-svg #uvmap-map").css("left", "0px");

	jQuery(".uvmap-map-reset").fadeOut(0);
});

/*
OLD CALCULATION	
jQuery(document).on("change", "#uvtix_tableguests", function()
{
	var selected_guests = parseInt(jQuery(this).val());

	var item_depositperc = jQuery(globalelement).attr("item_depositperc");
	var item_baseprice = jQuery(globalelement).attr("item_baseprice");
	var item_overcharge_price = jQuery(globalelement).attr("overcharge");
	var item_maxguests = jQuery(globalelement).attr("item_section_maxguests");
	var item_capacity = parseInt(jQuery(globalelement).attr("item_section_capacity"));
	item_overcharge_price = parseFloat(item_overcharge_price.replace(/[^\d\.\-]/g, ""));
	item_baseprice = parseFloat(item_baseprice.replace(/[^\d\.\-]/g, ""));

	if(typeof item_overcharge_price != "undefined")
	{
		if(selected_guests > item_capacity && item_overcharge_price > 0 )
		{
			var overcapacity = selected_guests - item_capacity;

			item_displaybase = item_baseprice + overcapacity * item_overcharge_price;
			if(typeof item_deposit != undefined)
				item_displaydeposit = item_displaybase*(item_depositperc/100);
		}	
		else{
			item_displaybase = item_baseprice;
			item_displaydeposit = item_baseprice*(item_depositperc/100);

		}
	
		item_displaybase = '$' + item_displaybase.formatMoney(2,',','.'); 
		item_displaydeposit = '$' + item_displaydeposit.formatMoney(2,',','.'); 
		item_displaybase = item_displaybase.replace(/\.(\d+)/, ".<span>$1</span>");
		item_displaydeposit = item_displaydeposit.replace(/\.(\d+)/, ".<span>$1</span>");

		jQuery("#uvtix_baseprice").html(item_displaybase);
		jQuery(".uvtix_baseprice").html(item_displaybase);
		jQuery("#uvtix_depositprice").html(item_displaydeposit);

	}
		
	

});
*/

/*
Added by edsson new calculations
*/
jQuery(document).on("change", "#uvtix_tableguests, #stadium_duration", function (e) {
	var selected_guests = parseInt(jQuery("#uvtix_tableguests").val());
	var stadium_duration = parseInt(jQuery("#stadium_duration").val());
	var global_type = jQuery(globalelement).attr('item_globaltype');

	var item_baseprice = jQuery(globalelement).attr("item_baseprice");
	var item_paynow = jQuery(globalelement).attr("item_paynow");
	var item_minimum = jQuery(globalelement).attr("item_minimum");
	var item_deposit = jQuery(globalelement).attr("item_deposit");

	var item_baseovercharge_price = jQuery(globalelement).attr("item_baseovercharge");
	var item_paynowovercharge_price = jQuery(globalelement).attr("item_paynowovercharge");
	var item_minimumovercharge_price = jQuery(globalelement).attr("item_minimumovercharge");

	var item_maxguests = jQuery(globalelement).attr("item_section_maxguests");
	var item_capacity = parseInt(jQuery(globalelement).attr("item_section_capacity"));
	var item_currency = jQuery(globalelement).attr("item_currency");

	item_baseovercharge_price = parseFloat(item_baseovercharge_price.replace(/[^\d\.\-]/g, ""));
	item_minimumovercharge_price = parseFloat(item_minimumovercharge_price.replace(/[^\d\.\-]/g, ""));

	item_baseprice = parseFloat(item_baseprice.replace(/[^\d\.\-]/g, ""));
	item_paynow = parseFloat(item_paynow.replace(/[^\d\.\-]/g, ""));
	item_minimum = parseFloat(item_minimum.replace(/[^\d\.\-]/g, ""));
	item_deposit = parseFloat(item_deposit.replace(/[^\d\.\-]/g, ""));

	if (typeof item_paynowovercharge_price != "undefined") {
		if (item_paynowovercharge_price != "") {
			item_paynowovercharge_price = parseFloat(item_paynowovercharge_price.replace(/[^\d\.\-]/g, ""));

			if (uv_venueid == 1305111780 && stadium_duration > 0) {
				var factorduration = 5;
				var overduration = stadium_duration - factorduration;
				var extra = 0;

				if (stadium_duration > 5) {
					extra = overduration * (item_baseprice / factorduration);
				}

				item_displaybase = (selected_guests * item_baseprice) + extra;
				item_displaypaynow = item_deposit;
				item_displaymin = item_minimum;
			} else {
				if (selected_guests > item_capacity && item_paynowovercharge_price > 0) {
					var overcapacity = selected_guests - item_capacity;

					item_displaybase = item_baseprice + overcapacity * item_baseovercharge_price;
					item_displaypaynow = item_paynow + overcapacity * item_paynowovercharge_price;
					item_displaymin = item_minimum + overcapacity * item_minimumovercharge_price;

				}
				else {
					item_displaybase = item_baseprice;
					item_displaypaynow = item_paynow;
					item_displaymin = item_minimum;

				}
			}

			var tmpcurrency = "$";

			if (typeof item_currency != "undefined" && item_currency != '' && item_currency != '$' && item_currency != "null") {
				tmpcurrency = item_currency;
			}


			item_displaybase = tmpcurrency + item_displaybase.formatMoney(2, ',', '.');
			item_displaypaynow = tmpcurrency + item_displaypaynow.formatMoney(2, ',', '.');
			item_displaymin = tmpcurrency + item_displaymin.formatMoney(2, ',', '.');

			jQuery(globalelement).attr("item_cart_price", item_displaybase);
			jQuery(globalelement).attr("item_cart_capacity", selected_guests);

			item_displaybase = item_displaybase.replace(/\.(\d+)/, ".<span>$1</span>");
			item_displaypaynow = item_displaypaynow.replace(/\.(\d+)/, ".<span>$1</span>");
			item_displaymin = item_displaymin.replace(/\.(\d+)/, ".<span>$1</span>");

			jQuery("#uvtix_baseprice").html(item_displaybase);

			if (uv_venueid == 1505790580) //Revelin
				jQuery("#uvtix_minimum").html(item_displaybase);
			else
				jQuery("#uvtix_minimum").html(item_displaymin);
			jQuery("#uvtix_depositprice").html(item_displaypaynow);
		} else if (uv_venueid == 1305111780 && stadium_duration > 0 && global_type == "table") {
			var factorduration = 5;
			var overduration = stadium_duration - factorduration;
			var extrabp = 0;
			var extrapn = 0;

			if (stadium_duration > 5) {
				extrabp = overduration * (item_baseprice / factorduration);
				extrapn = overduration * (item_deposit / factorduration);
			}


			item_displaybase = rawitem_displaybase = (item_baseprice + extrabp).toFixed(2).toString();
			item_displaypaynow = rawitem_displaypaynow = (item_deposit + extrapn).toFixed(2).toString();

			tmp_displaybase = item_displaybase.indexOf(".");
			tmp_displaypaynow = item_displaypaynow.indexOf(".");



			first_displaybase = item_displaybase.substring(0, tmp_displaybase + 1);
			last_displaybase = item_displaybase.substring(tmp_displaybase + 1, item_displaybase.length);
			item_displaybase = "$" + first_displaybase + "<span>" + last_displaybase + "</span>";

			first_displaypaynow = item_displaypaynow.substring(0, tmp_displaypaynow + 1);
			last_displaynow = item_displaypaynow.substring(tmp_displaypaynow + 1, item_displaypaynow.length);
			item_displaypaynow = "$" + first_displaypaynow + "<span>" + last_displaynow + "</span>";

			jQuery("#uvtix_baseprice").html(item_displaybase);
			jQuery("#uvtix_depositprice").html(item_displaypaynow);
			jQuery("#uvtix_minimum").html("$" + rawitem_displaybase);
		}
		else if (global_type == "rentalfee") {
			let uvnewprice = item_baseprice * selected_guests / item_capacity;

			let uvtmpcurrency = "$";
			item_displaybase = uvtmpcurrency + uvnewprice.formatMoney(2, ',', '.');

			jQuery(globalelement).attr("item_cart_price", item_displaybase);
			jQuery(globalelement).attr("item_cart_capacity", selected_guests);

			item_displaybase = item_displaybase.replace(/\.(\d+)/, ".<span>$1</span>");

			jQuery("#uvtix_baseprice").html(item_displaybase);
		}
	}
});

Number.prototype.formatMoney = function (decPlaces, thouSeparator, decSeparator) {

	var n = this,
		decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
		decSeparator = decSeparator == undefined ? "." : decSeparator,
		thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
		sign = n < 0 ? "-" : "",
		i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
		j = (j = i.length) > 3 ? j % 3 : 0;

	return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
};

function selectItem(element) {
	if (jQuery(element).hasClass("uv-listitemview"))
		var item = jQuery(element).parent();
	else
		var item = jQuery(element);
	console.log("item = "+element[0]);
	try {
	    jQuery(item).tooltip("hide");
	} catch (error) {
		document.querySelector("tooltip");
		document.querySelectorAll(".tooltip").forEach(function(toolt) {
			toolt.style.display = "none";
		});
	}
	pop_up.addClass("uv-popmap");
	expandPop(850);

	loadItem(jQuery(item));
}

function uvMapBlockDays(uvmapcalstartdate, uvserver, uvvenueid, request3dtable_restypeid) {
	if (uvmap_monthschecked.indexOf(uvmapcalstartdate) < 0) {
		jQuery("#uv-mapdate").addClass("uv-isloading");
		uvmap_monthschecked.push(uvmapcalstartdate);
		jQuery.ajax({
			url: uv_mapurl + "api.calendar.closedays.php",
			data: { "startdate": uvmapcalstartdate, "uvvenueid": uvvenueid, "uvserver": uvserver, "uvmaprestype": request3dtable_restypeid, "showcalendarevents": calendarevents },
			dataType: "json"
		}).done(function (response) {
			for (var i in response)
				uvmap_disableddates.push(response[i]);

			if (uv_venueid == 1305318461) {
				const year = uvstardatecustom.getFullYear();
				const month = String(uvstardatecustom.getMonth() + 1).padStart(2, '0'); // Months are zero-indexed, so we add 1
				const date = String(uvstardatecustom.getDate()).padStart(2, '0');
				// Format the date in "yyyy-mm-dd" format
				const formattedDate = `${year}-${month}-${date}`;

				const filteredArray = uvmap_disableddates.filter((element) => element !== formattedDate);

				uvmap_disableddates = filteredArray;
			}

			jQuery("#uv-mapdate").data("DateTimePicker").disabledDates(uvmap_disableddates);
			jQuery("#uv-mapdate").removeClass("uv-isloading");
		});
	}
}
function uvShowMap(uvdontshow) {
	if (uvdontshow == undefined)
		pop_mapcal.hide();

	pop_loader.hide();
	jQuery("div#supersized-loader").hide();
	//jQuery('.uv-mapinfo, .uv-maptablet').show();
	jQuery('.uv-mapinfo, .uv-maptablet').removeClass("uv-hidden");
}

function loadItems(calDate, map_floor, loadedfromroom) {
	if (typeof (loadedfromroom) == "undefined")
		loadedfromroom = false;

	pop_loader.show();

	if (loadedfromroom == false)
		emptyCart();

	var roomidtoken = "";
	if (typeof roomid != "undefined")
		roomidtoken = "&roomid=" + roomid;

	data = "apiserver=" + uv_apiurl + "&venueid=" + uv_venueid + "&caldate=" + calDate + "" + roomidtoken;



	if (uvmapPerspectives) {
		itemCatIDs = '';
		if (map_floor) {
			var cleanMapFloor = map_floor.replace(/\.$/, '');

			itemCatIDsArray = JSON.parse(uvmapPerspectives)[cleanMapFloor];

			if (itemCatIDsArray) {
				itemCatIDs = itemCatIDsArray.join(',');
			}

			if (itemCatIDs == '0') {
				data += "&filtercatids=-1";
			} else {
				data += "&filtercatids=" + itemCatIDs;
			}
		} else {
			data += "&filtercatids=-1";
		}
	}
	jQuery(".list-items").html("");
	url = uv_mapurl + "api.getitems2.php";
	jQuery.ajax({
		type: "POST",
		url: url,
		data: data,
		dataType: 'json',
		error: function (xhr, ajaxOptions, error) {
			console.log(error);
			alert("Error getting items!!!!!");
			pop_loader.hide();
		},
		success: function (result) {
			if (result) {


				items_all = eval(result);

				items_total_all = items_all['total_all'];


				/** block map if is the current date is the same that the map date **/
				var uvtoday = new Date();
				var uvtodaymonth = uvtoday.getMonth() + 1;
				if (uvtodaymonth < 10)
					uvtodaymonth = "0" + uvtodaymonth;
				var uvtodayday = uvtoday.getDate();
				if (uvtodayday < 10)
					uvtodayday = "0" + uvtodayday;

				var uvcomparedate = uvtoday.getFullYear() + '-' + uvtodaymonth + '-' + uvtodayday; //Current date yyyy-mm-dd
				var currentdatevarcalendar = jQuery("input[name='mapdate']").val(); //Map selected date yyyy-mm-dd

				var uvblockmap = false;
				if ((currentdatevarcalendar == uvcomparedate && uv_venueid == "45010349763")) {
					uvblockmap = true;
				}
				/** end **/
				if ((items_total_all > 0 || request3dtable == true) && !uvblockmap) {

					if (items_total_all <= 0 && uv_venueid == 708428765) {
						dmsjnoItms = "";
						if (uv_venueid == 708428765)
							dmsjnoItms = "For Same Day Reservations Contact The Pool Team at 702.697.2888";
						jQuery(".uv-map").html("<div class='uvmap-notitems text-center'><div class='alert alert-danger'>" + dmsjnoItms + "</div>");
					}
					else {
						items_all_parsed = items_all['all_parsed'];
						urcart_itms = items_all['all'];
						layout_id = items_all['layout_id'];
						layout_type = items_all['layout_type'];
						layout_customurl = items_all['layout_customurl'];

						if (layout_customurl) {
							jQuery('.uv-viewtour').fadeIn(0);
							/*jQuery('.uv-viewtour').on('click', function(){
								window.open(layout_customurl);
							});*/
						}

						if (layout_type == "table" || uv_venueid == 1305111780 || uv_venueid == 1305112235)
							jQuery(".uv-map-cart").fadeIn(0);

						var add2mobilebutton = '';

						if (uv_venueid == 1505790580 && mapismobile != "") //Revelin
							add2mobilebutton += '<h3 class="map-message">Please click on the VIEW MAP to see tables available.</h3>';


						if (jQuery(".uv-mapoptions").find(".uv-show-mapmobile").size() <= 0)
							jQuery(".uv-mapoptions").append("<button class='uv-show-mapmobile uv-btnoptdark'><i class='fa fa-picture-o'></i> " + mobilemapbuttontitle + "</button>" + add2mobilebutton);

						jQuery(document).off("click", ".uv-show-mapmobile");
						jQuery(document).on("click", ".uv-show-mapmobile", function () {

							jQuery(".uvmap-map-loader").fadeIn(0);

							pop_up.addClass("uv-popmap");
							pop_up.addClass("uv-popmapmobile");

							loadPop(uv_mapurl + "mobilemap.pop.php", function () {

								uvmapPinchContainer = document.getElementById('uvmap-map');
								uvmapPinchNewZoom = 1;

								if (mobilemappulldowntitle != "")
									mobilemappulldowntitle += "&nbsp;&nbsp;";

								jQuery("#mobilemapbuttontitle").html(mobilemappulldowntitle);

								uvLoadLayoutMap(layout_id, layout_type, map_floor, items_total_all, items_all_parsed, calDate, true);

								uvmapPinchStartMapX = jQuery("#uvmap-map").offset().top;
								uvmapPinchStartMapY = jQuery("#uvmap-map").offset().left;

								fadePop();

								jQuery(".pop-charge").css("left", "0px");
								jQuery(".pop-charge").css("top", "0px");

								doubleTapHolder();
							});

						});

						if (openMapPopup)
							$('.uv-show-mapmobile').click();

						if (mapismobile == "") {
							uvLoadLayoutMap(layout_id, layout_type, map_floor, items_total_all, items_all_parsed, calDate);
						} else {
							if (loadedfromroom == true) {
								jQuery(".uvmap-map-loader").fadeIn(0);

								loadPop(uv_mapurl + "mobilemap.pop.php", function () {
									uvLoadLayoutMap(layout_id, layout_type, map_floor, items_total_all, items_all_parsed, calDate, true);
									jQuery(".pop-charge").css("left", "0px");
									jQuery(".pop-charge").css("top", "0px");
								});
							}

							parseItems(items_total_all, items_all_parsed, calDate, layout_type, true);
							uvShowMap();
						}
						//kaos
						if (uv_venueid == 49061105) {
							setTimeout(function () {
								$(".uv-mapcust").sort(sort_itm).appendTo('.list-items');
								$(".uv-mapcustpatio").sort(sort_itm).appendTo('.list-items');

								function sort_itm(a, b) {
									return (parseInt($(b).attr('item_custcorep'))) < (parseInt($(a).attr('item_custcorep'))) ? 1 : -1;
								}

							}, 2000);

						}
					}
				} else {
					uvShowMap(false);
					var dmsjnoItms = "No items available for this day.";
					if (uv_venueid == 45010436541)
						dmsjnoItms = "Online reservations not available within 24 hours of booking, please inquire at the Pool Bar for rental availability?";
					//gardenofthegods, venuspool, gopoolvegas, soleilpool, linq, thepoolatharrahs, raceandsportsbook
					if (uv_venueid == 45010349775 || uv_venueid == 45010349769 || uv_venueid == 708428765 || uv_venueid == 45010349805 || uv_venueid == 708375117 || uv_venueid == 45010349787 || uv_venueid == 45010349763)
						dmsjnoItms = "Please visit the venue for same day reservations";

					if (uv_venueid == 45010813518)
						dmsjnoItms = "Please visit the venue for same day reservations. Online reservations close at 11:59pm one day prior. Thank you";

					if (uv_venueid == 708428765)
						dmsjnoItms = "For Same Day Reservations Contact The Pool Team at 702.697.2888";


					jQuery(".uv-map").html("<div class='uvmap-notitems text-center'><div class='alert alert-danger'>" + dmsjnoItms + "</div>");
				}
			} else
				uvShowMap(false);
		}
	});

	uvMapLoadEvent(calDate);
}

function uvLoadLayoutMap(layout_id, layout_type, map_floor, items_total_all, items_all_parsed, calDate, ismobile) {
	if (typeof (ismobile) == "undefined")
		ismobile = false;
	pop_loader.show();

	if (layout_id == null)
		layout_id = 1;

	if (map_floor_json && map_floor_json != "null" && map_floor == "") {
		floors = JSON.parse(map_floor_json);
		map_floor = floors[layout_id];

	} else if (!map_floor || typeof (map_floor) == "undefined") {
		map_floor = "uvdefault.";
	}
	mapcontent_index = uvmapMapMobCacheIds.indexOf(map_floor);
	if (mapcontent_index == -1 || ismobile == false) {
		map_floor_encoded = map_floor.replace("+", "%2B");

		url = uv_mapurl + "svg.map.php";
		data = "layout_id=" + layout_id + "&layout_type=" + layout_type + "&map_floor=" + map_floor_encoded + "&uv_extsiteurl=" + uv_extsiteurl;
		jQuery.ajax({
			type: "POST",
			url: url,
			data: data,
			error: function () {
				alert("Error!");
			},
			success: function (result) {
				obj = jQuery.parseJSON(result);

				mapcontent = obj.mapcontent;
				rooms = obj.rooms;

				if (ismobile == true) {
					uvmapMapMobCacheIds.push(map_floor);
					uvmapMapMobCacheCont.push(mapcontent);
					uvmapMapMobCacheRoom.push(rooms);

					doubleTapHolder();
				}

				uvMapLoadLayoutMapInc(mapcontent, rooms, layout_type, map_floor, items_total_all, items_all_parsed, calDate, ismobile)
			}
		});
	}
	else {
		mapcontent = uvmapMapMobCacheCont[mapcontent_index];
		rooms = uvmapMapMobCacheRoom[mapcontent_index];

		uvMapLoadLayoutMapInc(mapcontent, rooms, layout_type, map_floor, items_total_all, items_all_parsed, calDate, ismobile);
	}
}

function uvMapLoadLayoutMapInc(mapcontent, rooms, layout_type, map_floor, items_total_all, items_all_parsed, calDate, ismobile) {
	jQuery(".custom-title").fadeIn(0);
	jQuery(".uv-map").html(mapcontent);
	jQuery(".uv-map svg").attr("id", "uvmapsvg");
	jQuery(".uvmap-map-loader").fadeOut(0);
	jQuery(".list-items").html("");

	rooms = obj.rooms;
	room_options = "";
	if (rooms.length > 0) {
		for (var i = 0; i < rooms.length; i++) {
			room = rooms[i];
			code = room.code;
			label = room.label;
			file = room.file;
			tmp_file = file.replace("map.", "");
			tmp_file = tmp_file.replace("php", "");

			if (label == "Main Layout" && uvmapMainLayoutName != "")
				label = uvmapMainLayoutName;

			if (map_floor == tmp_file)
				jQuery(".uv-putmaproomname").text(label);

			room_options += "<li><a href='javascript:;' data-value='" + code + "'>" + label + "</a></li>";
		}

		jQuery(".uv-maproomselection").html(room_options);
		jQuery("#uv-maproomselection").html(room_options);
		jQuery(".uv-roomdropdown").removeClass("hidden");
		jQuery(".uvmap-roomdropdown").removeClass("uvmap-hide");
	} else {
		jQuery(".uv-maproomselection").html("");
		jQuery("#uv-maproomselection").html("");
		jQuery(".uv-roomdropdown").addClass("hidden");
		jQuery(".uvmap-roomdropdown").addClass("uvmap-hide");
	}

	if (ismobile == true) {
		if (UVtablercart.length > 0) {
			for (const itemid of UVtablercart) {
				if (itemid) {
					item_obj = jQuery(document).find("*[item_id='" + itemid + "']");
					item_sectionid = jQuery(item_obj).attr("item_sectionid");

					if (item_sectionid) {
						const element = jQuery(document).find('#S' + item_sectionid + 'I')[0];

						if (element && element.classList) {
							element.classList.add('item-section-in-cart');
						}
					}
				}
			}
		}
	}


	if (items_total_all > 0) {
		jQuery(".uv-showlistitems").fadeIn(0);
		parseItems(items_total_all, items_all_parsed, calDate, layout_type, ismobile);
	} else if (request3dtable == true) {
		if (typeof uv_microsite == "undefined")
			uv_microsite = "";

		//seasonsatthebrook if don't have items return to homepage
		/*
				if(uv_venueid == 1305364766)
				{
					window.location.href = "https://seasonsatthebrook.uvtix.com/";
				}
		*/
		if (uv_venueid == "3202320919" || uv_venueid == "704727639") {

			// 08/30/2016	
			var cutofftimeactive = false;
			jQuery.ajax({
				url: uv_mapurl + "checkrestypetime.php",
				data: { date: calDate, venueid: uv_venueid },
				dataType: "json"
			}).done(function (response) {
				cutofftimeactive = response["cutofftime_active"];
				if (cutofftimeactive) {
					jQuery('svg .item_section').attr('status', 'item_unavailable');
					
					createTooltip('svg .item_section', 'unavailable', 'Unavailable');
					jQuery(".list-items").html("");
					//console.log('here map0');
				}
				else {
					reservationformparams = "type=mobile&venueid=" + uv_venueid + "&restypeid=" + request3dtable_restypeid + "&resdate=" + jQuery("#uv-mapdate").siblings("input[name='mapdate']").val() + "&backend_url=" + backend_url + "&microsite=" + uv_microsite + "&showcaptcha=" + reservationcaptcha;

					checkUvtixLeadsForm(reservationformurl, reservationformparams);

					jQuery("svg .item_section").attr("status", "resinquiry");
					
					createTooltip("svg .item_section", "resinquiry", "Requervation Inquiry");
					jQuery(".list-items").html("");
					jQuery(".uv-showlistitems").fadeOut(0);
					//console.log('here map1');	
				}
			});
			/*	var timeZones = {
					'America/Los_Angeles' : 15,
					'America/Mexico_City' : 15,	
					'Pacific/Pitcairn': 15,
					'Pacific/Easter': 15,
					'America/New_York': 15,
					'US/Arizona': 16,
					'US/Alaska': 14,
					'US/Central': 16,
					'US/Eastern': 15,
					'US/Hawaii': 12,
					'US/Mountain':16,
					'US/Michigan':18,
					'US/Pacific':15,
					'US/Samoa':19						
				};
				var dateToday = new Date();
				var hours = dateToday.getHours();
				var minutes = dateToday.getMinutes();
				var tz = jstz.determine(); 
				var timezone = tz.name(); */

			//var fhrs=parseInt(hours+''+minutes);

			// 08/30/2016	
		}
		else {
			reservationformparams = "type=mobile&venueid=" + uv_venueid + "&restypeid=" + request3dtable_restypeid + "&resdate=" + jQuery("#uv-mapdate").siblings("input[name='mapdate']").val() + "&backend_url=" + backend_url + "&microsite=" + uv_microsite + "&showcaptcha=" + reservationcaptcha;

			checkUvtixLeadsForm(reservationformurl, reservationformparams);

			jQuery("svg .item_section").attr("status", "resinquiry");
			
			createTooltip("svg .item_section", "resinquiry", "Requervation Inquiry");
			jQuery(".list-items").html("");
			jQuery(".uv-showlistitems").fadeOut(0);
			//console.log('here map1');
		}
	}

	if (map_floor == "0.main.layout.") {
		jQuery(".uv-map svg *[id^='V'][id$='L']").each(function () {
			lv_name_id = jQuery(this).attr("id");
			lv_descr = jQuery(this).attr("layout-descr");

			lv_name_id = lv_name_id.replace("L", "");
			lv_name_id = lv_name_id.replace(/(V+[0-9]+)|\./g, " ");
			lv_name_id = lv_name_id.replace("V", "");


			lv_name = lv_name_id.toLowerCase().replace(/\b[a-z]/g, function (letter) {
				return letter.toUpperCase();
			});
			lv_name = lv_name.replace(/^\s/g, "");
			createTooltip(jQuery(this), 'layout-view', lv_name, null, null, null, lv_descr);
		});
	}

	uvShowMap();

	/*open sectionid when is present in url*/
	if (typeof (uv_loadsectionafterdatesel) != "undefined" && uv_loadsectionafterdatesel.length > 0) {
		setTimeout(function () {
			uvopenssectipfrommap(uv_loadsectionafterdatesel);
			uv_loadsectionafterdatesel = "";
		}, 1);
	}
}

function uvMapLoadEvent(caldate) {
	if (typeof roomid == "undefined")
		roomid = "";
	jQuery.ajax({
		url: 'https://api.urvenue.me/v1/uvmap/eventinfo/json/',
		data: {
			apikey: 'CFSOXUQSFXNGSBACGPQRMREP',
			sourcecode: 'microsite',
			sourceloc: 'uvtix',
			date: caldate,
			venueid: uv_venueid,
			roomid: roomid
		},
		dataType: "json"
	}).done(function (response) {
		if (response.uv.success.status == 'success' && response.uv.data.rowcount > 0) {

			flyer = uv_getimage(response.uv.data.events[0].flyers, "Flyer", "Vertical");

			/*console.log("hola");
			console.log(response);*/
			if (flyer["folder"]) {
				var uvveaeventfolder = flyer["folder"];
				var uvveaeventfile = flyer["file"];
			} else if (response.uv.data.events[0].flyers_recurrent[0]) {
				var uvveaeventfolder = response.uv.data.events[0].flyers_recurrent[0].flyer_folder;
				var uvveaeventfile = response.uv.data.events[0].flyers_recurrent[0].flyer_file;
				var uvveaeventratio = response.uv.data.events[0].flyers_recurrent[0].flyer_ratio;

				if ((uvveaeventratio != "Vertical") && typeof (response.uv.data.events[0].flyers_recurrent[1]) != undefined) {
					var uvveaeventfolder = response.uv.data.events[0].flyers_recurrent[0].flyer_folder;
					var uvveaeventfile = response.uv.data.events[0].flyers_recurrent[0].flyer_file;
				}
			}
			else
				jQuery(".uv-mapflyer").hide();

			var uvveaeventdescr = (response.uv.data.events[0].descr.length < 1) ? "No Event Description" : response.uv.data.events[0].descr;

			eventid = response.uv.data.events[0].id;

			var evRegex = /ev[0-9]+/gi;
			var matchs = evRegex.exec(token_globalstring);

			if (matchs != null)
				token_globalstring = token_globalstring.replace(/ev[0-9]+/gi, "ev" + eventid);
			else
				token_globalstring += 'ev' + eventid;

			gb_ticketsurl = response.uv.data.events[0].ticketsurl;

			jQuery(".uv-puteventname").html(response.uv.data.events[0].name);

			if (uv_venueid == 11066556 || uv_venueid == 701133708 || uv_venueid == 405660315) {
				var uvbackcaldate = caldate.replace(/-/g, "");
				var uvbackname = response.uv.data.events[0].name;
				uvbackname = uvbackname.replace(/ /g, "-");
				var uveventback = "/uvtix/" + uvbackcaldate + "/" + uvbackname;
				jQuery(".uveventback").attr('href', uveventback);
			}
			//seasonsatthebrook 
			uvcustomclass = '';
			var uvoperationhours = document.querySelector(".uv-event-operationhours");
			if (uvoperationhours.classList.contains('active')) {
				let uvoperationhouremaildesc = document.querySelector(".uv-event-operationhours").getAttribute("data-desc");
				let uvdoorsopen = response.uv.data.events[0].doorsopen;
				let uvstarttime = response.uv.data.events[0].starttime;
				let uvdescr = response.uv.data.events[0].descr;
				uvdoorsopen = uvhourampm(uvdoorsopen);
				uvstarttime = uvhourampm(uvstarttime);

				let uvoperationhours = "<div class='uv-event-operationhours'>";
				uvoperationhours += "<div class='uv-pb10'><b>Doors Open: </b>" + uvdoorsopen + "</div>";
				uvoperationhours += "<div class='uv-pb20'><b>Time Starting: </b>" + uvstarttime + "</div>";
				if (uvoperationhouremaildesc == "active") {
					uvoperationhours += "<div >" + uvdescr + "</div>";
				}

				jQuery(".uv-event-operationhours").html(uvoperationhours);
				jQuery(".uv-event-operationhours").removeClass("uv-hidden");
			}

			jQuery(".uv-puteventdescr").html(uvveaeventdescr);
			jQuery(".uv-mapflyer").html("<a class='uv-popimg' href='" + uvveaeventfolder + "/500SC0/" + uvveaeventfile + "'  style='display:block;'><div class='uv-imgresponsivecont uv-imghover'><img src='" + uvveaeventfolder + "/400SC0/" + uvveaeventfile + "' alt='Event: " + response.uv.data.events[0].name + "'></div></a>").removeClass("uv-mapnoflyer");
			jQuery(".uv-puteventflyerlink").html("<a class='uv-popimg' href='" + uvveaeventfolder + "/raw/" + uvveaeventfile + "'>View Flyer</a>").removeClass("uv-mapnoflyer");
			jQuery(".uv-evendropcont").addClass('uv-showevent');
			jQuery(".uv-evendropcont").css("display", "inline-block");
			jQuery(".uv-tabletevent").show();
			//jQuery(".uv-dropeventinfo").css("visibility", "visible");

			if (response.uv.data.events[0].descr != "") {
				jQuery(".uv-eventinfo").removeClass("hide");
			}
		}
		else {
			eventid = "";
			token_globalstring = token_globalstring.replace(/ev[0-9]/, "ev" + eventid);
			jQuery(".uv-puteventname, .uv-puteventflyerlink").html("-");
			jQuery(".uv-mapflyer").addClass("uv-mapnoflyer").html("<h1>No Event for This Date</h1>");
			jQuery(".uv-evendropcont, .uv-tabletevent").hide();
			jQuery(".uv-evendropcont").removeClass('uv-showevent');
			//jQuery(".uv-dropeventinfo").css("visibility", "hidden");
		}
	});
}

function uvhourampm(uvhour) {
	let uvhourarray = uvhour.split(":");
	if (uvhourarray.length > 2) {
		let uvhour = uvhourarray[0];
		let uvmin = uvhourarray[1];
		var uvoriginalhour = new Date();
		uvoriginalhour.setHours(uvhour, uvmin, 0);
		var uvhourAMPM = uvoriginalhour.toLocaleTimeString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true });


	}
	return uvhourAMPM;
}

var globalelement = null;
function loadItem(element) {
	globalelement = element;
	var monthNames = [
		"Jan", "Feb", "Mar",
		"Apr", "May", "Jun", "Jul",
		"Aug", "Sep", "Oct",
		"Nov", "Dec"
	];

	item_image = jQuery(element).attr("item_image");
	item_sectionid = jQuery(element).attr('item_sectionid');

	item_image_small = item_image_big = "";
	if (item_image) {
		item_image_small = item_image.replace("raw", "390SC260");
		item_image_big = item_image.replace("raw", "975SC650");
	}

	if (item_image == 0 || item_image == null) {
		item_image_small = "http://placehold.it/390x260";
		item_image_big = "http://placehold.it/975x650";
	}

	caldate = jQuery(element).attr("caldate");

	var tablePopUrl = uv_mapurl + "table.pop.php";

	if ((uv_venueid == 1305111780)) {
		tablePopUrl = uv_mapurl + "table.pop.1305111780.php";
	}
	else if (uv_venueid == 47010875213) {
		tablePopUrl = uv_mapurl + "table.pop.47010875213.php";
	}

	item_id = jQuery(element).attr("item_id");

	loadPop(tablePopUrl + "?flyer=" + item_image_small + '&sectionid=' + item_sectionid + "&caldate=" + caldate + "&itemid=" + item_id, function () {
		//Redirect to external tickets for felt mgm
		if (uv_venueid == 1505718056 && caldate == "2016-12-31")
			pop_up = replace_purchase_button(gb_ticketsurl, pop_up);

		content = pop_up.find('.pop-charge').html();


		item_id = jQuery(element).attr("item_id");
		item_name = jQuery(element).attr("item_name");
		item_allowlead = jQuery(element).attr("item_allowlead");
		item_restypeid = jQuery(element).attr("item_restypeid");
		item_layout_type = jQuery(element).attr("item_layout_type");
		item_customurl = jQuery(element).attr("item_customurl");
		item_globaltype = jQuery(element).attr("item_globaltype");
		item_sectionid = jQuery(element).attr("item_sectionid");

		item_deposit = jQuery(element).attr("item_deposit");
		item_baseprice = jQuery(element).attr("item_baseprice");
		item_status = jQuery(element).attr("status");

		// added by edsson
		item_paynow = jQuery(element).attr("item_paynow");
		tmp_paynow = item_paynow.indexOf(".");
		first_paynow = item_paynow.substring(0, tmp_paynow + 1);
		last_paynow = item_paynow.substring(tmp_paynow + 1, item_paynow.length);
		item_paynow = first_paynow + "<span>" + last_paynow + "</span>";

		item_minimum = jQuery(element).attr("item_minimum");
		caldateinit = caldate;
		//

		/***
			added by gabo pay now 
			uv_venueid==49061111   palmspearl
		***/
		if (uv_venueid == 49061111) {
			item_baseprice = item_paynow;
		}

		/******/


		tmp_deposit = item_deposit.indexOf(".");
		first_deposit = item_deposit.substring(0, tmp_deposit + 1);
		last_deposit = item_deposit.substring(tmp_deposit + 1, item_deposit.length);
		item_deposit = first_deposit + "<span>" + last_deposit + "</span>";

		if (item_baseprice == "" || item_baseprice < 0)
			item_baseprice = "FREE";
		else {
			tmp_baseprice = item_baseprice.indexOf(".");
			first_baseprice = item_baseprice.substring(0, tmp_baseprice + 1);
			last_baseprice = item_baseprice.substring(tmp_baseprice + 1, item_baseprice.length);
			item_baseprice = first_baseprice + "<span>" + last_baseprice + "</span>";
		}

		item_descr = itemDescr_arr[item_id];
		item_terms = itemTerms_arr[item_id];
		item_espoffer = itemOff_arr[item_id];

		// For Escapade
		if (uv_venueid == 705020694) {
			item_descr = 'IMPORTANTE <br><br/>PAQUETE 1,2,3 Y 4 RECLAMO VALIDO ANTES DE LAS 10 P.M. <br/> <label class="text-danger" style="margin-bottom: 0px">(SOLO APLICA EVENTO REGULAR)</label><br/> REQUIERE MINIMO 4 MAYORES DE +21 AÑOS AL MOMENTO DEL RECLAMO<br/>MENOS DE 4 MAYORES DE 21 A LA HORA DEL RECLAMO, SOLO SE LES ENTREGARA LA MITAD DEL PAQUETE  (BOTELLA.375ML O UNA CUBETA DEPENDIENDO DEL PAQUETE). PAQUETE NO SE ENTREGARA EN DOS PARTES<br/>MESAS VIP EVENTO PAGADO:<br/>4 PERSONAS MAYORES A 21 AÑOS A LA HORA DEL RECLAMO<br/> NO SE ENTREGA DESPUES DE LA 1 AM,<br/><label class="text-danger"> NO CAMBIOS NI DEVOLUCIONES.<label/>';
		}

		item_section_checkoutmin_state = jQuery(element).attr("item_section_checkoutmin_state");
		item_section_checkoutdep_state = jQuery(element).attr("item_section_checkoutdep_state");
		item_section_checkoutguest_state = jQuery(element).attr("item_section_checkoutguest_state");
		item_section_capacity = jQuery(element).attr("item_section_capacity");
		item_section_maxguests = jQuery(element).attr("item_section_maxguests");
		item_section_stockleft = jQuery(element).attr("item_stockleft");
		tmp_caldate = caldate.split("-");
		day = tmp_caldate[2];

		if (day) {
			if (day[0] == 0)
				day = day[1];
			caldate = monthNames[parseInt(tmp_caldate[1]) - 1] + " " + day + ", " + tmp_caldate[0];
		}



		item_descr_short = "";
		item_descr_temporal = item_descr;

		if (item_descr_temporal)
			item_descr_temporal = item_descr_temporal.replace(/(\<br\/>)|(\<br\s\/>)/g, "");

		if (item_descr_temporal) {
			limit = 170;
			if (item_descr_temporal[limit] == "<")
				limit--;
			else if (item_descr_temporal[limit] == ">")
				limit++;

			//item_descr_short = item_descr_temporal.substring(0, limit)+"...";			
			item_descr_short_more = item_descr_temporal.substring(0, limit) + "...<a href='javascript:;' class='uv-showinfo' data-target='.uv-fulltabledescr-purchase' data-title='Description'>more</a>";
			item_descr_short = (item_descr_temporal.length < limit) ? item_descr_temporal : item_descr_short_more;
		}

		if (item_espoffer != "" && item_espoffer != null) {
			if (item_descr != "")
				item_descr += "<br/><br/>";

			item_descr += "<b>Special Offer:</b><br/>" + item_espoffer;
		}

		if (item_section_checkoutguest_state == 1) {
			content = content.replace("[[uv-if-checkoutguests]]", "");
			content = content.replace("[[uv-endif-checkoutguests]]", "");

			var _opcselectedmax = 0;
			if ((uv_venueid == 708375117 && (item_sectionid == 801305214 || item_sectionid == 801305224 || item_sectionid == 801305234)) || (uv_venueid == 709719071) || (uv_venueid == 7012342324))
				_opcselectedmax = 1;

			var options = "";

			if (item_section_stockleft && (parseInt(item_section_stockleft) < item_section_maxguests))
				var item_section_maxguestsref = parseInt(item_section_stockleft);
			else
				var item_section_maxguestsref = item_section_maxguests;

			for (var i = 1; i <= item_section_maxguestsref; i++) {
				if (parseInt(item_section_capacity) == i && !_opcselectedmax)
					options += "<option value='" + i + "' selected>" + i + "</option>";
				else if (parseInt(item_section_maxguests) == i && _opcselectedmax)
					options += "<option value='" + i + "' selected>" + i + "</option>";
				else
					options += "<option value='" + i + "'>" + i + "</option>";
			}

			//add calculatio for rental fee
			if (item_globaltype == "rentalfee") {
				let uvnselgroups = item_section_maxguestsref / item_section_capacity;
				options = "";

				for (x = 1; x <= uvnselgroups; x++) {
					let uvguests = x * item_section_capacity;

					options += "<option value='" + uvguests + "'>" + uvguests + "</option>";
				}
			}

			content = content.replace("[[uv-checkoutguests-select]]", options);
		} else {
			content = content.replace(/(\[\[uv-if-checkoutguests\]\])+(.|\n)*(\[\[uv-endif-checkoutguests\]\])/, "");
		}

		if (item_section_checkoutdep_state == 1) {
			if (uv_venueid == 1305111780 && item_baseprice == 'FREE') {
				content = content.replace("[[uv-pricesclass]]", "cero-opacity");
			} else if (uv_venueid == 1305112235 && item_baseprice == 'FREE') {
				content = content.replace("[[uv-pricesclass]]", "cero-opacity");
			} else {
				content = content.replace("[[uv-pricesclass]]", "uv-tableprices-2");
			}
			content = content.replace("[[uv-if-checkoutdep]]", "");
			content = content.replace("[[uv-endif-checkoutdep]]", "");
		} else {
			if (uv_venueid == 1305111780 && item_baseprice == 'FREE') {
				content = content.replace("[[uv-pricesclass]]", "cero-opacity");
			} else if (uv_venueid == 1305112235 && item_baseprice == 'FREE') {
				content = content.replace("[[uv-pricesclass]]", "cero-opacity");
			} else {
				content = content.replace("[[uv-pricesclass]]", "");
			}
			content = content.replace(/(\[\[uv-if-checkoutdep\]\])+(.|\n)*(\[\[uv-endif-checkoutdep\]\])/, "");
		}


		//for tao 
		addlinemin = "";
		/*
				if(uv_venueid==3601327489 || uv_venueid==3601321553)
					addlinemin="<div class='clear-fix'>**Does not include applicable Taxes and Gratuity**</div>";
		*/
		if (item_section_checkoutmin_state == 1) {
			if (uv_venueid == 1505790580) //Revelin
				content = content.replace("[[uv-payatvenuelabel]]", "Total");
			else if (uv_venueid == 1305112235)
				content = content.replace("[[uv-payatvenuelabel]]", "Minimum Spend");
			else if (uv_venueid == 1305111780)
				content = content.replace("[[uv-payatvenuelabel]]", "Prepay Price");
			else if (uv_venueid == 47010856625)
				content = content.replace("[[uv-payatvenuelabel]]", "Rental Price");
			else
				content = content.replace("[[uv-payatvenuelabel]]", "Subtotal" + addlinemin);

		} else if (item_baseprice == "FREE") {
			content = content.replace("[[uv-payatvenuelabel]]", "");
		} else if (custom_payatlabel != "") {
			content = content.replace("[[uv-payatvenuelabel]]", custom_payatlabel);
		}
		else {
			if (item_globaltype == "seat")
				content = content.replace("[[uv-payatvenuelabel]]", "Prepay Price");
			else {
				var deflabpack = "Package Price";
				if (uv_venueid == 49061111 && item_id == 803090520)
					deflabpack = "MINIMUM SPEND";

				if (uv_venueid == 708428765)
					deflabpack = "RENTAL FEE";

				if (uv_venueid == 1305172631)
					deflabpack = "RENTAL FEE";

				if (uv_venueid == 47010856625)
					deflabpack = "Rental Price";

				content = content.replace("[[uv-payatvenuelabel]]", deflabpack);
			}
		}

		if (item_globaltype == "seat")
			content = content.replace("[[uv-howmany-label]]", "SEATS");
		else
			content = content.replace("[[uv-howmany-label]]", "GUESTS");

		if (tablepop_customtext == '') {
			if ((item_section_checkoutmin_state == 1 || item_section_checkoutguest_state == 1) && item_globaltype != "seat") {
				content = content.replace("[[uv-if-checkoutmin-or-checkoutguests]]", "");
				content = content.replace("[[uv-endif-checkoutmin-or-checkoutguests]]", "");

				if (item_section_checkoutmin_state == 1) {
					content = content.replace("[[uv-if-checkoutmin]]", "");
					content = content.replace("[[uv-endif-checkoutmin]]", "");
				} else {
					content = content.replace(/(\[\[uv-if-checkoutmin\]\])+(.|\n)*(\[\[uv-endif-checkoutmin\]\])/, "");
				}

				if (item_section_checkoutmin_state == 1 && item_section_checkoutguest_state == 1) {
					content = content.replace("[[uv-if-checkoutmin and uv-if-checkoutguests]]", "");
					content = content.replace("[[uv-endif-checkoutmin and uv-endif-checkoutguests]]", "");
				} else {
					content = content.replace(/(\[\[uv-if-checkoutmin and uv-if-checkoutguests\]\])+(.|\n)*(\[\[uv-endif-checkoutmin and uv-endif-checkoutguests\]\])/, "");
				}

				if (item_section_checkoutguest_state == 1) {
					content = content.replace("[[uv-if-checkoutguests-warning]]", "");
					content = content.replace("[[uv-endif-checkoutguests-warning]]", "");
				} else {
					content = content.replace(/(\[\[uv-if-checkoutguests-warning\]\])+(.|\n)*(\[\[uv-endif-checkoutguests-warning\]\])/, "");
				}
			} else {
				content = content.replace(/(\[\[uv-if-checkoutmin-or-checkoutguests\]\])+(.|\n)*(\[\[uv-endif-checkoutmin-or-checkoutguests\]\])/, "");
			}
		}
		else {
			content = content.replace("[[uv-if-checkoutmin-or-checkoutguests]]", "");
			content = content.replace("[[uv-endif-checkoutmin-or-checkoutguests]]", "");

			content = content.replace(/(\[\[uv-if-checkoutmin\]\])+(.|\n)*(\[\[uv-endif-checkoutmin\]\])/, "");
			content = content.replace(/(\[\[uv-if-checkoutmin and uv-if-checkoutguests\]\])+(.|\n)*(\[\[uv-endif-checkoutmin and uv-endif-checkoutguests\]\])/, "");
			content = content.replace(/(\[\[uv-if-checkoutguests-warning\]\])+(.|\n)*(\[\[uv-endif-checkoutguests-warning\]\])/, '[[uv-customtext]]');

			tablepop_customtext = tablepop_customtext.replace("[[uv-minimum]]", unescape(item_minimum));

			content = content.replace("[[uv-customtext]]", tablepop_customtext);


		}

		if (typeof (req_loadfrom) == "undefined")
			req_loadfrom = "";

		if (item_allowlead == 1) {
			if (req_loadfrom != "") {
				content = content.replace(/(\[\[uv-if-button-inquiry\]\])+(.|\n)*(\[\[uv-endif-button-inquiry\]\])/, "");

				if (req_loadfrom == "nanosites")
					content = content.replace("[[uv-button-inquiry-lead-url]]", "/uvcore/" + zs_token + "it" + item_id + "/uvinquiry/");
				else if (req_loadfrom == "microsites") {
					tokenparam = "uv" + uv_venueid + "dt" + shortdate + "it" + item_id;

					if (uvveavenueid)
						tokenparam += "ve" + uvveavenueid;

					if (roomid)
						tokenparam += "rm" + roomid;

					if (typeof (uvmapCustomItemLeads[item_sectionid]) != 'undefined' && uvmapCustomItemLeads[item_sectionid] != '0')
						uvmapGlobalTypeId = uvmapCustomItemLeads[item_sectionid];

					content = content.replace("[[uv-button-inquiry-lead-url]]", "//uvtix.com/websites/ln_core/uvcore/uvinquiry.php?token=" + tokenparam + "&urvenueid=" + uv_venueid + "&leadtypeid=" + uvmapGlobalTypeId);
				}
				else
					content = content.replace(/(\[\[uv-if-button-inquiry-lead\]\])+(.|\n)*(\[\[uv-endif-button-inquiry-lead\]\])/, "");


				content = content.replace("[[uv-if-button-inquiry-lead]]", "");
				content = content.replace("[[uv-endif-button-inquiry-lead]]", "");
			}
			else if (show_purchase_inquiry == 1) {
				content = content.replace(/(\[\[uv-if-button-inquiry-lead\]\])+(.|\n)*(\[\[uv-endif-button-inquiry-lead\]\])/, "");
				content = content.replace("[[uv-if-button-inquiry]]", "");
				content = content.replace("[[uv-endif-button-inquiry]]", "");
			}
			else {
				content = content.replace(/(\[\[uv-if-button-inquiry\]\])+(.|\n)*(\[\[uv-endif-button-inquiry\]\])/, "");
				content = content.replace(/(\[\[uv-if-button-inquiry-lead\]\])+(.|\n)*(\[\[uv-endif-button-inquiry-lead\]\])/, "");
			}
		}
		else {
			content = content.replace(/(\[\[uv-if-button-inquiry-lead\]\])+(.|\n)*(\[\[uv-endif-button-inquiry-lead\]\])/, "");
			if (show_purchase_inquiry == 1) {
				content = content.replace("[[uv-if-button-inquiry]]", "");
				content = content.replace("[[uv-endif-button-inquiry]]", "");
			} else {
				content = content.replace(/(\[\[uv-if-button-inquiry\]\])+(.|\n)*(\[\[uv-endif-button-inquiry\]\])/, "");
			}
		}

		if (item_espoffer != "" && item_espoffer != null) {
			content = content.replace("[[uv-special-offer]]", item_espoffer);
			content = content.replace("[[uv-if-special-offer]]", "");
			content = content.replace("[[uv-endif-special-offer]]", "");
		} else {
			content = content.replace(/(\[\[uv-if-special-offer\]\])+(.|\n)*(\[\[uv-endif-special-offer\]\])/, "");
		}

		content = content.replace("[[uv-if-promo-code]]", "");
		content = content.replace("[[uv-endif-promo-code]]", "");

		content = content.replace(/\[\[uv-itemid\]\]/g, unescape(item_id));

		content = content.replace("[[uv-date]]", unescape(caldate));
		content = content.replace("[[uv-dateinit]]", unescape(caldateinit));

		content = content.replace(/\[\[uv-itemname\]\]/g, unescape(item_name));
		content = content.replace("[[uv-baseprice]]", unescape(item_baseprice));
		content = content.replace("[[uv-baseprice]]", unescape(item_baseprice));

		content = content.replace("[[uv-deposit]]", unescape(item_deposit));

		// added by edsson
		content = content.replace("[[uv-paynow]]", unescape(item_paynow));

		if (uv_venueid == 1505790580) //Revelin
			content = content.replace("[[uv-minimum]]", unescape(item_baseprice));
		else
			content = content.replace("[[uv-minimum]]", unescape(item_minimum));
		/////////////////

		content = content.replace(/\[\[uv-itemimage-small\]\]/g, unescape(item_image_small));
		content = content.replace(/\[\[uv-itemimage-big\]\]/g, unescape(item_image_big));
		content = content.replace("[[uv-descr-short]]", unescape(item_descr_short));
		content = content.replace("[[uv-descr-full]]", unescape(item_descr));
		content = content.replace("[[uv-terms]]", unescape(item_terms));
		// 		console.log("capacity max "+item_section_maxguests+" capacity sec "+item_section_capacity);
		if (_opcselectedmax)
			content = content.replace(/\[\[uv\-itemcapacity\]\]/g, unescape(item_section_maxguests));
		else
			content = content.replace(/\[\[uv\-itemcapacity\]\]/g, unescape(item_section_capacity));

		content = content.replace(/\[\[item-image\]\]/g, unescape(item_image));
		content = content.replace(/\[\[item-name\]\]/g, unescape(item_name));
		content = content.replace(/\[\[item-restypeid\]\]/g, unescape(item_restypeid));
		content = content.replace(/\[\[item-id\]\]/g, unescape(item_id));

		content = content.replace("[[uv-checkoutmin-state]]", unescape(item_section_checkoutmin_state));
		content = content.replace("[[uv-checkoutdep-state]]", unescape(item_section_checkoutdep_state));
		content = content.replace("[[uv-checkoutguests-state]]", unescape(item_section_checkoutguest_state));

		if (uv_venueid == 705235320)
			content = content.replace("[[uv-if-checkoutmin-add-text]]", "<br/>Deposit amount will be credited <br/>toward total purchase");
		else
			content = content.replace("[[uv-if-checkoutmin-add-text]]", "");

		if (allowcartsingletable == 1 && item_layout_type == "table") {
			content = content.replace(/\[\[uv-if-button-cart\]\]/g, "");
			content = content.replace(/\[\[uv-endif-button-cart\]\]/g, "");
			content = content.replace(/\[\[uv-if-button-cartdiv\]\]/g, "");
			content = content.replace(/\[\[uv-endif-button-cartdiv\]\]/g, "");
		}
		else {
			content = content.replace(/(\[\[uv-if-button-cart\]\])+(.|\n)*(\[\[uv-endif-button-cart\]\])/, "");
			content = content.replace(/(\[\[uv-if-button-cartdiv\]\])+(.|\n)*(\[\[uv-endif-button-cartdiv\]\])/, "");
		}

		if (typeof (item_customurl) != 'undefined') {
			if (item_customurl != null && item_customurl != 'null') {
				content = content.replace(/\[\[uv-customviewurl\]\]/, item_customurl);
				content = content.replace(/\[\[uv-if-customviewurl\]\]/, "");
				content = content.replace(/\[\[uv-endif-customviewurl\]\]/, "");
				content = content.replace(/(\[\[uv-if-notcustomviewurl\]\])+(.|\n)*(\[\[uv-endif-notcustomviewurl\]\])/, "");
			}
			else {
				content = content.replace(/\[\[uv-if-notcustomviewurl\]\]/, "");
				content = content.replace(/\[\[uv-endif-notcustomviewurl\]\]/, "");
				content = content.replace(/(\[\[uv-if-customviewurl\]\])+(.|\n)*(\[\[uv-endif-customviewurl\]\])/, "");
			}
		}
		else {
			content = content.replace(/\[\[uv-if-notcustomviewurl\]\]/, "");
			content = content.replace(/\[\[uv-endif-notcustomviewurl\]\]/, "");
			content = content.replace(/(\[\[uv-if-customviewurl\]\])+(.|\n)*(\[\[uv-endif-customviewurl\]\])/, "");
		}

		jQuery(".uv-popmap").removeClass('closeover-pop');
		pop_up.find('.pop-charge').html(content);


		if (uv_venueid == 709319804 || uv_venueid == 709363062)
			pop_up.find('.pop-charge').find('#uvtix_tablepurchase').text('RESERVATION REQUEST');

		if (uv_venueid == 1505908617 && (item_sectionid > 1505928965 && item_sectionid < 1505928971))
			jQuery('<label>All guests in the bungalow MUST be 21 and over.</label>').appendTo('#uvtix_tablesubmit');

		jQuery(".uv-popmap .pop-charge").css("left", "auto");
		jQuery(".uv-popmap .pop-charge").css("top", "auto");

		fadePop();
	});
}

function parseItemsInc(type, total, items, caldate, layouttype) {
	colorcoding = new Array();

	if (type != "desktop" && type != "mobile")
		return;

	if (type == "desktop") {
		jQuery(".uv-map .item_section").attr("status", "item_unavailable");
		jQuery(".uv-map .item_section").attr("data-html", true);
	}

	if ((type == "mobile" && total <= 0) || total <= 0) {
		var showform = 1;
		if (uv_venueid == "3202320919") {
			var cutofftimeactive = false;
			jQuery.ajax({
				url: uv_mapurl + "checkrestypetime.php",
				data: { date: caldate },
				dataType: "json"
			}).done(function (response) {
				cutofftimeactive = response["cutofftime_active"];
				if (cutofftimeactive) {
					jQuery(".list-items").html("");
				}
				else {
					reservationformparams = "type=mobile&venueid=" + uv_venueid + "&restypeid=" + request3dtable_restypeid + "&resdate=" + jQuery("#uv-mapdate").siblings("input[name='mapdate']").val() + "&backend_url=" + backend_url + "&showcaptcha=" + reservationcaptcha;

					checkUvtixLeadsForm(reservationformurl, reservationformparams);
				}
			});
			/*var timeZones = {
				'America/Los_Angeles' : 15,
				'America/Mexico_City' : 15,	
				'Pacific/Pitcairn': 15,
				'Pacific/Easter': 15,
				'America/New_York': 15,
				'US/Arizona': 16,
				'US/Alaska': 14,
				'US/Central': 16,
				'US/Eastern': 15,
				'US/Hawaii': 12,
				'US/Mountain':16,
				'US/Michigan':18,
				'US/Pacific':15,
				'US/Samoa':19
				
			};
			var dateToday = new Date();
			var hours = dateToday.getHours();
			var minutes = dateToday.getMinutes();
			var tz = jstz.determine(); 
			var timezone = tz.name();*/




			/*if(hours >= timeZones[timezone] ){showform=0; }*/
		}
		else {
			reservationformparams = "type=mobile&venueid=" + uv_venueid + "&restypeid=" + request3dtable_restypeid + "&resdate=" + jQuery("#uv-mapdate").siblings("input[name='mapdate']").val() + "&backend_url=" + backend_url + "&showcaptcha=" + reservationcaptcha;

			checkUvtixLeadsForm(reservationformurl, reservationformparams);
		}

		jQuery(".list-items").html("");
		//console.log('map5');
	}
	else {
		jQuery(".list-items").html("");

		var items_list = "<li class='uv-maplistths'><div>Table/Section</div><div>Capacity</div><div>Price</div><div>View</div></li>";

		if (uv_venueid == 709478790 || uv_venueid == 709478774) //For damesngames, 
			items_list = "<li class='uvmap-listths'><div>Table/Section</div><div>Capacity</div><div>Guests</div><div>Price</div><div>View</div></li>";
		if (uv_venueid == 705663498) //For damesngames, 
			items_list = "<li class='uvmap-listths'><div>Section</div><div>Capacity</div><div>Price</div><div></div></li>";
		if (uv_venueid == 49061105) //For kaosnight, 
			items_list = "<li class='uvmap-listths'><div>Section</div><div>Guests</div><div>Price</div><div></div></li>";

		var resfromLoaded = false;

		/*
				console.log("items = "+items+"uv_venueid = "+uv_venueid);
				if(uv_venueid == 709200439)
				{
					var test_global_section_items;
					var test_section_varsinfo;
					for(testitemindex in items){	
						test_global_section_items =  items[testitemindex];
						for(j in test_global_section_items)
						{	
							test_section_varsinfo = test_global_section_items[j];
							console.log(test_section_varsinfo);
						}
						
					}
				}
		*/
		//items.sort();

		for (itemindex in items) {
			global_section_items = items[itemindex];

			var catavailable = false;
			var catitems = new Array;

			for (i in global_section_items) {
				section_varsinfo = global_section_items[i];

				section_id = section_varsinfo['section_id'];
				section_capacity = section_varsinfo['capacity'];
				section_checkoutguest = section_varsinfo['checkoutguest'];
				section_checkoutguest_state = section_varsinfo['checkoutguest_state'];
				section_checkoutdep = section_varsinfo['checkoutdep'];
				section_checkoutdep_state = section_varsinfo['checkoutdep_state'];
				section_lineorder = section_varsinfo['lineorder'];
				section_maxguests = section_varsinfo['maxguests'];
				section_overcharge = section_varsinfo['overcharge'];
				section_items = section_varsinfo['items'];
				section_id = section_id.replace(/[A-Z]/ig, "");

				let uvsendpaynow = 0;
				if (uv_venueid == 1305487216)
					uvsendpaynow = 1;

				var item_quantity = "";

				item_id = section_varsinfo['item_id'];
				item_name = escape(section_varsinfo['item_name']);
				item_catid = section_varsinfo['item_catid'];
				item_catname = section_varsinfo['item_catname'];
				item_globalcatname = section_varsinfo['item_globalcatname'];
				item_terms = section_varsinfo['item_terms'];
				item_descr = section_varsinfo['item_descr'];
				item_espoffer = section_varsinfo['item_espoffer'];
				item_deposit = section_varsinfo['item_deposit'];
				item_soldout = section_varsinfo['item_soldout'];
				item_depositperc = section_varsinfo['item_depositperc'];
				item_baseprice = section_varsinfo['item_baseprice'];
				item_image = section_varsinfo['item_image'];
				item_checkoutmin = section_varsinfo['item_checkoutmin'];
				item_checkoutmin_state = section_varsinfo['checkoutmin_state'];
				item_globaltype = section_varsinfo['item_globaltype'];
				item_mapid = section_varsinfo['item_mapid'];
				item_statename = section_varsinfo['item_statename'].toLowerCase();
				item_selecttable = section_varsinfo['item_selecttable'];
				item_state = section_varsinfo['item_state'];
				item_restypeid = section_varsinfo['item_restypeid'];
				item_allowlead = section_varsinfo['item_allowlead'];
				item_customurl = section_varsinfo['item_customurl'];
				item_secid = section_varsinfo['item_secid'];
				item_stockleft = section_varsinfo['item_stockleft'];

				if (item_baseprice < 0 || item_baseprice == "")
					item_baseprice = "FREE";

				item_sectionmultiitem = false;

				/*
						if(item_deposit != "" && section_checkoutdep_state==1)
							item_quantity = item_deposit;
						else
							item_quantity = item_baseprice;
				*/
				item_quantity = item_baseprice;


				/*Added by edsson*/
				item_baseprice = section_varsinfo["item_baseprice"];
				item_paynow = section_varsinfo["item_paynow"];
				//item_overcharge = section_varsinfo["item_overcharge"];
				item_baseovercharge = section_varsinfo["item_baseovercharge"];
				item_minimum = section_varsinfo["item_minimum"];
				item_minimumovercharge = section_varsinfo["item_minimumovercharge"];
				item_paynowovercharge = section_varsinfo["item_paynowovercharge"];
				item_currency = section_varsinfo["item_currency"];
				item_custclass = section_varsinfo["item_custclass"];
				item_custbasecore = section_varsinfo["item_custbasecore"];
				item_status = section_varsinfo["status"];
				/////////////////////	

				item_tooltipname = item_name;
				item_mapstatename = item_statename;

				if (global_section_items.length > 1) {
					item_tooltipname = item_globalcatname;
					item_mapstatename = "optional";
					//item_statename = "optional";	

					if (section_checkoutdep_state == 1 && uv_venueid != 1505807117)
						item_price = item_paynow;
					else
						item_price = item_baseprice;

					/** added by gabo **/
					/*
						Just for the venue of wynn in multiples items show the item base instead of pay now
						XS = 11066556
						Intrigue = 406544126
						EBC = 701133708
						EBC night : 405660315
						Eyecandylvwp : 47010734904
						Alibi: 1609407559
						
					*/
					if (uv_venueid == 11066556 || uv_venueid == 406544126 || uv_venueid == 701133708 || uv_venueid == 405660315 || uv_venueid == 47010734904 || uv_venueid == 49061111 || uv_venueid == 1305112235 || uv_venueid == 47010754609 || uv_venueid == 1609407559) {
						item_price = item_baseprice;
					}
					///////	


					let uvitemstate = section_varsinfo['item_statename'].toLowerCase();

					catitems.push({ name: unescape(item_name), price: item_price, selectable: item_selecttable, catname: item_globalcatname, status: uvitemstate });

					if (item_selecttable != -1 && catavailable == false)
						catavailable = true;
				}

				if (type == "desktop") {
					if (colorcoding.indexOf(item_statename) == -1) {
						colorcoding.push(item_statename);
					}

					tag_item = ".uv-map svg *[id*='S" + section_id + "I'], .uv-map svg *[id*='T" + section_id + "']";
					jQuery(tag_item).attr("status", item_mapstatename);
					jQuery(tag_item).attr("caldate", caldate);
					jQuery(tag_item).attr("item_id", item_id);
					jQuery(tag_item).attr("item_name", item_name);
					jQuery(tag_item).attr("item_image", item_image);
					jQuery(tag_item).attr("item_section_capacity", section_capacity);
					jQuery(tag_item).attr("item_section_maxguests", section_maxguests);
					jQuery(tag_item).attr("item_deposit", item_deposit);
					jQuery(tag_item).attr("item_depositperc", item_depositperc);
					jQuery(tag_item).attr("item_baseprice", item_baseprice);
					jQuery(tag_item).attr("item_cart_price", item_baseprice);
					jQuery(tag_item).attr("item_cart_capacity", section_capacity);
					jQuery(tag_item).attr("item_restypeid", item_restypeid);
					jQuery(tag_item).attr("item_sectionid", section_id);
					jQuery(tag_item).attr("item_customurl", item_customurl);
					jQuery(tag_item).attr("item_globaltype", item_globaltype);
					jQuery(tag_item).attr("item_globalcatname", item_globalcatname);
					//jQuery(tag_item).attr("overcharge", section_overcharge);

					/*Added by edsson*/
					jQuery(tag_item).attr("item_baseprice", item_baseprice);
					jQuery(tag_item).attr("item_paynow", item_paynow);
					//jQuery(tag_item).attr("item_overcharge", item_overcharge);
					jQuery(tag_item).attr("item_baseovercharge", item_baseovercharge);
					jQuery(tag_item).attr("item_minimum", item_minimum);
					jQuery(tag_item).attr("item_minimumovercharge", item_minimumovercharge);
					jQuery(tag_item).attr("item_paynowovercharge", item_paynowovercharge);
					jQuery(tag_item).attr("item_allowlead", item_allowlead);
					jQuery(tag_item).attr("item_currency", item_currency);
					/////////////////////	

					//Added by aa
					jQuery(tag_item).attr("item_stockleft", item_stockleft);

					jQuery(tag_item).attr("item_section_checkoutmin_state", item_checkoutmin_state);
					jQuery(tag_item).attr("item_section_checkoutdep_state", section_checkoutdep_state);
					jQuery(tag_item).attr("item_section_checkoutguest_state", section_checkoutguest_state);

					jQuery(tag_item).attr("item_layout_type", layouttype);

					/***
						added by gabo pay now 
						uv_venueid==49061111   palmspearl
					***/
					if (uv_venueid == 49061111) {
						item_quantity = item_paynow;
					}
					/***
						Remove the price of venue on the inquiries only
						uv_venueid==47010742031 jemaapool
					***/
					if (item_statename == "inquiries only" && uv_venueid == 47010742031) {
						item_quantity = "";
					}

					/***
							Remove the price of venue on the inquiries only
							blossommgm
						***/
					if (item_statename == "inquiries only" && uv_venueid == 1505718062) {
						item_quantity = "";
					}

					/* eliabeachclub */
					if (item_selecttable == -1 && uv_venueid == 1305187588) {
						item_quantity = "";
						item_mapstatename = "Unavailable";

					}

					/******/
					if (global_section_items.length == 1) {
						if (uvsendpaynow) {
							createTooltip(tag_item, item_statename, item_name, item_quantity, item_selecttable, "", "", "", item_paynow);
						} else {
							createTooltip(tag_item, item_mapstatename, item_tooltipname, item_quantity, item_selecttable, "", "");
						}
					}
				}

				if (
					item_statename == "inquiries only" ||
					(
						(uv_venueid == 1305111780 || uv_venueid == 1305112235) &&
						global_section_items.findIndex(item => item.item_statename == 'Inquiries Only') >= 0 &&
						global_section_items.filter(item => item.item_selecttable == '1').length > 0
					)
				) {
					tag_item = ".uv-map svg *[id*='S" + section_id + "I'], .uv-map svg *[id*='T" + section_id + "']";
					if (resfromLoaded == false) {
						resfromLoaded = true;
						reservationformparams = "type=mobile&venueid=" + uv_venueid + "&restypeid=" + request3dtable_restypeid + "&resdate=" + jQuery("#uv-mapdate").siblings("input[name='mapdate']").val() + "&backend_url=" + backend_url + "&showcaptcha=" + reservationcaptcha;


						//if(uv_venueid != 3202320913)
						checkUvtixLeadsForm(reservationformurl, reservationformparams);
					}
					jQuery(tag_item).attr("item_id", item_id);
					if (global_section_items.length < 1)
						jQuery(tag_item).attr("status", "resinquiry");
					jQuery(tag_item).attr("item_image", item_image);
					jQuery(tag_item).attr("item_name", item_name);
					itemDescr_arr[item_id] = item_descr;
					itemOff_arr[item_id] = item_espoffer;
					if (type == "desktop") {
						if (colorcoding.indexOf(item_statename) == -1) {
							colorcoding.push(item_statename);
						}

						if (global_section_items.length == 1){
							createTooltip(tag_item, "inquiries only", item_tooltipname, item_quantity);
						}
					}

					//continue;
				}

				itemTerms_arr[item_id] = item_terms;
				itemDescr_arr[item_id] = item_descr;
				itemOff_arr[item_id] = item_espoffer;

				item_status = item_statename;
				item_lbl_status = item_status;

				if ((typeof (hide_soldtables) == "undefined") || (typeof (hide_soldtables) != "undefined" && hide_soldtables == true && (item_status == "available" || item_status == "inquiries only" || item_status == "optional"))) {

					item_list_status = item_status;
					if (item_status == "inquiries only")
						item_list_status = "resinquiry";

					// if BESO venue
					let uv_addtablecontent = 0;
					if (uv_venueid == 1305487216)
						uv_addtablecontent = 1;

					item_list_iquiryonly = "";
					if (item_selecttable == -1) {
						item_list_iquiryonly = "uv-inquiry-only";
					}

					const uvbasepriceHTML = (uv_addtablecontent) ? `<div class='uvlabelprice uv-baseprice-label'>F&B Minimum</div><div class='uvprice uv-base-price'>${item_quantity}</div>` : item_quantity;
					const uvpaynowHTML = (uv_addtablecontent) ? `<div class='uvlabelprice uv-paynow-label'>Pay Now</div><div class='uvprice uv-paynow-price'>${item_paynow}</div>` : "";

					items_list += "<li class='uv-mapopentable uv-mapopentable-list" + item_custclass + " " + item_list_status + " " + item_list_iquiryonly + "' item_id='" + item_id + "' item_name='" + item_name + "' status='" + item_list_status + "' item_image='" + item_image + "' caldate='" + caldate + "' item_section_capacity='" + section_capacity + "' item_section_maxguests='" + section_maxguests + "' item_section_checkoutmin_state='" + item_checkoutmin_state + "' item_section_checkoutdep_state='" + section_checkoutdep_state + "' item_section_checkoutguest_state='" + section_checkoutguest_state + "' item_deposit='" + item_deposit + "' item_depositperc='" + item_depositperc + "' item_layout_type='" + layouttype + "' item_baseprice='" + item_baseprice + "' overcharge='" + section_overcharge + "' item_baseprice='" + item_baseprice + "' item_paynow='" + item_paynow + "' item_baseovercharge='" + item_baseovercharge + "' item_minimum='" + item_minimum + "' item_minimumovercharge='" + item_minimumovercharge + "' item_paynowovercharge='" + item_paynowovercharge + "' item_cart_price='" + item_baseprice + "' item_cart_capacity='" + section_capacity + "' item_customurl='" + item_customurl + "' item_restypeid='" + item_restypeid + "' item_allowlead='" + item_allowlead + "' item_currency='" + item_currency + "' item_sectionid='" + section_id + "' item_custcorep='" + item_custbasecore + "' item_stockleft='" + item_stockleft + "' item_globaltype='" + item_globaltype + "'>";

					if (item_selecttable > 0) {
						if (stateValues.indexOf(parseInt(item_state)) >= 0) {
							items_list += "	<div class='uv-listitemname'>" + unescape(item_name) + "</div>";
							if (uv_venueid == 709719071 || uv_venueid == 7012342324) {
								section_capacity = section_maxguests;
							}
							items_list += "	<div class='uv-listitemcapacity test-1'>" + section_capacity + "</div>";

							if (uv_venueid == 709478790 || uv_venueid == 709478774) //For damesngames, 
								items_list += "	<div class='uv-listitemmaxguests'>" + section_maxguests + "</div>";

							if (uv_venueid == 1505718062 && shortdate == "190607" && item_status == "inquiries only")
								items_list += "	<div class='uv-listitemdeposit'>-</div>";
							else {
								if (UV2hidePrices.indexOf(parseInt(uv_venueid)) >= 0 && item_status == "inquiries only")
									items_list += "	<div class='uv-listitemdeposit'>-</div>";
								else if (uv_venueid == 1305111780 && item_quantity == 'FREE')
									items_list += "	<div class='uv-listitemdeposit'>-</div>";
								else if (uv_venueid == 1305112235 && item_quantity == 'FREE')
									items_list += "	<div class='uv-listitemdeposit'>-</div>";
								else
									items_list += "	<div class='uv-listitemdeposit'>" + uvbasepriceHTML + uvpaynowHTML + "</div>";
							}

							if (item_status == "inquiries only") {
								var item_status_label = 'Inquiry Only';
								if (uv_venueid == 709319804 || uv_venueid == 709363062 || uv_venueid == 47010742012) //SLS
									item_status_label = 'Reservation Request';
								if (uv_venueid == 705020730) //Stampede
									item_status_label = 'Inquire';

								items_list += "	<div class='uv-listitemview'><button style='font-size:12px'>" + item_status_label + "</button></div>";
							}
							else
								items_list += "	<div class='uv-listitemview'><button>Book</button></div>";

						}
					} else if (item_selecttable < 0) {
						if (stateValues.indexOf(parseInt(item_state)) >= 0) {
							items_list += "	<div class='uv-listitemname'>" + unescape(item_name) + "</div>";
							items_list += "	<div class='uv-listitemcapacity test-2'>" + section_capacity + "</div>";

							if (uv_venueid == 709478790 || uv_venueid == 709478774) //For damesngames, 
								items_list += "	<div class='uv-listitemmaxguests'>" + section_maxguests + "</div>";

							item_statename_lbl = item_statename.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });
							//items_list += "	<div class='uv-listitemstatename'><small class='text-danger'>"+item_statename_lbl+"</small></div>";
							if (UV2hidePrices.indexOf(parseInt(uv_venueid) >= 0)) {
								var item_list_label = 'Inquiries Only';
								if (uv_venueid == 709319804 || uv_venueid == 709363062)
									item_list_label = 'Reservation Request';

								items_list += "	<div class='uv-listitemdeposit uv-inquiry-only'>" + item_list_label + "</div>";
							}
							else if (UV2hidePrices.indexOf(parseInt(uv_venueid) == -1))
								items_list += "	<div class='uv-listitemdeposit'>" + item_quantity + "</div>";
							items_list += "	<div class='uv-listitemview'></div>";
							if (type == "desktop" && item_status != "inquiries only")
								jQuery(tag_item).attr("status", "item_unavailable");
						}
					}

					items_list += "</li>";
				}
			}

			if (global_section_items.length > 1) {
				if (catavailable == false)
					jQuery(tag_item).attr("status", "sold");
				
				createTooltip(tag_item, item_mapstatename, item_tooltipname, item_quantity, catavailable, catitems);
			}
		}

		if (type == "desktop") {
			if (colorcoding.indexOf("unavailable") == -1)
				colorcoding.push("unavailable");
			createTooltip(".uv-map svg *[status='item_unavailable']", "unavailable");
			if (colorcoding.length > 0 && mapcolorcoding == true) {
				colorcoding.sort();
				jQuery(".uv-colorcoding ul").html("");
				for (var i = 0; i < colorcoding.length; i++) {
					code = colorcoding[i];
					code = code.replace(" ", "-");
					if (code == "unavailable" && uv_venueid == "1305111780")
						jQuery(".uv-colorcoding ul").append("<li class='" + code + "'><i class='fa fa-square'></i> sold out</li>");
					else
						jQuery(".uv-colorcoding ul").append("<li class='" + code + "'><i class='fa fa-square'></i> " + colorcoding[i] + "</li>");

				}
				jQuery(".uv-colorcoding").removeClass("uv-hidden");
			}
		}

		jQuery(".list-items").html(items_list);
	}

	jQuery(document).find(".uv-mapdesktop .item_section.uv-mapopentable[status='available'], .uv-mapopentable.uv-mapopentable-list[status='available'] .uv-listitemview").on('click', function (e) {
		selectItem(jQuery(this));
	});

	pop_loader.hide();
}

function uv_getimage(flyers, imagetype, imageratio) {
	aux = 0;

	fly_return = [];

	for (index in flyers) {
		flyer = flyers[index];

		if (aux == 0) {
			fly_return["folder"] = flyer['flyer_folder'];
			fly_return["file"] = flyer['flyer_file'];
			fly_return["flyer_type"] = flyer['flyer_type'];
			fly_return["flyer_ratio"] = flyer['flyer_ratio'];
		}

		var regex = new RegExp(flyer["flyer_type"]);
		match = regex.exec(imagetype);
		if (match != null) {
			fly_return["folder"] = flyer['flyer_folder'];
			fly_return["file"] = flyer['flyer_file'];
			fly_return["flyer_type"] = flyer['flyer_type'];
			fly_return["flyer_ratio"] = flyer['flyer_ratio'];
		}

		var regex = new RegExp(flyer["flyer_type"]);
		match = regex.exec(imagetype);
		var regex2 = new RegExp(flyer["flyer_ratio"]);
		match2 = regex2.exec(imageratio);

		if (match != null && match2 != null) {
			fly_return["folder"] = flyer['flyer_folder'];
			fly_return["file"] = flyer['flyer_file'];
			fly_return["flyer_type"] = flyer['flyer_type'];
			fly_return["flyer_ratio"] = flyer['flyer_ratio'];

			break;
		}

		aux++;
	}

	return fly_return;
}

/**
  * Function to replace purchase button with a link that will redirect to an external tickets site
  * @params:
  *   - ticketsurl: URL of the external tickets, this url comes from the ticketsurl var on the events feed.
  *   - popup: Object that has the html content of the popup
  * @return: popup object
  *
  * Author: Lizy
  */
function replace_purchase_button(ticketsurl, popup) {
	if (typeof (ticketsurl) != "undefined" && ticketsurl != "") {
		btn_bgcolor = jQuery(popup).find(".uv-popbody #uvtix_tablepurchase").css("background-color");
		btn_color = jQuery(popup).find(".uv-popbody #uvtix_tablepurchase").css("color");

		jQuery(popup).find(".uv-popbody #uvtix_tablepurchase").hide();
		jQuery(popup).find(".uv-popbody #uvtix_tablepurchase").after("<a class='btn btn-block uv-btngrad' href='" + ticketsurl + "' target='_blank' style='background-color:" + btn_bgcolor + ";color:" + btn_color + "'>PURCHASE</a>");
		jQuery(popup).find(".uv-popbody #uvtix_tablepurchase").remove();
	}

	return popup;
}

/**
  * Function updateCart()
  * @descr: Each a user add a table to the cart, this is updated changing the items list and count
  * Author: Lizy
  */
function updateCart() {
	var uvcartcaplabel = (uv_venueid == "1305112235") ? "Qty" : "Capacity";

	var str_list_header = '<li class="uv-maplistths uv-maplistheader"><div>Table</div><div>' + uvcartcaplabel + '</div><div>Price</div><div>Remove</div></li>';
	var str_list_content = str_list_header;

	var total = 0;
	var str_items = "";
	var str_capacities = "";

	if (UVtablercart.length > 0) {
		jQuery(".uv-map-cart-count").text(UVtablercart.length);

		for (var i in UVtablercart) {
			item_id = UVtablercart[i];

			item_obj = jQuery(document).find("*[item_id='" + item_id + "']");

			item_name = unescape(jQuery(item_obj).attr("item_name"));
			item_capacity = jQuery(item_obj).attr("item_cart_capacity");
			item_price = jQuery(item_obj).attr("item_cart_price");
			item_sectionid = jQuery(item_obj).attr("item_sectionid");

			if (uv_venueid == "1305112235") {
				item_price = UVtablercprices[i];

				item_price = item_price / 100;
				item_price = '$' + parseInt(item_price).formatMoney(2, ',', '.');
				item_price = item_price.replace(/\.(\d+)/, ".<span>$1</span>");

				item_price_fmt = UVtablercprices[i];
				item_price_fmt = item_price_fmt / 1;
				total = total + item_price_fmt;
			}
			else {
				item_price_fmt = parseInt(item_price.replace("$", "").replace(".", ""));
				total = total + item_price_fmt;
			}

			if (uv_venueid == "1305112235")
				var uvitemcapdisplay = UVtablercqtys[i];
			else
				var uvitemcapdisplay = item_capacity;

			str_list_content += '' +
				'<li>' +
				'	<div class="uv-listitemname">' + item_name + '</div>' +
				'	<div class="uv-listitemcapacity test-3">' + uvitemcapdisplay + '</div>' +
				'	<div class="uv-listitemdeposit">' + item_price + '</div>' +
				'	<div class="uv-listitemview"><button data-itemid="' + item_id + '" data-cart-ref="S' + item_sectionid + 'I"><i class="fa fa-times"></i></button></div>' +
				'</li>';

			str_items += item_id + "_";

			if (uv_venueid == "1305112235") {
				if (uvitemcapdisplay >= item_capacity)
					str_capacities += uvitemcapdisplay + "_";
				else
					str_capacities += item_capacity + "_";
			}
			else
				str_capacities += item_capacity + "_";
		}

		if (str_items.length > 0)
			str_items = str_items.slice(0, -1);
		if (str_capacities.length > 0)
			str_capacities = str_capacities.slice(0, -1);

		if (total > 0)
			total = (total / 100).toFixed(2);

		str_list_content += '' +
			'<li class="uv-maplistths uv-cart-total">' +
			'	<div class="uv-listitemname">Total:</div>' +
			'	<div class="uv-listitemcapacity test-4"></div>' +
			'	<div class="uv-listitemdeposit">$' + total + '</div>' +
			'	<div class="uv-listitemview"><button id="uvtix_tablecart_checkout" data-uvtix-item="' + str_items + '" data-uvtix-capacity="' + str_capacities + '"><i class="fa fa-spinner fa-spin uv-hidden checkout-loader"></i> Checkout</button></div>' +
			'</li>';
	}
	else {
		jQuery(".uv-map-cart-count").text(0);

		str_list_content += "<li class='text-center' style='padding:5px;padding-bottom:0px;display:block;font-size:12px;'><span class='text-danger'>Your shopping cart is empty.</span></li>";
	}

	jQuery(".list-items-cart").html(str_list_content);

}

/**
  * Function emptyCart()
  * @descr: Empty Actual Cart
  * Author: Lizy
  */
function emptyCart() {
	UVtablercart = new Array();
	UVtablercqtys = new Array();
	UVtablercprices = new Array();

	updateCart();
}

/**
  * Function animateCart()
  * @descr: Animation to send the popup to the cart icon and update the cart count
  * Author: Lizy
  */
function animateCart() {
	jQuery("body").scrollTop(0);

	//Animation Add to Cart
	var box_x = jQuery(".uv-map-cart-info").offset().left;
	var box_y = jQuery(".uv-map-cart-info").offset().top;

	jQuery(".uv-popmap").addClass("uv-map-cart-pop-animation");
	jQuery(".uv-popmap .pop-charge").append("<div class='uv-map-cart-added-animation'><i class='fa fa-shopping-cart'></i></div>");
	jQuery(".uv-popmap .pop-charge").animate({
		left: box_x,
		top: box_y
	}, 300, function () {
		jQuery(pop_up).fadeOut(0);
		hidePop();

		jQuery(".uv-popmap").removeClass("uv-map-cart-pop-animation");

		jQuery(".uv-map-cart-info").addClass("animate-item-added");


		updateCart();


	});

}

/**
  * Function touchStart()
  * @descr: Get the initial cordenates of the first click
  * Author: Lizy
  */
function touchStart(e) {
	var targetTouches = e.targetTouches;

	if (targetTouches.length == 2) {
		uvmapPinchMouseMapX = targetTouches[0].pageX - uvmapPinchStartMapX;
		uvmapPinchMouseMapY = targetTouches[0].pageY - uvmapPinchStartMapY;
	}

	mouse_pos_X = event.targetTouches[0].pageX;
	mouse_pos_Y = event.targetTouches[0].pageY;

	jQuery("#uvmap-map").offset({ left: jQuery("#uvmap-map").offset().left });
	jQuery("#uvmap-map").offset({ top: jQuery("#uvmap-map").offset().top });

	element_pos_X = parseInt(jQuery("#uvmap-map").offset().left);
	element_pos_Y = parseInt(jQuery("#uvmap-map").offset().top);

	uvmapPinchAllowMapMove = true;
}

function doubleTapHolder() {
	setTimeout(function () {
		jQuery(document).find(".mapmobile-svg .uvmap-map-container .item_section.uv-mapopentable[status='available']").each(function () {
			var jqueryElement = jQuery(this);

			var element = document.getElementById(jQuery(jqueryElement).attr("id"));

			initHammer(element, jqueryElement, "single");
		});

		var mapContainer = document.querySelector(".mapmobile-svg .uvmap-map-container");
		var jqueryMapContainer = jQuery(".mapmobile-svg .uvmap-map-container");

		initHammer(mapContainer, jqueryMapContainer, "double");
	}, 1000);
}

function initHammer(element, jqueryElement, tap) {
	var mc = new Hammer.Manager(element);

	mc.add(new Hammer.Tap({ event: 'doubletap', taps: 2 }));
	mc.add(new Hammer.Tap({ event: 'singletap' }));

	mc.get('doubletap').recognizeWith('singletap');
	mc.get('singletap').requireFailure('doubletap');

	if (tap == "single") {
		mc.on("singletap", function (ev) {
			selectItem(jQuery(jqueryElement));
		});
	}
	if (tap == "double") {
		mc.on("doubletap", function (ev) {
			touchDoubleTap(ev);
		});
	}
}
/**
  * Function touchDoubleTap()
  * @descr: Get the initial cordenates of the first click
  * Author: Lizy
  */
function touchDoubleTap(e) {
	//action on double tap goes below
	var xScreen = 0;
	var yScreen = 0;
	var newScale = 1;

	if (jQuery("#uvmap-map").hasClass("zoomin"))
		jQuery("#uvmap-map").removeClass("zoomin");
	else {
		jQuery("#uvmap-map").addClass("zoomin");
		xScreen = e.center.x - jQuery("#uvmap-map").offset().left;
		yScreen = e.center.y - jQuery("#uvmap-map").offset().top;
		newScale = 3;
	}

	jQuery(document).find(".mapmobile-svg .uvmap-map-container .uvmap-map").css('transform-origin', xScreen + 'px ' + yScreen + 'px');
	jQuery(document).find(".mapmobile-svg .uvmap-map-container .uvmap-map").css('transform', 'scale(' + newScale + ')');
}

/**
  * Function touchMove()
  * @descr: This function gaves the option to move the map in x,y(if the move is with one finger), or make a zoom if the the move is with 2 fingers
  * Author: Lizy
  */

function touchMove(e) {
	var targetTouches = e.targetTouches;

	if (uvmapPinchNewZoom > 1) {
		jQuery(".uvmap-map-reset").fadeIn(0);
	}

	if (targetTouches.length == 2) {
		var coef = 1.02;

		if (uvmapPinchNewZoom < 4) {
			oz = uvmapPinchCurrentLocation.zoom;
			uvmapPinchNewZoom = (uvmapPinchCurrentLocation.zoom *= coef);

			/// calculate click at current zoom
			ix = (uvmapPinchMouseMapX - uvmapPinchCurrentLocation.x) / oz;
			iy = (uvmapPinchMouseMapY - uvmapPinchCurrentLocation.y) / oz;

			/// calculate click at new zoom        
			nx = ix * uvmapPinchNewZoom;
			ny = iy * uvmapPinchNewZoom;

			/// move to the difference
			cx = (uvmapPinchCurrentLocation.x = ix - nx);
			cy = (uvmapPinchCurrentLocation.y = iy - ny);

			/// make sure we translate before scale!
			jQuery(document).find(".mapmobile-svg .uvmap-map-container .uvmap-map").css("transform", "translate(" + cx + "px, " + cy + "px) scale(" + uvmapPinchNewZoom + ")");
		}

		uvmapPinchAllowMapMove = false;
	}
	else if (targetTouches.length == 1 && uvmapPinchAllowMapMove == true && uvmapPinchNewZoom > 1) {

		current_mouse_pos_X = targetTouches[0].pageX;
		current_mouse_pos_Y = targetTouches[0].pageY;

		new_position_X = parseInt(element_pos_X + current_mouse_pos_X - mouse_pos_X);
		new_position_Y = parseInt(element_pos_Y + current_mouse_pos_Y - mouse_pos_Y);
		jQuery("#uvmap-map").offset({
			left: new_position_X,
			top: new_position_Y
		});
	}
}


/**
  * Function getTouchDistance()
  * @descr: This function get the distance between the pinch zoom
  * @return: distance
  * Author: Lizy
  */
function getTouchDistance(event) {
	tmp_dist = Math.sqrt(
		(event.targetTouches[0].pageX - event.targetTouches[1].pageX) * (event.targetTouches[0].pageX - event.targetTouches[1].pageX) +
		(event.targetTouches[0].pageY - event.targetTouches[1].pageY) * (event.targetTouches[0].pageY - event.targetTouches[1].pageY)
	);

	return tmp_dist;
}

createTooltip = function (element, item_type, item_name, item_baseprice, item_selecttable, items_list, layout_descr, item_specific_hideprice, item_paynow = "") {
	

	if (typeof (items_list) == "undefined")
		items_list = "";
	if (typeof (layout_descr) == "undefined")
		layout_descr = "";
	if (typeof (item_specific_hideprice) == "undefined")
		item_specific_hideprice = false;

	tooltip_content = "";
	item_name = unescape(item_name);

	item_type_lbl = item_type.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });

	if (item_type == "unavailable") {
		tooltip_content = "<div class='tooltip-custom'><div class='tooltip-custom-title'><h4 stlye='margin-top:-20px;'>Unavailable</h4></div></div>";

		if (uv_venueid == 16010746226 && shortdate == "190811") {
			tooltip_content = "<div class='tooltip-custom uv-inquiry-only-custom'><div class='tooltip-custom-content text-center' style='padding-top: 10px;'><span>For reservations please<br/>call 813-265-1234 ext. 2<br/>or<br/>text 813-786-1300</span>";
		}
	} else if (item_type == "resinquiry") {
		var tooltip_label = 'Reservation Inquiry';
		if (uv_venueid == 709319804 || uv_venueid == 709363062) //SLS
			tooltip_label = 'Reservation Request';

		if (uv_venueid == 1305197965) //godfreyhoteltampa
			tooltip_label = 'Reservation Request';

		tooltip_content = "<div class='tooltip-custom'><div class='tooltip-custom-title'><h4>" + tooltip_label + "</h4></div></div>";

	} else if (item_type == "inquiries only") {
		var tooltip_label = 'Inquiries Only';
		if (uv_venueid == 709319804 || uv_venueid == 709363062) //SLS
			tooltip_label = 'Reservation Request';

		tooltip_content = "<div class='tooltip-custom uv-inquiry-only-custom'><div class='tooltip-custom-title'><h4>" + item_name + "</h4></div><div class='tooltip-custom-content'><span class='pull-right text-success' style='padding-left:10px;'><i class='fa fa-check text-success'></i> " + tooltip_label + "</span>";

		if (uv_venueid == 1505718062 && shortdate == "190607")
			tooltip_content += "<span class='pull-left '></span>";
		else if (UV2hidePrices.indexOf(parseInt(uv_venueid)) !== -1 || item_specific_hideprice)
			tooltip_content += "<span class='pull-left '></span>";
		else
			tooltip_content += "<span class='pull-left '> " + item_baseprice + "</span>";
		tooltip_content += "<div class='clearfix'></div></div></div>";

	} else if (item_type == "optional") {

		if (uv_venueid == 1305111780 || uv_venueid == 1305112235) {
			tooltip_content = "<div class='tooltip-custom'><div class='tooltip-custom-title'><h4 stlye='margin-top:-20px;'>" + item_name + "</h4></div></div>";
		} else {
			tooltip_content = "<div class='tooltip-custom'><div class='tooltip-custom-title'><h4 stlye='margin-top:-20px;'>" + item_name + "</h4></div></div><div class='tooltip-custom-content'>";

			if (item_selecttable == false)
				tooltip_content += "<span class='pull-right text-danger'><i class='fa fa-times'></i> Sold</span>";
			else {
				if (items_list != "") {
					for (i in items_list) {
						item_catname = items_list[i].catname;
						item_name = items_list[i].name;
						item_price = items_list[i].price;
						item_selectable = items_list[i].selectable;
						item_status = items_list[i].status;

						if (uv_venueid != 1505807117) {
							item_name = item_name.replace(item_catname, "");
							item_name = item_name.replace("&#40;", "");
							item_name = item_name.replace("&#41;", "");
						}

						//hide price tooltip
						if ((uv_venueid == 11066556 && (item_type == 'sold out' || item_type == 'soldout' || item_type == '' || item_status == 'inquiries only'))) {

							item_price = '';
						}

						if (item_selectable == "-1") {
							type_class = "text-danger";
							type_icon = "fa fa-times";
						}
						else {
							type_class = "text-success";
							type_icon = "fa fa-check";
						}

						var tabdefpadd = "padding:5px;";
						if (uv_venueid == 45010774410)
							tabdefpadd = "";

						tooltip_content += "<table style='width:100%;'><tr><td style='" + tabdefpadd + "' nowrap><span class='pull-left'>" + item_name + "</span></td><td  style='" + tabdefpadd + "' nowrap><span class='pull-right " + type_class + "'><i class='" + type_icon + " " + type_class + "'></i> ";

						if (item_specific_hideprice == false)
							tooltip_content += item_price;

						tooltip_content += "</span></td></tr></table>";
					}
				}
				else
					tooltip_content += "<span class='pull-right' style='font-style:italic'>click for more info</span>";
			}


			tooltip_content += "<div class='clearfix'></div></div></div>";
		}
	} else if (item_type == "layout-view") {

		var layout_extra_html = '';
		if (layout_descr)
			layout_extra_html += '<div style="margin-bottom: 10px;">' + layout_descr + '</div>';

		tooltip_content = "<div class='tooltip-custom'><div class='tooltip-custom-title'><h4 stlye='margin-top:-20px;'>" + item_name + "</h4>" + layout_extra_html + "</div></div>";

	} else {
		var type_class = type_icon = "";
		if (item_selecttable > 0) {
			type_class = "text-success";
			type_icon = "fa fa-check";
		} else if (item_selecttable < 0) {
			type_class = "text-danger";
			type_icon = "fa fa-times";
		}

		if (item_type == "sold" && UV2hidePrices.indexOf(parseInt(uv_venueid)) >= 0)
			item_baseprice = "";
		if (item_type == "sold" && (uv_venueid == 1505790580 || uv_venueid == 49061105 || uv_venueid == 45010349763))
			item_baseprice = "";
		if (item_type == "not released" && (uv_venueid == 1305112235 || uv_venueid == 1305111780))
			item_baseprice = "";
		if (item_type == "not released" && (uv_venueid == 1305112235))
			item_type_lbl = "Reserved";

		// if BESO venue
		let uv_addmapcontent = 0;
		if (uv_venueid == 1305487216)
			uv_addmapcontent = 1;

		const uvbasepriceHTML = (uv_addmapcontent) ? `<div class='uvlabelprice uv-baseprice-label'>F&B Minimum</div><div class='uvprice uv-base-price'>${item_baseprice}</div>` : item_baseprice;
		const uvpaynowHTML = (uv_addmapcontent) ? `<div class='uvlabelprice uv-paynow-label'>Pay Now</div><div class='uvprice uv-paynow-price'>${item_paynow}</div>` : "";

		tooltip_content = "<div class='holi tooltip-custom'><div class='tooltip-custom-title'><h4>" + item_name + "</h4></div><div class='tooltip-custom-content'><span class='pull-left'>" + uvbasepriceHTML + uvpaynowHTML + "</span><span class='pull-right " + type_class + "'><i class='" + type_icon + " " + type_class + "'></i> " + item_type_lbl + "</span><div class='clearfix'></div></div></div>";
	}

	var extra_dates_html = '';
	var disableDates = $(element).attr('disabledates');
	var disableLabel = $(element).attr('disablelabel');
	var enableDates = $(element).attr('enabledates');
	var enableLabel = $(element).attr('enablelabel');

	if (!disableDates) {
		disableDates = $(element).find('g[disabledates]').attr('disabledates');
		disableLabel = $(element).find('g[disabledates]').attr('disablelabel');
	}
	if (!enableDates) {
		enableDates = $(element).find('g[enabledates]').attr('enabledates');
		enableLabel = $(element).find('g[enabledates]').attr('enablelabel');
	}
	var currentDate = jQuery("#uv-mapdate").siblings("input[name='mapdate']").val();

	if (enableDates && enableDates.indexOf(currentDate) !== -1 && enableLabel) {
		extra_dates_html += '<div style="margin-bottom: 10px;" class="tooltip-disable-dates-label">' + enableLabel + '</div>';
	} else if (disableDates && disableDates.indexOf(currentDate) !== -1 && disableLabel) {
		extra_dates_html += '<div style="margin-bottom: 10px;" class="tooltip-disable-dates-label">' + disableLabel + '</div>';
	}

	tooltip_content += extra_dates_html;

	params = {
		container: 'body',
		placement: 'top',
		title: tooltip_content,
		html: true
	};

	if (jQuery(element).parents(".global_section").size() > 0 && item_type != "Unavailable") {
		jQuery(element).parents(".global_section").tooltip(params);
	} else {
		jQuery(element).tooltip(params);
		/*
if(jQuery(element).parents("g").find("text").size()>0){
			jQuery(element).parents("g").find("text").tooltip(params);	
		}
*/
	}
	
}

function cleanCache() {
	uvmapMapMobCacheIds = [];
	uvmapMapMobCacheCont = [];
	uvmapMapMobCacheRoom = [];
}

function checkUvtixLeadsForm(resFormUrl, resFormParams) {
	if (uvtixleads == true) {
		loadUvtixLeadsForm('inline', resFormParams);
	}
	else {
		jQuery(".uv-res3dform").load(resFormUrl + "?" + resFormParams);
	}
}

function loadUvtixLeadsForm(type, params) {
	var load_item_info = false;
	var tokenparam = 'uv' + uv_venueid + 'dt' + shortdate;
	var resdate = '';

	if (uvveavenueid)
		tokenparam += 've' + uvveavenueid;

	if (roomid)
		tokenparam += 'rm' + roomid;

	var regex = /itemleadid=([0-9]+)\&/gi;
	var matchs = regex.exec(params);

	if (matchs != null) {
		tokenparam += 'it' + matchs[1];

		var element = jQuery('*[item_id="' + matchs[1] + '"]')[0];
		var it_image = jQuery(element).attr("item_image");
		var it_id = jQuery(element).attr("item_id");
		var it_customurl = jQuery(element).attr("item_customurl");
		var it_name = jQuery(element).attr("item_name");
		var it_sectionid = jQuery(element).attr("item_sectionid");

		var it_descr = "";

		if (typeof (itemDescr_arr) != "undefined")
			it_descr = itemDescr_arr[it_id];

		if (it_image) {
			big_image = it_image.replace("raw", "975SC650");
			small_image = it_image.replace("raw", "390SC260");
		}

		var item_descr_short = "";

		if (it_descr) {
			limit = 500;
			if (it_descr[limit] == "<")
				limit--;
			else if (it_descr[limit] == ">")
				limit++;

			item_descr_short = it_descr.substring(0, limit);

			if (it_descr.length <= 500)
				showmore = "";
			else
				showmore = "... <a href='javascript:;' class='uv-showinfo inquiry' data-target='.uv-fulltabledescr' data-title='Table Description'>more</a>";

			item_descr_short += showmore;
		}

		if (it_sectionid) {
			if (typeof (uvmapCustomItemLeads[it_sectionid]) != 'undefined' && uvmapCustomItemLeads[it_sectionid] != '0')
				uvmapGlobalTypeId = uvmapCustomItemLeads[it_sectionid];
		}

		load_item_info = true;
	}

	var regex = /resdate=([0-9|-]+)\&/gi;
	var matchs = regex.exec(params);

	if (matchs != null)
		resdate = matchs[1];

	if (type == 'popup') {
		var leadtypecustomname = "";
		if ((uv_venueid == 1505718062 || uv_venueid == 1505718056) && false) {
			//Custom Popup Message  
			if (uv_venueid == 1505718062)
				uvDisplayMsg("For table reservations please email <a href='mailto:blossom@mgmnationalharbor.com'>blossom@mgmnationalharbor.com</a>", "Reservations");
			else if (uv_venueid == 1505718056)
				uvDisplayMsg("For table reservations please email <a href='mailto:felt@mgmnationalharbor.com'>felt@mgmnationalharbor.com</a>", "Reservations");
		}
		else {

			if (uv_venueid == 1305197965) {
				//godfreyhoteltampa custom name and trigger leadtype
				var regextable = /tableid=([0-9]+)\&/gi;
				var matchstable = regextable.exec(params);
				console.log("matchstable = " + matchstable[1]);
				var elementtable = jQuery('*[id="S' + matchstable[1] + 'I"]')[0];
				var it_leadtypeid = jQuery(elementtable).find("g").attr("data-leadtypeid");

				var it_leadtypename = jQuery(elementtable).find("g").attr("data-leadtypename");
				if (it_leadtypename)
					leadtypecustomname = encodeURIComponent(it_leadtypename);
			}
			expandPop(800);
			loadPop("//uvtix.com/websites/ln_core/uvcore/uvinquiry.php?token=" + tokenparam + "&urvenueid=" + uv_venueid + "&resdate=" + resdate + "&clientid=" + uvmapclientid + "&leadtypeid=" + uvmapGlobalTypeId + "&leadtypecustomname=" + leadtypecustomname, function () {
				jQuery(".uv-popinquiry").parent().find(".uv-popheader h3").css({
					"color": "#fff",
					"margin-top": "-10px",
					"margin-bottom": "0px",
					"text-transform": "uppercase"
				});
				jQuery(".uv-popinquiry .form-success-message .message").css({
					"background": "transparent",
					"border": "none",
					"padding": "10px 0px",
					"font-size": "14px",
					"color": "#0f9ee2"
				});

				jQuery(".uv-popinquiry .text-area").css({
					"color": "#636363"
				});

				jQuery(".uv-popinquiry .btn-request-submit").css({
					"border": "none",
					"font-family": "inherit"
				});

				jQuery(".uv-popinquiry .form-success-message .message.success").css("color", "#0f9ee2");
				jQuery(".uv-popinquiry .form-success-message .message.danger").css("color", "#ff5c5c");


				if (uv_venueid == 1305197965) {
					//godfreyhoteltampa custom name and trigger leadtype
					jQuery("#leadtypeid [value=section-" + it_leadtypeid + "]").prop('selected', true).trigger('change');
				}

				if (load_item_info) {
					var uvdescrbelowhtml = (uv_venueid == "1305111780" || uv_venueid == 1305112235) ? "<div><p>Still Have Some Questions? Please fill in the Inquiry Form below!</p></div>" : "";

					if (it_customurl && it_customurl != null && it_customurl != 'null')
						jQuery(document).find('.uv-popmap .uv-popinquiry').find('form').before('<div class="row reservation-form-tableinfo"><div class="uv-poptableinfo" style="padding-left:15px;padding-bottom:20px;"><div class="uv-imgresponsivecont uv-map360orbig uv-isloading"><img src="' + small_image + '" onload="jQuery(this).parent().removeClass(\'uv-isloading\');"><div class="uv-mapimgopts uv-clearfix"><div><a href="' + big_image + '" class="uv-popimg"><button class="uv-btniconmaxi"><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" x="0px" y="0px" viewBox="0 0 100 125"><g transform="translate(0,-952.36218)"><path style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;opacity:1;color:#000000;fill:#000000;fill-opacity:1;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" d="M 49.78125 6 A 2.0002 2.0002 0 0 0 48.59375 6.5625 L 34.59375 20.5625 A 2.0002 2.0002 0 1 0 37.40625 23.40625 L 48 12.8125 L 48 40 C 47.98506 41.05663 48.943269 42.03125 50 42.03125 C 51.056731 42.03125 52.014943 41.05663 52 40 L 52 12.8125 L 62.59375 23.40625 A 2.0002 2.0002 0 1 0 65.40625 20.5625 L 51.40625 6.5625 A 2.0002 2.0002 0 0 0 49.78125 6 z M 21.75 33.96875 A 2.0002 2.0002 0 0 0 20.59375 34.5625 L 6.59375 48.5625 A 2.0002 2.0002 0 0 0 6.59375 51.40625 L 20.59375 65.40625 A 2.0002 2.0002 0 1 0 23.40625 62.5625 L 12.8125 52 L 40 52 C 41.056625 52.015 42.03125 51.0567 42.03125 50 C 42.03125 48.9433 41.056625 47.9851 40 48 L 12.8125 48 L 23.40625 37.40625 A 2.0002 2.0002 0 0 0 21.75 33.96875 z M 77.78125 33.96875 A 2.0002 2.0002 0 0 0 76.59375 37.40625 L 87.1875 48 L 60 48 L 59.8125 48 C 58.765159 48.049 57.857156 49.04635 57.90625 50.09375 C 57.95534 51.14105 58.952679 52.0493 60 52 L 87.1875 52 L 76.59375 62.5625 A 2.0002 2.0002 0 1 0 79.40625 65.40625 L 93.40625 51.40625 A 2.0002 2.0002 0 0 0 93.40625 48.5625 L 79.40625 34.5625 A 2.0002 2.0002 0 0 0 77.78125 33.96875 z M 49.78125 57.96875 C 48.798515 58.07675 47.978761 59.0116 48 60 L 48 87.15625 L 37.40625 76.5625 A 2.0002 2.0002 0 0 0 35.78125 75.96875 A 2.0002 2.0002 0 0 0 34.59375 79.40625 L 48.59375 93.40625 A 2.0002 2.0002 0 0 0 51.40625 93.40625 L 65.40625 79.40625 A 2.0002 2.0002 0 1 0 62.59375 76.5625 L 52 87.15625 L 52 60 C 52.02441 58.8655 50.909223 57.84445 49.78125 57.96875 z " transform="translate(0,952.36218)"/></g><text x="0" y="115" fill="#000000" font-size="5px" font-weight="bold" font-family="\'Helvetica Neue\', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by creative outlet</text><text x="0" y="120" fill="#000000" font-size="5px" font-weight="bold" font-family="\'Helvetica Neue\', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>Maximize</button></a></div><div><button class="uvjs-open360view uv-btnicon360" data-viewlink="' + it_customurl + '"><!--?xml version="1.0" encoding="UTF-8" standalone="no"?--><svg width="78px" height="66px" viewBox="0 0 78 66" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>Combined Shape</title><desc>Created with Sketch.</desc><defs></defs><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="noun_612343_cc" transform="translate(-11.000000, 0.000000)" fill="#ffffff"><g id="Group" transform="translate(11.000000, 0.000000)"><path d="M77.1,28.9 C77.2,28.5 77.2,28 77,27.6 C76.6,22.8 75.7,18.9 74.4,17 L74.2,16.6 L73.8,16.4 C71.2,14.9 68.1,13.6 64.6,12.5 C58.6,5 49.4,0.2 39,0.2 C28.7,0.2 19.4,5 13.4,12.5 C9.9,13.6 6.8,14.9 4.2,16.4 L3.8,16.6 L3.6,17 C1.9,19.7 0.8,25.8 0.8,33 C0.8,40.2 1.9,46.3 3.6,49 L3.8,49.4 L4.2,49.6 C6.8,51.1 9.9,52.4 13.4,53.5 C19.4,61 28.6,65.8 39,65.8 C49.3,65.8 58.6,61 64.6,53.5 C68.1,52.4 71.2,51.1 73.8,49.6 L74.2,49.4 L74.4,49 C76.1,46.3 77.2,40.2 77.2,33 C77.2,31.6 77.1,30.2 77.1,28.9 Z M39,53.4 C26,53.4 13.9,50.9 6.4,46.7 C5.8,45.5 5.2,43.2 4.8,40 C7.2,42.4 10.4,43.9 14.2,44.3 C14.8,44.4 15.4,44.4 16,44.4 C21.6,44.4 28.4,41.7 33.1,34.3 C35.1,37.3 38.9,41.7 44.2,42.6 C48.6,43.4 53.2,41.6 57.7,37.4 C59.8,38.8 63.9,41 68.2,39.8 C70.2,39.2 72,38 73.5,36.1 C73.2,41.3 72.4,45.1 71.5,46.7 C64.1,50.9 52,53.4 39,53.4 Z M39,12.6 C52,12.6 64.1,15.1 71.6,19.3 C72.4,20.8 73.2,24 73.5,28.5 C72,33 69.9,35.7 67.4,36.4 C63.3,37.6 58.9,33.8 58.9,33.7 L57.6,32.6 L56.4,33.8 C52.4,37.9 48.5,39.7 44.9,39.1 C38.6,38.1 34.8,30 34.7,30 L33.1,26.6 L31.5,30 C27.2,38.9 19.9,41.4 14.6,40.8 C9.5,40.3 5.6,37 4.4,32.4 C4.5,25.9 5.5,21.2 6.4,19.4 C13.9,15.1 26,12.6 39,12.6 Z M46.5,34.2 C51.1,34.2 54.8,30.5 54.8,25.9 C54.8,21.3 51.1,17.6 46.5,17.6 C41.9,17.6 38.2,21.3 38.2,25.9 C38.2,30.5 41.9,34.2 46.5,34.2 Z M46.5,21.2 C49.1,21.2 51.2,23.3 51.2,25.9 C51.2,28.5 49.1,30.6 46.5,30.6 C43.9,30.6 41.8,28.5 41.8,25.9 C41.8,23.3 43.9,21.2 46.5,21.2 Z" id="Combined-Shape"></path></g></g></g></svg> View 360</button></a></div></div></div></div><div class="uv-poptableoptions"><p>' + item_descr_short + '</p><span class="uv-fulltabledescr uv-hidden">' + it_descr + '</span>' + uvdescrbelowhtml + '</div></div>');
					else {
						big_image = (big_image == "null") ? "http://placehold.it/975x650" : big_image;
						small_image = (small_image == "null") ? "http://placehold.it/390x260" : small_image

						jQuery(document).find('.uv-popmap .uv-popinquiry').find('form').before('<div class="row reservation-form-tableinfo"><div class="uv-poptableinfo" style="padding-left:15px;padding-bottom:20px;"><a href="' + big_image + '" class="uv-popimg"><div class="uv-imgresponsivecont uv-imghover"><img src="' + small_image + '" onload="jQuery(this).parent().removeClass(\'uv-isloading\');"></div></a></div><div class="uv-poptableoptions"><p>' + item_descr_short + '</p><span class="uv-fulltabledescr uv-hidden">' + it_descr + '</span>' + uvdescrbelowhtml + '</div></div>');
					}

					if (item_descr_short == '')
						jQuery(document).find('.uv-popmap .uv-popinquiry .uv-poptableinfo').css('width', '100%');
					else
						jQuery(document).find('.uv-popmap .uv-popinquiry .uv-poptableinfo').css('width', '50%');

					if (it_name != '')
						jQuery(".uv-popinquiry").parent().find(".uv-popheader h3").html(unescape(it_name));

				}

				if (uv_venueid == 1305111780 || uv_venueid == 1305112235) {
					pop_up.find('.uv-poptableoptions').append("<div id='inquiry-stadium' class='text-center stadium-buttoms'><button style='padding: 8px 12px;border: 1px solid #161E4D;background: #161E4D;border-color: #161E4D;color: #fff;width: 48%;margin-top:20px'>Inquire</button></div>");
					pop_up.find('#inquiry-stadium').on('click', function () {
						$(this).fadeOut(0);
						pop_up.find('#uvjs-popinquirymappopup').css('display', 'block');
					});
					pop_up.find('.reservation-form-tableinfo').append("<div class='uv-powered-by'></div>");
				}

				fadePop();
			});
		}
	}
	else if (type == 'inline')
		jQuery(".uv-res3dform").load("//uvtix.com/websites/ln_core/uvcore/uvinquiry.php?token=" + tokenparam + "&formid=inline-leadsform&urvenueid=" + uv_venueid + "&resdate=" + resdate + "&clientid=" + uvmapclientid + "&leadtypeid=" + uvmapGlobalTypeId);
}

function redirectLayouUrl(layoutUrl) {
	if (typeof (layoutUrl) != 'undefined' && layoutUrl != '') {
		layoutUrl = layoutUrl.replace('{{tk_venue}}', 'uv' + uv_venueid);
		layoutUrl = layoutUrl.replace('{{tk_date}}', 'dt' + shortdate);

		window.open(layoutUrl, '_blank');
		return;
	}
}


/*
if(uv_venueid == "708428765")
{
	uvloungeId = "[[uv-itemid]]";
	uvloungeType = "[[uv-itemname]]";
	uvrentalFee = jQuery('#uvtix_baseprice').html().replace("<span>", "").replace("</span>","").replace("$","");//"[[uv-baseprice]]";
	uveventname = jQuery('.uv-puteventname').html().toLowerCase();
	uvmaxGuests = jQuery("#uvtix_tableguests option").last().val();
	uvresdate = jQuery('.uv-poptableddate').data('caldate');;
		
	var dataLayer = window.dataLayer = window.dataLayer || [];
	dataLayer.push({
		"event": "loungeDetailView",
		"lounge": {
		  "loungeId": uvloungeId,
		  "loungeType": uvloungeType,
		  "status": "available",
		  "rentalFee": uvrentalFee,
		  "maxGuests": uvmaxGuests
		},
		"eventDetails": {
		  "venueId": '<?=$venueid;?>',
		  "venueName": uvvenuename,
		  "eventId": ""+eventid+"",
		  "eventName": uveventname,
		  "eventDate": uvresdate
		}
	});
	console.log("script hello worl");
}
else
{
	console.log("script hello worl 22");
}
*/




