﻿
var INFOLIST_SearchMap = null;    //地图搜索下拉对象 获取值：<input>INFOLIST.options[INFOLIST.selectedIndex]   <div>INFOLIST.options[INFOLIST.selectIndex]
var INFOLIST_SearchArroundCenter = null;   //周边查询中心点下拉对象
var INFOLIST_BusStartStop = null;   //公交换乘起点下拉对象
var INFOLIST_BusEndStop = null;   //公交换乘终点下拉对象
var INFOLIST_PathStartStop = null;    //自驾起点下拉对象
var INFOLIST_PathEndStop = null;  //自驾下拉对象
var strCityCode_index=encode64("|cityCode=110100");
//页面初始化加载下拉
sfs.page.onload.add(initDropDown);
function initDropDown()
{
   getCityByIP(1,loadFun);
}
function loadFun()
{
   getWeatherNoMap(strCityCode_IP);
//   INFOLIST_SearchMap=isNewDropDown(INFOLIST_SearchMap,null,select('#txtMapName'),'300px');
//   INFOLIST_SearchArroundCenter=isNewDropDown(INFOLIST_SearchArroundCenter,null,select('#txtAroundName'),'153px');
//   INFOLIST_BusStartStop=isNewDropDown(INFOLIST_BusStartStop,null,select('#txtBusChangeStart'),'153px');
//   INFOLIST_BusEndStop=isNewDropDown(INFOLIST_BusEndStop,null,select('#txtBusChangeEnd'),'153px');
//   INFOLIST_PathStartStop=isNewDropDown(INFOLIST_PathStartStop,null,select('#txtMyStart'),'153px');
//   INFOLIST_PathEndStop=isNewDropDown(INFOLIST_PathEndStop,null,select('#txtMyEnd'),'153px');
   select('#map_City').value=strCityName_IP;
   select('#around_City').value=strCityName_IP;
   select('#bus_change_City').value=strCityName_IP;
   select('#bus_Line_City').value=strCityName_IP;
   select('#bus_Station_City').value=strCityName_IP;
   select('#my_City').value=strCityName_IP;
   select('#cityCode').value=strCityCode_IP;
   select('#cityName').value=strCityName_IP;
   strCityCode_index=encode64("|cityCode="+strCityCode_IP+"");
}
/*
 enums
*/

CITY = {
    "北京市":"110100",
    "上海市":"310100",
    "天津市":"120100",
    "广州市":"440100",
    "杭州市":"330100",
    "福州市":"350100",
    "莆田市":"350300",
    "厦门市":"350200",
    "宁波市":"330200",
    "温州市":"330300",
    "舟山市":"330900",
    "绍兴市":"330600",
    "温州市":"330300",
    "衢州市":"330800",
    "泉州市":"350500",
    "深圳市":"440300",
    "珠海市":"440400",
    "汕头市":"440500",
    "东莞市":"441900",
    "佛山市":"440600",
    "茂名市":"440900",
    "惠州市":"441300",
    "中山市":"442000",
    "韶关市":"440200",
    "潮州市":"445100"
}

/*
 enums
*/
/*
 初始化周边的附近下拉和更多
*/
sfs.page.onload.add( initAroundDropDown);
function initAroundDropDown(){
    dLayer = $('aroundContent_dLayer');  //下拉框
    sLayer = $('aroundContent_sLayer');  //显示下拉的元素
    
    datas = {
        '100米':'100',
        '300米':'300',
        '500米':'500',
        '1公里':'1000',
        '2公里':'2000'
    };
    
    pr = dLayer.select('ul');
    for( a in datas){
        n = pr.select('<li></li>');
        n = n.select('<a href="#" value="'+datas[a]+'">'+a+'</a>');
        n.addEvent('click',aroundDropDownOptionClick,'click' );
    }
    
    sLayer.onclick = function(e){
        e = e || window.event;
        cancelEventBubble(e);
        aroundDropDownClick();
    }   
    function hideD(){   $('aroundContent_dLayer').hide(); };  
    sfs.page.onclick.add( hideD );
}
function aroundDropDownClick(e){
    dLayer = $('aroundContent_dLayer');
    sLayer = $('aroundContent_sLayer');
    
    if( dLayer.visible() ) dLayer.hide();
    else{
        offset = cumulativeOffset(sLayer);
        dLayer.x( offset.left );
        dLayer.y( offset.top + sLayer.offsetHeight);
        dLayer.show();
    }
}
function aroundDropDownOptionClick(e,option){
    dLayer = $('aroundContent_dLayer');
    sLayer = $('aroundContent_sLayer');
    var hValue = $('txtAroundSpace');
    
    sLayer.update( option.cons());
    hValue.value = option.getAttribute('value');
}

function fillValue(obj){
    var aKey = $('txtAroundKey');
    if(aKey!=null&&obj.innerHTML!=null)
    {
       var a=obj.innerHTML;
       aKey.value=a;
    }
}
function aroundMoreOptionClick(e,option){
     aroundHotSearch(option);
}
/*
 初始化周边的附近下拉
*/

function onCitySelected(option)
{
    var busTabControls1=select("#busTabControls1");
    busTabControls1.checked=true;
    cityNO = $('cityName');
    cityCO = $('cityCode');
    if( cityNO != null) cityNO.value = option.name;
    if( cityCO != null) cityCO.value = option.code;
    getWeatherNoMap(option.code);
//    INFOLIST_SearchMap.city(''+option.code+'');
//    INFOLIST_SearchArroundCenter.city(''+option.code+'');
//    INFOLIST_BusStartStop.city(''+option.code+'');
//    INFOLIST_BusEndStop.city(''+option.code+'');
//    INFOLIST_PathStartStop.city(''+option.code+'');
//    INFOLIST_PathEndStop.city(''+option.code+'');
    select('#map_City').value=option.name;
    select('#around_City').value=option.name;
    select('#bus_change_City').value=option.name;
    select('#bus_Line_City').value=option.name;
    select('#bus_Station_City').value=option.name;
    select('#my_City').value=option.name;
    strCityCode_index=encode64("|cityCode="+option.code+"");
}
function toBus(){
    if(window.tab3) if( tab3.tabAction) tab3.tabAction();
    if(window.busTabControls1) if( busTabControls1.tabAction) busTabControls1.tabAction();
    copyValue('txtBusChangeStart','txtMyStart',txtBusChangeStart);
    copyValue('txtBusChangeEnd','txtMyEnd',txtBusChangeEnd);
}
function toMy(){
    if(window.tab4) if( tab4.tabAction) tab4.tabAction();
    copyValue('txtMyStart','txtBusChangeStart',txtMyStart);
    copyValue('txtMyEnd','txtBusChangeEnd',txtMyEnd);
}
//地图搜索
function mapSearch(){
    toLocation({
        'tname':1,
        'mk': $('txtMapName').value,
        'cityCode':$('cityCode').value },
        'map/map.htm');
}
//周边搜索
function aroundSearch(){
    var strCoord=select("#txtAroundName").getAttribute('xy');
    toLocation({
        'tname':2,
        'ms': $('txtAroundName').value,
        'd': $('txtAroundSpace').value,
        't': $('txtAroundKey').value,
        'co':strCoord,
        'cityCode':$('cityCode').value},
        'map/map.htm');
}
//公交换乘
function busChangeSearch(){
    var strCoordStart=select("#txtBusChangeStart").getAttribute('xy');
    var strCoordStop=select("#txtBusChangeEnd").getAttribute('xy');
    toLocation({
        'tname':3,
        's': $('txtBusChangeStart').value,
        'e': $('txtBusChangeEnd').value,
        'sco':strCoordStart,
        'eco':strCoordStop,
        'cityCode':$('cityCode').value},
        'map/map.htm');
}
//公交线路查询
function busLineSearch(){
    toLocation({
        'tname':4,
        'ln': $('txtBusLineName').value,
        'cityCode':$('cityCode').value},
        'map/map.htm');
}
//公交站点查询
function busStationSearch(){
    toLocation({
        'tname':5,
        'st': $('txtBusStationName').value,
        'cityCode':$('cityCode').value},
        'map/map.htm');
}
//自驾查询
function mySearch(){
    var strCoordStart=select("#txtMyStart").getAttribute('xy');
    var strCoordStop=select("#txtMyEnd").getAttribute('xy');
    toLocation({
        'tname':6,
        'as': $('txtMyStart').value,
        'ae': $('txtMyEnd').value,
        'sco':strCoordStart,
        'eco':strCoordStop,
        'cityCode':$('cityCode').value },
        'map/map.htm');
}
//热点查询
function mapHotSearch( obj){
    $('txtMapName').value = obj.innerHTML;
    mapSearch();
}
function aroundHotSearch(obj){
    $('txtAroundKey').value = obj.innerHTML;
    aroundSearch();
}
//分类查询
var strSearchByKindP="";
function searchPoi(obj){
     toLocation({
        'tname':7,
        'kName': obj.innerHTML,
        'cityCode':$('cityCode').value},
        'map/map.htm');
}
//切换城市
function switchCity(obj)
{
     toLocation({
        'cityCode':CITY[obj.innerHTML]},
        'map/map.htm');
}




