var objHTTP=getHTTPObject();
var ControlId=new String("");
var URL="/AJAX/Selection.aspx?";
function getHTTPObject()
{
	var objXMLHTTP;
	try
	{
		objXMLHTTP=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			objXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e1)
		{
			objXMLHTTP=null;
		}
	}
	if (!objXMLHTTP && typeof XMLHttpRequest!='undefined')
	{
		try
		{
			objXMLHTTP=new XMLHttpRequest();
		}
		catch(e)
		{
			objXMLHTTP=false;
		}
	}
	return objXMLHTTP;
}
function generateURL(QueryStr)
{
	var strQueryString=new String(QueryStr);
	while(strQueryString.indexOf(",")>0)
		strQueryString=strQueryString.replace(",","&");
	return URL+strQueryString;
}
function CallAJAX(strControlId,requestURL)
{

	ControlId=strControlId;
	objHTTP.open("GET",generateURL(requestURL+",Rand="+Math.random()),true);
	objHTTP.onreadystatechange=AJAXResponse;
	objHTTP.send(null);
}
function AJAXResponse()
{
	if(objHTTP.readyState==4)
	{
		HTTPResponse(objHTTP.responseText);
	}
}
function ClearAllElement(drpId)
{
	document.getElementById(drpId).options.length=0;
}
function EnableElement(drpId)
{
	document.getElementById(drpId).disabled='';
}
function DisableElement(drpId)
{
	document.getElementById(drpId).disabled='disabled';
	document.getElementById(drpId).style.backgroundColor="#dcdcdc";
	document.getElementById(drpId).style.color="#a3a3a3";
}
function ClearDiv(divId)
{
	document.getElementById(divId).innerHTML="";
}
function AddBookingProcess(divId)
{
	var strBookingProcess=new String("");
	strBookingProcess=strBookingProcess+"<div  style='WIDTH: 260px;FONT-WEIGHT:bold; FONT-SIZE:12px; COLOR:#993399; FONT-FAMILY:Verdana, Arial, Helvetica, sans-serif'>Online Booking Of Tickets Made Simple</div>";
	strBookingProcess=strBookingProcess+"<div style='text-align:left; WIDTH: 275px;FONT-SIZE:10px; COLOR:#993399; FONT-FAMILY:Verdana, Arial, Helvetica, sans-serif'>";
	strBookingProcess=strBookingProcess+"	<ol type='1' style='margin-top:7px;'>";
	strBookingProcess=strBookingProcess+"		<li>Select Movie, City, Location and Date.</li>";
	strBookingProcess=strBookingProcess+"		<li>Select Show, Login to the site.</li>";
	strBookingProcess=strBookingProcess+"		<li>Select Class & No. of Seats. You can Also choose your seats from the seat layout.</li>";
	//strBookingProcess=strBookingProcess+"		<li>You can also select Food Combo's and buy them online.</li>";
	strBookingProcess=strBookingProcess+"		<li>Make your payment using a credit card.</li>";
	strBookingProcess=strBookingProcess+"		<li>Enter your card details. On approval of payment you will receive the booking confirmation.</li>";
	strBookingProcess=strBookingProcess+"	</ol>";
	strBookingProcess=strBookingProcess+"</div>";
	document.getElementById(divId).innerHTML=strBookingProcess;
}
function AddFirstElement(drpId)
{
	var drpOption=document.createElement("OPTION");
	drpOption.text="Select "+drpId.substring(3,drpId.length);
	drpOption.value="0";
	document.getElementById(drpId).options[document.getElementById(drpId).length]=drpOption;
}
function HTTPResponse(strHTTPResult)
{
	if((strHTTPResult!="")&&(strHTTPResult.indexOf("<head>")<0))
	{
		var arrResponse=new Array();
		arrResponse=strHTTPResult.split("|");
		for(var i=0;i<arrResponse.length;i++)
		{
			arrResponse[i]=arrResponse[i].toString().split("=");
		}
		if(ControlId.toLowerCase()=="divshowtiming")
		{
			var divShowTimings=new String("");
			divShowTimings="<table class='showtimings01' border='0' cellspacing='0' cellpadding='0'>";
			for(var i=0;i<arrResponse.length;i=i+1)
			{
				divShowTimings=divShowTimings+"<tr>";
				for(var j=0;j<1;j++)
				{
					if((i+j)<arrResponse.length)
					{
						var strRemovestring='';
						strRemovestring=arrResponse[i+j][0];
						if(strRemovestring.indexOf("-1")<0)
						{
							divShowTimings=divShowTimings+"<td class='almostsold03' width='100%' align='left'><a style='text-decoration:none;' href=\"#\" id="+arrResponse[i+j][1]+" onclick=\"openSelectSeats('"+arrResponse[i+j][1]+"');return false;\">"+strRemovestring+"</a></td>";
						}
						else
						{
							strRemovestring=strRemovestring.replace("-1","");
							divShowTimings=divShowTimings+"<td class='almostsold03' width='100%' align='left'><a style='text-decoration:none;' href=\"#\" id="+arrResponse[i+j][1]+" onclick=\"openSelectSeats('"+arrResponse[i+j][1]+"');return false;\">"+strRemovestring+"&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;<img align='absmiddle' src='/images/goldclass_01.gif' border='0'></a></td>";
						}
					}
					else
					{
						divShowTimings=divShowTimings+"<td width='100%'>&nbsp;</td>";
					}
				}
				divShowTimings=divShowTimings+"</tr>";
			}
			divShowTimings=divShowTimings+"</table>";
			document.getElementById(ControlId).innerHTML=divShowTimings;
		}
		if(ControlId.toLowerCase()=="ddlcity" || ControlId.toLowerCase()=="ddllocation"
		|| ControlId.toLowerCase()=="ddlmovie" || ControlId.toLowerCase()=="ddldate")
		{
			for(var i=0;i<arrResponse.length;i++)
			{
				var drpOption=document.createElement("OPTION");
				drpOption.text=arrResponse[i][0];
				if(arrResponse[i][0].charAt(arrResponse[i][0].length-1)=="*")
				{
					drpOption.text=arrResponse[i][0].replace("*","");
				}
				drpOption.value=arrResponse[i][1];
				document.getElementById(ControlId).options[document.getElementById(ControlId).length]=drpOption;
				document.getElementById(ControlId).style.backgroundColor="#ffffff";
				document.getElementById(ControlId).style.color="#723078";
				if(arrResponse[i][0].charAt(arrResponse[i][0].length-1)=="*")
				{
					drpOption.style.color="#F87217";
				}
			}
			if(document.getElementById(ControlId).length>1)
			{
				EnableElement(ControlId);
			}
		}
	}
}
function Redirect_InnerBooking(strTab)
{
	var strLocationId=document.getElementById('ddlLocation').options[document.getElementById('ddlLocation').selectedIndex].value;
	var strMovieId=document.getElementById('ddlMovie').options[document.getElementById('ddlMovie').selectedIndex].value;
	var strDate=document.getElementById('ddlDate').options[document.getElementById('ddlDate').selectedIndex].value;
	var strCityId=document.getElementById('ddlCity').options[document.getElementById('ddlCity').selectedIndex].value;
	if(strMovieId!="0" && strCityId!="0" && strLocationId!="0" && strDate!="0")
	{
		var redirectURL="/Fame_Inner/InnerBookingPage.aspx?";
		redirectURL=redirectURL+"MovieId="+strMovieId+"&";
		redirectURL=redirectURL+"CityId="+strCityId+"&";
		redirectURL=redirectURL+"LocationId="+strLocationId+"&";
		redirectURL=redirectURL+"DateId="+strDate+"&";
		redirectURL=redirectURL+"TabName="+strTab;
		window.top.location.href=redirectURL;
	}
}
function openSelectSeats(strShow_Id)
{
	var strLocationId=document.getElementById('ddlLocation').options[document.getElementById('ddlLocation').selectedIndex].value;
	location.href="SeatSelection.aspx?Show_Id="+strShow_Id+"&Theatre_Id="+strLocationId;
	//location.href="SeatSelection_Offer.aspx?Show_Id="+strShow_Id+"&Theatre_Id="+strLocationId;
	//location.href="SeatSelection_sms.aspx?Show_Id="+strShow_Id+"&Theatre_Id="+strLocationId;
}