﻿function ChoseCity(cityId)
{
   var liId;
   var divId;
   var result=false;
   var tempHotCityId=$("#hotCityId").val();
   for(var r = 0;r < tempHotCityId.split(',').length;r++)
   {
      if(tempHotCityId.split(',')[r] == cityId)
      {
           result = true;
           liId = r+1;
           divId = 'newvouch_'+(r+1);
       }
    }
   var postData = "cityId=" + cityId+ "&Type=DefaultPageLine" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            var elem = document.getElementById("city_tap");
            var elemlist = elem.getElementsByTagName("li");
            var listName='newvouch';
            for (var i = 0; i < elemlist.length; i++) {
                var m = i + 1;
                if (document.getElementById(listName + "_" + m) != null) {                    
                    elemlist[i].className = "unsel_tag";//"sel02";
                    document.getElementById(listName + "_" + m).style.display = "none";
                }
            }
           if(!result)
           {
               liId=6;
               divId='newvouch_6';
           }
           document.getElementById(liId).className= "onsel_tag";//'sel01';
           document.getElementById(divId).innerHTML=msg;
           document.getElementById(divId).style.display='block';
           
           document.getElementById(liId).innerHTML = "<span class=\"tag_left001\"></span><span class=\"tag_center001\">"+$("#hd"+cityId).val() +"</span><span class=\"tag_right001\"></span>" ;     
           document.getElementById("cityContainer1").style.display='none';                
        }
    });
}
function MoreCity()
{
    document.getElementById("cityContainer1").style.display='block';
}

function secBoard(elementID, listName, elementname, n) {
    var elem = document.getElementById(elementID);
    var elemlist = elem.getElementsByTagName(elementname);
    for (var i = 0; i < elemlist.length; i++) {
        var m = i + 1;
        if (document.getElementById(listName + "_" + m) != null) {

            elemlist[i].className = "unsel_tag";//"sel02";
            document.getElementById(listName + "_" + m).style.display = "none";
        }
    }
    if (n != 7) {
        elemlist[n - 1].className = "onsel_tag";//"sel01";
    }
    document.getElementById(listName + "_" + n).style.display = "block";
}
function showLeft(id){
var iptOffSet=$(id).offset();
var iptLeft=iptOffSet.left;
var iptTop=iptOffSet.top+20;
$("#CityContainers").css({left:iptLeft+"px",top:iptTop+"px"});
$("#CityContainers").css({"display":"block"});}

 function SearchLine() {
     if($("#txtDepartureCity").val()=="城市名")
     {
          if($("#txtDestinationCity").val() != "城市/景点/主题/线路编号")
          {
             destinationCity = $("#txtDestinationCity").val();
             if(isDangerousString(destinationCity))
             {
                   alert("目的地中含有非法字符!");
                   return false;
             }
             window.location.href = globeUrl + "LineQuery.aspx?DestinationCity=" + encodeURIComponent(destinationCity)+"&page=1";
          }
          else
          {
             alert("请选择出发城市或输入目的城市！");
             return false;
          }
      }
      else
      { 
         if( $("#txtDestinationCity").val() != "城市/景点/主题/线路编号" )
         {
            var departureCity = $("#txtDepartureCity").val();
            var  destinationCity = $("#txtDestinationCity").val();
             if(isDangerousString(departureCity))
            {
               alert("出发城市中含有非法字符!");
               return false;
            }
            if(isDangerousString(destinationCity))
            {
               alert("目的地中含有非法字符!");
               return false;
            }
            window.location.href = globeUrl + "LineQuery.aspx?DepartureCity=" + encodeURIComponent(departureCity)+"&DestinationCity=" + encodeURIComponent(destinationCity)+"&page=1";
         }
         else
         {
            var departureCity = $("#txtDepartureCity").val();
             if(isDangerousString(departureCity))
            {
               alert("出发城市中含有非法字符!");
               return false;
            }
            window.location.href = globeUrl + "LineQuery.aspx?DepartureCity=" + encodeURIComponent(departureCity) + "&page=1";
         }
      }
}
 function SearchLineInfo() {
        if($("#txtDepartureCity").val()=="城市名")
        {
        if($("#txtDestinationCity").val() != "城市/景点/主题/线路编号")
        {
        destinationCity = $("#txtDestinationCity").val();
        if(isDangerousString(destinationCity))
        {
        alert("目的地中含有非法字符!");
        return false;
        }
        window.location.href = globeUrl + "LineQuery.aspx?DestinationCity=" + encodeURIComponent(destinationCity)+"&page=1";
        }
        else
        {
        alert("请选择出发城市或输入目的城市！");
        return false;
        }
        }
        else
        {
        if( $("#txtDestinationCity").val() != "城市/景点/主题/线路编号" )
        {
        var departureCity = $("#txtDepartureCity").val();
        var  destinationCity = $("#txtDestinationCity").val();
        if(isDangerousString(departureCity))
        {
        alert("出发城市中含有非法字符!");
        return false;
        }
        if(isDangerousString(destinationCity))
        {
        alert("目的地中含有非法字符!");
        return false;
        }
        window.location.href = globeUrl + "LineQuery.aspx?DepartureCity=" + encodeURIComponent(departureCity)+"&DestinationCity=" + encodeURIComponent(destinationCity)+"&page=1";
        }
        else
        {
        var departureCity = $("#txtDepartureCity").val();
        if(isDangerousString(departureCity))
        {
        alert("出发城市中含有非法字符!");
        return false;
        }
        window.location.href = globeUrl + "LineQuery.aspx?DepartureCity=" + encodeURIComponent(departureCity) + "&page=1";
        }
        }
        }
        //回车相应搜索按钮
        document.onkeydown=function(e)
        {
        var isie = (document.all) ? true:false; var key;
        var ev;
        if(isie)
        {//IE浏览器
        key = window.event.keyCode;
        ev = window.event;
        }
        else
        {//火狐浏览器
        key = e.which;
        ev = e;
        }
        if((($("#txtDepartureCity").val()!="城市名")||($("#txtDestinationCity").val() != "城市/景点/主题/线路编号"))&&(key == 13))
        {
        SearchLineInfo();
        }
        };


$(function(){
			$('#demo').kxbdMarquee({direction:'up'});
});
