﻿// 
var px = "px";
var overmap = 0;
var imagesizes = [];
var currentMagnification = 0.0;
var magnification_increment = 0.10;
var fit_initial_image_option = true; /* boolean option: fit seat map in both directions. If false then only width is used. */
var currentImageID = -1;
var current_seat_map = -1;
var current_seat_map_image_id = -1;
var current_scroll_direction = ""
var current_scroll_amount = 0;
var current_scroll_targetamount = 100;
var current_scroll_targetmillisec = 50;
var scrollamt_horiz;
var scrollamt_vert;
var sliderStart = 12;
var sliderHeight = 200;
var sliderWidth = 200;
var sliderIncrements = [0, 10, 40, 70, 100];
var sliderPercentages = [0.0625, 0.125, 0.25, 0.50, 1.00];
var sliderScale = [(sliderPercentages[1] - sliderPercentages[0]) / 10, (sliderPercentages[2] - sliderPercentages[1]) / 30, (sliderPercentages[3] - sliderPercentages[2]) / 30, (sliderPercentages[4] - sliderPercentages[3]) / 30, 0];
var currentSeatDotSize = 0;
var cursize = null;
var cursize_list = []; // array of cursize items, indexed by current_seat_map
var trackZoom = 0;
var seatdotsvisible = false;
var GetPerformanceDetails = null;
var current_price_type;
var perf_no = 0;
var pkg_no = 0;
var SeatingItems = null;
var dotOpacity = 70; // 1-99 are sensible values
var PriceLookups = [];
var ZoneDescriptions = [];
// var seatdots = [];
var syos_proceed_visible = false;
var userCartInfo = null;
var hilight_timer;
var hilightedZone = -1;
var syos_navigation_help_status = true;
var NavImageSourceDirectory = "/syos/images/Nav";
var tkt_unavailable_message = "Sorry, no tickets avaialble for purchase at the moment.";
var click_more_dots_message = "Click on more dots to add more seats. ";
var target_zoomin_magnification = 1.0;
var show_pricetypes_radio_in_table = true;
var omit_price_current_pricetype = true;
var order_timer;

var slider_mag_lookup_values = [0.9917, 0.9833,
	0.9750, 0.9667, 0.9583, 0.9500, 0.9417, 0.9333,
	0.9250, 0.9167, 0.9083, 0.9000, 0.8917, 0.8833,
	0.8750, 0.8667, 0.8583, 0.8500, 0.8417, 0.8333,
	0.8250, 0.8167, 0.8083, 0.8000, 0.7917, 0.7833,
	0.7750, 0.7667, 0.7583, 0.7500, 0.7417, 0.7333,
	0.7250, 0.7167, 0.7083, 0.7000, 0.6917, 0.6833,
	0.6750, 0.6667, 0.6583, 0.6500, 0.6417, 0.6333,
	0.6250, 0.6167, 0.6083, 0.6000, 0.5917, 0.5833,
	0.5750, 0.5667, 0.5583, 0.5500, 0.5417, 0.5333,
	0.5250, 0.5167, 0.5083, 0.5000, 0.4958, 0.4917,
	0.4875, 0.4833, 0.4792, 0.4750, 0.4708, 0.4667,
	0.4625, 0.4583, 0.4542, 0.4500, 0.4458, 0.4417,
	0.4375, 0.4333, 0.4292, 0.4250, 0.4208, 0.4167,
	0.4125, 0.4083, 0.4042, 0.4000, 0.3958, 0.3917,
	0.3875, 0.3833, 0.3792, 0.3750, 0.3708, 0.3667,
	0.3625, 0.3583, 0.3542, 0.3500, 0.3458, 0.3417,
	0.3375, 0.3333, 0.3292, 0.3250, 0.3208, 0.3167,
	0.3125, 0.3083, 0.3042, 0.3000, 0.2958, 0.2917,
	0.2875, 0.2833, 0.2792, 0.2750, 0.2708, 0.2667,
	0.2625, 0.2583, 0.2542, 0.2500, 0.2479, 0.2458,
	0.2438, 0.2417, 0.2396, 0.2375, 0.2354, 0.2333,
	0.2313, 0.2292, 0.2271, 0.2250, 0.2229, 0.2208,
	0.2188, 0.2167, 0.2146, 0.2125, 0.2104, 0.2083,
	0.2063, 0.2042, 0.2021, 0.2000, 0.1979, 0.1958,
	0.1938, 0.1917, 0.1896, 0.1875, 0.1854, 0.1833,
	0.1813, 0.1792, 0.1771, 0.1750, 0.1729, 0.1708,
	0.1688, 0.1667, 0.1646, 0.1625, 0.1604, 0.1583,
	0.1563, 0.1542, 0.1521, 0.1500, 0.1479, 0.1458,
	0.1438, 0.1417, 0.1396, 0.1375, 0.1354, 0.1333,
	0.1313, 0.1292, 0.1271, 0.1250, 0.1219, 0.1188,
	0.1156, 0.1125, 0.1094, 0.1063, 0.1031, 0.1000,
	0.0969, 0.0938, 0.0906, 0.0875, 0.0844, 0.0813,
	0.0781, 0.0750, 0.0719, 0.0688, 0.0656, 0.0625];

function get_index_for_zone_no(iZoneNo) {
	try {
		for (var i = 0; i < zoneinfo.length; i++) {
			if (zoneinfo[i].zone_no == iZoneNo) {
				return i;
			}
		}
	}
	catch (e) {alert('create zoneinfo array in syos2.ascx (averages of coordinates by zone: use GetZoneInfo(Averages).sql to setup )');}
	return -1;
}

function caculatePosition(dPct) {
	for (var x = 0; x < slider_mag_lookup_values.length; x++) {
		if (dPct > slider_mag_lookup_values[x])
			return x;
	}
	return slider_mag_lookup_values.length;
}

function window_scrolling() {
	var ww = getwindowsize();
	var st = getscrolltop();
	var syos2_holder = $g("syos2_holder");
	syos2_holder.style.top = "" + Math.floor((ww.y + st.y - syos2_height) / 2) + px;
}

function window_resized() {
	if (syos2_visible) {
		var syos2_holder = $g("syos2_holder");
		var ww = getwindowsize();
		var st = getscrolltop();
		var syos2 = $g("syos2");

		// set size
		syos2_width = ww.x - (2 * syos2_inset);
		syos2_holder.style.width = "" + syos2_width + px;

		syos2_height = ww.y - (2 * syos2_inset);
		syos2_holder.style.height = "" + syos2_height + "px";

		syos2_holder.style.left = "" + Math.floor((ww.x - syos2_width) / 2) + px;
		syos2_holder.style.top = "" + Math.floor((ww.y + st.y - syos2_height) / 2) + px;

		adjustWindow();

		if (typeof arrange_section_selection == "function") {
			arrange_section_selection();
		}
	}
}

function setup_syos_data() {
	var img = null;
	var width = 0;
	var height = 0;
	for (var seatmap_id = 0; seatmap_id < 20; seatmap_id++) {
		var sm = $g("seat_map" + seatmap_id);
		if (sm) {
			imagesizes[seatmap_id] = { width: 0, height: 0, images: [] };
			for (var image_id = 0; image_id < 9; image_id++) {
				img = $g("sm" + seatmap_id + "_" + image_id);
				if (img) {
					width = parseInt(img.style.width);
					height = parseInt(img.style.height);
					imagesizes[seatmap_id].width = width;
					imagesizes[seatmap_id].height = height;
					imagesizes[seatmap_id].images[image_id] = { "width": width, "height": height };
				} else break;
			}
		} else break;
	}

	var syos_navigation_help_cookie = readCookie('syos_navigation_help');
	if (syos_navigation_help_cookie)
		syos_navigation_help_status = false;
	// dofeedback();

	window.onscroll = window_scrolling;
	window.onresize = window_resized;
}

imageholder = function(w, h, ds, s) {
	this.width = w;
	this.height = h;
	this.dotsize = ds;
	this.src = s;
}

setRect = function(o, left, top, width, height) {
	if (typeof o != "object")
		o = $g("" + o);
	if (o.style) {
		o.style.left = "" + Math.floor(left) + px;
		o.style.top = "" + Math.floor(top) + px;
		if (width)
			o.style.width = "" + Math.floor(width) + px;
		if (height)
			o.style.height = "" + Math.floor(height) + px;
	}
}

function setSlider(pct) {
	var newpos = caculatePosition(pct);
	var offset = 0;
	var syos_zoom_slider = $g("syos_zoom_slider");
	/*
	for (var x = 0; x < sliderPercentages.length; x++)
	{
	if (pct < sliderPercentages[x])
	{
	var remnant = 0;
	if (x > 0)
	{
	offset = sliderIncrements[x - 1];
	remnant = pct - sliderPercentages[x - 1];
	try
	{
	offset += Math.floor(remnant / sliderScale[x - 1]);
	}
	catch (e) { }
	// alert("offset=" + offset);
	}
	break;
	}
	}
	*/
	// syos_zoom_slider.style.top = "" + (sliderStart + (offset * (sliderHeight / 100))) + px; // offset * 2 because scale is 200 not 100
	syos_zoom_slider.style.top = "" + (sliderStart + newpos) + px; // offset * 2 because scale is 200 not 100
	// alert("setSlider = " + pct);
	// dofeedback();
}

sizeitem = function(w, h) {
	this.width = w;
	this.height = h;
	this.left = 0;
	this.top = 0;
	this.center_x = 0;
	this.center_y = 0;
	this.magnification_increment = 0.00;
}


function resizeImages(x, increment) {
	if (cursize == null)
		cursize = new sizeitem(Math.floor(imagesizes[current_seat_map].width * currentMagnification), Math.floor(imagesizes[current_seat_map].height * currentMagnification));
	//	cursize = { width: Math.floor(imagesizes[current_seat_map].width * currentMagnification), height: Math.floor(imagesizes[current_seat_map].height * currentMagnification), center_x:0, center_y:0 };
	var newsize = new sizeitem(Math.floor(imagesizes[current_seat_map].width * increment.pct), Math.floor(imagesizes[current_seat_map].height * increment.pct));
	newsize.magnification_increment = increment.pct;

	// { width: Math.floor(imagesizes[current_seat_map].width * increment.pct), height: Math.floor(imagesizes[current_seat_map].height * increment.pct), center_x:0, center_y:0 };

	var syos_panel_seats = $g("seat_map" + current_seat_map + "_container"); // 
	var syos_panel_seatmaps = $g("seat_map" + current_seat_map + "_seatmaps");
	var targets = syos_panel_seatmaps.getElementsByTagName("img");
	for (var i = 0; i < targets.length; i++) {
		targets[i].style.display = ((increment.inc == i || (increment.inc == targets.length && i == (targets.length - 1))) ? "block" : "none");
		targets[i].style.width = "" + newsize.width + px;
		targets[i].style.height = "" + newsize.height + px;
	}
	// var syos_panel_seatdots = $g("seat_map"+ current_seat_map + "_dots");
	// syos_panel_seatdots.style.width = "" + newsize.width + px;
	// syos_panel_seatdots.style.height = "" + newsize.height + px;

	// keep image on the panel
	var syos2_seat_selector = $g("syos2_seat_selector"); // the div that holds seat image
	var viewport_size = { width: parseInt(syos2_seat_selector.style.width), height: parseInt(syos2_seat_selector.style.height) }; // and height
	var seatmap_pos = { left: parseInt(syos_panel_seats.style.left), top: parseInt(syos_panel_seats.style.top) }; 		// position of seat_map panel: top
	// don't allow it to do something stupid
	if (Math.abs(seatmap_pos.left > newsize.width))
		seatmap_pos.left = 0;
	if (Math.abs(seatmap_pos.top > newsize.height))
		seatmap_pos.top = 0;

	if (true) { // (currentMagnification < increment.pct)
		// enlarging

		if (newsize.width < viewport_size.width) {
			// recenter it left to right
			newsize.left = Math.floor((viewport_size.width - newsize.width) / 2);
		} else {
			// enlarge on current center point
			cursize.center_x = (-1 * seatmap_pos.left) + Math.floor(viewport_size.width / 2);
			newsize.center_x = Math.floor(newsize.width * (cursize.center_x / cursize.width));
			if (seatmap_pos.left > 0)
				newsize.left = 0;
			else
				newsize.left = 0 - newsize.center_x + Math.floor(viewport_size.width / 2);

		}
		syos_panel_seats.style.left = "" + newsize.left + px;

		if (newsize.height < viewport_size.height) {
			// recenter it top to bottom
			newsize.top = Math.floor((viewport_size.height - newsize.height) / 2);
		} else {
			cursize.center_y = (-1 * seatmap_pos.top) + Math.floor(viewport_size.height / 2);
			newsize.center_y = Math.floor(newsize.height * (cursize.center_y / cursize.height));
			if (seatmap_pos.top > 0)
				newsize.top = 0;
			else
				newsize.top = 0 - newsize.center_y + Math.floor(viewport_size.height / 2); ;
		}
		syos_panel_seats.style.top = "" + newsize.top + px;

		// dofeedback(syos_panel_seats);
		cursize = newsize;
	}

}


function dofeedback(oItem) {
	/*
	if (!oItem && current_seat_map > -1)
	{
	oItem = $g("seat_map" + current_seat_map + "_container");
	}
	if (oItem)
	{
	var cm = (Math.floor(currentMagnification * 1000)) / 10;
	var syos_panel_seats = $g("seat_map" + current_seat_map + "_container"); //
	var targets = syos_panel_seats.getElementsByTagName("img");
	$("#feedback").html("" + oItem.style.left + ", " + oItem.style.top + ": " + cm + ", w: " + targets[0].style.width + ", h: " + targets[0].style.height);
	}
	*/
}

function calculate_resize(x) {
	var inc = 4;
	var newx = 0;
	var prev = 0;
	if (x > 100)
		x = 100;
	if (x <= 100) {
		if (x > 0) {
			for (var i = 0; i < sliderIncrements.length; i++) {
				var temp = x - sliderIncrements[i];
				if (temp < 0)
				{
					inc = prev;
					newx = x - sliderIncrements[prev];
					break;
				}
				else
					prev = i;
			}
		} else {
			inc = 0;
			newx = 0;
		}
	}

	return { pct: Math.abs(sliderPercentages[inc] + (newx * sliderScale[inc])), "newx": newx, "inc": inc, "x": x }
}



function seatdot_visibility(sShowHide) {
	if (seatdotsvisible && sShowHide == 'hide') {
		$("#seat_map" + current_seat_map + "_dots").hide();
		seatdotsvisible = false;
	} else if (!seatdotsvisible && sShowHide == 'show') {
		plotSeats(current_seat_map, false);
		$("#seat_map" + current_seat_map + "_dots").show();
		seatdotsvisible = true;
	}

}

function doZoom(x, y) {
	seatdot_visibility('hide');

	lastX = y;
	var amt = 100 - (Math.floor(200 * (y - sliderStart) / sliderHeight)) / 2;
	var increment = calculate_resize(amt);

	if (trackZoom == 0) {
		// alert("x,y,amt => { " + x + ", " + y + ", " + amt + "}");
		trackZoom = 1;
	}

	resizeImages(amt, increment);
	currentMagnification = increment.pct;

}

function doDragMap(x, y) {
	dofeedback();
}

function zoom_set(iDir) {
	if (((currentMagnification + (magnification_increment * iDir)) < 1.0) && ((currentMagnification + (magnification_increment * iDir)) > 0)) {
		var newmagnification = currentMagnification + (magnification_increment * iDir);
		setSlider(newmagnification);
		var amt = (Math.floor(newmagnification * 200)) / 2;
		var increment = calculate_resize(amt);
		// alert("currentMagnification=" + currentMagnification + ", newmagnification=" + newmagnification + ", amt=" + amt);
		resizeImages(amt, increment);
		plotSeats(current_seat_map, false);
		currentMagnification = newmagnification;
		setSlider(currentMagnification);
	}
	// dofeedback();
}


function scrollmap(oImg, sDir, iAction) {
	if (iAction == 1) {
		if (oImg.src.indexOf(NavImageSourceDirectory) == -1)
			oImg.setAttribute("origsrc", oImg.src);
		scrollamt_horiz = Math.floor((current_scroll_targetamount * currentMagnification) * ((sDir == 'W') ? 1 : sDir == 'E' ? -1 : 0));
		scrollamt_vert = Math.floor((current_scroll_targetamount * currentMagnification) * ((sDir == 'N') ? 1 : sDir == 'S' ? -1 : 0));
		setTimeout("scrollmap(null,0)", current_scroll_targetmillisec);
		current_scroll_direction = sDir;
		oImg.src = NavImageSourceDirectory + sDir + "1" + ".png";
		oImg.onmouseout = function() { scrollmap(oImg, sDir, -1); };
	} else if (iAction == -1) {
		if (oImg.attributes["origsrc"] != null && oImg.attributes["origsrc"].nodeValue != null)
			oImg.src = oImg.attributes["origsrc"].nodeValue;
		else
			oImg.src = NavImageSourceDirectory + sDir + "0" + ".png";
		scrollamt_horiz = 0;
		scrollamt_vert = 0;
		current_scroll_direction = "";
		oImg.onmouseout = function() { };
	} else {
		if (current_scroll_direction != ""){
			var seatmap_container = $g("seat_map" + current_seat_map + "_container");
			var left = parseInt(seatmap_container.style.left);
			var top = parseInt(seatmap_container.style.top);
			seatmap_container.style.left = "" + (left + scrollamt_horiz) + px;
			seatmap_container.style.top = "" + (top + scrollamt_vert) + px;
			setTimeout("scrollmap(null,0)", current_scroll_targetmillisec); // queue it up again.
		}
	}
}

function set_rowseatpricebaloon(row, seat, price, section, purchased) {
	$('#rowseatpricebaloon_row').html(row);
	$('#rowseatpricebaloon_seat').html(seat);
	$('#rowseatpricebaloon_price').html(price);
	$('#rowseatpricebaloon_section').html(section);
	$('#rowseatpricebaloon_purchased').html(purchased > 0 ? seatIsPurchased : seatNotPurchased)
}

function hilighter() {
	var iMapId = this.attributes["iMapId"].nodeValue;
	var index = this.attributes["index"].nodeValue;
	var tgt = this.attributes["zone_no"].nodeValue;
	// hilighter2(iMapId, index, tgt, this );
	var loc = "hilighter2(" + iMapId + "," + index + "," + tgt + ",'" + this.id + "')";
	// alert(loc);
	hilight_timer = setTimeout(loc, 100);
	seat_view_for_image(this);
}

function hilighter2(iMapId, index, zone_no, oImgId) {
	hilight_timer = null;
	var oImg = $g(oImgId);

	// alert("x: " + this.attributes["x_coord"].nodeValue );

	// alert("iMapId=" + iMapId + ", index=" + index + ", zone = " + seats[iMapId][index].zone );

	var zone_div = $g("zone" + zone_no);

	if (zone_div && zone_div.childNodes.length < hilight_threshhold) {
		for (var x = 0; x < zone_div.childNodes.length; x++) {
			zone_div.childNodes[x].src = avail1;
			// if (seatdots[x].attributes["zone_no"].nodeValue == zone_no)
			//	seatdots[x].src = avail1;
		}
	}

	var xy = getxy(oImg);
	var rowseatpricebaloon = $g("rowseatpricebaloon");
	rowseatpricebaloon.style.left = "" + (xy.x - 112 + Math.floor(seat_dot_sizes[iMapId] * currentMagnification * 0.5)) + px;
	rowseatpricebaloon.style.top = "" + (xy.y - 117) + px;
	var seat_price_index = "pl" + oImg.attributes["zone_no"].nodeValue + "_pt" + current_price_type;
	var seat_price = PriceLookups[seat_price_index];
	var done = false;

	if (seat_price == null) {
		for (var a = 0; a < GetPerformanceDetails.ZonePricingItems.length; a++) {
			if (GetPerformanceDetails.ZonePricingItems[a].ZoneNo == oImg.attributes["zone_no"].nodeValue) {
				for (var b = 0; b < GetPerformanceDetails.ZonePricingItems[a].Prices.length; b++) {
					if (GetPerformanceDetails.ZonePricingItems[a].Prices[b].PriceTypeId == current_price_type) {
						ZoneDescriptions[seat_price_index] = GetPerformanceDetails.ZonePricingItems[a].OriginalDesc != null ? GetPerformanceDetails.ZonePricingItems[a].OriginalDesc : GetPerformanceDetails.ZonePricingItems[a].Description;
						PriceLookups[seat_price_index] = GetPerformanceDetails.ZonePricingItems[a].Prices[b].PriceString;
						done = true;
						break;
					}
				}
			}
			if (done)
				break;
		}
	}
	set_rowseatpricebaloon(oImg.attributes["seat_row"].nodeValue, oImg.attributes["seat_num"].nodeValue, PriceLookups[seat_price_index], ZoneDescriptions[seat_price_index], oImg.attributes["purchased"].nodeValue);
	$('#rowseatpricebaloon').show();
}



function unhilighter() {
	if (hilight_timer) {
		clearTimeout(hilight_timer);
		hilight_timer = null;
	} else
		unhilighter2(this);
}

function unhilighter2(oImg) {
	// alert("x: " + this.attributes["x_coord"].nodeValue );
	var iMapId = oImg.attributes["iMapId"].nodeValue;
	var index = oImg.attributes["index"].nodeValue;

	// alert("iMapId=" + iMapId + ", index=" + index + ", zone = " + seats[iMapId][index].zone );

	// var seat_map_dots_div = $g("seat_map" + iMapId + "_dots");
	// var seatdots = seat_map_dots_div.getElementsByTagName("img");

	var zone_no = oImg.attributes["zone_no"].nodeValue;
	var zone_div = $g("zone" + zone_no);

	if (zone_div && zone_div.childNodes.length < hilight_threshhold) {
		for (var x = 0; x < zone_div.childNodes.length; x++) {
			zone_div.childNodes[x].src = avail;
			// if (seatdots[x].attributes["zone_no"].nodeValue == zone_no )
			//	seatdots[x].src = avail;
		}
	}
	$('#rowseatpricebaloon').hide();

}

function buyseat() {
	do_buyseat(this);
}

centerOnPoint = function(x, y, width, height) {
	this.x = (typeof x == "undefined") ? 0 : x;
	this.y = (typeof y == "undefined") ? 0 : y;
	this.width = (typeof width == "undefined") ? 0 : width;
	this.height = (typeof height == "undefined") ? 0 : height;
	this.viewport_size = { width: 0, height: 0 };
}

function display_seat(iSeatNo) {
	var iMapId = -1;
	var seat_img = $g("seat" + iSeatNo);
	var center_on = new centerOnPoint();
	var largest_image_size = null;
	var targetsize = null;

	var factor = slider_mag_lookup_values[ Math.floor(200 - (target_zoomin_magnification*200))]
	
	if (!seat_img) {
		for (var x = 0; x < SeatingItems.length; x++) {
			if (SeatingItems[x].seat_no == iSeatNo) {
				iMapId = SeatingItems[x].syos_map_id - 1;
				largest_image_size = imagesizes[iMapId].images[imagesizes[iMapId].images.length - 1];

				targetsize = new sizeitem(Math.floor(largest_image_size.width * factor), Math.floor(largest_image_size.height * factor));
				
				center_on.x = Math.floor(targetsize.width / 2 + (SeatingItems[x].x * targetsize.width * -1));
				center_on.y = Math.floor(targetsize.height / 2 + (SeatingItems[x].y * targetsize.height * -1));
				break;
			}
		}
	} else {
		iMapId = seat_img.attributes["iMapId"].nodeValue;
		largest_image_size = imagesizes[iMapId].images[imagesizes[iMapId].images.length - 1];
		// targetsize = new sizeitem(largest_image_size.width, largest_image_size.height);
		targetsize = new sizeitem(Math.floor(largest_image_size.width * factor), Math.floor(largest_image_size.height * factor));
		center_on.x = Math.floor(targetsize.width / 2 + (seat_img.attributes["x_coord"].nodeValue * targetsize.width * -1));
		center_on.y = Math.floor(targetsize.height / 2 + (seat_img.attributes["y_coord"].nodeValue * targetsize.height * -1));
	}

	center_on.width = largest_image_size.width;
	center_on.height = largest_image_size.height;
	center_on.magnification_increment = factor;  // 1.0;
	targetsize.magnification_increment = factor;   // 1.0; // <-- is this necessary??
	var syos2_seat_selector = $g("syos2_seat_selector"); // the div that holds seat image
	center_on.viewport_size = { width: parseInt(syos2_seat_selector.style.width), height: parseInt(syos2_seat_selector.style.height) }; // and height
	targetsize.left = 0 - center_on.x + Math.floor(center_on.viewport_size.width / 2);
	targetsize.top = 0 - center_on.y + Math.floor(center_on.viewport_size.height / 2);

	cursize_list[iMapId] = targetsize;

	if (iMapId == current_seat_map) {
		cursize = targetsize;
	}

	select_map(iMapId, center_on);

	// alert("zoom to seat_no=" + iSeatNo + ", iMapId=" + iMapId);
}

function remove_seat(iSeatNo) {
	var img = $g("seat" + iSeatNo);
	do_buyseat(img);
}

function format_performance_cart(oSublineItemArray) {
	if (typeof format_performance_cart_override == "function") {
		// call call customizing version of this method instead
		format_performance_cart_override(oSublineItemArray)
		return;
	}

	if (!oSublineItemArray) {
		$('#syos_proceed').hide();
		syos_proceed_visible = false;
		return;
	}
	if (!syos_proceed_visible) {
		$('#syos_proceed').show();
		syos_proceed_visible = true;
	}
	var cart_details = $g("cart_details");
	var holder = document.createElement("div");

	var table = document.createElement("table");
	table.setAttribute("class", "perf_cart");

	var tr = document.createElement("tr");
	var td = document.createElement("th");
	td.appendChild(document.createTextNode("Seat"));
	tr.appendChild(td);

	td = document.createElement("th");
	td.style.textAlign = "right";
	td.style.paddingRight = "10px";
	td.style.width = "100px";
	td.appendChild(document.createTextNode("Price"));
	tr.appendChild(td);

	td = document.createElement("th");
	td.appendChild(document.createTextNode("Action"));
	tr.appendChild(td);

	table.appendChild(tr);
	var findseat_span = null;
	var desc_added = false;
	for (var a = 0; a < oSublineItemArray.length; a++) {
		desc_added = false;
		tr = document.createElement("tr");

		td = document.createElement("td");
		findseat_span = document.createElement("span");
		findseat_span.setAttribute("class", "action");
		findseat_span.setAttribute("onclick", "display_seat(" + oSublineItemArray[a].seat_no + ")");
		findseat_span.setAttribute("title", "Click here to zoom to this seat.");
		
		if (GetPerformanceDetails.SinglePriceType == 0 && perf_no > 0) { // only do this for single tickets, not subscription packages
			// more than 1 pricetype is available, so show a dropdown menu 
			findseat_span.appendChild(document.createTextNode(oSublineItemArray[a].Location + "\u00a0"));
			td.appendChild(findseat_span);
			var img = $g("seat" + oSublineItemArray[a].seat_no); // get image to determine zone number
			if (img) {
				var seat_zone = img.attributes["zone_no"].nodeValue;
				if (seat_zone) {
					for (var uu = 0; uu < GetPerformanceDetails.ZonePricingItems.length; uu++) {
						if (GetPerformanceDetails.ZonePricingItems[uu].Prices.length < 2)
							break; // don't show select when there's only 1 price anyway
					
						if (GetPerformanceDetails.ZonePricingItems[uu].ZoneNo == seat_zone) {
							var prtype_select = document.createElement("select");
							prtype_select.setAttribute("class", "seatpricetypeselect");
							prtype_select.setAttribute("onchange", "changePriceForSelectedSeat(" + oSublineItemArray[a].li_seq_no + "," + oSublineItemArray[a].seat_no + ",this.options[this.selectedIndex].value,this)");
							for (var yy = 0; yy < GetPerformanceDetails.ZonePricingItems[uu].Prices.length; yy++) {
								try {
									if (GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].Price > 0) {
										var ptOption = document.createElement("option");
										ptOption.setAttribute("value", "" + GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceTypeId);
										if (GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceTypeId == oSublineItemArray[a].price_type_id) {
											ptOption.setAttribute("selected", "selected");
										}

										if (GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceTypeId == oSublineItemArray[a].price_type_id && omit_price_current_pricetype)
											ptOption.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceTypeName));
										else
											ptOption.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceTypeName + " " + GetPerformanceDetails.ZonePricingItems[uu].Prices[yy].PriceString));
										prtype_select.appendChild(ptOption);
									}
								}
								catch (xerr) { }
							}
							td.appendChild(prtype_select);
							desc_added = true;
							break;
						}
					}
				}
			}
		}
		if ( ! desc_added ) {
			findseat_span.appendChild(document.createTextNode(oSublineItemArray[a].Location + ", " + oSublineItemArray[a].price_type_name));
			td.appendChild(findseat_span);
		}
		tr.appendChild(td);

		td = document.createElement("td");
		td.style.textAlign = "right";
		td.style.paddingRight = "10px";
		td.appendChild(document.createTextNode(oSublineItemArray[a].formattedPrice));
		tr.appendChild(td);

		td = document.createElement("td");
		findseat_span = document.createElement("span");
		findseat_span.appendChild(document.createTextNode("remove"));
		findseat_span.setAttribute("class", "action");
		findseat_span.setAttribute("onclick", "remove_seat(" + oSublineItemArray[a].seat_no + ")");
		td.appendChild(findseat_span);
		tr.appendChild(td);


		table.appendChild(tr);

		if (typeof format_performance_cart_complete == "function")
			format_performance_cart_complete();
	}


	holder.appendChild(table);

	var msg = document.createElement("p");
	msg.setAttribute("class", "cart_details_msg");

	var cartlink = document.createElement("a");
	if (typeof SYOS_Close == "function") {
		cartlink.setAttribute("href", "javascript:SYOS_Close()");
		cartlink.appendChild(document.createTextNode(typeof SYOS_DoneButtonText == "undefined" ? "Continue »" : SYOS_DoneButtonText));
	} else {
		cartlink.setAttribute("href", "javascript:jump_to_cart(this)" );  // cartURL should be set in the syos.ascx control!
		cartlink.appendChild(document.createTextNode("Click here to view cart or checkout."));
	}
	cartlink.setAttribute("class", "cartLink");
	msg.appendChild(cartlink);

	msg.appendChild(document.createTextNode(click_more_dots_message));
	if (typeof click_more_dots_message_addl == "function")
		msg.appendChild(document.createTextNode( click_more_dots_message_addl() ));
		

	if (typeof img_wait != "undefined") {
		var img_wait_img = document.createElement("img");
		img_wait_img.id = "jump_cart_wait_img";
		img_wait_img.style = "display:none;" + (typeof img_wait_style != "undefined" ? img_wait_style : "");
		img_wait_img.alt = "";
		img_wait_img.src = img_wait;
		msg.appendChild(img_wait_img);
	}

	holder.appendChild(msg);


	$('#cart_details').html($(holder).html());

	cart_details.style.left = "-9999px";
	$(cart_details).show();
	var parxy = getxy(cart_details.parentNode);
	var cart_details_width = parseInt(cart_details.style.width);
	cart_details.style.top = "" + (0 - cart_details.clientHeight - 1) + "px";
	cart_details.style.left = "" + Math.floor((cart_details.parentNode.clientWidth - cart_details_width) / 2) + px;

	var perf_cart_header = $g("perf_cart_header");
	perf_cart_header.style.top = "" + (0 - cart_details.clientHeight - 21) + "px";
	perf_cart_header.style.left = cart_details.style.left;
	perf_cart_header.style.width = "" + (cart_details.clientWidth) + px; // 16 = 2 * 8 padding on cart_details div
	$('#span_minimize_restore').html("minimize");
}

function jump_to_cart(caller) {
	var jump_cart_wait_img = $g("jump_cart_wait_img");
	if (jump_cart_wait_img) {
		$(caller).hide();
		$(jump_cart_wait_img).show();
	}
	location.href = (typeof cartURL == "undefined") ? "/tickets/cart.aspx" : cartURL;
}


function get_time_remaining() {
	var time_remaining = $g("time_remaining");
	if (time_remaining) {
		var time_remaining_parts = time_remaining.childNodes[0].nodeValue.split(":");
		return (parseInt(time_remaining_parts[0]) * 60) + parseInt(time_remaining_parts[1]);
	}
}

function formattime(i) {
	var o = $g("time_remaining");
	if (i > 0 && o) {
		j = i % 60;
		if (j == 0)
			k = Math.ceil(i / 60);
		else
			k = Math.ceil(i / 60) - 1;
		if (j < 10)
			j = "0" + j;
		$(o).html( "" + k + ":" + j );
	}
}

function syos_decrement_timer() {
	var time_remaining = get_time_remaining() - 1;

	if (time_remaining > 0) {
		formattime(time_remaining);
		clearTimeout(order_timer);
		order_timer = setTimeout("syos_decrement_timer();", 995);
	} else {
		if (typeof time_expired_handler == "function")
			time_expired_handler();
		else
			alert("Your cart may have timed out.");
		$('#time_remaining_holder').hide();
		order_timer = null;
	}
}


function count_down_timer() {
	if (!order_timer)
		order_timer = setTimeout("syos_decrement_timer();", 995);
}

function do_buyseat(oImg) {

	var req = getreq();

	this.handler = function() {
		if (req.readyState == 4) {
			document.body.style.cursor = "default";
			$('#img_wait_seatclick').hide();

			if (req.status == 200) {
				var rslt = JSON.parse(req.responseText);
				try {
					rslt = rslt.d;
				}
				catch (err) { }
				if (rslt.Success) {
					var current_parent = $g("zone" + oImg.attributes["zone_no"].nodeValue);
					var new_parent = $g("selected_zone" + oImg.attributes["iMapId"].nodeValue);
					if (rslt.TimeRemaining == "00:00") {
						$('#time_remaining_holder').hide();
					} else {
						$('#time_remaining_holder').show();
						$('#time_remaining').html(rslt.TimeRemaining);
						count_down_timer();
					}

					if (oImg.src.indexOf(yours) > -1) {
						// do not purchse item: remove from cart
						try {
							new_parent.removeChild(oImg);
							current_parent.appendChild(oImg);
						}
						catch (e) { }


						oImg.setAttribute("purchased", -1);
						oImg.src = current_parent.childNodes.length > hilight_threshhold ? avail : avail1; // return to how current seats are looking
						oImg.setAttribute("li_seq_no", 0);
						$('#rowseatpricebaloon_purchased').html(seatNotPurchased);
					} else {
						var cImg = null;
						for (var a = 0; a < rslt.CartInfo.SubLineItemsSeats.length; a++) {
							cImg = $g("seat" + rslt.CartInfo.SubLineItemsSeats[a].seat_no)
							if (cImg) {
								if (rslt.CartInfo.SubLineItemsSeats[a].li_seq_no == rslt.LineItem) { // only concerned with seats in the current line item
									try {
										current_parent.removeChild(cImg);
										new_parent.appendChild(cImg);
									}
									catch (e) { /* on a reload the item may not have been changed to be in the separate holder zone */ }
									cImg.setAttribute("purchased", 1);
									cImg.setAttribute("li_seq_no", rslt.CartInfo.SubLineItemsSeats[a].li_seq_no);
									cImg.src = yours;
								}
							}
						}
						$('#rowseatpricebaloon_purchased').html(seatIsPurchased);
					}
					try {
						format_performance_cart(rslt.CartInfo.SubLineItemsSeats);
					}
					catch (e) {
						$('#syos_proceed').hide();
						syos_proceed_visible = false;
					}
				}
				else
					alert(rslt.ErrorMessage);
			}
			else
				alert(req.responseText);
		}
	}

	this.validate = function() {
		// SeatClick( int perf_no, int seat_no, int price_type, int zone_no, int li_seq_no, bool reserve, bool leave_single )
		var retval = { "perf_no": perf_no, "seat_no": 0, "price_type": current_price_type, "zone_no": 0, "li_seq_no": 0, "reserve": true, "leave_single": leave_single, "pkg_no": pkg_no };
		retval.seat_no = oImg.attributes["seat_no"].nodeValue;
		if (oImg.attributes["li_seq_no"] && (oImg.attributes["li_seq_no"].nodeValue > 0 )) {
			retval.li_seq_no = oImg.attributes["li_seq_no"].nodeValue;
			retval.reserve = false;
		}
		retval.zone_no = oImg.attributes["zone_no"].nodeValue;
		if (retval.seat_no > 0)
			return retval;
	}

	var sendObj = this.validate();

	if (sendObj && req) {
		var img_wait_seatclick = $g("img_wait_seatclick");
		var oImgXY = getxy(oImg);
		img_wait_seatclick.style.left = "" + (oImgXY.x + 24) + px;
		img_wait_seatclick.style.top = "" + (oImgXY.y + 8) + px;
		$(img_wait_seatclick).show();
		document.body.style.cursor = "wait";

		if (pkg_no > 0)
			req.open(HTTP_VERB, (srvr + SYOSWS + "PackageClick"), true);
		else
			req.open(HTTP_VERB, (srvr + SYOSWS + "SeatClick"), true);
		req.setRequestHeader(CONTENT_TYPE, APP_JSON);
		req.onreadystatechange = this.handler;
		req.send(JSON.serialize(sendObj));
	}

}


function plotSeats(iMapId, bInitialize) {
	if (current_seat_map < 0)
		return;
	
	if (cursize == null)
		cursize = new sizeitem(Math.floor(imagesizes[current_seat_map].width * currentMagnification), Math.floor(imagesizes[current_seat_map].height * currentMagnification));
	// cursize = { width: Math.floor(imagesizes[current_seat_map].width * currentMagnification), height: Math.floor(imagesizes[current_seat_map].height * currentMagnification), center_x:0, center_y:0 };

	var seat_map_dots_div = $g("seat_map" + iMapId + "_dots");
	var seatdots = seat_map_dots_div.getElementsByTagName("img");

	var done = false;
	var done2 = false;
	var dotoffset = seat_dot_sizes[iMapId] * currentMagnification / 2;
	var current_zone = 0;
	var current_zone_div = null;

	if (bInitialize) {
		var img = null;
		if (SeatingItems && (seatdots == null || seatdots.length == 0)) {
			// seatdots = [];
			for (var x = 0; x < SeatingItems.length; x++) {
				if (SeatingItems[x].syos_map_id == (iMapId + 1)) {
					img = document.createElement("img");
					if (SeatingItems[x].zone_no != current_zone) {
						if (current_zone > 0)
							seat_map_dots_div.appendChild(current_zone_div);
						current_zone = SeatingItems[x].zone_no;
						current_zone_div = document.createElement("div");
						current_zone_div.id = "zone" + current_zone;
					}
					img.src = avail;
					img.style.position = "absolute";
					img.style.zIndex = "10";
					img.style.left = "" + Math.floor((cursize.width / 2) + (-1 * cursize.width * SeatingItems[x].x) - dotoffset) + px;
					img.style.top = "" + Math.floor((cursize.height / 2) + (-1 * cursize.height * SeatingItems[x].y) - dotoffset) + px;
					img.style.width = "" + Math.floor(seat_dot_sizes[iMapId] * currentMagnification) + px;
					img.style.height = img.style.width;
					img.style.filter = "alpha(opacity=" + dotOpacity + ")";
					img.style.opacity = "." + dotOpacity;
					img.style.mozOpacity = "." + dotOpacity;
					img.id = "seat" + SeatingItems[x].seat_no;
					img.setAttribute("zone_no", SeatingItems[x].zone_no);
					img.setAttribute("x_coord", "" + SeatingItems[x].x);
					img.setAttribute("y_coord", "" + SeatingItems[x].y);
					img.setAttribute("iMapId", iMapId);
					img.setAttribute("index", x);
					img.setAttribute("seat_no", SeatingItems[x].seat_no);
					img.setAttribute("seat_num", SeatingItems[x].seat_num);
					img.setAttribute("seat_row", SeatingItems[x].seat_row);
					if (!userCartInfo)
						img.setAttribute("purchased", -1);
					else {
						done2 = false;
						for (var y = 0; y < userCartInfo.SubLineItemsSeats.length; y++) {
							if (userCartInfo.SubLineItemsSeats[y].seat_no == SeatingItems[x].seat_no) {
								done2 = true;
								img.setAttribute("purchased", 1);
								img.setAttribute("li_seq_no", userCartInfo.SubLineItemsSeats[y].li_seq_no);
								img.src = yours;
								break;
							}
						}
					}
					img.onmouseover = hilighter;
					img.onmouseout = unhilighter;
					img.onclick = buyseat;
					current_zone_div.appendChild(img);
				}
				// seatdots[seatdots.length] = img;
			}
			if (current_zone_div != null)
				seat_map_dots_div.appendChild(current_zone_div);
			current_zone_div = document.createElement("div"); // reuse current_zone_div variable
			current_zone_div.id = "selected_zone" + iMapId;
			seat_map_dots_div.appendChild(current_zone_div);

			done = true;
		}
	}

	if (!done) {
		seatdots = seat_map_dots_div.getElementsByTagName("img");
		for (var i = 0; i < seatdots.length; i++) {
			seatdots[i].style.left = "" + Math.floor((cursize.width / 2) + (-1 * cursize.width * seatdots[i].attributes["x_coord"].nodeValue) - dotoffset) + px;
			seatdots[i].style.top = "" + Math.floor((cursize.height / 2) + (-1 * cursize.height * seatdots[i].attributes["y_coord"].nodeValue) - dotoffset) + px;
			seatdots[i].style.width = "" + Math.floor(seat_dot_sizes[iMapId] * currentMagnification) + px;
			seatdots[i].style.height = seatdots[i].style.width;
		}
	}
	seatdotsvisible = true;
}

function nothing() { }

function loadMap(iMapId) {
	var req = getreq();

	this.validate = function() {
		var zone_no = 0;
		for (var a = 0; a < GetPerformanceDetails.ZonePricingItems.length; a++) {
			if (GetPerformanceDetails.ZonePricingItems[a].syos_map_id == (iMapId + 1)) { // syos_map_id is not zero-based
				zone_no = GetPerformanceDetails.ZonePricingItems[a].ZoneNo;
				break;
			}
		}

		var tgt = pkg_no > 0 ? pkg_no : perf_no;
		var retval = { "perf_no": tgt, "zone_no": zone_no, "includeAllZones": true };

		if (retval.perf_no > 0 && retval.zone_no > 0)
			return retval;
	}

	var sendObj = this.validate();

	this.handler = function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				var rslt = JSON.parse(req.responseText);
				try {
					rslt = rslt.d;
				} catch (err) { }
				if (rslt && rslt.SeatingItems) {
					SeatingItems = rslt.SeatingItems;
					plotSeats(iMapId, true);
					if (rslt.CartInfo && rslt.CartInfo.SubLineItemsSeats && rslt.CartInfo.SubLineItemsSeats.length > 0) {
						if (rslt.CartInfo.TimeRemaining == "00:00") {
							$('#time_remaining_holder').hide();
						} else {
							$('#time_remaining').html(rslt.CartInfo.TimeRemaining);
							count_down_timer();
						}
						format_performance_cart(rslt.CartInfo.SubLineItemsSeats);
						for (var b = 0; b < rslt.CartInfo.SubLineItemsSeats.length; b++) {
							var reserved_seatimg = $g("seat" + rslt.CartInfo.SubLineItemsSeats[b].seat_no);
							if (reserved_seatimg) {
								reserved_seatimg.src = yours;
								reserved_seatimg.setAttribute("purchased", 1);
								reserved_seatimg.setAttribute("li_seq_no", rslt.CartInfo.SubLineItemsSeats[b].li_seq_no);
							}
						}
						userCartInfo = rslt.CartInfo;
					}
					$('#loading_seats').hide();
					if (syos_navigation_help_status)
						$('#syos_navigation_help').fadeIn();
				} else alert("Unable to retrieve Seating data.");

			} else alert("Connection error"); // better messaging than this.
		}
	}

	if (sendObj && req) {
		req = getreq();
		req.open(HTTP_VERB, (srvr + SYOSWS + "PerfSeatsForZone"), true);
		req.setRequestHeader(CONTENT_TYPE, APP_JSON);
		req.onreadystatechange = this.handler;
		req.send(JSON.serialize(sendObj));
	}
}

function hide_other_seatmaps(iMapId){
	for (var x = 0; x < 50; x++){
		var seat_map = $g("seat_map" + x);
		if (!seat_map )
			break;

		if (x == iMapId) // skip current map
			continue;
			
		var seat_map_seatmaps = $g("seat_map" + x + "_seatmaps");
		if (seat_map_seatmaps) {
			for (var y = 0; y < 4; y++)
			{
				var sm = $g("sm" + x + "_" + y);
				if (sm)
					sm.style.display = "none";
			}
		}
	}
}


function select_map(iMapId, oCenterOnPoint) {
	if ((!SeatingItems)) {
		this.loadMap(iMapId);
	} else {
		if (cursize) {
			// save current one
			cursize.magnification_increment = currentMagnification;
			cursize_list[current_seat_map] = cursize;
			cursize = null;
		}
		cursize = typeof cursize_list[iMapId] == "undefined" ? null : cursize_list[iMapId];
	}


	var selectedImage = null;
	if (current_seat_map != iMapId) {
		$('#seat_map' + current_seat_map).hide();
		// selectedImage = $g("sm" + current_seat_map + "_" + current_seat_map_image_id);
		// if ( selectedImage )
		// 	selectedImage.style.display = "none"; // hide any currently visible one;
	}
	$('#seat_map' + iMapId).show();


	if ((current_seat_map != iMapId) || oCenterOnPoint) {
		current_seat_map = iMapId;
		var tab_select_seats = $g("tab_select_seats");
		setTab(tab_select_seats);

		for (var x = 0; x < imagesizes[iMapId].images.length; x++) {
			if (cursize || (syos2_width <= imagesizes[iMapId].images[x].width)) {
				if (oCenterOnPoint && oCenterOnPoint.width > imagesizes[iMapId].images[x].width) {
					currentMagnification = oCenterOnPoint.magnification_increment;
					cursize.magnification_increment = currentMagnification;
					continue;
				}
				selectedImage = $g("sm" + iMapId + "_" + x);
				var targetWidth = syos2_width - (2 * syos2_map_inset);
				var targetHeight = Math.floor(targetWidth * (imagesizes[iMapId].height / imagesizes[iMapId].width));
				var seat_map_container = $g("seat_map" + iMapId + "_container");
				if (cursize) {
					currentMagnification = cursize.magnification_increment;
					if (currentMagnification == 0)
						alert("currentMagnification = 0!");

					if (oCenterOnPoint) {
						seat_map_container.style.left = "" + (0 - oCenterOnPoint.x + Math.floor(oCenterOnPoint.viewport_size.width / 2)) + px;
						seat_map_container.style.top = "" + (0 - oCenterOnPoint.y + Math.floor(oCenterOnPoint.viewport_size.height / 2)) + px;
					} else {
						seat_map_container.style.left = "" + cursize.left + px;
						seat_map_container.style.top = "" + cursize.top + px;
					}
					targetHeight = cursize.height;
					targetWidth = cursize.width;
				} else {
					var syos2_map = $g("syos2_map");
					var syos2_map_height = parseInt(syos2_map.style.height);
					current_seat_map_image_id = x;
					var targetmag_width = targetWidth / imagesizes[iMapId].width;
					var targetmag_height = syos2_map_height / imagesizes[iMapId].height;
					currentMagnification = fit_initial_image_option ? Math.min(targetmag_width, targetmag_height) : targetWidth / imagesizes[iMapId].width;

					targetWidth = Math.floor(imagesizes[iMapId].width * currentMagnification);
					targetHeight = Math.floor(imagesizes[iMapId].height * currentMagnification);
					
					if ( targetWidth < (syos2_width - (2 * syos2_map_inset)))
						seat_map_container.style.left = "" + Math.floor(( syos2_width - (2 * syos2_map_inset) - targetWidth)/2) + px;

					if (targetHeight < syos2_map_height)
						seat_map_container.style.top = "" + Math.floor((syos2_map_height - targetHeight)/2) + px;

					
					// if (selectedImage.src.indexOf(img_clear) > -1)
					selectedImage.src = img_src[iMapId][x]; // to avoid preloading the images
				}


				selectedImage.style.width = "" + targetWidth + px;
				selectedImage.style.height = "" + targetHeight + px;
				selectedImage.style.display = "block";

				for (var y = 0; y < imagesizes[iMapId].images.length; y++) {
					if (y != x || cursize) {
						// since we're done with the selected as used above, we'll repurpose the variable
						// for use in our iteration here
						selectedImage = $g("sm" + iMapId + "_" + y);
						selectedImage.style.width = "" + targetWidth + px;
						selectedImage.style.height = "" + targetHeight + px;
						// if (selectedImage.src.indexOf(img_clear) > -1 || selectedImage.src.indexOf(img_src[iMapId][y]) == -1 )
						selectedImage.src = img_src[iMapId][y]; // to avoid preloading the images
					}
				}

				if (!cursize) {
					cursize = new sizeitem(targetWidth, targetHeight);
					cursize.magnification_increment = currentMagnification;
				}

				hide_other_seatmaps(iMapId);

				setSlider(currentMagnification);
				break;
			}
		}

		var seat_map_dots_div = $g("seat_map" + iMapId + "_dots");
		seatdots = seat_map_dots_div.getElementsByTagName("img");
		plotSeats(iMapId, true);

	} else {
		if (SeatingItems != null)
			setTab($g("tab_select_seats"));
	}

	if (current_seat_map > -1) {
		current_vfs = vfs_images[current_seat_map];
		if (current_vfs != null) {
			var vfsimg = $g("vfs_" + (current_seat_map + 1));
			if (vfsimg && ( vfsimg.src == null || vfsimg.src.indexOf(img_clear) > -1) )
				vfsimg.src = current_vfs.url;
		}
	}

	// dofeedback();
}


/*
	as a user mouses over a map, show the pricing grid underneath.
*/



function BuildMapPricing(iMapId) {
	if (typeof BuildMapPricingOverride == "function"){
		BuildMapPricingOverride(iMapId);
	} else BuildMapPricingLocal(iMapId);
}

function BuildMapPricingLocal(iMapId) {
	var perfOrPkgNo = perf_no > 0 ? perf_no : pkg_no;

	var done = false;
	var div_map_pricing = $g("div_map_pricing");
	var child_tables = div_map_pricing.getElementsByTagName("table");
	for (var b = 0; b < child_tables.length; b++)
		if (child_tables[b].id != ("pricing" +  perfOrPkgNo + "" + iMapId))
			child_tables[b].style.display = "none";
	else {
		child_tables[b].style.display = "block";
		done = true;
	}

	if (!done) {
		var width = 250; // startpoint;
		var table = document.createElement("table");
		table.setAttribute("cellspacing", "0");
		table.setAttribute("class", "map_pricing map_pricing" + (iMapId - 1));
		table.style.display = "block";
		table.id = "pricing" +  perfOrPkgNo + "" + iMapId;
		var tr = document.createElement("tr");
		var td = document.createElement("th");

		var show_pricetype_selection = (GetPerformanceDetails.ZonePricingItems[0].Prices.length > 1);
		if (show_pricetype_selection && show_pricetypes_radio_in_table && ( ! isIE || IEv > 7 )) {
			td.appendChild(document.createTextNode("Selected Pricing:"));
			td.style.textAlign = "right";
			td.setAttribute("class", "sp_zonename");
			// td.style.width = "250px";
			tr.appendChild(td);

			var inputradio = null;

			for (var a1 = 0; a1 < GetPerformanceDetails.ZonePricingItems[0].Prices.length; a1++) {
				td = document.createElement("th");
				td.style.textAlign = "center";
				inputradio = document.createElement("input");
				inputradio.type = "radio";
				inputradio.name = "radio_currentpricetype" + iMapId;
				if (a1 == 0) {
					inputradio.setAttribute("checked", "checked");
					current_price_type = GetPerformanceDetails.ZonePricingItems[0].Prices[a1].PriceTypeId;
				}
				inputradio.onclick = selectPrice;
				inputradio.value = GetPerformanceDetails.ZonePricingItems[0].Prices[a1].PriceTypeId;
				td.appendChild(inputradio);
				tr.appendChild(td);
			}
			table.appendChild(tr);
			tr = document.createElement("tr");
			td = document.createElement("th");
		} else {
			try {
				current_price_type = GetPerformanceDetails.ZonePricingItems[0].Prices[0].PriceTypeId;
			} catch (e) {
				current_price_type = GetPerformanceDetails.SinglePriceType;
			}
		}

		td.appendChild(document.createTextNode("Seating Section"));
		td.setAttribute("class", "sp_zonename");
		// td.style.width = "250px";
		tr.appendChild(td);
		
		
		
		for (var a = 0; a < GetPerformanceDetails.ZonePricingItems[0].Prices.length; a++) {
			td = document.createElement("th");
			try {
				for (var a1 = 0; a1 < GetPerformanceDetails.ZonePricingItems.length; a1++) {
					if (GetPerformanceDetails.ZonePricingItems[a1] != null && GetPerformanceDetails.ZonePricingItems[a1].Prices[a] != null) {
						td.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[a1].Prices[a].PriceTypeName));
						break;
					}
				}
			} catch (Error) {
				td.appendChild(document.createTextNode("n/a"));
			}
			
			// td.style.width = "150px";
			td.style.textAlign = "center";
			tr.appendChild(td);
			width += 150;
		}
		table.appendChild(tr);

		for (var c = 0; c < GetPerformanceDetails.ZonePricingItems.length; c++) {
			if (GetPerformanceDetails.ZonePricingItems[c].syos_map_id == iMapId ) {
				tr = document.createElement("tr");
				tr.setAttribute("class", "zone_no" + GetPerformanceDetails.ZonePricingItems[c].ZoneNo);
				td = document.createElement("td");
				td.setAttribute("class", "sp_zonename");
				td.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[c].Description));
				tr.appendChild(td);

				for (var d = 0; d < GetPerformanceDetails.ZonePricingItems[c].Prices.length; d++) {
					td = document.createElement("td");
					td.style.textAlign = "center";
					try {
						td.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[c].Prices[d].PriceString));
					}
					catch (err) {
						td.appendChild(document.createTextNode("n/a"));
					}
					tr.appendChild(td);
				}
				table.appendChild(tr);
			}
		}



		// table.style.width = "" + width + px;
		table.style.width = "100%";

		var holder = document.createElement("div");
		holder.appendChild(table);

		if (isIE && (IEv < 8)) {
			if (show_pricetype_selection) {
				var pricing_div = document.createElement("div");
				pricing_div.setAttribute("id", "ie7_pricing_div");
				pricing_div.appendChild(document.createTextNode("Please select your price level: "));

				var ie_pricing_select = document.createElement("select");
				ie_pricing_select.setAttribute("onchange", "current_price_type=this.options[this.selectedIndex].value");
				for (var a1 = 0; a1 < GetPerformanceDetails.ZonePricingItems[0].Prices.length; a1++) {
					if (a1 == 0)
						current_price_type = GetPerformanceDetails.ZonePricingItems[0].Prices[a1].PriceTypeId;
					var pricing_option = document.createElement("option");
					pricing_option.setAttribute("value", GetPerformanceDetails.ZonePricingItems[0].Prices[a1].PriceTypeId);
					pricing_option.appendChild(document.createTextNode(GetPerformanceDetails.ZonePricingItems[0].Prices[a1].PriceTypeName));
					ie_pricing_select.appendChild(pricing_option);
				}
				pricing_div.appendChild(ie_pricing_select);
				holder.appendChild(pricing_div);
			}

			var ieHTML = $(holder).html();
			$('#div_map_pricing').html(ieHTML);
		} else div_map_pricing.appendChild(holder);

		if (typeof BuildMapPricingComplete == "function")
			BuildMapPricingComplete();
	}
}

function selectPrice(){
	current_price_type = this.value;
}


function setover(iFacilNo, iMap){
	overmap = iMap;
	var img = $g("f" + iFacilNo + "_" + iMap);
	if (img && (iMap > 0)) {
		img.style.mozOpacity = ".9999";
		img.style.opacity = ".9999";
		img.style.filter = "alpha(opacity=99)";
		dosetout(iFacilNo, 0);
	}
	BuildMapPricing(iMap);
}

function dosetout(iFacilNo, iMap) {
	var img = $g("f" + iFacilNo + "_" + iMap);
	if (img && (iMap > 0)) {
		img.style.mozOpacity = ".0001";
		img.style.opacity = ".0001";
		img.style.filter = "alpha(opacity=00)";
	}

	if (overmap == 0) {
		img = $g("f" + iFacilNo + "_0");
		img.style.mozOpacity = ".9999";
		img.style.opacity = ".9999";
		img.style.filter = "alpha(opacity=99)";
	}

}

function setout(iFacilNo, iMap) {
	// postpone descision about what to do for 100ms. Then if we haven't
	// entered a new item, we'll enable the composite map.
	setTimeout("dosetout(" + iFacilNo + "," + iMap + ")", 100);
	overmap = 0;
}

function setRowSeatPriceSection(r, s, p, t) {
	$('#rowseatpricebaloon_row').html(r);
	$('#rowseatpricebaloon_seat').html(s);
	$('#rowseatpricebaloon_price').html(p);
	$('#rowseatpricebaloon_section').html(t);
}

function toggle_pricing(oImg, r, s, p, t) {
	var loc = getxy(oImg);
	var loc2 = getxy("syos2_seat_selector");
	var img_width = parseInt(oImg.style.width);
	var rowseatpricebaloon = $g("rowseatpricebaloon");
	rowseatpricebaloon.style.left = "" + (loc.x - loc2.x - 113 + Math.floor(img_width / 2)) + px;
	rowseatpricebaloon.style.top = "" + (loc.y - loc2.y - 117 + 2) + px;
	if (r) {
		setRowSeatPriceSection(r, s, p, t);
		$(rowseatpricebaloon).show();
	} else
		$(rowseatpricebaloon).hide();
}

function setTab(oTabDiv) {
	if (oTabDiv.id != syos2_current_tab && (oTabDiv.id != "tab_select_seats" || current_seat_map > -1)) {
		var img = $g(syos2_current_tab + "_img");
		img.src = "/syos/images/TabDimmed64_170x35.png";

		img = $g(oTabDiv.id + "_img");
		img.src = "/syos/images/TabSelected170x35.png";

		syos2_current_tab = oTabDiv.id;

		if (oTabDiv.id == "tab_select_seats") {
			$('#syos2_seat_selector').show();
			if (vfs_images[current_seat_map] != null)
				$('#view_from_seats_holder').show();
			else {
				$('#view_from_seats_holder').hide();
				view_from_seats_visible = false;
			}
		} else {
			$('#syos2_seat_selector').hide();
			view_from_seats_visible = false;

		}

		if (oTabDiv.id == "tab_syos_help")
			$('#syos2_help').show();
		else
			$('#syos2_help').hide();


	}
	if (oTabDiv.id == "tab_select_seats" && current_seat_map == -1)
		alert("Please select a seating section.");
}

function adjustWindow(){
	var syos2 = $g("syos2");
	syos2.style.width = "" + (syos2_width) + px;
	syos2.style.height = "" + (syos2_height) + px;


	var syos2_map = $g("syos2_map");
	var syos2_map_top = parseInt(syos2_map.style.top);
	var syos2_map_height = syos2_height - syos2_map_top - syos2_map_inset;  // - syos_proceed_height;
	var syos2_map_width = syos2_width - (2 * syos2_map_inset);
	syos2_map.style.height = "" + syos2_map_height + px;
	syos2_map.style.width = "" + syos2_map_width + px;
	syos2_map.style.left = "" + syos2_map_inset + px;

	var syos_proceed = $g("syos_proceed");
	// var syos_proceed_height = parseInt(syos_proceed.style.height);
	syos_proceed.style.top = "" + (syos2_map_top + syos2_map_height) + px;
	var cart_details = $g("cart_details");
	syos_proceed.style.width = cart_details.style.width;
	syos_proceed.style.left = "" + Math.floor((syos2_map_width - parseInt(cart_details.style.width)) / 2) + px;

	var syos2innershad_v = $g("syos2innershad_v");
	syos2innershad_v.style.left = "" + syos2_map_inset + px;
	syos2innershad_v.style.top = "" + syos2_map_top + px;
	syos2innershad_v.style.height = syos2_map.style.height;

	var syos2innershad_h = $g("syos2innershad_h");
	syos2innershad_h.style.left = "" + syos2_map_inset + px;
	syos2innershad_h.style.top = "" + syos2_map_top + px;
	syos2innershad_h.style.width = syos2_map.style.width;

	var syos2_section_selector = $g("syos2_section_selector");
	syos2_section_selector.style.width = syos2_map.style.width;
	syos2_section_selector.style.height = syos2_map.style.height;

	var syos2_seat_selector = $g("syos2_seat_selector");
	syos2_seat_selector.style.width = syos2_map.style.width;
	syos2_seat_selector.style.height = syos2_map.style.height;

	var syos2_help = $g("syos2_help");
	syos2_help.style.width = syos2_map.style.width;
	syos2_help.style.height = syos2_map.style.height;

	if (typeof syos_key_placement_adjust == "function")
		syos_key_placement_adjust();

	addShadow("syos2");
}

function set_performance_summary() {
	// GetPerformanceDetails
	var div = document.createElement("div");
	div.id = "performance_summary_details";
	var h3 = document.createElement("h3");
	h3.appendChild(document.createTextNode(GetPerformanceDetails.Title));
	div.appendChild(h3);
	var p = document.createElement("p");
	p.setAttribute("class", "perf_summary_details");
	p.appendChild(document.createTextNode(GetPerformanceDetails.VenueName + ", " + GetPerformanceDetails.Date));
	div.appendChild(p);
	$('#performance_summary').html($(div).html());
}


function toggle_syos2(iFacilityNo, iSelectedMap, oCenterOnPoint ) /* parameters 2 and 3 are optional */ {
	if (imagesizes.length == 0)
		setup_syos_data()

	var syos2_section_selector_imageholder = $g("syos2_section_selector_imageholder");
	var selectorImages = null;
	var syos2_holder = $g("syos2_holder");
	if (syos2_visible) {
		document.body.style.cursor = "wait";
		$('#rowseatpricebaloon').hide(); // in case it was showing
		selectorImages = syos2_section_selector_imageholder.getElementsByTagName("img");
		var target = "f" + default_facility_no + "_";
		for (var x = 0; x < selectorImages.length; x++) {
			if (selectorImages[x].id.substr(0, 3) == target.substr(0, 3))
				selectorImages[x].style.display = "block";
			else
				selectorImages[x].style.display = "none";

		}
		// reset items

		for (var x = 0; x < 50; x++) {
			var cseatmap = $g("seat_map" + x);
			if (!cseatmap)
				break;


			var seat_map_container = $g("seat_map" + x + "_container");
			if (seat_map_container) {
				seat_map_container.style.left = "0px";
				seat_map_container.style.top = "0px";
			}
			
			var seat_map_dots_div = $g("seat_map" + x + "_dots");
			if (!seat_map_dots_div)
				continue;
			
			var seat_map_dots_div_nodecount = seat_map_dots_div.childNodes.length;
			for (var y = seat_map_dots_div_nodecount - 1; y > -1; y--)
				seat_map_dots_div.removeChild(seat_map_dots_div.childNodes[y]);
		}


		setTab($g("tab_select_section"));
		overmap = 0;
		currentMagnification = 0.0;
		currentImageID = -1;
		current_seat_map_image_id = -1;
		current_scroll_direction = ""
		current_scroll_amount = 0;
		currentSeatDotSize = 0;
		cursize = null;
		cursize_list = []; // array of cursize items, indexed by current_seat_map
		trackZoom = 0;
		GetPerformanceDetails = null;
		current_price_type = 0;
		perf_no = 0;
		pkg_no = 0;
		SeatingItems = null;
		PriceLookups = [];
		ZoneDescriptions = [];
		syos_proceed_visible = false;
		userCartInfo = null;
		hilightedZone = -1;
		CartInfo = null;
		$('#syos_proceed').hide();
		seatdotsvisible = false;
		document.body.style.cursor = "default";
		$('#loading_seats').show();
		current_seat_map = -1;

		$(syos2_holder).hide();
		syos2_visible = false;


		var div_map_pricing = $g("div_map_pricing");
		var child_tables = div_map_pricing.getElementsByTagName("table");
		for (var b = 0; b < child_tables.length; b++)
			child_tables[b].style.display = "none";
	} else {
		var view_from_seats_checkbox = $g("view_from_seats_checkbox");
		view_from_seats_checkbox.checked = false;
		selectorImages = syos2_section_selector_imageholder.getElementsByTagName("img");
		var target = "f" + iFacilityNo + "_";
		for (var x = 0; x < selectorImages.length; x++) {
			if (selectorImages[x].id.substr(0, target.length) == target)
				selectorImages[x].style.display = "block";
			else
				selectorImages[x].style.display = "none";
		}


		var ww = getwindowsize();
		var st = getscrolltop();
		var syos2 = $g("syos2");

		// set size
		syos2_width = ww.x - (2 * syos2_inset);
		syos2_holder.style.width = "" + syos2_width + px;

		syos2_height = ww.y - (2 * syos2_inset);
		syos2_holder.style.height = "" + syos2_height + "px";

		syos2_holder.style.left = "" + Math.floor((ww.x - syos2_width) / 2) + px;
		syos2_holder.style.top = "" + (st.y + syos2_inset) + px; //Math.floor((ww.y + syos2_height) / 2)

		var syos_label_text = $g("syos_label_text");
		syos_label_text.style.backgroundColor = syos2.style.backgroundColor;

		adjustWindow();

		if (typeof arrange_section_selection == "function") {
			arrange_section_selection();
		}

		set_performance_summary();
		if (iSelectedMap) {
			if (oCenterOnPoint)
				select_map(iSelectedMap, oCenterOnPoint);
			else
				select_map(iSelectedMap);
		}
		$(syos2_holder).show();
		syos2_visible = true;
	}
}


var view_from_seats_visible = false;
var current_vfs = null;

function track_view_from_seats(e) {
	if (current_vfs) {
		var offsetAmt = { x: 14, y: 22 };
		var view_from_seats_imageholder = $g('view_from_seats_imageholder');
		if (e.clientX > syos2_inset && e.clientY > syos2_inset) {
			if (e.clientX < (syos2_inset + syos2_width) && e.clientY < (syos2_inset + syos2_height)) {
				if (!view_from_seats_visible) {
					$(view_from_seats_imageholder).show();
					view_from_seats_visible = true;
				}
				var trialX = (offsetAmt.x + e.clientX);
				if (trialX + view_from_seats_imageholder.offsetWidth + 15 > (syos2_inset * 2) + syos2_width)
					trialX = (syos2_inset * 2) + syos2_width - view_from_seats_imageholder.offsetWidth - 15;
				view_from_seats_imageholder.style.left = "" + trialX + px;
				view_from_seats_imageholder.style.top = "" + (offsetAmt.y + e.clientY) + px;
			}
			else if (view_from_seats_visible) {
				$(view_from_seats_imageholder).hide();
				view_from_seats_visible = false;
			}
		}
		else if (view_from_seats_visible) {
			$(view_from_seats_imageholder).hide();
			view_from_seats_visible = false;
		}
	}
}

function show_view_from_seats(bShow) {
	if (bShow) {
		current_vfs = vfs_images[current_seat_map];
		if (current_vfs != null) {
		
			var vfsimg = $g("vfs_" + (current_seat_map + 1));
			if (vfsimg.src == null || vfsimg.src.indexOf(img_clear) > -1)
				vfsimg.src = current_vfs.url;
			var sibling_images = vfsimg.parentNode.getElementsByTagName("img");
			for (var x = 0; x < sibling_images.length; x++) {
				if (sibling_images[x].id != vfsimg.id)
					$(sibling_images[x]).hide();
				else
					$(sibling_images[x]).show();
			}
			DW.addEvent(window, 'mousemove', track_view_from_seats);
			
		}
	} else {
		DW.removeEvent(window, 'mousemove', track_view_from_seats);
		current_vfs = null;
		$('#view_from_seats_imageholder').hide();
		view_from_seats_visible = false;
	}
}


function seat_view_for_image(oImg) {
	if (view_from_seats_visible)
	{
		var x_coord = Math.floor(((cursize.width / 2) + (-1 * oImg.attributes["x_coord"].nodeValue * cursize.width)) / (cursize.width / current_vfs.cols)); // range: 0...#cols - 1
		var y_coord = Math.floor(((cursize.height / 2) + (-1 * oImg.attributes["y_coord"].nodeValue * cursize.height)) / (cursize.height / current_vfs.rows)); // range; 0...#rows - 1
		// alert("(" + x_coord + ", " + y_coord + ")");
		var vfsimg = $g("vfs_" + (current_seat_map + 1));
		if (vfsimg) {
			vfsimg.style.left = "" + Math.floor((-1 * x_coord * current_vfs.width) / current_vfs.cols) + px;
			vfsimg.style.top = "" + Math.floor((-1 * y_coord * current_vfs.height) / current_vfs.rows) + px;
		}
	}
}


function RemoveAllSeats(iPerfNo, iPkgNo, fCompletionAction ) {
	var req = getreq();

	this.handler = function(){
		if (req.readyState == 4) {
			if (req.status == 200) {
				var rslt = JSON.parse(req.responseText);
				try {
					rslt = rslt.d;
				} catch (err) { }
				if (rslt.Success) {
					if (fCompletionAction)
						fCompletionAction(rslt);
				}
			}
		}

	}

	this.validate = function() {
		return { "perf_no": iPerfNo, "pkg_no": iPkgNo };
	}

	var sendObj = this.validate();

	if (sendObj && req) {
		req = getreq();
		req.open(HTTP_VERB, (srvr + SYOSWS + "RemoveAllSeats"), true);
		req.setRequestHeader(CONTENT_TYPE, APP_JSON);
		req.onreadystatechange = this.handler;
		req.send(JSON.serialize(sendObj));
	}

}

function hide_help(sHowlong) {
	$('#syos_navigation_help').hide();
	if (sHowlong == 'permanent')
		createCookie('syos_navigation_help', 'hide', 1000);
	else if ( sHowlong == "session" )
		createCookie('syos_navigation_help', 'hide');
}

function toggle_cart_display(oSpan,minText,maxText) {
	var cart_details = $g("cart_details");
	var perf_cart_header = $g("perf_cart_header");
	if ($(oSpan).html() == maxText) {
		var parxy = getxy(cart_details.parentNode);
		var cart_details_width = parseInt(cart_details.style.width);
		cart_details.style.top = "" + (0 - cart_details.clientHeight - 1) + "px";
		cart_details.style.left = "" + Math.floor((cart_details.parentNode.clientWidth - cart_details_width) / 2) + px;

		perf_cart_header.style.top = "" + (0 - cart_details.clientHeight - 21) + "px";
		perf_cart_header.style.left = cart_details.style.left;
		perf_cart_header.style.width = "" + (cart_details.clientWidth) + px; // 16 = 2 * 8 padding on cart_details div

		$(oSpan).html(minText);
	} else {
		$(oSpan).html(maxText);
		cart_details.style.left = "-9999px";
		perf_cart_header.style.top = "" + (0 - perf_cart_header.clientHeight) + px;
	}
}

function doshowsyos(iPerfNo, iFacilityNo, oCaller) {
	if (typeof doshowsyos_override == "function")
		doshowsyos_override(iPerfNo, iFacilityNo, oCaller);
	else
		doshowsyos_local(iPerfNo, iFacilityNo, oCaller);
}

function doshowsyos_local(iPerfNo, iFacilityNo, oCaller, postCallBackHandler ) {
	var req = getreq();

	this.handler = function() {
		if (req.readyState == 4) {
			document.body.style.cursor = "default";
			if (oCaller.style)
				oCaller.style.cursor = "default";
			if (req.status == 200) {
				var rslt = JSON.parse(req.responseText);
				try {
					rslt = rslt.d;
				} catch (err) { }
				if (rslt.Success) {
					GetPerformanceDetails = rslt;
					if (GetPerformanceDetails.SinglePriceType > 0)
						current_price_type = GetPerformanceDetails.SinglePriceType;
					toggle_syos2(iFacilityNo);

					if (GetPerformanceDetails.SingleMapID > 0)
						setover(iFacilityNo, GetPerformanceDetails.SingleMapID);
				} else {
					alert(tkt_unavailable_message);
				}
				if (postCallBackHandler)
					postCallBackHandler(rslt);
			} else if (postCallBackHandler)
				postCallBackHandler();
		}
	}


	this.validate = function(){
		var retval = { "perf_no": 0 };
		retval.perf_no = iPerfNo;
		perf_no = retval.perf_no;
		if (retval.perf_no > 0)
			return retval;
	}

	var sendObj = this.validate();

	if (req && sendObj){
		document.body.style.cursor = "wait";
		if (oCaller.style)
			oCaller.style.cursor = "wait";
		req = getreq();
		req.open(HTTP_VERB, (srvr + SYOSWS + "GetPerformanceDetails"), true);
		req.setRequestHeader(CONTENT_TYPE, APP_JSON);
		req.onreadystatechange = this.handler;
		req.send(JSON.serialize(sendObj));
	}
}


function changePriceForSelectedSeat(iLiSeqNo, iSeatNo, iPriceType, oCaller) {
	var req = getreq();

	this.handler = function() {
		if (req.readyState == 4) {
			document.body.style.cursor = "default";
			if (req.status == 200) {
				var rslt = JSON.parse(req.responseText);
				try {
					rslt = rslt.d;
				} catch (err) { }
				if (rslt.PerformanceNumber)
					format_performance_cart(rslt.SubLineItemsSeats);
				else alert(req.responseText);
			} else alert(req.responseText);
		}
	}

	this.validate = function() {
		return { "iLiSeqNo": iLiSeqNo, "iSeatNo": iSeatNo, "iPriceType": iPriceType };
	}

	var sendObj = this.validate();
	if (req && sendObj) {
		$(oCaller).hide();
		document.body.style.cursor = "wait";
		req = getreq();
		req.open(HTTP_VERB, (srvr + SYOSWS + "ChangePriceForSelectedSeat"), true);
		req.setRequestHeader(CONTENT_TYPE, APP_JSON);
		req.onreadystatechange = this.handler;
		req.send(JSON.serialize(sendObj));
	}
}

/*$(document).ready(function()
{
	setup_syos_data();
});
*/

DW.addEvent(window, 'load', setup_syos_data);