﻿

var tr01_03 = "#FFFFFF";

var mouseOverColor="#FFD373";

var style3 = 'style="position: relative; left: 0px; top: 0px; width: 100%;overflow:hidden; text-overflow:ellipsis;"';
var ywzm = new Array("A","B","C","D","E","F","G","H","J","K","L","M","N","Q","S","T","W","X","Y","Z","SH");
var popup_gd=25;  //数据显示高度
var popup_i; 
var popup_int0=0;


var popup_int3=0;
//北京|PEK|B  城市|三字代码|拼音首字母

var hotelshcs = new Array("北京|0101|B", "上海|0201|S", "广州|2001|G", "深圳|2003|S", "长沙|1901|C", "武汉|1801|W", "南京|1101|N", "杭州|1201|H", "大连|0801|D", "青岛|1601|Q", "重庆|0401|C", "呼和浩特|0701|H", "郑州|1701|Z", "西安|2701|X", "沈阳|0802|S", "长春|0901|C", "昆明|2501|K", "乌鲁木齐|3101|W", "天津|0301|T", "太原|0601|T", "合肥|1301|H", "福州|1402|F", "南昌|1501|N", "哈尔滨|1001|H", "济南|1602|J", "南宁|2102|N", "海口|2202|H", "贵阳|2401|G", "兰州|2801|L", "银川|2901|Y", "西宁|3001|X");
//出发城市及图片ID



//到达城市及图片ID




function Hotelshowclick(cityid, imgid, hidcityid) {
 $(document).mousedown(function(){
  $('#HotelCityList').hide();
 });

        //首字母 
        function InitialLetterTab()
        {
           $("#HotelFirstLetter").html("");
            for(var l in ywzm)
            {
                if(ywzm[l]=="SH")
                {
                     $("#HotelFirstLetter").append("<td id='H_"+ywzm[l]+"' style='cursor:pointer' alias='"+ywzm[l]+"' class='clafirst'  style='color:red'>"+ywzm[l]+"<td>");
                }
                else
                {
                    $("#HotelFirstLetter").append("<td id='H_" + ywzm[l] + "' style='cursor:pointer'  alias='" + ywzm[l] + "' class='clafirst' style='color:blue'>" + ywzm[l] + "<td>");
                 }
                
            }    
        }
        InitialLetterTab();
        InitialCityByLetter("SH");

        $(".clafirst").mouseover(function(){
                                    this.style.backgroundColor=mouseOverColor;
                                }).mouseout(function(){
                                    this.style.backgroundColor="";
                                }).click(function(){
                                    $(".clafirst").css("color","blue");
                                    this.style.color="red";
                                    InitialCityByLetter(this.getAttribute("alias"));
                                }).mousedown(function(oevent){
                                    oevent.stopPropagation();//阻止全局的mousedown.停止事件的传播，阻止它被分派到其他 Document 节点
                                });

                                $("#H_SH").css("color", "red");
         $("#HotelCityList").toggle();

         var offset =getPos(cityid);
          
          $("#HotelCityList").css({"left":offset.left+"px","top":offset.top+"px"}); 
          
                                
         $("#"+imgid).mousedown(function(oevent){
        oevent.stopPropagation();//阻止全局的mousedown
      });; 
                
function InitialCityByLetter(fletter)
{
    var temArray=new Array();
    
    if(fletter=="SH")
    {
        temArray=hotelshcs;
    }
    else
    {
        for(var i in hotelqtcs)
        {
            if(Split(hotelqtcs[i],2,"|")==fletter)
            {
                temArray.push(hotelqtcs[i]);
            }
        }
    }    
    var tab="";
    for(popup_i=0;popup_i<36;popup_i++){
	    if(popup_i==0 || popup_i % 6 ==0){
		    tab+= '  <tr align="center" style="background-color:' +tr01_03+ ';">';
	    }
	    if(popup_i<temArray.length){
		    tab+= '    <td height="'+popup_gd+'" width="14.3%" class="citytd"  style="cursor:pointer"  ID="popup_td_cszm_'+popup_int0+'" Hotelfirstletter="'+Split(temArray[popup_i],1,"|")+'" title="'+Split(temArray[popup_i],0,"|")+'" style="font-size: 9pt"><NOBR '+style3+'  ID="popup_NOBR_cszm_'+Split(temArray[popup_i],1,"|")+'_'+popup_int0+'">'+Split(temArray[popup_i],0,"|")+'</NOBR></td>';
		    popup_int0++;
	    }else{
		    tab+= '    <td height="'+popup_gd+'" width="14.3%">&nbsp;</td>';
	    }
	    popup_int3 = popup_i+1;
	    if(popup_int3 % 6 ==0){
		    tab+= '  </tr>';
	    }
    }
    ;
    $("#HotelTabStartCity tr").remove();
    $("#HotelTabStartCity").html("<tbody>" + tab + "</tbody>").show();


    $("#HotelTabStartCity td").mouseover(function()
     { this.style.backgroundColor = mouseOverColor }).mouseout(function() { this.style.backgroundColor = "" }).click(function() {

     $("#" + hidcityid).val(this.getAttribute("Hotelfirstletter")); //给隐

        $("#" + cityid).val(this.getAttribute("title")); //显示的

        $("#HotelCityList").hide();


    }).mousedown(function(oevent) {
        oevent.stopPropagation(); //阻止全局的mousedown
    });
}                         
    
   
}


function Split(popup_str,popup_n,popup_s){ //字符串,取第几个数据,分割字符
	var popup_split;
	 popup_split=popup_str.split(popup_s);
	return popup_split[popup_n];
}

function getPos(divval) {
    var element = document.getElementById(divval);
    var position;

    var node = element;
    var leftvalue = 0;
    var topvalue = 0;
    if (navigator.userAgent.indexOf("MSIE 7.0") > 0 || navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 8.0") > 0) {
        while (node && node.tagName.toUpperCase() != "BODY") {
            leftvalue += node.offsetLeft;
            topvalue += node.offsetTop;
            node = node.offsetParent;
        }
    }

    else {
        leftvalue = element.offsetLeft;
        topvalue = element.offsetTop;
    }

    position = {
        left: leftvalue,
        top: topvalue + element.offsetHeight
    };

    return position;
}
