﻿// JScript File
var winOpen;
var index = 1;

var enableCache = false;
var jsCache = new Array();
var getvalue = new Array();
var AjaxObjects = new Array();

var enableCache2 = false;
var jsCache2 = new Array();
var AjaxObjects2 = new Array();
var getvalue2 = new Array();
        
var enableCache1 = false;
var jsCache1 = new Array();
var AjaxObjects1 = new Array();

var style_cookie_name = "style" ;
var style_cookie_duration = 30 ;

var Addr_enableCache = false;
var Addr_jsCache = new Array();
var Addr_AjaxObjects = new Array();

// **************************************************** For Destination City Populate Here **************************************
        
function PopulateDepartureCityCallAjax() 
{
	var City;
	var url;
	City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dep_City").value;
		
    if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dep_City").value == "")
    {
        CloseDepartureCityDiv()
        return false;
	}
		
	url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateDepCity';	
	
    if (enableCache && jsCache[url]) {
        document.getElementById(divId).innerHTML = jsCache[url];
        return;
    }

    var ajaxIndex = AjaxObjects.length;
    AjaxObjects[ajaxIndex] = new sack();
    AjaxObjects[ajaxIndex].requestFile = url;
    AjaxObjects[ajaxIndex].onCompletion = function() { ShowDepartureCityDivContent(ajaxIndex, url); };
    AjaxObjects[ajaxIndex].runAJAX();
}

function ShowDepartureCityDivContent(ajaxIndex, url) 
{
	document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").innerHTML = AjaxObjects[ajaxIndex].response;
	
	if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").innerHTML=='')
	{
		CloseDepartureCityDiv()
        return false;
	}
	else
	{
		if (enableCache) {
			jsCache[url] = AjaxObjects[ajaxIndex].response;
		}
		AjaxObjects[ajaxIndex] = false;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").style.display="block"; 
    }
}


function GetDepartureCityAjaxDetails(divId) 
{        
     if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").value == "")
     {
        CloseDepartureCityDiv()
        return false;
    }
    var City;
	var url;
	City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dep_City").value;
		    
    url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateDepCity';	
	
		
	//alert(url);
    if (enableCache2 && jsCache2[url]) {
        document.getElementById(divId).innerHTML = jsCache2[url];
        return;
    }

    var ajaxIndex2 = AjaxObjects2.length;
    AjaxObjects2[ajaxIndex2] = new sack();
    AjaxObjects2[ajaxIndex2].requestFile = url;
    AjaxObjects2[ajaxIndex2].onCompletion = function() { ShowDepartureCityContent(divId, ajaxIndex2, url); };
    AjaxObjects2[ajaxIndex2].runAJAX();
}

function ShowDepartureCityContent(divId, ajaxIndex2, url) 
{
	//document.getElementById(divId).innerHTML = AjaxObjects[ajaxIndex].response;
	var returnvalue = AjaxObjects2[ajaxIndex2].response;
	//alert(returnvalue);	

	if (enableCache2) {
		jsCache2[url] = AjaxObjects2[ajaxIndex2].response;
	}
	AjaxObjects2[ajaxIndex2] = false;
	//document.getElementById(divId).style.display = '';
}

function CloseDepartureCityDiv()
{
  if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").style.display="none";
    }   
  if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="none";
    }    
  if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Company_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Company_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Company_City").style.display="none";
    }   
 if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav1_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav1_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav1_City").style.display="none";
    }   
 if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav2_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav2_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Fav2_City").style.display="none";
    }  
  if (document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="none";
    }           
}

function PutDepartureCityTextBoxValue(Value)
{
	document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dep_City").value =Value;
	document.getElementById("ctl00_SA_YellowCab_Content_Div_Dep_City").style.display="none";
}

// **************************************************** For Destination City Populate Here **************************************
 
function PopulateDestinationCityCallAjax() 
{
	var City;
	var url;
	City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dest_City").value;
		
    if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dest_City").value == "")
    {
        CloseDestinationCityDiv()
        return false;
	}
		
	url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateDestCity';	
	
    if (enableCache && jsCache[url]) {
        document.getElementById(divId).innerHTML = jsCache[url];
        return;
    }

    var ajaxIndex = AjaxObjects.length;
    AjaxObjects[ajaxIndex] = new sack();
    AjaxObjects[ajaxIndex].requestFile = url;
    AjaxObjects[ajaxIndex].onCompletion = function() { ShowDestinationCityDivContent(ajaxIndex, url); };
    AjaxObjects[ajaxIndex].runAJAX();
}

function ShowDestinationCityDivContent(ajaxIndex, url) 
{
	document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").innerHTML = AjaxObjects[ajaxIndex].response;
	
	if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").innerHTML=='')
	{
		CloseDestinationCityDiv()
        return false;
	}
    else
    {
		if (enableCache) {
			jsCache[url] = AjaxObjects[ajaxIndex].response;
		}
		AjaxObjects[ajaxIndex] = false;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").style.display="block"; 
	}
}


function GetDestinationCityAjaxDetails(divId) 
{        
    if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").value == "")
    {
        CloseDestinationCityDiv()
        return false;
    }
    var City;
	var url;
	City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dest_City").value;
		    
    url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateDestCity';	
	
		
	//alert(url);
    if (enableCache2 && jsCache2[url]) {
        document.getElementById(divId).innerHTML = jsCache2[url];
        return;
    }

    var ajaxIndex2 = AjaxObjects2.length;
    AjaxObjects2[ajaxIndex2] = new sack();
    AjaxObjects2[ajaxIndex2].requestFile = url;
    AjaxObjects2[ajaxIndex2].onCompletion = function() { ShowDepartureCityContent(divId, ajaxIndex2, url); };
    AjaxObjects2[ajaxIndex2].runAJAX();
}

function ShowDepartureCityContent(divId, ajaxIndex2, url) 
{
	//document.getElementById(divId).innerHTML = AjaxObjects[ajaxIndex].response;
	var returnvalue = AjaxObjects2[ajaxIndex2].response;
	//alert(returnvalue);	

	if (enableCache2) {
		jsCache2[url] = AjaxObjects2[ajaxIndex2].response;
	}
	AjaxObjects2[ajaxIndex2] = false;
	//document.getElementById(divId).style.display = '';
}


function CloseDestinationCityDiv()
{
  if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City"))
    {
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").style.display="";
        document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").style.display="none";
    }   
}


function PutDestinationCityTextBoxValue(Value)
{
	document.getElementById("ctl00_SA_YellowCab_Content_Txt_Dest_City").value =Value;
	document.getElementById("ctl00_SA_YellowCab_Content_Div_Dest_City").style.display="none";
}

// **************************************************** For Common City Populate Start Here **************************************
 
function PopulateCityCallAjax(CallType) 
{
	var City;
	var url;
	if (CallType=='HOME')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Home_City").value;
		
		if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_Home_City").value == "")
		{
			CloseDepartureCityDiv()
			return false;
		}
	}
	
	
	else if (CallType=='COMPANY')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_company_City").value;
		
		if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_company_City").value == "")
		{
			CloseDepartureCityDiv()
			return false;
		}
	}
	
	
	else if (CallType=='FAV1')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav1_City").value;
		
		if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav1_City").value == "")
		{
			CloseDepartureCityDiv()
			return false;
		}
	}
	
	
	else if (CallType=='FAV2')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav2_City").value;
		
		if (document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav2_City").value == "")
		{
			CloseDepartureCityDiv()
			return false;
		}
	}
	
		
	url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateCityCommon' + '&ReqType=' + CallType;	
	
    if (enableCache && jsCache[url]) {
        document.getElementById(divId).innerHTML = jsCache[url];
        return;
    }

    var ajaxIndex = AjaxObjects.length;
    AjaxObjects[ajaxIndex] = new sack();
    AjaxObjects[ajaxIndex].requestFile = url;
    AjaxObjects[ajaxIndex].onCompletion = function() { ShowCityDivContent(ajaxIndex, url, CallType); };
    AjaxObjects[ajaxIndex].runAJAX();
}

function ShowCityDivContent(ajaxIndex, url, CallType) 
{
	if (CallType=='HOME')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").innerHTML = AjaxObjects[ajaxIndex].response;
		
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").innerHTML=='')
		{
			CloseDepartureCityDiv()
			return false;
		}
	    else
	    {
			if (enableCache) {
				jsCache[url] = AjaxObjects[ajaxIndex].response;
			}
			AjaxObjects[ajaxIndex] = false;
			document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="block"; 
		}
	}
	
	
	else if (CallType=='COMPANY')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").innerHTML = AjaxObjects[ajaxIndex].response;
	    
	    if (document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").innerHTML=='')
		{
			CloseDepartureCityDiv()
			return false;
		}
		else
		{
			if (enableCache) {
				jsCache[url] = AjaxObjects[ajaxIndex].response;
			}
			AjaxObjects[ajaxIndex] = false;
			document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="block"; 
		}
	}
	
	
	else if (CallType=='FAV1')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").innerHTML = AjaxObjects[ajaxIndex].response;
	    if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").innerHTML=='')
		{
			CloseDepartureCityDiv()
			return false;
		}
		else
		{
			if (enableCache) {
				jsCache[url] = AjaxObjects[ajaxIndex].response;
			}
			AjaxObjects[ajaxIndex] = false;
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").style.display="block"; 
		}
	}
	
	
	else if (CallType=='FAV2')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").innerHTML = AjaxObjects[ajaxIndex].response;
	    if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").innerHTML=='')
		{
			CloseDepartureCityDiv()
			return false;
		}
		else
		{
			if (enableCache) {
				jsCache[url] = AjaxObjects[ajaxIndex].response;
			}
			AjaxObjects[ajaxIndex] = false;
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").style.display="block"; 
		}
	}
}


function GetCityAjaxDetails(divId,CallType) 
{        
	if (CallType=='HOME')
	{
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").value == "")
		{
			CloseCityDiv(CallType)
			return false;
		}
	}
	
	
	else if (CallType=='COMPANY')
	{
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").value == "")
		{
			CloseCityDiv(CallType)
			return false;
		}
	}
	
	
	else if (CallType=='FAV1')
	{
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").value == "")
		{
			CloseCityDiv(CallType)
			return false;
		}
	}
	
	
	else if (CallType=='FAV2')
	{
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").value == "")
		{
			CloseCityDiv(CallType)
			return false;
		}
	}

    var City;
	var url;	
	if (CallType=='HOME')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_Home_City").value;
	}
	
	
	else if (CallType=='COMPANY')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_company_City").value;
	}
	
	
	else if (CallType=='FAV1')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav1_City").value;
	}
	
	else if (CallType=='FAV2')
	{
		City = document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav2_City").value;
	}
			    
    url = 'AjaxRequest.aspx?SearchValue='+ City + '&Type=PopulateCityCommon' + '&ReqType=' + CallType;	
	
    if (enableCache2 && jsCache2[url]) {
        document.getElementById(divId).innerHTML = jsCache2[url];
        return;
    }

    var ajaxIndex2 = AjaxObjects2.length;
    AjaxObjects2[ajaxIndex2] = new sack();
    AjaxObjects2[ajaxIndex2].requestFile = url;
    AjaxObjects2[ajaxIndex2].onCompletion = function() { ShowCityContent(divId, ajaxIndex2, url); };
    AjaxObjects2[ajaxIndex2].runAJAX();
}

function CloseCityDiv(CallType)
{
	if (CallType=='HOME')
	{	
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City"))
		{
			document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="";
			document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="none";
		}  		
	}
	
	
	else if (CallType=='COMPANY')
	{	
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City"))
		{
			document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="";
			document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="none";
		}  		
	}
	
	
	else if (CallType=='FAV1')
	{	
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City"))
		{
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").style.display="";
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").style.display="none";
		}  		
	}
	
	
	else if (CallType=='FAV2')
	{	
		if (document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City"))
		{
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").style.display="";
			document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").style.display="none";
		}  		
	}
	
 
}

function ShowCityContent(divId, ajaxIndex2, url) 
{
	var returnvalue = AjaxObjects2[ajaxIndex2].response;

	if (enableCache2) {
		jsCache2[url] = AjaxObjects2[ajaxIndex2].response;
	}
	AjaxObjects2[ajaxIndex2] = false;
}

function PutCityTextBoxValue(Value,CallType)
{
	if (CallType=='HOME')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Txt_Home_City").value =Value;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_Home_City").style.display="none";	
	}
	
	
	else if (CallType=='COMPANY')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Txt_company_City").value =Value;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_company_City").style.display="none";	
	}
	
	
	else if (CallType=='FAV1')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav1_City").value =Value;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_fav1_City").style.display="none";	
	}
	
	
	else if (CallType=='FAV2')
	{
		document.getElementById("ctl00_SA_YellowCab_Content_Txt_fav2_City").value =Value;
		document.getElementById("ctl00_SA_YellowCab_Content_Div_fav2_City").style.display="none";	
	}
	
}
// **************************************************** For Common City Populate End Here **************************************
