﻿// JScript File

//Starts Here datafunctions_regionalfeatures.js
//Global Variable

var glb_popdestlist;
var glb_popdestid;
var glb_popdestionation;
var glb_popdestcitieslist;
var glb_popdestcityname;
var glb_popdestionationsbycity; 
var pagingdivemoved; 
//used in map
var rskey_maptimeout="Mapping Application has timed out. Click OK to reload application  or Cancel to disable mapping."
var rskey_noroutemessage=" ! Map for this route is unavailable";


//508
var rskey_window = " - Opens New Window";
var rskey_tripplaner = " - Link to 511 Transit Tripplanner Website";
var rskey_popupbox = " - Open a Simulated Dialog";



//*********************************Starts Here:Agency profile by agencyid *********************

function getPopDestinations(callbackfunction)
{

if(glb_popdestlist==null){
      $.ajax({
      type: "GET",
      url: popdestlist_servicepath,
      dataType: "json",
      success: function(objdestinationlist){
           SetDestinationsList(objdestinationlist);
           callbackfunction(objdestinationlist);
          
           
       
       },
       
      error: function(){
          //alert("Error While Retrieving Popular Destination List : ");
          var referencetext="ServiceError:"+  popdestlist_servicepath;
          logerror(null,window.location,"datafunctions_regionalfeatures.js","getPopDestinations",InfoDestinationsByCategory,referencetext,"","");
       }
    });
  
  }
  else
  {
   callbackfunction(glb_popdestlist);
  }  
    
}
function SetDestinationsList(objdestinationlist)
 {
    glb_popdestlist=objdestinationlist;
  
 }
 
 //------------------------------
 
function getPopDestinationById(did,callbackfunction)
{

if(glb_popdestid!=did){
    SetDestinationID(did);
   
      $.ajax({
      type: "GET",
      url: popdestbyid_servicepath,
      data: "did=" + did,
      dataType: "json",
      success: function(objdestination){
          SetDestination(objdestination);
          callbackfunction(objdestination);
         
           
       
       },
       
      error: function(){
         //alert( "Error While Retrieving Popular Destination By ID : ");
         var referencetext="ServiceError:"+  popdestbyid_servicepath+"?did="+did ;
         logerror(null,window.location,"datafunctions_regionalfeatures.js","getPopDestinationById",InfoDestinationsById,referencetext,"","");
       }
    });
  
  }
  else
  {
   callbackfunction(glb_popdestionation);
  }  
    
}

function SetDestination(objdestinationlist)
 {
    glb_popdestionation=objdestinationlist;
    
 }
 
 function SetDestinationID(id)
 {
    glb_popdestid=id;
 }
 
 
function getPopDestinationCities(callbackfunction)
{

if(glb_popdestcitieslist==null){
      $.ajax({
      type: "GET",
      url: popdestcities_servicepath,
      dataType: "json",
      success: function(objcities){
           SetDestinationCities(objcities);
           callbackfunction(objcities);
          
           
       
       },
       
      error: function(){
         //alert( "Error While Retrieving Popular Destination Cities : ");
          var referencetext="ServiceError:"+  popdestcities_servicepath ;
          logerror(null,window.location,"datafunctions_regionalfeatures.js","getPopDestinationCities",InfoDestinationCities,referencetext,"","");
       }
    });
  
  }
  else
  {
   callbackfunction(glb_popdestcitieslist);
  }  
    
}

function SetDestinationCities(objcities)
{
    glb_popdestcitieslist=objcities;
}



function getPopDestinationByCity(cityname,callbackfunction)
{

if(glb_popdestcityname!=cityname){

      $.ajax({
      type: "GET",
      url: popdestbycity_servicepath,
      data: "city=" + cityname,
      dataType: "json",
      success: function(objdestinations){
           SetDestinationsByCity(objdestinations);
           SetCity(cityname);
           callbackfunction(objdestinations);
          
       
       },
       
      error: function(){
         //alert( "Error While Retrieving Popular Destination By City : ");
          var referencetext="ServiceError:"+  popdestbycity_servicepath+"?city="+cityname  ;
          logerror(null,window.location,"datafunctions_regionalfeatures.js","getPopDestinationByCity",InfoDestinationsByCity,referencetext,"","");
       }
    });
  
  }
  else
  {
   callbackfunction(glb_popdestionationsbycity);
  }  
    
}

function SetDestinationsByCity(objdestinations)
{
    glb_popdestionationsbycity=objdestinations;
}

function SetCity(cityname)
{
    glb_popdestcityname=cityname;
    
}

function HasAgencyServing(objdestination)
{
     var hasAgency=false;
     for(var property in objdestination.AgenciesServing){
        hasAgency=true;
        break;
     }
     return hasAgency 

}

function getAgencyProfile(agencyid,callbackfunction)
{
     $.ajax({
      type: "GET",
      data: "cid=" + agencyid ,
      url: agencyprofile_servicepath,
      dataType: "json",
      success: function(agencyprofile){
      callbackfunction(agencyprofile);
      },
       
      error: function(){
         //alert( "Error While Retrieving Agency profile : ");
         var referencetext="ServiceError:"+  agencyprofile_servicepath+"?cid="+agencyid  ;
          logerror(null,window.location,"datafunctions_regionalfeatures.js","getAgencyProfile",InfoAgency,referencetext,"","");
       }
    });
}

function getAgencyAddress(agencyprofile)
 {
      var str_return=null;
           if(agencyprofile.Address!=null)
           {
           str_return=agencyprofile.Address;
           }
       return str_return;
 }
 function getAgencyPhone(agencyprofile)
 {
      var str_return=null;
           if(agencyprofile.InternalContactInformation!=null)
           {
           str_return=agencyprofile.InternalContactInformation;
           }
       return str_return;
 }
                                    

//*********************************Help From Resource Starts Here **********************
function getHelp(resourceids,lang,callbackfunction)
{  
    try
    {
        $.ajax({
          type: "GET",
          data: "resourceids=" + resourceids+"&lang="+lang ,
          url: "gethelp.aspx",
          dataType: "text",
          success: function(helptext){
             callbackfunction(helptext)
           },
          error: function(){
             //alert( "Error While Retrieving Help:");
              var referencetext="Help:"+  resourceids +",language:"+lang ;
              logerror(null,window.location,"datafunctions_regionalfeatures.js","getHelp",ErrorWWWNonFatal,referencetext,"","");
           }
        });
    
    }
    catch(err)
    {
        var referencetext="Help:"+  resourceids +",language:"+lang ;
        logerror(err,window.location,"datafunctions_regionalfeatures.js","getHelp",ErrorWWWNonFatal,referencetext,"","")
    }    
     
     
}


//*********************************Help From Resource Ends Here **********************
//Ends Here datafunctions_regionalfeatures.js

//Starts Here renderingfucntions_regionalfeatures.js

    // JScript File

    //*********************************Starts Here: Popular Destionations  Categories List*********************
        
        
        
        function renderpopdestcategories(objcategories,selectedcategory,callbackfunction,container_div,loadcitiescallback,cty,did,loaddestdetailscallback)
        {
               try
               {
                   
                    $("#" + container_div).empty();
                     var _rowid;
                     var _cellcount=0;
                     $("<table  id='category_table' cellpadding='1' align='center'></table>").appendTo("#"+ container_div);
                       
                       $(objcategories.PopDestCatg).each(function(i)
                       {
                            //508
                            
                             var cindex = (i+1) * 25;
                             var ctabindex = 1500 + cindex - 2;
                             //508:end
                             
                             //append rows
                             if(_cellcount==0||_cellcount>2)
                             {
                                 _cellcount=0;
                                 _rowid='tr_cat_' + i;
                                 $("<tr id='" + _rowid +"'></tr>").appendTo("#category_table");
                             }
                             
                                //mantis#:3655
                             var iframeStr = "";
                             if($.browser.msie && $.browser.version=="6.0")
                             {
                                iframeStr = "<iframe title='Empty' id='iframe_destbycategory_" + objcategories.PopDestCatg[i].CategoryID +"' style='display:none;'></iframe>" 
                             }
                             
                             
                             if(i==0) //508
                             {
                                 $("<td valign='top'><ul class='popdestcategorymenu' id='popdestcategorymenu_"+ i +"'>" +
                                 "<li id='li_popdestcategorymenu_"+ i +"' class='sub'><a style='color:rgb(150, 150, 150);' href='javascript:void(0);' tabindex='"+ctabindex+"'></a>" +
                                 "<table cellpadding='0' cellspacing='0' class='importantRed' ><tr>"+
					             "<td><span id='span_selected_cat_" + objcategories.PopDestCatg[i].CategoryID + "' style='display:none;'>"+
					             "<img alt=' ' src='http://images.transit.511.org/RUI/fw/redDot.gif' width='10' height='10'/></span></td>"+
					             "<td><h2 class='hiddenText_508'>Destination by Category</h2>"+ objcategories.PopDestCatg[i].CategoryName +"</td></tr></table>"+
					             iframeStr +
					             "<div id='div_destbycategory_"+ objcategories.PopDestCatg[i].CategoryID +"'></div>"+
                                 "</li></ul><img alt='" + objcategories.PopDestCatg[i].CategoryName + "'  src='rotate/" + objcategories.PopDestCatg[i].ImageUrl+ "' width='142' height='66'" +
                                 " class='pop_photo'/></td>").appendTo("#" + _rowid);  //508
                             }
                             else //508
                             {
                                  $("<td valign='top'><ul class='popdestcategorymenu' id='popdestcategorymenu_"+ i +"'>" +
                                 "<li id='li_popdestcategorymenu_"+ i +"' class='sub'><a style='color:rgb(150, 150, 150);' href='javascript:void(0);' tabindex='"+ctabindex+"'></a>" +
                                 "<table cellpadding='0' cellspacing='0' class='importantRed' ><tr>"+
					             "<td><span id='span_selected_cat_" + objcategories.PopDestCatg[i].CategoryID + "' style='display:none;'>"+
					             "<img alt=' ' src='http://images.transit.511.org/RUI/fw/redDot.gif' width='10' height='10'/></span></td>"+
					             "<td>"+ objcategories.PopDestCatg[i].CategoryName +"</td></tr></table>"+
					             iframeStr +
					             "<div id='div_destbycategory_"+ objcategories.PopDestCatg[i].CategoryID +"'></div>"+
                                 "</li></ul><img alt='" + objcategories.PopDestCatg[i].CategoryName + "'  src='rotate/" + objcategories.PopDestCatg[i].ImageUrl+ "' width='142' height='66'" +
                                 " class='pop_photo'/></td>").appendTo("#" + _rowid);   //508                         
                             }
                              _cellcount++;
                             
                             $("#li_popdestcategorymenu_"+ i).unbind("mouseover").bind("mouseover",
                             function()
                             {
                               if(!$(this).hasClass("click"))
                                {
                                 $(this).removeClass("sub").removeClass("click").addClass("hover");
                                }
                               
                             });
                             $("#li_popdestcategorymenu_"+ i).unbind("mouseout").bind("mouseout",
                             function()
                             {
                                if(!$(this).hasClass("click"))
                                {
                                    $(this).removeClass("hover").removeClass("click").addClass("sub");
                                }
                                 
                             });	
                             
                             $("#li_popdestcategorymenu_"+ i).unbind("click").bind("click",
                             function(event)
                             {
                               // markselectedcategory(objcategories.PopDestCatg[i].CategoryID);
                                $(this).removeClass().addClass("click");
                                callbackfunction(objcategories.PopDestCatg[i],"div_destbycategory_" +objcategories.PopDestCatg[i].CategoryID);
                               
                                $("#a_categoryStart").focus();  //508
                                 //Fix for 0002466: Dropdown list in popular destinations in Firefox/3 and above 
                                  //yzhou: remove customize slider
//                                 if($.browser.mozilla && $.browser.version.substr(0,3)=="1.9")
//                                 {
//                                  
//                                   $("#ctl00_ContentPlaceHolder1_Map1_sliderHGC").attr("style","position: absolute; left: 10px; top: 35px; width: 13px; height: 154px;z-index:1;");
//                                 }   
    //                            if($(this).hasClass("click"))
    //                            {
    //                                $(this).removeClass();
    //                                $("#div_destbycategory_"+ objcategories.PopDestCatg[i].CategoryID).hide();
    //                            }
    //                            else
    //                            { 
    //                                $(this).removeClass().addClass("click");
    //                                $("#div_destbycategory_"+ objcategories.PopDestCatg[i].CategoryID).show();
    //                                callbackfunction(objcategories.PopDestCatg[i],"div_destbycategory_" +objcategories.PopDestCatg[i].CategoryID);
    //                               
    //                            }
                               
                               
                             });	
                             
                             $("#div_destbycategory_"+ objcategories.PopDestCatg[i].CategoryID).unbind("mouseout").bind("mouseout",	
                             function(event)
                             { 
                                   
                                     if($.browser.msie)//to avoid blinking effects for ie
                                     {
                                        if(event.srcElement.tagName=='DIV')
                                        { 
                                       
                                            $(this).hide();
                                            $(this).attr("style","z-index:999999999");
                                        }
                                     }
                                     else
                                     {
                                            if($.browser.mozilla)
                                            {
                                             
                                                if(event.relatedTarget.tagName=='DIV'||event.relatedTarget.tagName=='IMG')
                                                { 
                                                    $(this).hide();
                                                }
                                            }
                                     
                                          
                                             
                                     }   
                                  
                             }).unbind("mouseover").bind("mouseover",function()
                                {
                                   
                                                                           
                                        $(this).show();
                                    
                                  
                                });	
                             if(selectedcategory==objcategories.PopDestCatg[i].CategoryID)
                               {
                               
                                    markselectedcategory(selectedcategory);
                                    callbackfunction(objcategories.PopDestCatg[i],"div_destbycategory_" +objcategories.PopDestCatg[i].CategoryID );
                               }
                       });
                      
                      //Row Divider for cities and categories
                      $("<table cellpadding='0'><tr><td style='padding:2px 0 4px 0;'>" +
                      "<img alt=' ' src='http://images.transit.511.org/RUI/fw/transitBox/Divider.gif' /></td></tr></table>").appendTo("#"+container_div); 
    				 
				      loadcitiescallback(container_div,cty);											
                      
                      if(did!=null)
                      {
                        loaddestdetailscallback(did,container_div);
                      } 
               
               
               }
               catch(err)
                {
                    logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderpopdestcategories",ErrorWWWNonFatal,"","","");
                }
       
                 
                 
        }

    //*********************************Ends Here: Popular Destionations  Categories List*********************        
        
    //*********************************Starts Here: Popular Destionations By Category *********************                
        function renderdestinationsbycategory(objdestinations,container,callbackfunction,container_destdetail,container_destwithpaging)
        {
           try
           {
             //508: tabindex
             var categoryindex = objdestinations.CategoryID;
             var cindex = categoryindex * 25;
             var ctabindex = 1500 + cindex;
             var atabindex = ctabindex -1;
             //508: end 
             $("#"+ container).empty().addClass("populardestlistdiv").show();
             $("<table id='tbl_destination_list' cellspacing='0' width='100%'></table>").appendTo("#"+container);
             var objcategory;
             var objdestlist=objdestinations.DestinationsInCategory;
            if($(objdestlist).size()>0)
            {
                 objcategory=new Array() ;
                 $(objdestlist).each(function(i)
                 {
                    objcategory.push(objdestinations.CategoryName);
                 });  
                 
                 
                  if($.browser.msie && $.browser.version=="6.0")
                  {
                     $("#iframe_destbycategory_"+ objdestinations.CategoryID).empty().addClass("populardestlistdiv").show();  //mantis#:3655
                  }
                 
                 
                 
                $("<tr class='destlinkclass'><td ><a tabindex='"+atabindex+"' style='color:rgb(255, 255, 255);' id='a_categoryStart' href='javascript:void(0);'> </a></td><td ><a title='All " + objdestinations.CategoryName + "' tabindex='"+ctabindex+"'  id='a_All_cat_" + objdestinations.CategoryID + "' href='javascript:void(0);' class='destlinkclass' >All " + objdestinations.CategoryName + "</a></td></tr>").appendTo("#tbl_destination_list");  //508

                $("#a_All_cat_" + objdestinations.CategoryID).unbind("click").bind("click",
                        function()
                        {
                            loadDestinationByCategoryMap(objdestinations.CategoryID);
                            markselectedcategory(objdestinations.CategoryID);
                            setcategory(objdestinations.CategoryID);
                            renderdestinationpagelist(objdestlist,objcategory,container_destwithpaging,callbackfunction,container_destdetail);
                            hidedestinationdetail();
                            $("#tbl_destination_list").find("td.destlistclick").parent().removeClass().addClass("destlistunclick");
                            $(this).parent().parent().removeClass().addClass("destlistclick");
                            $("#"+container).hide();
                            
                             if($.browser.msie && $.browser.version=="6.0")
                             {
                                    $("#iframe_destbycategory_"+ objdestinations.CategoryID).removeClass().hide();  //mantis#:3655
                             }
                            
                            //added to hide tourist info
                            hidetourism();
                            return false;
                        }).unbind("mouseover").bind("mouseover",function(event)
                        {
                            $(this).parent().parent().removeClass().addClass("destlisthover");
                           
                           if($.browser.mozilla)event.stopPropagation();
                            
                        }).unbind("mouseout").bind("mouseout",function(event)
                        {
                            if(!$(this).parent().parent().hasClass("destlistclick"))
                            {
                             
                               $(this).parent().parent().removeClass().addClass("destlistunclick");
                                
                            }
                             
                            
                        });
                        
            }
             
              $(objdestlist).each(function(i)
              {
                
                var destTabindex = ctabindex + 1 + i;  //508: destination of category tabindex
               
                if(objdestlist[i].Name!=null&&objdestlist[i].Name!='')
                {
                   
                   $("<tr class='destlinkclass'><td >&nbsp;</td><td ><a title='" +objdestinations.CategoryName+" : "+ objdestlist[i].Name + " (" + objdestlist[i].City +")' tabindex='"+destTabindex+"' id='a_dest_" + objdestlist[i].ID  + "' href='javascript:void(0);'  class='destlinkclass'>" + objdestlist[i].Name + " (" + objdestlist[i].City +")</a></td></tr>").appendTo("#tbl_destination_list");  //508
                    $("#a_dest_" +  objdestlist[i].ID).unbind("click").bind("click",
                    function(event)
                    { 
                       // $("#div_category_list").find("span[@id*='span_selected_cat_']").hide();
                       
                        SetMapLoadlType("category", objdestinations.CategoryID);  
                        renderdestinationshortview(objdestlist[i],objdestinations.CategoryName,container_destwithpaging,callbackfunction,container_destdetail);
                        loadpopdestdetails(objdestlist[i].ID,"div_populardest");
                        //9.3
                         bln_clearmap=false;    
                        loadDestinationByID(objdestlist[i].ID);
                       // callbackfunction(objdestlist[i].ID,container_destdetail);
                        $("#tbl_destination_list").find("td.destlistclick").parent().removeClass().addClass("destlistunclick");
                        $(this).parent().parent().removeClass().addClass("destlistclick");
                        $("#"+container).hide();
                        //added to hide tourist info
                         hidetourism();    
                        return false;
                    }).unbind("mouseover").bind("mouseover",function(event)
                    {
                          $(this).parent().parent().removeClass().addClass("destlisthover");
                           
                       
                    }).unbind("mouseout").bind("mouseout",function(event)
                    {
                        if(!$(this).parent().parent().hasClass("destlistclick"))
                        {
                        
                                $(this).parent().parent().removeClass().addClass("destlistunclick");
                                 
                      
                        }
                         
                        
                    });
                 }   
              });
             
               
//                 $("#"+ container).unbind("mouseout").bind("mouseout",function(){$(this).hide();}
//                 ).unbind("mouseover").bind("mouseover",function(){$(this).show();})
 
   
           
           }
           catch(err)
           {
                logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderdestinationsbycategory",ErrorWWWNonFatal,"","","");
           }     
                 
                       
        }
       
    //*********************************Ends Here: Popular Destionations By Category *********************                

    //*********************************Starts Here: Popular Destionations With Paging Starts Here *********************                
      
       
      function renderdestinationpagelist(objdestinations,objdestcategory,container_div,detailcallback,detailcontainer)//show multiplse destinations
       {
         try
         {
               var destrecordcount=parseInt($(objdestinations).size(),10)-1;
               var cntlen=1;
               var divcount=1;
               var pagelen=10;
               var cellcount=1;
               var rowid='';
               var _recordcount=0;
               
             showdestinationpagediv(); 
             $("#" + container_div).empty().show();
             
             $("<table class='underMapBox' cellpadding='0' cellspacing='0' id='tbl_underMapBox'></table>").appendTo("#"+ container_div);
             $("<tr><td class='boxTop'></td></tr>").appendTo("#tbl_underMapBox");
             $("<tr><td class='contentBox' id='td_undermapContentBox'></td></tr>").appendTo("#tbl_underMapBox");
             $("<tr><td class='boxBtm'></td></tr>").appendTo("#tbl_underMapBox");
             $("<p align='right'><a id='a_viewstart' title='Destination List' tabindex='8788'><span class='hiddenText_508'>Destination List</span></a><a title='Print Destination List "+ rskey_window+"' tabindex='8790' id='print_dest' href='javascript:void(0);'><b>Print</b></a>&nbsp;&nbsp;<a tabindex='8792' href='javascript:void(0);' id='a_podest_bottomhelp'>"+
             "<img alt='help' src='http://images.transit.511.org/RUI/fw/iconHelp.gif' title='Help Popular Destination List" +rskey_popupbox+"'/></a></p>").appendTo("#td_undermapContentBox");  //508
             
             function render_popdistlisthelp(helpitem)
                {
                    renderhelp(helpitem,rskey_popdestbelow,xpos,ypos,"a_podest_bottomhelp");
                }
             
             $("#a_podest_bottomhelp").unbind("click").bind("click",
               function(event)
               {  
//                     xpos=event.pageX-350;
//                     ypos=event.pageY;
                     ///508
                    if(event.pageX>0)
                         xpos=event.pageX-350;
                    else
                         xpos=150;
                  
                    if(event.pageY>0)
                         ypos=event.pageY;
                    else
                         ypos=100;
                     
                     
                     ///
                     getHelp("pdesthelpbelow","en",render_popdistlisthelp);
                     $("#a_help_start").focus();//508
                    
               });
             
             
             $(objdestinations).each(function(idx)
             {  
                var tindex = 8800+idx;   //508
                if(objdestinations[idx].Name!=null && objdestinations[idx].Name!='')
                {
                    if(cntlen==1)
                    {
                        //Add New Div
                        if(divcount==1)
                        {
                            $("<div id='div_dest_page" + divcount + "'></div>").appendTo("#td_undermapContentBox");
                            $("<table cellpadding='0' cellspacing='0' class='underMapLegend' id='tbl_underMapLegend"+divcount+"'></table>").appendTo("#div_dest_page" + divcount);
                        }
                        else
                        {
                            $("<div id='div_dest_page" + divcount + "' style='display:none'></div>").appendTo("#td_undermapContentBox");
                            $("<table cellpadding='0' cellspacing='0' class='underMapLegend' id='tbl_underMapLegend"+divcount+"'></table>").appendTo("#div_dest_page" + divcount);
                        }
                    }
                    
                    if(cellcount==1)
                    {
                       rowid='tr_dest_page'+divcount +idx; 
                       $("<tr id='"+ rowid +"'></tr>").appendTo("#tbl_underMapLegend" + divcount);
                    }
                    var _catText='';
                    
                    if($.trim(objdestcategory[idx])!='')
                    {
                        _catText ="<br>"+ $.trim(objdestcategory[idx]);
                    }
                    $("<td class='"+ getItemClass(_recordcount) +"' valign='top'><a  tabindex='"+tindex+"'  href='javascript:void(0);' id='a_shortnamelink"+idx +"' style='text-decoration:none;'><strong>" + objdestinations[idx].Name + "</strong></a>" +
                        "<input type='hidden' id='txt_image_"+ objdestinations[idx].ID + "' value='"+ getItemImageName(_recordcount) +"'>" + _catText + "<br><span id='p_destdescription_"+objdestinations[idx].ID+"'>" + objdestinations[idx].Location + "</span></td>" ).appendTo("#"+ rowid);  //508
                    $("#a_shortnamelink"+idx).unbind("click").bind("click",function()
                    {
                       /* Commented for mantis issue 0003306
                        detailcallback(objdestinations[idx].ID,detailcontainer);
                        */
                        /*Added for mantis issue 0003306*/
                         function renderdetailonly(objdestination)
                         {
                             renderpopdestdetails(objdestination,detailcontainer); 
                         }
                         getPopDestinationById(objdestinations[idx].ID,renderdetailonly);
                        //9.3
                        loadDestinationMap(objdestinations[idx].ID);
                    }); 
                    UpdateDetailLink("p_destdescription_"+objdestinations[idx].ID );
                    if(idx==0){$("#a_shortnamelink0").focus();}
                    cellcount++;
                    if(cellcount>2)
                    {
                        cellcount=1;
                    }    
                 
                 
                 
                    if(cntlen==pagelen && idx<destrecordcount)
                    {
                       
                        $("<div class='underMapPageNavBox'><table width='100%'><tr id='tr_dest_nav" + divcount + "'>"+
                        "<td id='td_dest_nav"+divcount+"' style=' width:100%;text-align:right'></td></tr></table></div>").appendTo("#div_dest_page" + divcount);
                        //Display Previous  
                       if(divcount>1)
                       {
                         $("<a tabindex='8994' title='Destination List - Previous' id='a_dest_prev_" + divcount + "' href='javascript:void(0);'><< Previous</a>").appendTo("#td_dest_nav" + divcount);  //508
                         $("#a_dest_prev_" + divcount).unbind("click").bind("click",function(){
                              var prevdivid="div_dest_page" + (parseInt($(this).attr("id").split("_")[3],10)-parseInt(1));
                              var presentdivid="div_dest_page" + $(this).attr("id").split("_")[3];
                                $("#"+ prevdivid).show();
                                $("#"+ presentdivid).hide();
                                $("#a_viewstart").focus();//508
                            });     
                       }
                       else
                       {
                        $("&nbsp;").appendTo("#td_dest_nav" + divcount);
                       }
                       //Display More  
                        $("<a tabindex='8991' title='Destination List - Next' id ='a_dest_more_" + divcount + "' href='javascript:void(0);'>Next >></a>").appendTo("#td_dest_nav" + divcount);  //508
                        $("#a_dest_more_" + divcount).unbind("click").bind("click",function(){
                            var nextdivid="div_dest_page" + (parseInt($(this).attr("id").split("_")[3],10)+parseInt(1));
                            var presentdivid="div_dest_page" + $(this).attr("id").split("_")[3];
                                $("#"+ nextdivid).show();
                                $("#"+ presentdivid).hide();
                                $("#a_viewstart").focus();//508
                            });
                        divcount++;
                        cntlen=0;
                    } 
                    
                    if(idx==destrecordcount)
                    {
                       if(divcount>1)
                       {
                         //Display Previous  for the last page
                         $("<div class='underMapPageNavBox'><table width='100%'><tr><td style=' width:100%;text-align:right'><a tabindex='8993' id='a_dest_prev_" + divcount + "' href='javascript:void(0);'><< Previous</a></td></tr></table></div>").appendTo("#div_dest_page" + divcount);  //508
                         $("#a_dest_prev_" + divcount).unbind("click").bind("click",function(){
                              var prevdivid="div_dest_page" + (parseInt($(this).attr("id").split("_")[3],10)-parseInt(1));
                              var presentdivid="div_dest_page" + $(this).attr("id").split("_")[3];
                                $("#"+ prevdivid).show();
                                $("#"+ presentdivid).hide();
                                $("#a_viewstart").focus();//508
                            });     
                       }
                    }
                 


                   cntlen++;
                   _recordcount++; 
                }
               
                  
             });

		    		
    		$("#print_dest").unbind("click").bind("click",function()
            {
                
                if($("#dd_popular_city").val()!=0)
                {
                    window.open("printdestinations.aspx?city=" + $("#dd_popular_city").val(),null,MapWindowParams); 
                } 
                else
                {
               
                    if(getcategory()!=null)
                    {
                        window.open("printdestinations.aspx?categoryid=" + getcategory(),null,MapWindowParams); 
                    }
                }   
            }); 
            
            $("#a_viewstart").focus();		//508
		    
         }
         catch(err)
         {
            
            logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderdestinationpagelist",ErrorWWWNonFatal,"","","");
         
         } 
         
         
           
     }
     
     
       
    //*********************************Ends Here: Popular Destionations With Paging Ends Here *********************                  
       
    //*********************************Starts Here: Popular Destionations Short View  Starts Here *********************                  

    function renderdestinationshortview(objdestinations,categoryname,container_div,detailcallback,detailcontainer)
    {
        try
        {
             showdestinationpagediv();
             $("#" + container_div).empty().show();
             $("#<table class='underMapBox' cellpadding='0' cellspacing='0' id='tbl_underMapBox'></table>").appendTo("#"+ container_div);
             $("<tr><td class='boxTop'></td></tr>").appendTo("#tbl_underMapBox");
             $("<tr><td class='contentBox' id='td_undermapContentBox'></td></tr>").appendTo("#tbl_underMapBox");
             $("<tr><td class='boxBtm'></td></tr>").appendTo("#tbl_underMapBox")
             $("<p align='right'><a id='a_shortviewstart' tabindex='8788'><span class='hiddenText_508'>Destination Information:</span></a><a title='Print Destination"+ rskey_window+"'  tabindex='8790' id='print_dest' href='javascript:void(0);'><b>Print</b></a>&nbsp;&nbsp;<a tabindex='8792' title='Help Popular Destination List" +rskey_popupbox+"' href='javascript:void(0);' id='a_podest_shortbottomhelp'>"+
             "<img alt='help' src='http://images.transit.511.org/RUI/fw/iconHelp.gif' title='Help Popular Destination List" +rskey_popupbox+"'/></a></p>").appendTo("#td_undermapContentBox"); //508
             
             function render_popdistlisthelp(helpitem)
                {
                    renderhelp(helpitem,rskey_popdestbelow,xpos,ypos,"a_podest_shortbottomhelp");
                }
             
             $("#a_podest_shortbottomhelp").unbind("click").bind("click",
               function(event)
               {  
//                     xpos=event.pageX-350;
//                     ypos=event.pageY;
                     //508
                    if(event.pageX>0)
                    xpos=event.pageX-350;
                    else
                    xpos=150;
                  
                    if(event.pageY>0)
                    ypos=event.pageY;
                    else
                    ypos=100;
                     
                     getHelp("pdesthelpbelow","en",render_popdistlisthelp);
                     $("#a_help_start").focus();//508
                    
               });
             var _catText="";
             if(categoryname!="")
             {
                _catText="<br>" + categoryname;
             }
             
             $("<div id='div_dest_page1'></div>").appendTo("#td_undermapContentBox");
             $("<table cellpadding='0' class='underMapLegend' id='tbl_underMapLegend1'></table>").appendTo("#div_dest_page1");
             $("<tr id='tr_dest_page11'></tr>").appendTo("#tbl_underMapLegend1");
             $("<td class='itemA' valign='top'><strong><a href='javascript:void(0);' tabindex='8793' id='a_shortnamelink' style='text-decoration:none;'>" + objdestinations.Name + "</a></strong>" +
             _catText + "<br><span id='p_destdescription'>" + objdestinations.Location + "</span></td>" ).appendTo("#tr_dest_page11");  //508: one destination tabindex
            $("#a_shortnamelink").unbind("click").bind("click",function()
            {
                detailcallback(objdestinations.ID,detailcontainer);
                //9.3
                loadDestinationMap(objdestinations.ID);
            });
            $("#a_shortnamelink").focus();    
            UpdateDetailLink("p_destdescription");
            $("#print_dest").unbind("click").bind("click",function()
            {
                 window.open("printdestinations.aspx?did=" + objdestinations.ID,null,MapWindowParams); 
                
            });  
              
        }
        catch(err)
        {
        
            logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderdestinationshortview",ErrorWWWNonFatal,"","","");
        } 
         
        
    }     
        
    //*********************************Ends Here: Popular Destionations Short View Ends Here *********************                              


    //*********************************Starts Here: Popular Destionations Detail View Starts Here *********************    
       
    function renderpopdestdetails(objdestination,containerdiv)//single destination
        {
         
           try
           {
               
                var bln_anydataexist=false;
                //9.3
                
                if(GetMapLoadType()==undefined){loadDestinationByID(objdestination.destination.pd.ID);}
                
                 for(var property in objdestination.destination.pd.Categories){
                    markselectedcategory(property);
                 }
                  
                   hidesearchbycity();
                   clearpopularcitysearch();
                      
                    var img_tag='';
                    if(objdestination.destination.pd.ThumbnailFileName!=null)
                    {
                         if(objdestination.destination.pd.ImageFileName!=null)
                         {
                            img_tag="<a target='_blank' href='http://transit.511.org/static/destinations/"  + objdestination.destination.pd.ImageFileName +"'>"+
                                    "<img src='http://transit.511.org/static/destinations/"  + objdestination.destination.pd.ThumbnailFileName + "' align='right' width='170px' alt='image of popular destination'></a>";
                         }
                         else
                         {
                           img_tag="<img src='http://transit.511.org/static/destinations/"  + objdestination.destination.pd.ThumbnailFileName + "' align='right' width='170px' alt='image of popular destination'>";
                         }  
                    } 
                    var dest_name='&nbsp;';
                    if(objdestination.destination.pd.Name!=null&&objdestination.destination.pd.Name!='')
                    {
                      dest_name=objdestination.destination.pd.Name;
                      bln_anydataexist=true;
                    }   
                       
                
                
                $("#"+  containerdiv).find("#div_destdetail_top").remove();    
                $("#"+  containerdiv).find(".popDetail_Btm").remove();            
                $("<div class='popDetail_Top' id='div_destdetail_top'>" +
	            "<table cellpadding='0' width='100%'>"+
	            "<tr><td><span class='largeText'><a id='a_detailview' tabindex='2499' href='javascript:void(0);' style='text-decoration:none'><strong>"+ dest_name +"</strong></a></span>"+
	            "</td><td style='text-align:right'><a tabindex='2500' title='Print information of "+dest_name+".'  id='print_dest' href='javascript:void(0);'><b>Print</b></a></td><td width='23'>&nbsp;<a tabindex='2502' title='Hide information of "+dest_name+".' id='a_destdetail_close' href='javascript:void(0);'><img alt='close' src='http://images.transit.511.org/RUI/fw/transitBox/X.jpg' /></a>" +
		        "</td></tr></table></div>").appendTo("#"+ containerdiv); //508: first tag 

//                $("#"+  containerdiv).find("#div_destdetail_top").remove();    
//                $("#"+  containerdiv).find(".popDetail_Btm").remove();            
//                $("<div class='popDetail_Top' id='div_destdetail_top'>" +
//	            "<table cellpadding='0' width='100%'>"+
//	            "<tr><td><span class='largeText'><a id='a_detailview' tabindex='2499' href='javascript:void(0);' style='text-decoration:none'><strong>"+ dest_name +"</strong></a></span>"+
//	            "</td><td style='text-align:right'><a id='print_dest' href='javascript:void(0);'><b>Print</b></a></td><td width='23'>&nbsp;<a id='a_destdetail_close' href='javascript:void(0);'><img src='http://images.transit.511.org/RUI/fw/transitBox/X.jpg' /></a>" +
//		        "</td></tr></table></div>").appendTo("#"+ containerdiv); 
//                
                
                $("#"+  containerdiv).find("#div_destdetail_Tile").remove();      
		        $("<div class='popDetail_Tile' id='div_destdetail_Tile'></div>").appendTo("#"+ containerdiv);
		        $("<div class='popDetail_Scroll' id='div_destdetail_scroll'></div>").appendTo("#div_destdetail_Tile");
		        if(objdestination.destination.pd.Description!=null&&objdestination.destination.pd.Description!='')
		        {   
		            $("<table cellpadding='0'><tr><td valign='top'><p>"+ img_tag +" <span id='p_destdescription'>" + addTabindex(objdestination.destination.pd.Description,'<a', 2510)+ "</span></p></td></tr></table>").appendTo("#div_destdetail_scroll"); // 508: dynamically add tabindex to pd Description
		        }
		        else
		        {
		            $("<table cellpadding='0'><tr><td valign='top'><p>&nbsp;</p></td><td valign='top'>"+img_tag+"</td></tr></table>").appendTo("#div_destdetail_scroll");
		        }
              
        		
                /*
                if(HasAgencyServing(objdestination.destination.pd))
                {
                    bln_anydataexist=true;
		            $("<p class='overviewHeader'>Transit agencies serving this location</p>").appendTo("#div_destdetail_scroll");
                    $("<table cellpadding='0'><tr><td style='padding:2px 0 2px 0;'>"+
                    "<img src='http://images.transit.511.org/RUI/fw/transitBox/Divider.gif' /></td></tr></table>").appendTo("#div_destdetail_scroll");
                    $("<table id='tbl_dest_agencies'  cellspacing='3' width='100%'></table>").appendTo("#div_destdetail_scroll");
                    var cellcount=1;
                    var rowcount=1;
                     for(var property in objdestination.destination.pd.AgenciesServing){
                         if(cellcount==1)
                         {
                            $("<tr id='tr_dest_agency" + rowcount + "'></tr>").appendTo("#tbl_dest_agencies");
                         }
                         $("<td><p><a href='../schedules/index.aspx?#m1=A&m2="+getAgencyDisplayMode(property)+"&cid="+property+"'>" + objdestination.destination.pd.AgenciesServing[property]  +"</a></p></td>").appendTo("#tr_dest_agency" + rowcount);
                      
                           if(cellcount==3)
                           {
                            cellcount=1;
                            rowcount++;
                           }  
                           else
                           { 
                            cellcount++; 
                           } 
                      }
                }      
                */
                if(objdestination.destination.x!=null &&objdestination.destination.y!=null && objdestination.destination.x!=0 &&objdestination.destination.y!=0)
                {
                   bln_anydataexist=true;
                    var x=objdestination.destination.x;
                    var y=objdestination.destination.y;
                    
                    var _desturlname = objdestination.destination.pd.Name;
                    _desturlname = replacecharacter(_desturlname,"&", "%26");
                    _desturlname = replacecharacter(_desturlname,"'", "%27");  
                    
                    var plan_fromtrippath= tripplanner_url+'XSLT_TRIP_REQUEST2?';
                    plan_fromtrippath+='sessionID=0&type_origin=coord&name_origin='+ x +':'+ y+':WGS84[DD.ddddd]:'+_desturlname;
                    
                    var plan_totrippath=tripplanner_url +'XSLT_TRIP_REQUEST2?';
                    plan_totrippath+='sessionID=0&type_destination=coord&name_destination='+ x +':'+ y+':WGS84[DD.ddddd]:'+_desturlname;

                    var nearbyroutesandstops_path=tripplanner_url +'XSLT_DM_REQUEST?';
                    nearbyroutesandstops_path+='sessionID=0&UseAllStops=1&type_dm=coord&name_dm='+ x +':'+ y+':WGS84[DD.ddddd]:'+_desturlname;
                    
		            $("<p class='overviewHeader'>Plan a Trip</p>").appendTo("#div_destdetail_scroll");
                    $("<table cellpadding='0'><tr><td style='padding:2px 0 2px 0;'>"+
                    "<img alt=' ' src='http://images.transit.511.org/RUI/fw/transitBox/Divider.gif' /></a></td></tr></table>").appendTo("#div_destdetail_scroll");
                    $("<div style='margin: 4px 0 0 10px;'><a title='Plan a trip to this location" + rskey_tripplaner + "'  tabindex='2590' href='"+ plan_totrippath+"'>"+
                    "<img alt='Plan a trip to this location' src='http://images.transit.511.org/RUI/fw/transitBox/btn_ToLocation.jpg' /></a> "+
                    "<a title='Plan a trip from this location" + rskey_tripplaner + "' tabindex='2594' href='"+ plan_fromtrippath +"'><img alt='Plan a trip from this location' src='http://images.transit.511.org/RUI/fw/transitBox/btn_FromLocation.jpg' /></a></div>").appendTo("#div_destdetail_scroll");
                    
                    
                    
                    $("<br><p class='overviewHeader'>Find Nearby Transit Routes and Services</p>").appendTo("#div_destdetail_scroll");
    	            $("<table cellpadding='0'><tr><td style='padding:2px 0 2px 0;'>"+
                    "<img alt=' ' src='http://images.transit.511.org/RUI/fw/transitBox/Divider.gif' /></a></td></tr></table>").appendTo("#div_destdetail_scroll");
                    $("<div style='margin: 4px 0 0 10px;'><a title='Find nearby routes and services" + rskey_tripplaner +"' tabindex='2596' href='"+ nearbyroutesandstops_path+"'>"+
                        "<img alt='Nearby Routes and Services' src='http://images.transit.511.org/RUI/fw/transitBox/bt_NearByServices.png' /></a>").appendTo("#div_destdetail_scroll");
    	       
                }    
    	       
    	       
    	        $("<div class='popDetail_Btm'></div>").appendTo("#"+ containerdiv); 
                $("#a_destdetail_close").unbind("click").bind("click",function()
                {
                    $("#"+  containerdiv).find("#div_destdetail_top").remove();
                    $("#"+  containerdiv).find("#div_destdetail_Tile").remove();
                    showsearchbycategory();
                    showsearchbycity();
                    //$("#div_populardest_withpaging").empty();
                    CloseAllMaptips();
                }); 
               
                collapsesearchbycategory();
                UpdateDetailLink("p_destdescription");
            if(bln_anydataexist==false)
            {
                $("<p align='center'><b>No Information Available</b></p>").appendTo("#div_destdetail_scroll");
            }
            $("#print_dest").unbind("click").bind("click",function()
            {
                window.open("printdestinations.aspx?did=" + objdestination.destination.pd.ID ,null,MapWindowParams); 
            });
            $("#a_detailview").focus();/*508*/
          
           }
           catch(err)
           {
                logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderpopdestdetails",ErrorWWWNonFatal,"","","");
           }
           
           
      }      
      
      function CheckInCategory(objdestination,categoryid)
      {
            var strReturn=false;
            if(categoryid!=null)
            {
                 for(var property in objdestination.destination.pd.Categories)
                 {
                    
                    if(property==categoryid)
                    {
                        strReturn=true;
                        break;
                    }
                 }
                
               
            }
            return strReturn;
      }
      
      function CheckInCity(objdestination,city)
      {
            var strReturn=false;
            if(city!=''&&city!=null)
            {
                if(objdestination.destination.pd.City==city)
                {
                  
                    strReturn=true;
                }
            }
            return strReturn;
      }
    //*********************************Ends Here: Popular Destionations Detail View Ends Here *********************         

    
       
    //*********************************Starts Here: Popular Destionations Search By City *********************
    function renderpopdestsearchbycity(objcities,selectedcity,callbackfunction,container_div,destbycitymapcallback)
    {
        try
        {
        
            $("#" + container_div).find("#div_city_list").remove();
            $("<div id='div_city_list'></div>").appendTo("#" + container_div); 
            $("<table id='city_table' cellpadding='0' class='popularSelectTable' ></table>").appendTo("#div_city_list");
            $("<tr id='tr_search_bycity'>"+
            "<td width='45'><h2 class='hiddenText_508'>Destinations by City</h2><label for='dd_popular_city'><strong>By City:</strong></label></td>"+
            "<td align='right'>"+
            "<select tabindex='1800' id='dd_popular_city' class='pop_citySelector'></select>"+
            "</td></tr>").appendTo("#city_table");  // 508

		    $("<table cellpadding='0'  id='tbl_featured_dest' class='popularSelectTable'"+
		    " style='display:none'></table>").appendTo("#div_city_list");
		    $("<tr><td width='120'><strong>Featured Destinations:</strong></td>"+
		    "<td align='right'>"+
		    "<select tabindex='1810' id='dd_popular_dest' class='pop_featSelector'></select>"+
		    "</td></tr>").appendTo("#tbl_featured_dest"); //508
    		
	        $("<table cellpadding='0'  id='tbl_reset_form' 'class='popularSelectTable'></table>").appendTo("#div_city_list");
	        $("<tr><td align='left'><a tabindex='1820' title ='Clear Form' id='a_popular_clearform' href='javascript:void(0);'>Clear Form</a></td>"+
	        "<td style='text-align:right;'>"+
	        "<a id='a_popular_maplink' href='javascript:void(0);' style='display:none'>"+
	        "Show all Popular Destinations within map extent</a></td></tr>").appendTo("#tbl_reset_form"); //508
	           var option_html;
	           option_html= "<option value='0'>All Locations</option>"; 
               $(option_html).appendTo("#dd_popular_city");
	         
              $(objcities).each(function(i){
                option_html= "<option value='" + objcities[i].CityName+ "'>" + objcities[i].CityName + "</option>";
                $(option_html).appendTo("#dd_popular_city");
              });
              
                
               
               
                if(selectedcity!=null)
                {
                   selectedcity=replacecharacter(selectedcity,"%20"," ");
                   $("#dd_popular_city").val(selectedcity);
                   $("#tbl_featured_dest").show();
                   loadpopdestinationsbycity(selectedcity);
                   destbycitymapcallback($("#dd_popular_city").val());
                }
                else
                {
                    $("#dd_popular_city").val("0");
                }
                 
               $("#dd_popular_city").unbind("change").bind("change",function(){
                     //$("#div_category_list").find("span[@id*='span_selected_cat_']").hide();
                     hidedestinationdetail();
                     hidedestinationpagediv();
                     //added to hide tourist info
                    hidetourism();
                    if($("#dd_popular_city").val()!="0")
                    {
                     callbackfunction($("#dd_popular_city").val());
                    
                    }
                    else
                    {
                         $("#tbl_featured_dest").hide();
                         map_initialmap();
                    } 
               });
                
             $("#a_popular_clearform").unbind("click").bind("click",function(){map_initialmap();hidedestinationpagediv();clearpopularcitysearch();});

                
        
        }
        catch(err)
        {
            logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderpopdestsearchbycity",ErrorWWWNonFatal,"","","");
        }
        
        
        
         
    }     
       
    //*********************************Ends Here: Popular Destionations Search By City *********************


    //*********************************Starts Here: Popular Destionations List By City *********************
    function renderdestinationsbycities(objdestinations,detailcallback,detailcontainer,destmapbycitycallback)
    {
        
        try
        {
            
              $("#dd_popular_dest").empty();
              var option_html;
              var category_name;
              var objcategory;
              objcategory=new Array();
            
              option_html= "<option value='0'>--Show all Destinations--</option>"; 
              $(option_html).appendTo("#dd_popular_dest");
             
              $(objdestinations.DestinationsInCity).each(function(i)
              {
                          category_name="";
                          
                            for(var property in objdestinations.DestinationsInCity[i].NameWithCategory)
                             {
                                category_name= objdestinations.DestinationsInCity[i].NameWithCategory[property];
                                objcategory.push(category_name);
                                break;
                             }
                             if(category_name=="")
                             {
                                objcategory.push(category_name);
                             }
                            if(objdestinations.DestinationsInCity[i].Name!=null && objdestinations.DestinationsInCity[i].Name!='')
                            { 
                                if(category_name!='')
                                {
                                    option_html= "<option value='" + objdestinations.DestinationsInCity[i].ID + "'>" + objdestinations.DestinationsInCity[i].Name + "(" + category_name + ")</option>";
                                }
                                else
                                {
                                    option_html= "<option value='" + objdestinations.DestinationsInCity[i].ID + "'>" + objdestinations.DestinationsInCity[i].Name + "</option>";
                                }    
                                $(option_html).appendTo("#dd_popular_dest");
                            }    
              });
              
               $("#dd_popular_dest").val("0");
//                         option_html= "<option value=''></option>";
//                         $(option_html).appendTo("#dd_popular_dest");
              
            renderdestinationpagelist(objdestinations.DestinationsInCity,objcategory,"div_populardest_withpaging",detailcallback,detailcontainer);
             
             $("#tbl_featured_dest").show();
            // $("#a_popular_maplink").show();
        
       
        $("#dd_popular_dest").unbind("change").bind("change",function(event)
        {
          if($(this).val()!=0&&$(this).val()!='')
          {
          
            $(objdestinations.DestinationsInCity).each(function(i){
            
                if(objdestinations.DestinationsInCity[i].ID==$("#dd_popular_dest").val())
                {
                  
                  category_name="";
                  for(var property in objdestinations.DestinationsInCity[i].NameWithCategory)
                     {
                        category_name= objdestinations.DestinationsInCity[i].NameWithCategory[property];
                     }
                    
                     SetMapLoadlType("city", objdestinations.DestinationsInCity[i].City);  
                     renderdestinationshortview(objdestinations.DestinationsInCity[i],category_name,"div_populardest_withpaging",detailcallback,detailcontainer);
                     var destid=$("#dd_popular_dest").val();
                     loadpopdestdetails(destid,'div_populardest');
                     //9.3
                       bln_clearmap=false;    
                       loadDestinationByID(destid);
                }
            }); 
          }
          else
          {
             
              if($(this).val()=='')
              {
                hidedestinationpagediv();
              }
              else
              {
                 renderdestinationpagelist(objdestinations.DestinationsInCity,objcategory,"div_populardest_withpaging",detailcallback,detailcontainer);
                 destmapbycitycallback($("#dd_popular_city").val());
              }
               
          }
       
        });
        
        }
        catch(err)
        {
            logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderpopdestsearchbycity",ErrorWWWNonFatal,"","","");
        }
        
                  
    }  
    

    function hidedestinationdetail()
    {
        $("#div_destdetail_top").hide();
        $("#div_destdetail_Tile").hide();
    }
   function showdestinationdetail()
    {
        $("#div_destdetail_top").show();
        $("#div_destdetail_Tile").show();
    }

    function hidedestinationpagediv()
    {
        $("#div_populardest_withpaging").hide();
        //$("#tr_populardest_withpaging").hide();
       
    }
    function showdestinationpagediv()
    {
        $("#div_populardest_withpaging").show();
        //$("#tr_populardest_withpaging").show();
       
    }
    function hidesearchbycity()
    {
        $("#div_city_list").hide();
       
    }  

    function collapsesearchbycategory()
    {
      
       document.getElementById('div_popdest_panel').className='accTrigClosed';
       $("#category_table").hide();
        $("#div_popdest_panel").unbind("click").bind("click",function()
        {
          
           document.getElementById('div_popdest_panel').className='accTrigOpen';
           $("#category_table").show();
           hidedestinationdetail();
           showsearchbycity();
        });
    }  
    
    function showsearchbycategory()
    {
        document.getElementById('div_popdest_panel').className='accTrigOpen';
        $("#category_table").show();
        $("#div_popdest_panel").unbind("click");
        
    }
    
    function clearpopularcitysearch()
    {
         $("#dd_popular_city").val("0");
         $("#tbl_featured_dest").hide();
         //$("#a_popular_maplink").hide(); 
         //hidedestinationpagediv()
    }

    function showsearchbycity()
    {
      $("#div_city_list").show();
     
    }
    
    function markselectedcategory(categoryid)
    {
       
        $("#span_selected_cat_" + categoryid).show();
    }
    
    function hidedestinationlist()
    {
        
        $("#div_destination_list").hide();
    }
    
    function setcategoryselected(categoryname)
    {
        $("#dd_popular_city").val(categoryname);
    }
    function setcategory(categoryid)
    {
        glb_categoryid=categoryid;
    }
    function getcategory()
    {
        return glb_categoryid;
    }

    //*********************************Ends Here: Popular Destionations  *********************

function renderhelp(helpitem,headeritem,Xpos,Ypos,callingelementid)
{ 
  try
   {
        $("body").find("#div_destinations_help").remove();
            var help_html='';
            var tPosX=Xpos;
            var tPosY=Ypos;
            help_html="<div id='div_destinations_help' style='z-index:1099999;position:absolute;'>";
            help_html+="<table class='helpTable' cellspacing='0'><tr><td class='boxTop'></td></tr>";
            help_html+="<tr>";
            help_html+="<td class='contentBox'>";
            help_html+="<div class='closeBox' style='padding-right: 4px;'>";
            help_html+="<a id='a_helpclose'  href='javascript:void(0);'><img alt='Close' src='http://images.transit.511.org/RUI/fw/btnX_9pxSquare.gif' alt='"+ rskey_altclose +"' /></a>";
            help_html+="</div><a tabindex='1501' style='color:rgb(227, 227, 227);' id='a_help_start' href='javascript:void(0);' title='Pop up help window start'> </a><h1 class='helpHeader'>"+headeritem+"</h1>";
            help_html+="<div class='boxDivider'></div>" ;
            help_html+="<div id='div_schedule_help_data' class='helpTableListingdiv' >"+ helpitem +"</div><a tabindex='1502' style='color:rgb(227, 227, 227);' id='a_help_end' href='javascript:void(0);' title='End of help Close Help Window'> </a>"
            help_html+="</td></tr><tr><td class='boxBtm'></td></tr></table></div>"
            $(help_html).appendTo("body")
            $('#div_destinations_help').css({top: tPosY, left:tPosX});
            $("#a_help_start").focus();//508:focus
            $("#a_helpclose").unbind("click").bind("click",
            function()
            {
                $("body").find("#div_destinations_help").remove();
                $("#"+ callingelementid).focus();
            });
            $("#a_help_end").unbind("click").bind("click",
            function()
            {
                $("body").find("#div_destinations_help").remove();
                $("#"+ callingelementid).focus();
            });
    }
   catch(err)
      {
          
           var referencetext="Help:"+  headeritem;
            logerror(err,window.location,"renderingfucntions_regionalfeatures.js","renderhelp",ErrorWWWNonFatal,referencetext,"","");
      }
    
    
    
      
}

function UpdateDetailLink(objcontainer)
{
   
 $("#"+objcontainer).find("a").filter("[@href]").each(function()
                {
                    var str_href=$(this).attr("href");
                    if(str_href!='')
                    {
                        var arr_str=str_href.split("did");
                        if(arr_str.length>1)
                        {
                           var did =arr_str[1].split("=")[1];
                           $(this).attr("href","javascript:void(0);");
                           $(this).unbind("click").bind("click",function()
                           {
                                 hidedestinationpagediv();
                                 glb_MapLoadTypeName=null;
                                 glb_MapLoadTypeId=null;
                                 appendtourl("m1=P&did="+ did,true); 
                                       
                           });  
                        }
                    }
                    
                });
}
function getItemClass(idx)
{
    var strClass='itemA';
    idx++;
    if(idx>78){idx=parseInt(idx,10)-78}//subtract 26 to start the count from 1
     switch (idx) 
     {
        case 1 : 
            strClass='itemA';
            break;
        case 2 : 
            strClass='itemB';
            break;
        case 3 : 
            strClass='itemC';
            break;
        case 4 : 
            strClass='itemD';
            break;
        case 5 : 
            strClass='itemE';
            break;
        case 6 : 
            strClass='itemF';
            break;
        case 7 : 
            strClass='itemG';
            break; 
        case 8 : 
            strClass='itemH';
            break;   
        case 9 : 
            strClass='itemI';
            break;
        case 10 : 
            strClass='itemJ';
            break;
        case 11 : 
            strClass='itemK';
            break;
        case 12 : 
            strClass='itemL';
            break;
        case 13 : 
            strClass='itemM';
            break;
        case 14 : 
            strClass='itemN';
            break;
        case 15 : 
            strClass='itemO';
            break; 
        case 16 : 
            strClass='itemP';
            break;
        case 17 : 
            strClass='itemQ';
            break;
        case 18 : 
            strClass='itemR';
            break;
        case 19 : 
            strClass='itemS';
            break;
        case 20 : 
            strClass='itemT';
            break;
        case 21 : 
            strClass='itemU';
            break;
        case 22 : 
            strClass='itemV';
            break;
        case 23 : 
            strClass='itemW';
            break; 
        case 24 : 
            strClass='itemX';
            break; 
        case 25 : 
            strClass='itemY';
            break; 
        case 26 : 
            strClass='itemZ';
            break; 
        case 27 : 
            strClass='itemA1';
            break;
        case 28 : 
            strClass='itemB1';
            break;
        case 29 : 
            strClass='itemC1';
            break;
        case 30 : 
            strClass='itemD1';
            break;
        case 31 : 
            strClass='itemE1';
            break;
        case 32 : 
            strClass='itemF1';
            break;
        case 33 : 
            strClass='itemG1';
            break; 
        case 34 : 
            strClass='itemH1';
            break;   
        case 35 : 
            strClass='itemI1';
            break;
        case 36 : 
            strClass='itemJ1';
            break;
        case 37 : 
            strClass='itemK1';
            break;
        case 38 : 
            strClass='itemL1';
            break;
        case 39 : 
            strClass='itemM1';
            break;
        case 40 : 
            strClass='itemN1';
            break;
        case 41 : 
            strClass='itemO1';
            break; 
        case 42 : 
            strClass='itemP1';
            break;
        case 43 : 
            strClass='itemQ1';
            break;
        case 44 : 
            strClass='itemR1';
            break;
        case 45 : 
            strClass='itemS1';
            break;
        case 46 : 
            strClass='itemT1';
            break;
        case 47 : 
            strClass='itemU1';
            break;
        case 48 : 
            strClass='itemV1';
            break;
        case 49 : 
            strClass='itemW1';
            break; 
        case 50 : 
            strClass='itemX1';
            break; 
        case 51 : 
            strClass='itemY1';
            break; 
        case 52 : 
            strClass='itemZ1';
            break; 
        case 53 : 
            strClass='itemA2';
            break;
        case 54 : 
            strClass='itemB2';
            break;
        case 55 : 
            strClass='itemC2';
            break;
        case 56 : 
            strClass='itemD2';
            break;
        case 57 : 
            strClass='itemE2';
            break;
        case 58 : 
            strClass='itemF2';
            break;
        case 59 : 
            strClass='itemG2';
            break; 
        case 60 : 
            strClass='itemH2';
            break;   
        case 61 : 
            strClass='itemI2';
            break;
        case 62 : 
            strClass='itemJ2';
            break;
        case 63 : 
            strClass='itemK2';
            break;
        case 64 : 
            strClass='itemL2';
            break;
        case 65 : 
            strClass='itemM2';
            break;
        case 66 : 
            strClass='itemN2';
            break;
        case 67 : 
            strClass='itemO2';
            break; 
        case 68 : 
            strClass='itemP2';
            break;
        case 69 : 
            strClass='itemQ2';
            break;
        case 70 : 
            strClass='itemR2';
            break;
        case 71 : 
            strClass='itemS2';
            break;
        case 72 : 
            strClass='itemT2';
            break;
        case 73 : 
            strClass='itemU2';
            break;
        case 74 : 
            strClass='itemV2';
            break;
        case 75 : 
            strClass='itemW2';
            break; 
        case 76 : 
            strClass='itemX2';
            break; 
        case 77 : 
            strClass='itemY2';
            break; 
        case 78 : 
            strClass='itemZ2';
            break;                                      
     }

    return strClass;
}

function getItemImageName(idx)
    {
    var strImageName='mapAlphaIconA.gif';
    idx++;
    if(idx>78){idx=parseInt(idx,10)-78}//subtract 26 to start the count from 1
     switch (idx) 
     {
        case 1 : 
            strImageName='mapAlphaIconA.gif';
            break;
        case 2 : 
            strImageName='mapAlphaIconB.gif';
            break;
        case 3 : 
            strImageName='mapAlphaIconC.gif';
            break;
        case 4 : 
            strImageName='mapAlphaIconD.gif';
            break;
        case 5 : 
            strImageName='mapAlphaIconE.gif';
            break;
        case 6 : 
            strImageName='mapAlphaIconF.gif';
            break;
        case 7 : 
            strImageName='mapAlphaIconG.gif';
            break; 
        case 8 : 
            strImageName='mapAlphaIconH.gif';
            break;   
        case 9 : 
            strImageName='mapAlphaIconI.gif';
            break;
        case 10 : 
            strImageName='mapAlphaIconJ.gif';
            break;
        case 11 : 
            strImageName='mapAlphaIconK.gif';
            break;
        case 12 : 
            strImageName='mapAlphaIconL.gif';
            break;
        case 13 : 
            strImageName='mapAlphaIconM.gif';
            break;
        case 14 : 
            strImageName='mapAlphaIconN.gif';
            break;
        case 15 : 
            strImageName='mapAlphaIconO.gif';
            break; 
        case 16 : 
            strImageName='mapAlphaIconP.gif';
            break;
        case 17 : 
            strImageName='mapAlphaIconQ.gif';
            break;
        case 18 : 
            strImageName='mapAlphaIconR.gif';
            break;
        case 19 : 
            strImageName='mapAlphaIconS.gif';
            break;
        case 20 : 
            strImageName='mapAlphaIconT.gif';
            break;
        case 21 : 
            strImageName='mapAlphaIconU.gif';
            break;
        case 22 : 
            strImageName='mapAlphaIconV.gif';
            break;
        case 23 : 
            strImageName='mapAlphaIconW.gif';
            break; 
        case 24 : 
            strImageName='mapAlphaIconX.gif';
            break; 
        case 25 : 
            strImageName='mapAlphaIconY.gif';
            break; 
        case 26 : 
            strImageName='mapAlphaIconZ.gif';
            break; 
        case 27 : 
            strImageName='mapAlphaIconA1.gif';
            break;
        case 28: 
            strImageName='mapAlphaIconB1.gif';
            break;
        case 29 : 
            strImageName='mapAlphaIconC1.gif';
            break;
        case 30 : 
            strImageName='mapAlphaIconD1.gif';
            break;
        case 31 : 
            strImageName='mapAlphaIconE1.gif';
            break;
        case 32 : 
            strImageName='mapAlphaIconF1.gif';
            break;
        case 33 : 
            strImageName='mapAlphaIconG1.gif';
            break; 
        case 34 : 
            strImageName='mapAlphaIconH1.gif';
            break;   
        case 35 : 
            strImageName='mapAlphaIconI1.gif';
            break;
        case 36 : 
            strImageName='mapAlphaIconJ1.gif';
            break;
        case 37 : 
            strImageName='mapAlphaIconK1.gif';
            break;
        case 38 : 
            strImageName='mapAlphaIconL1.gif';
            break;
        case 39 : 
            strImageName='mapAlphaIconM1.gif';
            break;
        case 40 : 
            strImageName='mapAlphaIconN1.gif';
            break;
        case 41 : 
            strImageName='mapAlphaIconO1.gif';
            break; 
        case 42 : 
            strImageName='mapAlphaIconP1.gif';
            break;
        case 43 : 
            strImageName='mapAlphaIconQ1.gif';
            break;
        case 44 : 
            strImageName='mapAlphaIconR1.gif';
            break;
        case 45 : 
            strImageName='mapAlphaIconS1.gif';
            break;
        case 46 : 
            strImageName='mapAlphaIconT1.gif';
            break;
        case 47 : 
            strImageName='mapAlphaIconU1.gif';
            break;
        case 48 : 
            strImageName='mapAlphaIconV1.gif';
            break;
        case 49 : 
            strImageName='mapAlphaIconW1.gif';
            break; 
        case 50 : 
            strImageName='mapAlphaIconX1.gif';
            break; 
        case 51 : 
            strImageName='mapAlphaIconY1.gif';
            break; 
        case 52 : 
            strImageName='mapAlphaIconZ1.gif';
            break; 
        case 53 : 
            strImageName='mapAlphaIconA2.gif';
            break;
        case 54: 
            strImageName='mapAlphaIconB2.gif';
            break;
        case 55 : 
            strImageName='mapAlphaIconC2.gif';
            break;
        case 56 : 
            strImageName='mapAlphaIconD2.gif';
            break;
        case 57 : 
            strImageName='mapAlphaIconE2.gif';
            break;
        case 58 : 
            strImageName='mapAlphaIconF2.gif';
            break;
        case 59 : 
            strImageName='mapAlphaIconG2.gif';
            break; 
        case 60 : 
            strImageName='mapAlphaIconH2.gif';
            break;   
        case 61 : 
            strImageName='mapAlphaIconI2.gif';
            break;
        case 62 : 
            strImageName='mapAlphaIconJ2.gif';
            break;
        case 63 : 
            strImageName='mapAlphaIconK2.gif';
            break;
        case 64 : 
            strImageName='mapAlphaIconL2.gif';
            break;
        case 65 : 
            strImageName='mapAlphaIconM2.gif';
            break;
        case 66 : 
            strImageName='mapAlphaIconN2.gif';
            break;
        case 67 : 
            strImageName='mapAlphaIconO2.gif';
            break; 
        case 68 : 
            strImageName='mapAlphaIconP2.gif';
            break;
        case 69 : 
            strImageName='mapAlphaIconQ2.gif';
            break;     
        case 70 : 
            strImageName='mapAlphaIconR2.gif';
            break;
        case 71 : 
           strImageName='mapAlphaIconS2.gif';
            break;
        case 72 : 
            strImageName='mapAlphaIconT2.gif';
            break;
        case 73 : 
            strImageName='mapAlphaIconU2.gif';
            break;
        case 74 : 
            strImageName='mapAlphaIconV2.gif';
            break;
        case 75 : 
            strImageName='mapAlphaIconW2.gif';
            break;
        case 76 : 
            strImageName='mapAlphaIconX2.gif';
            break; 
        case 77 : 
             strImageName='mapAlphaIconY2.gif';
            break; 
        case 78 : 
            strImageName='mapAlphaIconZ2.gif';
            break; 
                                                    
     }

    return strImageName;
}			
	
//Ends Here renderingfucntions_regionalfeatures.js

//Starts Here controlfunctions_regionalfeatures.js

//* * * * * * * * * resources/destinations.en.js starts here  * * * * * * * * * * *//
//used in help

var rskey_altHelp="Help";
var rskey_maphelpheader="Help using the maps";
var rskey_popdestbelow="Popular Destinations";
var rskey_popdesttop="Popular Destinations";
var rskey_altclose="Close";
var rskey_servicearea ="Service Area";


//Prototype functions starts here

function setTopActive(el,data_div) { 
	// clear top tab state	
	document.getElementById('a_transitbasics').setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/transitBasics_off.jpg');
	document.getElementById('a_populardestination').setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/popDestinations_off.jpg');
	document.getElementById('a_nighterservice').setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/allNighter_off.jpg');
	
	//508 code start: set tabs to default
	var tabtext = "#002F75";
	var tabtexthighlight = "#732D2D";
	//tab title
	document.getElementById('titleTransitBasics').setAttribute('title','Transit Basics - Tab');  
	document.getElementById('titleDestination').setAttribute('title','Popular Destinations - Tab'); 
	document.getElementById('titleDestination').setAttribute('name','FirstTab');  
	document.getElementById('titleAllNighter').setAttribute('title','Popular Destinations - Tab');	
	var a_transitBasics = document.getElementById('titleTransitBasics');
    var a_destination = document.getElementById('titleDestination');
	var a_allnighter = document.getElementById('titleAllNighter');
	a_transitBasics.style.color = tabtext;  // IE has problem with 'setAttribute' function
	a_destination.style.color = tabtext;
	a_allnighter.style.color = tabtext;
	// remove <h1> header
	$("#transitbasic").remove();
	$("#popdest").remove();
	$("#allnighter").remove();
	// 508 codes end
	// set active tab
	if(el=='a_transitbasics')
	{
	    document.getElementById(el).setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/transitBasics_on.jpg');
	    //508: add <h1> when tab is selected
	    a_transitBasics.style.color = tabtexthighlight; 	      
	    $("#a_transitbasics").empty();
	    var tabcontent = "<h1 id='transitbasic' class='hiddenText_508'>Transit Basics</h1><div align='center'><a id='titleTransitBasics' title='Transit Basics - Tab Selected' tabindex='1410'  style='color: rgb(115, 45, 45);'>Transit Basics</a></div>";
	    $("#a_transitbasics").append(tabcontent);    
	    //508: end
	}
	if(el=='a_populardestination')
	{ 
	    document.getElementById(el).setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/popDestinations_on.jpg');
	    a_destination.style.color = tabtexthighlight;//508	  
	    var tabcontent = "<h1 id='popdest' class='hiddenText_508'>Popular Destinations</h1><div align='center'><a id='titleDestination' name='FirstTab' title='Popular Destinations - Tab Selected' tabindex='1400' style='color: rgb(115, 45, 45);'>Popular Destinations</a></div>";    
	    $("#a_populardestination").empty();
	    $("#a_populardestination").append(tabcontent); 
	    
	}
	if(el=='a_nighterservice')
	{
	    document.getElementById(el).setAttribute('background','http://images.transit.511.org/RUI/fw/transitBox/allNighter_on.jpg');
	    a_allnighter.style.color = tabtexthighlight;//508	       
	    $("#a_nighterservice").empty();
	    var tabcontent = "<h1 id='allnighter' class='hiddenText_508'>All Nighter Services</h1><div align='center'><a id='titleAllNighter' title='All Nighter Services - Tab Selected' tabindex='1420' style='color: rgb(115, 45, 45);'>All Nighter Service</a></div>";
	    $("#a_nighterservice").append(tabcontent); 	   
	}
	
	// clear active tab text class
	document.getElementById('a_transitbasics').className='topOff';
	document.getElementById('a_populardestination').className='topOff';
	document.getElementById('a_nighterservice').className='topOff';
	
	// set active tab text class
	document.getElementById(el).className='topOn';
	
	// clear active panels
	document.getElementById('tier_transitBasics').style.display = "none";
	document.getElementById('tier_popDestinations').style.display = "none";
	document.getElementById('tier_allNighter').style.display = "none";
	
	// show active panel
	document.getElementById(data_div).style.display = "block";
	
	document.getElementById('accContent1').style.display = "block";
	document.getElementById('div_popdest_panel').className='accTrigOpen';
	
	
};



//Prototype functions ends here

// JScript File
var glb_popdestcatid;
var glb_MapLoadTypeName;
var glb_MapLoadTypeId;
var bln_callagencymap;
var bln_clearmap;
var glb_imageIndicator;
function load_regionalpage()
{
   
   setMasterPageActiveSection("a_regionalfeature_mastertab");
   bindtabclicks();
   loadfromhistory();
}
function loadfromhistory()
{
 var param_array=getqueryparam();
    if(param_array!=null)
    {
    
        for(j=0;j<param_array.length;j++)
              {
                 var param=param_array[j].split("=");
                 
                 if(param[0]=="m1")
                 {
                   
                    if(param[1]=="T"){
                         loadtbtab(); 
                        if($("#mlink")==0) $("#titleTransitBasics").focus(); //508 and mobile link focus
                         
                      } 
                    else if(param[1]=="P"){ 
                        if($("#mlink")==0) $("#titleDestination").focus();//508 
                         loadpdtab();
                         }
                    else if(param[1]=="N"){ 
                        loadnightertab();
                       if($("#mlink")==0) $("#titleAllNighter").focus();//508
                        }
                 }
              }   
    }
    else
    {
      
      loadpdtab();
      //$("#titleDestination").focus();//508
    }

}
function bindtabclicks()
{
    
      $("#a_transitbasics").unbind("click").bind("click", function()
      {loadtbtab();
        $("#dd_tbselector").focus();  //508
      });

      $("#a_populardestination").unbind("click").bind("click", function()
      {loadpdtab();
        $("#a_podest_tophelp").focus();  //508
      });

      $("#a_nighterservice").unbind("click").bind("click", function()
      {loadnightertab();
        $("#dd_nighterselector").focus();  //508
      });
}

function loadtbtab()
{
 loadTabTitle("Transit Basics");  
 if($.browser.msie)
 {
    
    $("#div_tb_data").removeClass("overviewContent").addClass("ieoverviewContent");
    $("#tb_bottom_div").attr("height","25px");
 }
 else
 {
    $("#tb_bottom_div").attr("height","25px");
 }
 hidedestinationpagediv();
 loadmaphelp("tb");
  //document.title="Bay Area Basics";
  setTopActive('a_transitbasics','tier_transitBasics');  
 
    var param_array=getqueryparam();
    if(param_array!=null)
    {
     
        for(j=0;j<param_array.length;j++)
              {
                 var param=param_array[j].split("=");
                    if(param[0]=="m1")
                    {
                        if(param[1]!="T")
                        {
                          
                          appendtourl("m1=T&m2="+ $("#dd_tbselector").val(),true);
                          break;
                        }
                    }
                
                 if(param[0]=="m2")
                 { 
                  $("#dd_tbselector").val(param[1]);
                   if(param[1]=="All")
                    {
                       $("#div_tb_data").find("div").show(); 
                    }
                    else
                    {
                       $("#div_tb_data").show().find("div").not("[@id=" + param[1] +"]").hide() ;
                       showtransitbasicsubdivs(param[1]);
                       //$("#" + param[1]).show() ;
                      $("#tb_bottom_div").show();
                    } 
                  
                 
                 }
              }
              
    }
    else
    { 
      $("#div_tb_data").show().find("div").hide() ;
     // $("#" + $("#dd_tbselector").val()).show();
      showtransitbasicsubdivs($("#dd_tbselector").val());
       
    }
   $("#dd_tbselector").unbind("change").bind("change",function()
    {
  
         if((checkexistinquerystring("m1=T")==false||checkexistinquerystring("m2=" + $(this).val())==false))
           {
             bln_callagencymap=false;
             appendtourl("m1=T&m2="+ $(this).val(),true);
                
           }
       
    });
    
    $("#a_transitbasics").unbind("click").attr("href","javascript:void(0);");
    $("#a_populardestination").attr("href","javascript:void(0);")
            .unbind("click").bind("click", function(){bln_clearmap=true;hidemaheader();map_initialmap();loadpdtab();});
    $("#a_nighterservice").attr("href","javascript:void(0);")
            .unbind("click").bind("click", function(){bln_clearmap=true;hidemaheader();map_initialmap();loadnightertab();});
   if(bln_callagencymap!=false)
   {
         bln_callagencymap=false;
         loadagenciespoints(); 
   }
   $("#a_tbprint").unbind("click").bind("click",function()
   {
        window.open("printtransitbasics.aspx?tbselector=" + $("#dd_tbselector").val(),null,MapWindowParams); 
   });
   
  var referencetext=$("#dd_tbselector").val();
  logevent(window.location,"controlfunctions_regionalfeatures.js","loadtbtab",InfoTransitBasics,referencetext,"","");
}


function loadnightertab()
{
   // document.title="All Nighter Service";
   //$("#mapBoxTall").unbind("click");
   loadTabTitle("All Nighter Service");  
   map_initialmap();
   bln_callagencymap=true;
    hidedestinationpagediv();
    loadmaphelp("ns");

    setTopActive('a_nighterservice','tier_allNighter');
    
    var param_array=getqueryparam();
    if(param_array!=null)
    {
     
        for(j=0;j<param_array.length;j++)
              {
                 var param=param_array[j].split("=");
                 
                if(param[0]=="m1")
                {
                    if(param[1]!="N")
                    {
                      
                      appendtourl("m1=N&m2="+ $("#dd_nighterselector").val(),true);
                      break;
                    }
                }
                
                 if(param[0]=="m2")
                 { 
                  $("#dd_nighterselector").val(param[1]);
                   if(param[1]=="All")
                    {
                       $("#div_ns_data").find("div").show(); 
                    }
                    else
                    {
                      
                       $("#div_ns_data").show().find("div").not("[@id=" + param[1] +"]").hide() ;
                       $("#" + param[1]).show() ;
                       if(param[1]!="RouteandSchedule")
                       {
                         
                         
                         $("#RouteandSchedule").show();
                       }
                       else
                       {
                            $("#div_ns_main").hide();
                       }
                      
                      
                    } 
                  
                 
                 }
              }
    }
    else
    { 
        if(checkexistinquerystring("m1=N")==false)
        { 
          appendtourl("m1=N",true);    
        }
        else
        { 
            $("#div_ns_main").show();
            $("#div_ns_data").show().find("div").hide() ;
           
            $("#" + $("#dd_nighterselector").val()).show();
            if( $("#dd_nighterselector").val()!="RouteandSchedule")
            {
                $("#RouteandSchedule").show();
            }
            else
            {
                $("#div_ns_main").hide();
            }
           
        }
        
        
    
    }

    
   
   $("#dd_nighterselector").unbind("change").bind("change",function()
    {
         if((checkexistinquerystring("m1=N")==false||checkexistinquerystring("m2=" + $(this).val())==false))
           {
           
             appendtourl("m1=N&m2="+ $(this).val(),true);
                
           }
       
    });
   
    $("#a_transitbasics").attr("href","javascript:void(0);").unbind("click").bind("click",function(){bln_clearmap=true;bln_callagencymap=true;hidemaheader();map_initialmap();loadtbtab();});
           
    $("#a_populardestination").attr("href","javascript:void(0);")
            .unbind("click").bind("click", function(){bln_clearmap=true;hidemaheader();map_initialmap();loadpdtab();});  
            
    $("#a_nighterservice").unbind("click").attr("href","javascript:void(0);");             
    
    var referencetext=$("#dd_nighterselector").val();
    logevent(window.location,"controlfunctions_regionalfeatures.js","loadnightertab",InfoNighterService,referencetext,"","");
}


function loadpdtab()
{
    loadTabTitle("Popular Destinations");  
   
    if(bln_clearmap!=false)
    {
       map_initialmap();
      $("#mapBoxTall").unbind("click");
    }
    bln_callagencymap=true;
    setTopActive('a_populardestination','tier_popDestinations');
    setmapheadertext("&nbsp;");
    loadmaphelp("pd");
    loadpopdesttophelp();
    loadtourist();
    $("#div_transitbasics").hide();
    $("#div_populardest").show();
    $("#div_nighterservice").hide();
    
    $("#a_transitbasics").attr("href","javascript:void(0);").unbind("click").bind("click",function(){bln_clearmap=true;bln_callagencymap=true;hidemaheader();map_initialmap();loadtbtab();});
    $("#a_populardestination").unbind("click").attr("href","javascript:void(0);");
    $("#a_nighterservice").attr("href","javascript:void(0);")
            .unbind("click").bind("click", function(){bln_clearmap=true;hidemaheader();map_initialmap();loadnightertab();});
  
   if($.browser.mozilla)
   {
       if(pagingdivemoved==undefined)//move pagination div only once for mozilla 
       {
         pagingdivemoved=true;
         $("#div_populardest_withpaging").attr("style","padding:0 0 0 488px;display:none");
         $("#div_populardest_withpaging").insertAfter("#tbl_regionalmain");
       } 
       
   }
    var param_array=getqueryparam();
    if(param_array!=null)
    {
       
        var pcid='';
        var cty='';
        var did='';
         for(j=0;j<param_array.length;j++)
              {
                 var param=param_array[j].split("=");
                   if(param[0]=="pcid")
                   {
                  
                        if(param[1]!='')
                        {
                            pcid=param[1];
                        }
                   }
                   if(param[0]=="did")
                   {
                  
                        if(param[1]!='')
                        {
                            did=param[1];
                        }
                   }
                   
                   if(param[0]=="cty")
                   {
                  
                        if(param[1]!='')
                        {
                            cty=param[1];
                        }
                   }
              }  
              
             loadpopdestfromhistory(pcid,cty,did);
    }
    else
    {
        if(checkexistinquerystring("m1=P")==false)
        { 
          appendtourl("m1=P",true);    
        }
        else
        {
            loadpopdest("div_populardest",null,null,null);
        }
        
    } 
        
    
    
}


function loadpopdestfromhistory(pcid,cty,did)
{
    if(pcid==''&&cty==''&&did=='')
    {
       
        if(checkexistinquerystring("m1=P")==false)
        { 
          appendtourl("m1=P",true);    
        }
        else
        {
             loadpopdest("div_populardest",null,null,null);
        }
    } 
  
    if(pcid!=''&&did=='')
    {
       
       if(glb_popdestcatid!=pcid)
        {
             hidedestinationlist();
        }
        hidedestinationdetail();
        hidedestinationpagediv();
        loadpopdest("div_populardest",pcid,null,null); 
    }
    
    if(did!='')
    {
     
       loadpopdest("div_populardest",null,did,null); 
       //loadpopdestdetails(did,"div_populardest");
    }
    
    if(cty!='')
    {
        loadpopdest("div_populardest",null,null,cty);
        setcategoryselected(cty);
       
        
    }
   
}
function loadpopdest(container_div,pcid,did,cty)
{
    function render_categories(objcategories)
    {
        if(did!=null)
        {
            renderpopdestcategories(objcategories,pcid,loadpopdestbycategory,container_div,loadpopdestcities,null,did,loadpopdestdetails);
        }
        else
        {
           renderpopdestcategories(objcategories,pcid,loadpopdestbycategory,container_div,loadpopdestcities,cty,null,null);
        }
        
        logevent(window.location,"controlfunctions_regionalfeatures.js","loadpopdest",InfoDestinationsByCategory,"","","");
    }
    getPopDestinations(render_categories);
    
}

function loadpopdestbycategory(objdestinations,container)
{
   function render_destinationsbycategroy(objdestinations,container)
   {
        renderdestinationsbycategory(objdestinations,container,loadpopdestdetails,"div_populardest","div_populardest_withpaging");
   }
   
  
  
   if(checkexistinquerystring("pcid="+ objdestinations.CategoryID)==false)
    {
      
      glb_popdestcatid=objdestinations.CategoryID;
      appendtourl("m1=P&pcid="+ objdestinations.CategoryID,true);       
    }
    else
    {
      
        render_destinationsbycategroy(objdestinations,container);
    }
  
}

function loadpopdestdetails(did,container_div)
{
   function render_popdestdetails(objdestination)
   {
       
         
       if(checkexistinquerystring("did="+ did)==false)
        {
   
          appendtourl("m1=P&did="+ did,true);       
        }
        else
        {
       
             renderpopdestdetails(objdestination,container_div);
             showdestinationdetail();
             logevent(window.location,"controlfunctions_regionalfeatures.js","loadpopdestdetails",InfoDestinationsById,"","","");
            
        }
         
        
   }   
   
    getPopDestinationById(did,render_popdestdetails);
}

function loadpopdestcities(container_div,cty)
{

    function render_searchbycity(objcitylist)
    {
        renderpopdestsearchbycity(objcitylist,cty,loadpopdestinationsbycity,container_div,loadDestinationMapByCity);
       // logevent(window.location,"controlfunctions_regionalfeatures.js","loadpopdestcities",InfoDestinationCities,"","","");
    }
    getPopDestinationCities(render_searchbycity);
    
}

function loadpopdestinationsbycity(cityname)
{

    function render_destinationsbycities(objdestinations)
    {
       
          
       if(checkexistinquerystring("cty="+ cityname)==false)
        {
         
          appendtourl("m1=P&cty="+ cityname,true);       
        }
        else
        {
            renderdestinationsbycities(objdestinations,loadpopdestdetails,"div_populardest",loadDestinationMapByCity);
            logevent(window.location,"controlfunctions_regionalfeatures.js","loadpopdestinationsbycity",InfoDestinationsByCity,cityname,"","");
        }
    }
    
    getPopDestinationByCity(cityname,render_destinationsbycities);
}

function showtransitbasicsubdivs(divid)
{
//    if(divid=='BayAreaOverview'||divid=='ABigRegion'|| divid=='ADiverseTransport')
      if(divid=='GeneralInformation')
       {
            $("#GeneralInformation").show();
            $("#ABigRegion").show();
            $("#ADiverseTransport").show();
            $("#RegionalTransit").show();
            $("#TransitCoverageArea").show();
            $("#GettingAroundonTransit").show();
            $("#MoreInfoFingerTip").show();
            $("#RegionalOutreach").show();
        }
       if(divid=='RegionalFeatures')
       {
            $("#RegionalConnectivity").show();
            $("#Airports").show();
            $("#CableCars").show();
            $("#HistoricStreetcars").show();
            $("#NewTechnology").show();
          
        }
        
       if(divid=='TripGroup')
       {
            $("#PlanYourTrip").show();
            $("#MY511").show();
            $("#511DepartureTimes").show();
            $("#TransLink").show();
            $("#FaresandFarePayment").show();
            $("#HoursofService").show();
        }
        
       if(divid=='RidingTransit')
       {
            $("#Accessibletransit").show();
            $("#HelpfulHints").show();
            $("#RidesharingParking").show();
            $("#BikesonTransit").show();
            $("#PetsonTransit").show();
            $("#SafetyTips").show();
        }
//    
//    //if(divid=='GettingAroundonTransit'||divid=='RegionalTransit'|| divid=='PlanningYourtripon')
//    if(divid=='GettingAroundonTransit')
//    {
//        $("#GettingAroundonTransit").show();
//        $("#RegionalTransit").show();
//        $("#PlanningYourtripon").show();
//    }
    if(divid=='')
    {
        $("#div_ns_data").find("div").show() ;
    }
    else
    {
        $("#"+ divid).show();

    } 
    $("#div_tbprint").show();
    
//    if(divid=='AirportTravelandOther')
//    {
//         $("#AirportTravelandOther").show();
//    }
//    if(divid=='HoursofService')
//    {
//        $("#HoursofService").show();
//    }
//    
//    if(divid=='FaresandFarePayment')
//    {
//        $("#FaresandFarePayment").show();
//    }
//    
//    if(divid=='TransLink')
//    {
//        $("#TransLink").show();
//    }
//    if(divid=='Accessibletransit')
//    {
//        $("#Accessibletransit").show();
//    }
//    if(divid=='BikesonTransit')
//    {
//        $("#BikesonTransit").show();
//    }
}
//Map Function Starts Here
function loadagenciespoints()
{
   try
   {
         hidemaheader();
         map_ShowALLAgencyPoints();
         unbindmapdivevents();
         ShowAgencyMap();
         logevent(window.location,"controlfunctions_regionalfeatures.js","loadagenciespoints",MapTransitBasicMap,"","","");
   }
   catch(err)
   {
        logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadagenciespoints",ErrorWWWNonFatal,"","","")
   }
  
    
}

function ShowAgencyMap()
{
                var _pagex1;
                var _pagey1;
                $("#mapBoxTall").unbind("mousedown").bind("mousedown",function(event)
                {
                    _pagex1=event.pageX ;
                    _pagey1=event.pageY ;
                    
                });  
                
                $("#mapBoxTall").unbind("click").bind("click",function(event)
                { 
                    if(Math.abs(event.pageX-_pagex1)<3)
                      {
                        var _mapcontrol = $("#mapBoxTall");
                        var offset = _mapcontrol.offset();
                        var Xpos= event.pageX - offset.left;
                        var Ypos= event.pageY - offset.top ;
 
                            var Xmin=glb_xmin;
                            var Ymin=glb_ymin;
                            var Xmax=glb_xmax;
                            var YMax=glb_ymax;                            
                            var MapWidth=484;
                            var MapHeight=482;
                            

                            function render_agencyprofile(stragencyparam)
                            {
                           
                             if(stragencyparam!='')
                             {
                             
                                    var arragencyparam=stragencyparam.split("~");
                                    var _agencyid=arragencyparam[0];
                                    var _agencyxpos=arragencyparam[1];
                                    var _agencyypos=arragencyparam[2];
                                    
                                    function render_agencyMap(agencyobj)
                                    {
                                       // var _agencymaptipbody="";
                                        var _agencymaptipbody="";
                                        if(getAgencyAddress(agencyobj)!=null)
                                        {
                                            _agencymaptipbody=getAgencyAddress(agencyobj);
                                        }
                                        if(getAgencyPhone(agencyobj)!=null)
                                        {
                                            _agencymaptipbody+="<br></br><br></br><b>Tel: </b>"+ getAgencyPhone(agencyobj) ;
                                        }
                                        
                                        map_highlightagency(_agencyid,"bus");                                        
                                        setmapheadertext(agencyobj.Name + " "+ rskey_servicearea);
                                    }
                                    getAgencyProfile(_agencyid,render_agencyMap); 
                                
                               
                             }
                            }
                               
                            function getAgencyIDForMapTip(Xpos,Ypos,Xmin,Ymin,Xmax,YMax,MapWidth,MapHeight,callbackfunction)
                            {
                                 $.ajax({
                                  type: "GET",
                                  data: "Xpos="+Xpos+"&Ypos="+ Ypos+"&Xmin="+Xmin+"&Ymin="+ Ymin+"&Xmax="+ Xmax+"&Ymax="+YMax+"&MapWidth="+ MapWidth+"&MapHeight="+MapHeight,
                                  url: "../Mapping/GetAgencyID.aspx",
                                  dataType: "text",
                                  success: function(returnItem){
                                     callbackfunction(returnItem);
                                     
                                   },
                                  error: function(){
                                     //alert( "Error While Retrieving Map Tips Data : ");
                                      var referencetext="Xpos="+Xpos+"&Ypos="+ Ypos+"&Xmin="+Xmin+"&Ymin="+ Ymin+"&Xmax="+ Xmax+"&Ymax="+YMax+"&MapWidth="+ MapWidth+"&MapHeight="+MapHeight;
                                      logerror(null,window.location,"controlfunctions_regionalfeatures.js","getAgencyIDForMapTip",ErrorWWWNonFatal,referencetext,"","");
                                   }
                                });
                            }
                            
                            getAgencyIDForMapTip(Xpos,Ypos,Xmin,Ymin,Xmax,YMax,MapWidth,MapHeight,render_agencyprofile);                   
                   }                       
                  else  // close maptip when pan
                     {                                 
                        CloseAllMaptips();
                     } 
              });            
}


function loadDestinationByCategoryMap(categoryid)
{
   try
   {
        // glb_imageIndicator is passed to "getdestinationID.cs" for caculating image name of maptip 
            glb_imageIndicator = "multiple"; 
            if(ismapenable()==true)
                {
                       unbindmapdivevents();
                        map_ShowDestinationByCategory(categoryid);
                        loadpopdestmaptip("category",categoryid,null, glb_imageIndicator);
                        //setmapheadertext(getAgencyName() + " "+rskey_mapheaderforroute +" " + getSelectedRouteDesignator(getSelectedRouteID()) + " - " +  getSelectedDirectionName());   
                        glb_MapLoadTypeName="category";
                        glb_MapLoadTypeId=categoryid;
                        logevent(window.location,"controlfunctions_regionalfeatures.js","loadDestinationByCategoryMap",MapDestinationsByCategory,"","","");
                }  
   
   }
   catch(err)
   {
    
        
        logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadDestinationByCategoryMap",ErrorWWWNonFatal,categoryid,"","");
   
   }
   
    
    
}

function loadDestinationMap(destid)  // select a destination from drop down list, use imageIndicator from previous action
{
   try
    {
      if(ismapenable()==true)
        {
            
            unbindmapdivevents();
            var img_name='mapAlphaIconA.gif';
            if($("#txt_image_"+ destid).val()!=undefined)
               {
                    img_name=$("#txt_image_"+ destid).val();
               }  
              bln_clearmap=false;        
              map_ShowDestinationBySelect(destid,img_name,glb_MapLoadTypeName,glb_imageIndicator,glb_MapLoadTypeId);  // changed for user page back from section 2
             // map_ShowDestinationBySelect(destid,img_name); 
              loadpopdestmaptip(glb_MapLoadTypeName,glb_MapLoadTypeId,destid,glb_imageIndicator);
              logevent(window.location,"controlfunctions_regionalfeatures.js","loadDestinationMap",MapDestinationsById,"","","");
        } 
   
    }
    catch(err)
    {
      logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadDestinationMap",ErrorWWWNonFatal,destid,"","");
    
    }
   
   
       
}


function SetMapLoadlType(name,id)
{
    glb_MapLoadTypeName=name;
    glb_MapLoadTypeId=id;
}
function SetMapImageIndicator(strIndicator)
{
    glb_imageIndicator=strIndicator;
}
function GetMapLoadType()
{
    return glb_MapLoadTypeName; 
}
function loadDestinationMapByCity(cty)
{
    try
    {
         glb_imageIndicator = "multiple";
         if(ismapenable()==true)
            {
             
                unbindmapdivevents();
                map_ShowDestinationByCity(cty);
                loadpopdestmaptip("city",cty,null,glb_imageIndicator);
                glb_MapLoadTypeName="city";
                glb_MapLoadTypeId=cty;
                logevent(window.location,"controlfunctions_regionalfeatures.js","loadDestinationMapByCity",MapDestinationsByCity,"","","");
            }    
    
    }
    catch(err)
    {
        logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadDestinationMapByCity",ErrorWWWNonFatal,cty,"","");
    }
    
   
}

function loadDestinationByID(destid)
{
    try
    {
        glb_imageIndicator = "single";
        if(ismapenable()==true)
        { 
          unbindmapdivevents();  
          map_ShowDestinationByID(destid);
          loadpopdestmaptip(glb_MapLoadTypeName,glb_MapLoadTypeId,destid,glb_imageIndicator);      
          logevent(window.location,"controlfunctions_regionalfeatures.js","loadDestinationByID",MapDestinationsById,"","","");
        }    
    
    }
    catch(err)
    {
         logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadDestinationByID",ErrorWWWNonFatal,destid,"","");
    }
    
}

function loadnighterroutemap(routeid,routetext,mode)
{
    try
    {
        if(ismapenable()==true)
        {
           unbindmapdivevents();
           map_highlightSpecialRoute(routeid,routetext,mode);
           loadroutemaptip(routeid,routetext,mode);
           setmapheadertext(routetext);
           logevent(window.location,"controlfunctions_regionalfeatures.js","loadnighterroutemap",MapNighterRoute,"","",routeid);
        } 
    
    }
    catch(err)
    {
        logerror(err,window.location,"controlfunctions_regionalfeatures.js","loadnighterroutemap",ErrorWWWNonFatal,"","",routeid);
    }
    
   
}

function unbindmapdivevents()
    {
        $("#mapBoxTall").unbind("click");
        $("#mapBoxTall").unbind("mousedown");
        CloseAllMaptips();
    }
    
function ismapenable()
{
    return enable_mapping;
}    

function loadpopdestmaptip(type,code,destid,usedimage)
{

        function ShowDestinationMapTips()
        {
                
             $("#mapBoxTall").unbind("click").bind("click",function(event)
                {
                         CloseAllMaptips();
                });
           
         
         }
  
      ShowDestinationMapTips();
            
}



function loadroutemaptip(routeid,agencyname,mode)
{ 
     var _pagex1;
                var _pagey1;
                $("#mapBoxTall").unbind("mousedown").bind("mousedown",function(event)
                {
                    _pagex1=event.pageX ;
                    _pagey1=event.pageY ;
                    
                });
                function ShowRouteMapTips()
                {
                        
                     $("#mapBoxTall").unbind("click").bind("click",function(event)
                        {                      
                          if(Math.abs(event.pageX-_pagex1)<3)
                           {
                                    var _mapcontrol = $("#mapBoxTall");
                                    var offset = _mapcontrol.offset();
                                    //alert( "left: " + offset.left + ", top: " + offset.top );

                                    var Xpos= event.pageX - offset.left;
                                    var Ypos= event.pageY - offset.top;
         
                                    var Xmin=glb_xmin;
                                    var Ymin=glb_ymin;
                                    var Xmax=glb_xmax;
                                    var YMax=glb_ymax;
                                    var MapWidth=484;
                                    var MapHeight=482;
                                    

                                    function render_RouteMapTip(strroute)
                                    {
                                   
                                       
                                        if(strroute!='')
                                        {
                                           
                                            
                                            var _routeparam=strroute.split("~");
                                           
                                            if(_routeparam[0]!='')
                                            {
                                                var arr_routelist= _routeparam[0].split(";");
                                              
                                                for (idx=0;idx<arr_routelist.length;idx++)
                                                {
                                                   if(arr_routelist[idx]==routeid)
                                                   {                                                  
                                                    map_RouteByClick(routeid,_routeparam[1],_routeparam[2],agencyname,mode,event.pageX,event.pageY)
                                                    break;
                                                   }
                                                   
                                                }     
                                            }                                        
                                            
                                           
                                            
                                        }
                                    }
                                       
                                    function getMapRouteID(Xpos,Ypos,Xmin,Ymin,Xmax,YMax,MapWidth,MapHeight,callbackfunction)
                                    {
                                         $.ajax({
                                          type: "GET",
                                          data: "Xpos="+Xpos+"&Ypos="+ Ypos+"&Xmin="+Xmin+"&Ymin="+ Ymin+"&Xmax="+ Xmax+"&Ymax="+YMax+"&MapWidth="+ MapWidth+"&MapHeight="+MapHeight,
                                          url: "../Mapping/GetRouteID.aspx",
                                          dataType: "text",
                                          success: function(returnItem){ CloseAllMaptips();//yzhou: mouse click on map, maptip is closed
                                             callbackfunction(returnItem);
                                             
                                           },
                                          error: function(){
                                             //alert( "Error While Retrieving Map Tips Data : ");
                                             var referencetext="Xpos="+Xpos+"&Ypos="+ Ypos+"&Xmin="+Xmin+"&Ymin="+ Ymin+"&Xmax="+ Xmax+"&Ymax="+YMax+"&MapWidth="+ MapWidth+"&MapHeight="+MapHeight;
                                             logerror(null,window.location,"controlfunctions_regionalfeatures.js","getMapRouteID",ErrorWWWNonFatal,referencetext,"","");
                                           }
                                        });
                                    }
                                    
                                    getMapRouteID(Xpos,Ypos,Xmin,Ymin,Xmax,YMax,MapWidth,MapHeight,render_RouteMapTip);
                                 }
                                 
                              else  // close maptip when pan
                             {                                 
                                CloseAllMaptips();
                             }      
                                 
                         });
                   
                 
              }
          
                
                
                ShowRouteMapTips();
            
}

function setmapheadertext(headertext)
    {
      if(ismapenable()==true)
        {  
            $("#span_mapheader").show();
            $("#span_mapheader").html("<b>"+ headertext +"<b>");
            
        }    
    }
    
function hidemaheader()
{
    $("#span_mapheader").hide();
}

function getmapheadertext()
{

    return  $("#span_mapheader").text();
}

function appendStaticUrl(url)
{
     appendtourl(url,true);
}

function loadmaphelp(helpfor)
    {
      
     
       function render_maphelp(helpitem)
        {
            renderhelp(helpitem,rskey_maphelpheader,xpos,ypos,"a_maphelp");
        }
        
           var xpos;
           var ypos;
           var maphelpheader;
          
           $("#td_maphelp").empty();
           $("<a  title='Map Help" + rskey_window + "' id='a_maphelp' href='javascript:void(0);'  >"+
           "<img alt=' ' src='http://images.transit.511.org/RUI/fw/iconHelp.gif' title='Map Help" + rskey_window + "' /></a>").appendTo("#td_maphelp");
           
           $("#a_maphelp").unbind("click").bind("click",
           function(event)
           {
                 xpos=event.pageX-350;
                 ypos=event.pageY;
                 
                 if(helpfor=='tb')
                 {
                    maphelpheader=rskey_maphelpheader;
                    getHelp("maphelptb","en",render_maphelp);
                 }
                 if(helpfor=='pd')
                 {
                    maphelpheader=rskey_maphelpheader;
                    getHelp("maphelppd","en",render_maphelp);
                 }
                 if(helpfor=='ns')
                 {
                    maphelpheader=rskey_maphelpheader;
                    getHelp("maphelpns","en",render_maphelp);
                 }
              
                
           });
           
    }
   
   function loadpopdesttophelp()
    {
      
       function render_help(helpitem)
        {  
            renderhelp(helpitem,rskey_popdesttop,xpos,ypos,"a_podest_tophelp");
        }
           var xpos;
           var ypos;
           var maphelpheader;
         
//           $("#p_popdest_tophelp").empty();
//           $("<a  title = 'Popular Destinations Help" + rskey_popupbox + "' tabindex='1500' id='a_podest_tophelp' href='javascript:void(0);'  >"+
//           "<img title ='Popular Destinations Help " + rskey_popupbox + "'  src='http://images.transit.511.org/RUI/fw/iconHelp.gif' alt='Help' height='18px' /></a>").appendTo("#p_popdest_tophelp");  //508580:help is shared  tabindex
           
           $("#a_podest_tophelp").unbind("click").bind("click",
           function(event) //508: x,y is not detected by "enter"
           { 
                 
                 if(event.pageX>0)
                    xpos=event.pageX-350;
                 else
                    xpos=150;
                  
                  if(event.pageY>0)
                    ypos=event.pageY;
                  else
                    ypos=100;
                
                 getHelp("pdesthelptop","en",render_help);
                
           });
           
    }
   
   function DestdetailsFromMap(destid)
   {
      //  CloseAllMaptips();  // commented for 9.3
        /* Commented for mantis issue 0003306
        glb_MapLoadTypeName="";
        glb_MapLoadTypeId="";
        loadpopdestdetails(destid,'div_populardest')
        */
        //loadDestinationMap(destid); // commented for 9.3
         function renderdetailonly(objdestination)
         {
             renderpopdestdetails(objdestination,'div_populardest'); 
         }
     
         getPopDestinationById(destid,renderdetailonly);
        
   }
   //Functions for tourist info starts here
   function linkTouristDetails(did,objsource)
   {
         
         glb_MapLoadTypeName=null;
         glb_MapLoadTypeId=null;
         appendtourl("m1=P&did="+ did,true); 
         hidedestinationpagediv();
         $(".touristvisitedlinks").removeClass("touristvisitedlinks").addClass("touristlinks");
         $(objsource).removeClass("touristlinks").addClass("touristvisitedlinks");
         logevent(window.location,"controlfunctions_regionalfeatures.js","linkTouristDetails",TouristAttractionLinkClicked,"","","");   
            
   }
   
   function loadtourist()
   {
     $("#btntourist").unbind("click").bind("click",function()
     { 
       // $("#div_populardest").hide();
       // SetTouristRotateImage();
        $("#div_touristmain").show(); 
        $("#a_mstart").focus(); //508
        logevent(window.location,"controlfunctions_regionalfeatures.js","loadtourist",TouristAttractionsSectionshown,"","","");
        hidedestinationpagediv();
     });
     
     $("#a_toptourist_close").unbind("click").bind("click",function()
     {
       //$("#div_populardest").show();
        hidetourism();
     });
   }
   
   function hidetourism()
   {
     $("#div_touristmain").hide(); 
   }
   
   function SetTouristRotateImage()//Make here ajax request to get the rotating image from service
   {
   
      $("#imgtouristimage").attr("src","../destinations/rotate/hub_14.jpg");
   }
//Ends Here controlfunctions_regionalfeatures.js


