// JavaScript Document
function onChange()
{
	$('#select_date').html("<option>Select Date:</option>");
	$('#select_time').html("<option>Select Time:</option>");
	$('#select_movie').html('<option>loading....<option>');
	$("#book_ticket_button").attr("href", "#");
	$('#select_date').attr("disabled", true); 
	$('#select_time').attr("disabled", true); 
	var theatre_name = $('#select_cinema :selected').text();
	var venue_code = $('#select_cinema :selected').val();
	//alert(""+theatre_name+venue_code);
	$.ajax({
          		type: "GET",
		        url: "getMovieNames.php",
        		data: "venue_code=" + venue_code ,
		        success: function(msg)
				{
					$('#select_movie').attr("disabled", false);
					$('#select_movie').html(msg);
				}
     		});
}
function onChange1()
{
	$('#select_date').html('<option>loading....<option>');
	$('#select_time').attr("disabled", true); 
	$("#book_ticket_button").attr("href", "#");
	var movie_code = $('#select_movie :selected').val();
	var venue_code = $('#select_cinema :selected').val();
	$.ajax({
          		type: "GET",
		        url: "getMovieDates.php",
        		data: "venue_code=" + venue_code +'&movie_code='+movie_code,
		        success: function(msg)
				{
					//alert(""+msg);
					$('#select_date').attr("disabled", false);
					$('#select_date').html(msg);
				}
     		});
}
function onChange2()
{
	$('#book_ticket_button').attr("disabled", true);
	$('#select_time').html('<option>loading....<option>');
	$("#book_ticket_button").attr("href", "#");
	var movie_code = $('#select_movie :selected').val();
	var venue_code = $('#select_cinema :selected').val();
	var get_date = $('#select_date :selected').text();
	$.ajax({
          		type: "GET",
		        url: "getMovieTimes1.php",
        		data: "venue_code=" + venue_code + '&movie_code=' + movie_code + '&get_date=' + get_date,
		        success: function(msg)
				{
					$('#select_time').attr("disabled", false);
					$('#select_time').html(msg);
				}
     		});
}
function onChange3()
{
	var get_date = $('#select_time :selected').val();
	var movie_code = $('#select_movie').val();
	var venue_code = $('#select_cinema :selected').val();
	$("#book_ticket_button").attr("href", "#");
	$("#book_ticket_button1").hide();
	$.ajax({
          		type: "GET",
		        url: "get_movie_names1.php",
        		data: "venue_code=" + venue_code + '&movie_code=' + movie_code + '&movie_date=' + get_date,
		        success: function(msg)
				{
					$("#book_ticket_button1").show();
					$("#book_ticket_button").attr("href", msg);
				}
     		});
}
function onChange4()
{
	$('#select_date').html('<option>loading....<option>');
	$('#select_time').attr("disabled", true); 
	$("#book_ticket_button").attr("href", "#");
	var movie_code = $('#select_movie').val();
	var venue_code = $('#select_cinema :selected').val();
	$.ajax({
          		type: "GET",
		        url: "getMovieDates.php",
        		data: "venue_code=" + venue_code +'&movie_code='+movie_code,
		        success: function(msg)
				{
					//alert(""+msg);
					$('#select_date').attr("disabled", false);
					$('#select_date').html(msg);
				}
     		});
}
function onChange5()
{
	$('#book_ticket_button').attr("disabled", true);
	$('#select_time').html('<option>loading....<option>');
	$("#book_ticket_button").attr("href", "#");
	var movie_code = $('#select_movie').val();
	var venue_code = $('#select_cinema :selected').val();
	var get_date = $('#select_date :selected').text();
	$.ajax({
          		type: "GET",
		        url: "getMovieTimes.php",
        		data: "venue_code=" + venue_code + '&movie_code=' + movie_code + '&get_date=' + get_date,
		        success: function(msg)
				{
					$('#select_time').attr("disabled", false);
					$('#select_time').html(msg);
				}
     		});
}
function book_ticket()
{
	var theatre_name = $('#select_cinema :selected').text();
	var venue_code = $('#select_cinema :selected').val();
	var session_code = $('#select_date :selected').val();
	var book_my_show_string = "http://in.bookmyshow.com/go/?ref="+theatre_name+"&cid="+venue_code+"&sid="+session_code;
	alert(""+book_my_show_string);
	$("#select_date").attr("href", "http://www.google.com/");
	//window.location = book_my_show_string;
}
function checkLink()
{
	var get_link_val = $("#book_ticket_button").attr('href');
	if(get_link_val == "#")
	{
		alert("Please Select");
	}
	else
	{
		var link_is = $("#book_ticket_button").attr("href");
		window.location = link_is;
		//alert(""+link_is);
	}
}

