﻿// JScript File

 var Value;
    var keyValue="";
  
    var  drpLocation=null;
    var  drpDate=null;  
    var drpCity=null;
   

function trim(str) {
 if (str == null)
  return "";
 if (str.length <1)
    return "";
    
 var i =0;
 while (str.charAt(i) == ' ')
        i++;
 str = str.substr(i);
 i = str.length;
 while (str.charAt(--i) == ' ')
        ;
 str = str.substr(0, (str.length + 1 + (i - str.length)));
 return str;
}
 function SearchTheater1Movie(drpCity1,drpLocation1)
    {
          drpCity=drpCity1;
           drpLocation=drpLocation1;  
         Value=0;
         if(Value==0)
            {
            if(document.getElementById('drpCity_Movie').value!='0')
            {
	            keyValue=document.getElementById('drpCity_Movie').value;	           
	        }	       	     
	        if(keyValue!="")
	        {  
	            var listt = document.getElementById('drpLocation_Movie'); 
	            listt.options.length = 0 ; 
	            
	            listt.options[listt.options.length] = new Option("Loading....","0");
	            
	            MovieHome.CityWiseTheaterDetails(keyValue,SearchTheater1Movie_CallBack);
	          
	            document.getElementById('txtCityid_Movie').value=document.getElementById('drpCity_Movie').value;
	        }
	         
	
	       }
	
	
	
     }


function SearchTheater1Movie_CallBack(response) 
{
 
    Value=1;
   var objTable = response.value;
	var count=0;
	var NoOfRows="";
	if(objTable !=null)
	{	
	if(objTable.Rows==null)
	{
	count=1;
	
	NoOfRows=objTable.length;
	}
	else
	{
	count=2;
	
	NoOfRows=objTable.Rows.length;
	//alert(NoOfRows)
	}
	if(NoOfRows==0 && keyValue!=0)
	{
	
	alert("Sorry! There are no Location available for the selected city.");
	}
	 if(objTable == null || typeof(objTable) != "object") 
	 { 
	 return; 
	 } 
	 var list = document.getElementById('drpLocation_Movie');
	  list.options.length = 0 ; 
	  list.options[list.options.length] = new Option("Select Your Location","0");
	for(var i = 0 ; i < NoOfRows; i++) 
		{	
			
			if(count==1)
			{
			list.options[list.options.length] = new Option(trim(objTable[i].TM_Name),objTable[i].TM_Id);
			}
			else
			{
					
			list.options[list.options.length] = new Option(trim(objTable.Rows[i].TM_Name),objTable.Rows[i].TM_Id);
			}
		}
    }
    else
    {
        alert("Sorry! There are no Location available for the selected city.");
    }
}

function SearchDateofShows1Movie(drpLocation1,drpDate1)
{
      drpLocation=drpLocation1
      drpDate=drpDate1  
   var keycenter=document.getElementById('txtCityid_Movie').value;
   
   var keyTheater=document.getElementById('drpLocation_Movie').value;
   
   var Keymovie=document.getElementById('txtMovid_Movie').value;	          
   
   var list1 = document.getElementById('drpDate_Movie'); list1.options.length = 0 ; 
   list1.options[list1.options.length] = new Option("Loading....","0");
   MovieHome.GetShowDate_Details(keycenter,keyTheater,Keymovie,SearchDate1Movie_CallBack);
   document.getElementById('txtTheaterid_Movie').value=document.getElementById('drpLocation_Movie').value;	
}
function SearchDate1Movie_CallBack(response) 
{
   var objTable = response.value;
   
	var count=0;
	
	var NoOfRows;
	if(objTable !=null)
	{
	if(objTable.Rows==null)
	{
	count=1;
	NoOfRows=objTable.length;
	}
	else
	{
	count=2;
	NoOfRows=objTable.Rows.length;
	}

	 if(objTable == null || typeof(objTable) != "object") { return; } 
	 var list = document.getElementById('drpDate_Movie'); list.options.length = 0 ; 
	 list.options[list.options.length] = new Option("Select Your Date","0");
	  for(var i = 0 ; i < NoOfRows; i++) 
		{	
			if(count==1)
			{
			list.options[list.options.length] = new Option(objTable[i].SD_ShowDate,objTable[i].SD_ShowDate);
			}
			else
			{
			list.options[list.options.length] = new Option(objTable.Rows[i].SD_ShowDate,objTable.Rows[i].SD_ShowDate);
			}
		}
	}
	
}

function testDate1Movie()
{
document.getElementById('txtdate_Movie').value=document.getElementById('drpDate_Movie').value;
 return;
}
