// [MODULE-HEADER]
// *************************************************************************************************
//
// Name:				ShoWareWebControlsSeatContainer.js
//
// Created:			9/12/2003 VisionOne AG, St Gallen fbe
// Modified:		10/19/2009 VisionOne AG, St Gallen  RHA	: SCR 1554  JTP Seatmap Publishing 
// Modified:		04.12.2006 VisionOne AG, St. Gallen DST	: Hide reservation time on seatmap tooltip (frontend)
// Modified:		Mi-07.04.2004 VisionOne AG, St. Gallen EPE	: changed the CSS class at the function swscST
// Modified:		12/02/2004 VisionOne AG, St Gallen fbe	: Changed the Css to 'SeatMapTooltipText'
// Modified:		9/12/2003 VisionOne AG, St Gallen fbe	: Creation
//
// *************************************************************************************************

var SWSC_BACKGROUNDCOLOR = "#FFFFFF";
var SWSC_LEFT = 0;
var SWSC_TOP = 150;

//
// Show the seat tooltip of a nonbookable seat
//
function swscNT(seatTypeIndex)
{
	swscShowBalloon("<center>" + swsc_seatType[seatTypeIndex] + "</center>");
	return true;
}


//
// Shows the seat tooltip for html drawn seat map
//
// Parameters:
// seatIdentifier: the seat identifier
// rowInformationIndex: The row information index in the swsc_rowInformation array. If -1 there isnt a row information
// seatTypeIndex: The seat type index in the swsc_seatType array
// seatStatusIndex: The seat status index in the swsc_seatStatus array
// priceCategoryIndex: The price category index in the swsc_priceCategory array
// reservationEnd: The reservation end date. If the seat is not reserved it will be empty
// contingentSubscription: Indicates the subscription/contigent status of the seat. If 'S' the seat has a subscription. If it is 'C' the seat has a contingent. Otherwise the value is '0' (zero)
// nonBookableNameIndex: The index of the non bookable description in the swsc_nonBookable array. -1 if it doesnt apply for this seat
// perspectiveImageIndex: The index of the image to use as the perspective from this seat.
//
function swscST(seatIdentifier, rowInformationIndex, seatTypeIndex, seatStatusIndex, priceCategoryIndex, reservationEnd, contigentSubscription, nonBookableNameIndex, perspectiveImageIndex)
{
	var rowInformation = "";
	if (rowInformationIndex >= 0)
		rowInformation = swsc_rowInformation[rowInformationIndex];

	var seatType = "";
	if (seatTypeIndex >= 0)
		seatType = swsc_seatType[seatTypeIndex];

	var nonBookableName = "";
	if (nonBookableNameIndex >= 0)
		nonBookableName = swsc_nonBookable[nonBookableNameIndex]; 

	swscSTGeneral(seatIdentifier, rowInformation, seatType, seatStatusIndex, swsc_priceCategory[priceCategoryIndex], reservationEnd, contigentSubscription, nonBookableName, perspectiveImageIndex);
	
	return true;
}

//
// Shows the seat tooltip
//
// Parameters:
// seatIdentifier: the seat identifier
// rowInformation: The row information
// seatType: The seat type
// seatStatusIndex: The seat status index in the swsc_seatStatus array
// priceCategory: The price category name
// reservationEnd: The reservation end date. If the seat is not reserved it will be empty
// contingentSubscription: Indicates the subscription/contigent status of the seat. If 'S' the seat has a subscription. If it is 'C' the seat has a contingent. Otherwise the value is '0' (zero)
// nonBookableName: The non bookable description
// perspectiveImageIndex: The index of the image to use as the perspective from this seat.
//
function swscSTGeneral(seatIdentifier, rowInformation, seatType, seatStatusIndex, priceCategory, reservationEnd, contigentSubscription, nonBookableName, perspectiveImageIndex)
{
	var text = "<table border=0 width='100%' cellspacing=0 cellpadding=0><tr><td class='SeatMapTooltipTitleText'><center>" + swsc_keywords[0] + ": " + seatIdentifier + "</center></td></tr><tr><td> </td></tr><tr><td class='SeatMapTooltipText'><center>";
	
	if (rowInformation != "")
		text += rowInformation + "<br>";
		
	if (seatType != "")
		text += seatType + "<br>";

	if (seatStatusIndex >= 0)
		text += swsc_seatStatus[seatStatusIndex] + "<br>";
	
	// 04.12.2006 VisionOne AG, St. Gallen DST: Hide reservation time on seatmap tooltip (frontend) 
	// if (reservationEnd != "")
	//	 text += reservationEnd + "<br>";
	
	if (contigentSubscription == "C")
		text += swsc_keywords[1];
	else if (contigentSubscription == "S")
		text += swsc_keywords[2];
	
	if (nonBookableName != "")
		text += ": " + nonBookableName; 
	if (contigentSubscription == "C" || contigentSubscription == "S")
		text += "<br>";
	
	text += priceCategory + "<br>";
	text += "</center></td></tr>";
	
	if (perspectiveImageIndex != null)
	{
		if (perspectiveImageIndex > -1)
		{
			if (SeatContainerPerspectiveImageURLs)
			{
				if (SeatContainerPerspectiveLabel)
				{
					text += "<tr><td class='SeatMapPerspectiveLabel'>" + SeatContainerPerspectiveLabel + "</tr>";
				}
				var imgurl = SeatContainerPerspectiveImageURLs[perspectiveImageIndex];
				text += "<tr><td class='SeatMapPerspectiveImage' align='center'><img src='" + imgurl + "'></td></tr>";
			}
		}
	}
	
	text += "</table>";

	swscShowBalloon(text);	
	return true;
}

var balloonChangeVDirSave = 5;
var balloonSpaceSave = 10;
//
// Show the balloon with the text
//
function swscShowBalloon(text)
{
	// 5/08/2004 VisionOne AG, St Gallen fbe
	// Changing the position of the tooltip
	balloonChangeVDirSave = balloonChangeVDir;
	balloonSpaceSave = balloonSpace;
	balloonChangeVDir = -10;
	balloonSpace = 14;
	
	showBalloon(text, SWSC_LEFT, SWSC_TOP, SWSC_BACKGROUNDCOLOR);
}

//
// Hides the balloon tooltip
//
function swscHT()
{
	hideBalloon();
		
	// 5/08/2004 VisionOne AG, St Gallen fbe
	// Changing the position of the tooltip	
	balloonChangeVDir = balloonChangeVDirSave;
	balloonSpace = balloonSpaceSave;	
	
	return true;
}

//
// Add seat to list for reservation
//
function addSeat(seatImage, seatId, seatStatusIndex)
{
	var seatCheckBox = document.getElementById(seatId);
	if (seatCheckBox.checked == 0)
	{
		seatCheckBox.checked = 1;
		seatImage.style.backgroundColor = "#FFFFFF";
		seatImage.src = swsc_seatImageUrls[0];
	}
	else
	{
		seatCheckBox.checked = 0;
		seatImage.style.backgroundColor = seatImage.attributes['initialColor'].value;
		seatImage.src = swsc_seatImageUrls[seatStatusIndex];
	}
}

