﻿/*firefox window.event*/
function __firefox(){
    HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
    window.constructor.prototype.__defineGetter__("event", __window_event);
    Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style(){
    return this.style;
}
function __window_event(){
    return __window_event_constructor();
}
function __event_srcElement(){
    return this.target;
}
function __window_event_constructor(){
    if(document.all){
        return window.event;
    }
    var _caller = __window_event_constructor.caller;
    while(_caller!=null){
        var _argument = _caller.arguments[0];
        if(_argument){
            var _temp = _argument.constructor;
            if(_temp.toString().indexOf("Event")!=-1){
                return _argument;
            }
        }
        _caller = _caller.caller;
    }
    return null;
}
if(window.addEventListener){
    __firefox();
}
/*end firefox.event*/

document.write('<style>\r\
#ltox1{z-index:100000;margin:0px;padding:0px;border:1px solid #809EB9;width:180px;font-size:12px;color:#666666;background: #fff;position:absolute;}\r\
#ltox1 ul{margin:0px;padding:0px}\r\
#ltox2{list-style:none}\r\
#ltox2 li{list-style:none;line-height:22px;border-bottom:1px dashed #999;color:#444;padding-left:4px}\r\
#ltox3{border:0px;margin:0px;padding:0px;list-style:none;height:220px;overflow-y:auto;overflow-x:hidden}\r\
#ltox3 li{padding: 1px 5px 0px 5px;text-align: right;border-top: 1px solid #FFFFFF;border-bottom: 1px solid #FFFFFF;cursor: pointer;line-height: 20px;color: #0055aa;}\r\
#ltox3 p{margin: 0px;padding: 0px;float: left; }\r\
#ltox3 li:hover{background: #E7F1FD; border-top: 1px solid #7F9DB9; border-bottom: 1px solid #7F9DB9; }\r\
#ltox3 .selected{background-color:#f7F1FD;}\r\
</style>')
document.write('<div id="ltox1"><ul id="ltox2"><li>输入中文或英文首字母进行选择</li></ul><ul id="ltox3"></ul></div>')
var object=null
function set_ccc(Obj){
	this.object = Obj;
	document.getElementById("ltox1").style.display="block"
	var layer = document.getElementById("ltox1");
	//取得对象位置给层定位
	var t = this.object.offsetTop,  h = this.object.clientHeight, l = this.object.offsetLeft,p = this.object.type;
	while (this.object = this.object.offsetParent){t += this.object.offsetTop; l += this.object.offsetLeft;}
	var cw = layer.clientWidth, ch = layer.clientHeight;
    var dw = document.body.clientWidth, dl = document.body.scrollLeft, dh = document.body.clientHeight,dt = document.body.scrollTop;
	if (document.body.clientHeight + dt - t - h >= ch) {
        layer.style.top = ((p=="image")? t + h : t + h + 3)+'px';
    }else {
        layer.style.top  = ((t - dt < ch) ? ((p=="image")? t + h : t + h + 3) : t - ch)+'px';
    }
    if (dw + dl - l >= cw){
        layer.style.left = l+'px'; 
    }else{ 
        layer.style.left = ((dw >= cw) ? dw - cw + dl : dl)-4+'px';
    }
			
	object = window.event.srcElement		
	document.onclick=this.click_hCity;
}

function iDiv(str,citys){
var istr = str
istr = istr.replace(" ","")
if (citys!=null){
var bcity = citys.split("@")	
}else{
var bcity = city.split("@")
}
var inhtml ='';
if (istr != ""){
	for(var k=0;k<bcity.length;k++){
		var hcitys = bcity[k]
		var hcity = hcitys.split("|")
		//alert(hcitys);
		if (hcity[0].substr(0,istr.length).toUpperCase()==istr.toUpperCase() || hcity[1].substr(0,istr.length).toUpperCase()==istr.toUpperCase() || hcity[1].substr(0,istr.length).toUpperCase()==istr.toUpperCase()){
		inhtml += '<li onclick="ivalue(\''+hcity[1]+'\');"><p>'+hcity[1]+'</p>'+hcity[0]+'</li>'
		}
	}
}else{
	for(var k=0;k<bcity.length;k++){
		var hcitys = bcity[k]
		var hcity = hcitys.split("|")
		inhtml += '<li onclick="ivalue(\''+hcity[1]+'\');"><p>'+hcity[1]+'</p>'+hcity[0]+'</li>'
		}
}	
	document.getElementById("ltox3").innerHTML = inhtml;
}

function hCity(){document.getElementById("ltox1").style.display="none";}
this.ivalue = function (Str){this.object.value=Str;hCity()}
this.click_hCity = function (){if(event.srcElement.id!=object.name) hCity();}
hCity();
lcity="Beijing|北京@Shanghai|上海@Guangzhou|广州@Shenzhen|深圳@Hangzhou|杭州@Nanjing|南京@Chengdu|成都@Hong Kong|香港@Qingdao|青岛@Wuhan|武汉@Xiamen|厦门@Dalian|大连@Chongqing|重庆@Tianjin|天津@Changsha|长沙@Xian|西安"
iDiv("",lcity);



