var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var ie6 = window.XMLHttpRequest ? false : true;
var moveTimer = null;
var moveTimerRight = null;
var IMGDIR =OTHER_PATH+"/common/images";
var menu = null;
var overf;

//if (top.location != location) {
//	top.location.href = location.href;
//}

function getObj(id) {
    return document.getElementById(id);
}

function checklogin() {
    if (trim(getObj('goTo').value) == '企业会员') {
        document.loginform.action = "./company_space/index.html";
        document.loginform.submit();
    }else if (trim(getObj('goTo').value) == '个人会员') {
        document.loginform.action = "./personal_space/index.html";
        document.loginform.submit();
    }
}

function clearText(obj, content) {
    if (obj.value == content) {
        obj.value = '';
        obj.style.color = '#000';
    }
}

function backText(obj, content) {
    if (obj.value == '') {
        obj.value = content;
        obj.style.color = '#999';
    }
}

function gotoLeft() {
    Marquee();
}

function gotoRight() {
    MarqueeRight();
}

function Marquee() {
    if (getObj('movie2').offsetWidth - getObj('showplay').scrollLeft <= 0)
        getObj('showplay').scrollLeft -= getObj('movie1').offsetWidth;
    else {
        getObj('showplay').scrollLeft += 226 ;
    }
    window.clearInterval(moveTimer);
    moveTimer = setInterval(Marquee, speed);
}

function MarqueeRight() {
    //getObj('showplay').scrollLeft = getObj('showplay').scrollWidth;
    if (getObj('showplay').scrollLeft <= 0)
        getObj('showplay').scrollLeft += getObj('movie2').offsetWidth;
    else {
        getObj('showplay').scrollLeft -= 226 ;
    }
    window.clearInterval(moveTimer);
    moveTimer = setInterval(Marquee, speed);
}

function comsearch() {
    window.location.href = "map_search_list.html";
}

function doane(event) {
    e = event ? event : window.event;
    if(is_ie) {
        e.returnValue  = false;
        e.cancelBubble = true;
    } else if(e) {
        e.stopPropagation();
        e.preventDefault();
    }
}

function getRCvalue(name) {
    var tag_value = '';
    var s = document.getElementsByName(name);
    for (var i=0,l=s.length; i<l;i++ ){
        if (s[i].checked == true){
            tag_value += s[i].value+' ';
        }
    }
    return tag_value;
}

function  trim(str) {
    for(var  i  =  0  ;  i<str.length  &&  str.charAt(i)==" "  ;  i++  )  ;
    for(var  j  =str.length;  j>0  &&  str.charAt(j-1)==" "  ;  j--)  ;
    if(i>j)  return  "";
    return  str.substring(i,j);
}

var pmwindragstart = new Array();

function pmwindrag(obj, menuid) {
    obj.onmousedown = function(e) {
        if(is_ie) {
            document.body.onselectstart = function() {
                return false;
            }
        }
        pmwindragstart = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
        pmwindragstart[2] = parseInt(getObj(menuid).style.left);
        pmwindragstart[3] = parseInt(getObj(menuid).style.top);
        doane(e);
    }
    _attachEvent(document.body, 'mousemove', function(e) {
        if(pmwindragstart[0]) {
            var pmwindragnow = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
            if (getObj(menuid)) {
                with (getObj(menuid)) {
                    style.left = (pmwindragstart[2] + pmwindragnow[0] - pmwindragstart[0]) + 'px';
                    style.top = (pmwindragstart[3] + pmwindragnow[1] - pmwindragstart[1]) + 'px';
                }
            }
            doane(e);
        }
    });
    obj.onmouseup = function(e) {
        if(is_ie) {
            document.body.onselectstart = function() {
                return true;
            }
        }
        pmwindragstart = [];
        doane(e);
    }
    obj.onmouseover = null;
}

function _attachEvent(obj, evt, func) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, func, false);
    } else if (obj.attachEvent) {
        obj.attachEvent("on" + evt, func);
    }
}

function inArray (testarray,value) {
	var i;
	for (i=0; i < testarray.length; i++) {
		if (testarray[i] === value){
		    return true;
		}
	}
	return false;
}


function makeSelectCityHtml(pmwidth, pmheight, menuid, k, url, IMGDIR, showtitle, more) {
    var html = '';
    if (showtitle == true) {
        html += '<div id="myv" style="width: ' + pmwidth + 'px; background: red; margin: 0px; text-align: left">' +
            '<div id="myvcd" style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 1px solid #D9D9D9; position: relative; left: 0px; top: 0px">' +
            '<div id="mycd"  style=" position: relative; left: 0px; top: 0px; width: ' + pmwidth + 'px; height: 32px; line-height:32px;text-indent:20px; margin-bottom: -30px; background-color:#FFF; border-bottom:2px solid #e56f0b; color:#e56f0b;font-weight:bold;font-size:14px;">热门城市</div>' ;
        if (more) {
            html += '<a href="###" onclick="closeXm(\'morecity\')"><img style="position: absolute; right: 20px; top: 12px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0" id="cityclose"/></a>';
        } else {
            html += '<a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img style="position: absolute; right: 20px; top: 12px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0" id="cityclose"/></a>';
        }

        html += '<div id="pmwinmask" style="margin-top: 25px; position: absolute; width: 100%; height: 100%;">';

        html += "<div id='hotcities'>";
        html += '<a href="#" onclick="changCity(\'1101\',\'北京\', \''+menuid+'\', \''+showtitle+'\')">北京</a>';
        html += '<a href="#" onclick="changCity(\'3101\',\'上海\', \''+menuid+'\', \''+showtitle+'\')">上海</a>';
        html += '<a href="#" onclick="changCity(\'4401\',\'广州\', \''+menuid+'\', \''+showtitle+'\')">广州</a>';
        html += '<a href="#" onclick="changCity(\'4403\',\'深圳\', \''+menuid+'\', \''+showtitle+'\')">深圳</a>';
        html += '<a href="#" onclick="changCity(\'5001\',\'重庆\', \''+menuid+'\', \''+showtitle+'\')">重庆</a>';
        html += '<a href="#" onclick="changCity(\'3702\',\'青岛\', \''+menuid+'\', \''+showtitle+'\')">青岛</a>';
        html += '<a href="#" onclick="changCity(\'2102\',\'大连\', \''+menuid+'\', \''+showtitle+'\')">大连</a>';
        html += '<a href="#" onclick="changCity(\'3301\',\'杭州\', \''+menuid+'\', \''+showtitle+'\')">杭州</a>';
        html += '<a href="#" onclick="changCity(\'4201\',\'武汉\', \''+menuid+'\', \''+showtitle+'\')">武汉</a>';
        html += '<a href="#" onclick="changCity(\'6101\',\'西安\', \''+menuid+'\', \''+showtitle+'\')">西安</a>';
        html += '<a href="#" onclick="changCity(\'3201\',\'南京\', \''+menuid+'\', \''+showtitle+'\')">南京</a>';
        html += '<a href="#" onclick="changCity(\'1401\',\'太原\', \''+menuid+'\', \''+showtitle+'\')">太原</a>';
        html += "</div>";
    }

    html += "<div id='mapbgdiv'>";
    html += "<span style='margin-top:110px;margin-left:100px' onclick='javascript:alertCity(65, 4, \""+showtitle+"\", this.innerHTML,event);'>新疆</span>";
    html += "<span style='margin-top:210px;margin-left:100px' onclick='javascript:alertCity(54, 1, \""+showtitle+"\", this.innerHTML,event);'>西藏</span>";
    html += "<span style='margin-top:170px;margin-left:150px' onclick='javascript:alertCity(63, 2, \""+showtitle+"\", this.innerHTML,event);'>青海</span>";
    html += "<span style='margin-top:130px;margin-left:160px' onclick='javascript:alertCity(62, 2, \""+showtitle+"\", this.innerHTML,event);'>甘肃</span>";
    html += "<span style='margin-top:130px;margin-left:240px' onclick='javascript:alertCity(15, 3, \""+showtitle+"\", this.innerHTML,event);'>内蒙古</span>";
    html += "<span style='margin-top:220px;margin-left:200px' onclick='javascript:alertCity(51, 3, \""+showtitle+"\", this.innerHTML,event);'>四川</span>";
    html += "<span style='margin-top:230px;margin-left:240px' onclick='province=\"\";changCity(\"5001\",\"重庆\", \""+menuid+"\", \""+showtitle+"\");'>重庆</span>";
    html += "<span style='margin-top:280px;margin-left:190px' onclick='javascript:alertCity(53, 3, \""+showtitle+"\", this.innerHTML,event);'>云南</span>";
    html += "<span style='margin-top:288px;margin-left:260px' onclick='javascript:alertCity(45, 2, \""+showtitle+"\", this.innerHTML,event);'>广西</span>";
    html += "<span style='margin-top:333px;margin-left:260px' onclick='javascript:alertCity(46, 3, \""+showtitle+"\", this.innerHTML,event);'>海南</span>";
    html += "<span style='margin-top:288px;margin-left:300px' onclick='javascript:alertCity(44, 3, \""+showtitle+"\", this.innerHTML,event);'>广东</span>";
    html += "<span style='margin-top:262px;margin-left:240px' onclick='javascript:alertCity(52, 2, \""+showtitle+"\", this.innerHTML,event);'>贵州</span>";
    html += "<span style='margin-top:252px;margin-left:275px' onclick='javascript:alertCity(43, 2, \""+showtitle+"\", this.innerHTML,event);'>湖南</span>";
    html += "<span style='margin-top:220px;margin-left:282px' onclick='javascript:alertCity(42, 3, \""+showtitle+"\", this.innerHTML,event);'>湖北</span>";
    html += "<span style='margin-top:160px;margin-left:276px' onclick='javascript:alertCity(14, 2, \""+showtitle+"\", this.innerHTML,event);'>山西</span>";
    html += "<span style='margin-top:150px;margin-left:300px' onclick='javascript:alertCity(13, 2, \""+showtitle+"\", this.innerHTML,event);'>河北</span>";
    html += "<span style='margin-top:130px;margin-left:310px' onclick='province=\"\";changCity(\"1201\",\"天津\", \""+menuid+"\", \""+showtitle+"\");'>天津</span>";
    html += "<span style='margin-top:110px;margin-left:350px' onclick='javascript:alertCity(21, 2, \""+showtitle+"\", this.innerHTML,event);'>辽宁</span>";
    html += "<span style='margin-top:90px;margin-left:370px'  onclick='javascript:alertCity(22, 2, \""+showtitle+"\", this.innerHTML,event);'>吉林</span>";
    html += "<span style='margin-top:60px;margin-left:370px'  onclick='javascript:alertCity(23, 3, \""+showtitle+"\", this.innerHTML,event);'>黑龙江</span>";
    html += "<span style='margin-top:120px;margin-left:287px' onclick='province=\"\";changCity(\"1101\",\"北京\", \""+menuid+"\", \""+showtitle+"\");'>北京</span>";
    html += "<span style='margin-top:168px;margin-left:320px' onclick='javascript:alertCity(37, 3, \""+showtitle+"\", this.innerHTML,event);'>山东</span>";
    html += "<span style='margin-top:188px;margin-left:340px' onclick='javascript:alertCity(32, 2, \""+showtitle+"\", this.innerHTML,event);'>江苏</span>";
    html += "<span style='margin-top:160px;margin-left:230px' onclick='javascript:alertCity(64, 1, \""+showtitle+"\", this.innerHTML,event);'>宁夏</span>";
    html += "<span style='margin-top:190px;margin-left:286px' onclick='javascript:alertCity(41, 3, \""+showtitle+"\", this.innerHTML,event);'>河南</span>";
    html += "<span style='margin-top:193px;margin-left:250px' onclick='javascript:alertCity(61, 2, \""+showtitle+"\", this.innerHTML,event);'>陕西</span>";
    html += "<span style='margin-top:242px;margin-left:312px' onclick='javascript:alertCity(36, 2, \""+showtitle+"\", this.innerHTML,event);'>江西</span>";
    html += "<span style='margin-top:262px;margin-left:332px' onclick='javascript:alertCity(35, 2, \""+showtitle+"\", this.innerHTML,event);'>福建</span>";
    html += "<span style='margin-top:282px;margin-left:355px' >台湾</span>";
    html += "<span style='margin-top:232px;margin-left:345px' onclick='javascript:alertCity(33, 2, \""+showtitle+"\", this.innerHTML,event);'>浙江</span>";
    html += "<span style='margin-top:212px;margin-left:355px' onclick='province=\"\";changCity(\"3101\",\"上海\", \""+menuid+"\", \""+showtitle+"\");'>上海</span>";
    html += "<span style='margin-top:212px;margin-left:322px' onclick='javascript:alertCity(34, 3, \""+showtitle+"\", this.innerHTML,event);'>安徽</span>";
    html += "</div>";

    html += '</div></div></div>';
    return html;
}
var province;

function alertCity(num, row, showtitle, prov, e) {
    province = prov;
    var smallmapxy = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
    var pmwidth = 230;
    var pmheight = 114;
    var menuid = 'fwin_map';
    var k = 'map';
    var url = ''
    var html = '';
    html += '<div id="alertdivtitle"><a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img id="alertdivtitlex" style="position: absolute; right: 10px; top: 3px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0" width="7px" height="7px"/></a></div><div id="alertdiv"><ul id="alertdivul" style="height:'+(row * 25)+'px;">';
    var i = 0;
    var index = 0;
    for (var j = 0; j < provCityArray[i].length; j++) {
        index++;
        if (parseInt(provCityArray[i][j].id) == parseInt(num)) {
            for (var g = 0; g < provCityArray[index].length; g++) {
                if (showtitle == 'true') {
                    html+='<li><a href="#" onclick="changCity(\''+provCityArray[index][g].id+'\',\''+provCityArray[index][g].name+'\', \''+menuid+'\' , \''+showtitle+'\')">'+provCityArray[index][g].name+'</a></li>';
                } else {
                    html+='<li><a href="#" onclick="changCity(\''+provCityArray[index][g].id+'\',\''+provCityArray[index][g].name+'\', \''+menuid+'\', \''+showtitle+'\')">'+provCityArray[index][g].name+'</a></li>';
                }
            }
            break;
        }
    }
    html += '</ul></div><div id="alertdivbottom"></div>';
    showWindowmap('map', 'open', '230', '114', smallmapxy[0], smallmapxy[1], html, row);
}

function showWindowmap(k, action, divwidth, divheight, divx, divy, html, row) {
    var menuid = 'fwin_' + k;
    if (getObj(menuid)) getObj(menuid).parentNode.removeChild(getObj(menuid));
    var scrollTop    = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
    var pmwidth  = divwidth;
    var pmheight = divheight;
    if (action == 'open') {
        div = document.createElement('div');
        div.id = menuid;
        div.style.width = pmwidth + 'px';
        div.style.height = 7 + (row * 25 ) + 4 +'px';
        div.style.left = (divx - 128) + 'px';
        div.style.top  = (divy + scrollTop - 25 ) - (row * 25) + 'px';
        div.style.position = 'absolute';
        div.style.zIndex = '1100002';
        div.className = 'fwinmask';
        getObj('append_parentmap').appendChild(div);
        div.innerHTML = html;
        getObj(menuid).style.display = '';
        getObj('alertdivbottom').style.top = (row * 25) + 4 + 'px';
    } else if (action == 'close') {
        getObj(menuid).parentNode.removeChild(getObj(menuid));
    }
}


function writeDate() {
    var html    = '';
    var wday    = '';
    var dateObj = new Date();
    var year    = dateObj.getYear();
    year = year < 1900 ? (1900 + year) : year;
    var month   = dateObj.getMonth() + 1;
    var day     = dateObj.getDate();
    var weekday = dateObj.getDay();
    if (weekday == 0) wday = "星期日";
    if (weekday == 1) wday = "星期一";
    if (weekday == 2) wday = "星期二";
    if (weekday == 3) wday = "星期三";
    if (weekday == 4) wday = "星期四";
    if (weekday == 5) wday = "星期五";
    if (weekday == 6) wday = "星期六";
    html += year+'年'+month+'月'+day+'日'+' '+wday;
    document.write(html);
}

function productsMoveLeft() {
    photo_index += 1;
    var vcd = getObj('smallPhotoDiv').scrollLeft;
    if (getObj('movie2').offsetWidth - getObj('smallPhotoDiv').scrollLeft <= 0) {
        getObj('smallPhotoDiv').scrollLeft -= getObj('movie1').offsetWidth - (52 + 5);
    } else {
        getObj('smallPhotoDiv').scrollLeft += 52 + 5 ;
    }
    if (photo_index > imgnum.length / 2) {
        photo_index = 1;
    }
    for (var i=0; i < imgnum.length; i++) {
        if (photo_index == i) {
            imgnum[photo_index].style.borderColor = "orange";
            getObj('bigPhoto').src = imgnum[photo_index].src;
        } else {
            imgnum[i].style.borderColor = "#ccc";
        }
    }
    window.clearInterval(moveTimer);
    moveTimer = setInterval(productsMoveLeft, speed);
}

function productsMoveRight() {
    photo_index -= 1;
    //getObj('showplay').scrollLeft = getObj('showplay').scrollWidth;
    var vcd = getObj('smallPhotoDiv').scrollLeft;
    if (getObj('smallPhotoDiv').scrollLeft <= 0)
        getObj('smallPhotoDiv').scrollLeft += getObj('movie2').offsetWidth;
    else {
        getObj('smallPhotoDiv').scrollLeft -= 52 + 5 ;
    }

    if (photo_index < 0) {
        photo_index = imgnum.length / 2;
    }
    for (var i=0; i < imgnum.length; i++) {
        if (photo_index == i) {
            imgnum[photo_index].style.borderColor = "orange";
            getObj('bigPhoto').src = imgnum[photo_index].src;
        } else {
            imgnum[i].style.borderColor = "#ccc";
        }
    }
    window.clearInterval(moveTimer);
    moveTimer = setInterval(productsMoveLeft, speed);
}

function changetab(num, allnum, prefix) {
    for (var i=1; i <= allnum; i++) {
        if (i == num) {
            getObj(prefix+num).style.fontWeight = "bold";
            getObj(prefix+num).style.backgroundImage = "url('./images/p_tab_title_bg1.jpg')";
            getObj(prefix+num).style.backgroundRepeat='repeat-x';
            getObj(prefix+num).style.color = "#C00204";
            getObj("content"+num).style.display = "";
        } else {
            getObj("content"+i).style.display = "none";
            getObj(prefix+i).style.fontWeight = "normal";
            getObj(prefix+i).style.color = "#626260";
            getObj(prefix+i).style.backgroundImage = "url('./images/p_tab_title_bg.jpg')";
        }
    }
}

function changeLook(num, prefix, allnum) {
    for (var i=1; i <= allnum; i++) {
        if (i == num) {
            getObj(prefix+"_p_title_"+num).style.display = "none";
            getObj(prefix+"_p_img_"+num).style.display = "";
        } else {
            getObj(prefix+"_p_title_"+i).style.display = "";
            getObj(prefix+"_p_img_"+i).style.display = "none";
        }
    }
}

function writeTime() {
    var time = new Date();
    var h = "", m = "", s = "";
    h = time.getHours() + 100 + "";
    m = time.getMinutes() + 100 + "";
    s = time.getSeconds() + 100 + "";
    var html = h.substr(1) + ':' + m.substr(1) + ':' + s.substr(1);
    getObj('showtime').innerHTML = html;
}

function noticeMarquee() {
    if (getObj('movie2').offsetWidth - getObj('showmarquee').scrollLeft <= 0)
        getObj('showmarquee').scrollLeft -= getObj('movie1').offsetWidth;
    else {
        getObj('showmarquee').scrollLeft ++ ;
    }
}

function changeComanyTab(num, allnum) {
    for (var i=1; i <= allnum; i++) {
        if (i == num) {
            getObj("tab_"+num).style.fontWeight = "bolder";
            getObj("tab_"+num).style.backgroundImage = "url('./images/company_current_tab_bg.jpg')";
            getObj("tab_"+num).style.backgroundRepeat='repeat-x';
            getObj("tab_"+num).style.color = "#016E01";
            getObj("bo_"+num).style.backgroundColor = "#fff";
            getObj("content_"+num).style.display = "";
        } else {
            getObj("content_"+i).style.display = "none";
            getObj("bo_"+i).style.backgroundColor = "#016E01";
            getObj("tab_"+i).style.fontWeight = "normal";
            getObj("tab_"+i).style.backgroundImage = "url('./images/company_no_current_tab_bg.jpg')";
        }
    }
}


function showWindow(k, url, action, center, divwidth, divheight, divx, divy, showhtml, backdiv) {
	
    var menuid = 'fwin_' + k;
    var clientWidth  = document.body.clientWidth;
    var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
    var scrollTop    = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
    var pmwidth  = divwidth;
    var pmheight = divheight;
    if (action == 'open') {
        if(!getObj(menuid)) {
            if (backdiv) {
            	var newMask = document.createElement("div");
                newMask.id = 'mask';
                newMask.style.position = "absolute";
                newMask.style.zIndex = "1";
                _scrollWidth = Math.max(document.body.scrollWidth,document.documentElement.scrollWidth);
                _scrollHeight = $(document).height()<clientHeight? clientHeight : $(document).height();
                newMask.style.width = _scrollWidth + "px";
                newMask.style.height = _scrollHeight + "px";
                newMask.style.top = "0px";
                newMask.style.left = "0px";
                newMask.style.background = "#333";
                newMask.style.filter = "alpha(opacity=50)";
                newMask.style.opacity = "0.50";
                document.body.appendChild(newMask);
            }
            div = document.createElement('div');
            div.id = menuid;
            div.style.width = pmwidth + 'px';
            div.style.height = pmheight == "auto" ? "auto" : pmheight + 'px';

            if (center == 'true') {
                div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
                var jh = pmheight == "auto" ? clientHeight/2 : pmheight;
                div.style.top = ((clientHeight - jh) / 2 + scrollTop) + 'px';
            } else {
                div.style.left = divx + 'px';
                div.style.top  = scrollTop + divy + 'px';
            }

            div.style.position = 'absolute';
            div.style.zIndex = '11001';
            div.className = 'fwinmask';
            div.innerHTML = showhtml;
            getObj('append_parent').appendChild(div);
        }
        getObj(menuid).style.display = '';
    } else if (action == 'close') {
        getObj(menuid).parentNode.removeChild(getObj(menuid));
        if (getObj('mask')) getObj('mask').parentNode.removeChild(getObj('mask'));
        if (getObj('fwin_map')) getObj('fwin_map').parentNode.removeChild(getObj('fwin_map'));
        if (getObj('direction')) getObj("direction").style.display = '';
    }
}

function makeZijiaHtml(pmwidth, pmheight, menuid, k, url, IMGDIR) {
    var html = '';
    html += '<div style="width: ' + (parseInt(pmwidth) + 0 ) + 'px;height: ' + (parseInt(pmheight) + 0 ) + 'px; background: #fff;  text-align: left">' +
            '<div style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 2px solid #ababab; position: relative; left: 0px; top: 0px">' +
            '<div onmouseover="pmwindrag(this, \''+menuid+'\')" style="cursor: move; position: relative; left: 0px; top: 0px; width: ' + pmwidth + 'px; height: 25px; line-height:25px;text-indent:20px; margin-bottom: -30px; border-bottom:2px solid #016E01;">自驾导航</div>' +
            '<a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img style="position: absolute; right: 20px; top: 8px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0"/></a>' +
            '<div id="pmwinmask" style="margin-top: 25px; position: absolute; width: 100%; height: 100%;">';

    html += "<form name='actform' method='post' action='#'>";
    html += "<input type='hidden' id='citycode' name='citycode' value='1101'>";
    html += "<input type='hidden' id='address' name='address' value=''>";
    html += "<input type='hidden' id='start_x' name='start_x' value=''>";
    html += "<input type='hidden' id='start_y' name='start_y' value=''>";
    html += "<input type='hidden' id='end_x'   name='end_x' value=''>";
    html += "<input type='hidden' id='end_y'   name='end_y' value=''>";
    html += "<input type='hidden' id='start_name' name='start_name' value=''>";
    html += "<input type='hidden' id='end_name' name='end_name' value=''>";
    html += "<input type='hidden' id='show_type' name='show_type' value='driver'>";
    html += "<input type='hidden' id='start_end_f' name='start_end_f' value=''>";
    html += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
    html += "<tr><td height='10'></td></tr>";
    html += "<tr>";
    html += "<td>&nbsp;&nbsp;<input type='radio' name='queryradio' id='queryto' onclick='showHidden(this);' checked>去这里 <input type='radio' name='queryradio' id='queryfrom' onclick='showHidden(this);'>从这来</td>";
    html += "</tr>";
    html += "<tr><td height='10'></td></tr>";
    html += "<tr id='showTo'>";
    html += "<td>&nbsp;&nbsp;起点：<input type='text' id='key_work_search1' name='key_work_search1' onkeyup='show_poi_list(1);' style='width:150px;'> <input type='button' value='查询' onclick='javascript:gotoZMap();' style='border:1px solid #ccc'/>";
    html += "<div style='position: absolute; width: 240px; background: #FFFFFF; height: auto; z-index: 100000; margin-left: -249px; margin-top:21px;border:1px solid #999;display:none;' id='showpoimenu1'>";
    html += "</div>";
    html += "</td>";
    html += "</tr>";
    html += "<tr id='showFrom' style='display:none'>";
    html += "<td>&nbsp;&nbsp;终点：<input type='text' id='key_work_search2' name='key_work_search2' onkeyup='show_poi_list(2);' style='width:150px;'> <input type='button' value='查询' onclick='javascript:gotoZMap();' style='border:1px solid #ccc'/>";
    html += "<div style='position: absolute; width: 240px; background: #FFFFFF; height: auto; z-index: 100000; margin-left: -249px; margin-top:21px;border:1px solid #999;display:none;' id='showpoimenu2'>";
    html += "</div>";
    html += "</td>";
    html += "</tr>";
    html += "<tr><td height='10'></td></tr>";
    html += "</table>";
    html += "</form>";

    html += '</div></div></div>';
    return html;
}

function makeGjHtml(pmwidth, pmheight, menuid, k, url, IMGDIR) {
    var html = '';
    html += '<div style="width: ' + (parseInt(pmwidth) + 0 ) + 'px;height: ' + (parseInt(pmheight) + 0 ) + 'px; background: #fff;  text-align: left">' +
            '<div style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 2px solid #ababab; position: relative; left: 0px; top: 0px">' +
            '<div onmouseover="pmwindrag(this, \''+menuid+'\')" style="cursor: move; position: relative; left: 0px; top: 0px; width: ' + pmwidth + 'px; height: 25px; line-height:25px;text-indent:20px; margin-bottom: -30px; border-bottom:2px solid #016E01;">公交换乘</div>' +
            '<a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img style="position: absolute; right: 20px; top: 8px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0"/></a>' +
            '<div id="pmwinmask" style="margin-top: 25px; position: absolute; width: 100%; height: 100%;">';

    html += "<form name='actform' method='post' action='#'>";
    html += "<input type='hidden' id='citycode' name='citycode' value='1011'>";
    html += "<input type='hidden' id='address' name='address' value=''>";
    html += "<input type='hidden' id='start_x' name='start_x' value=''>";
    html += "<input type='hidden' id='start_y' name='start_y' value=''>";
    html += "<input type='hidden' id='end_x'   name='end_x' value=''>";
    html += "<input type='hidden' id='end_y'   name='end_y' value=''>";
    html += "<input type='hidden' id='start_name' name='start_name' value=''>";
    html += "<input type='hidden' id='end_name' name='end_name' value=''>";
    html += "<input type='hidden' id='show_type' name='show_type' value='bus'>";
    html += "<input type='hidden' id='start_end_f' name='start_end_f' value=''>";
    html += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
    html += "<tr><td height='10'></td></tr>";
    html += "<tr>";
    html += "<td>&nbsp;&nbsp;<input type='radio' name='queryradio' id='queryto' onclick='showHidden(this);' checked>去这里 <input type='radio' name='queryradio' id='queryfrom' onclick='showHidden(this);'>从这来</td>";
    html += "</tr>";
    html += "<tr><td height='10'></td></tr>";
    html += "<tr id='showTo' style='height:30px;'>";
    html += "<td>&nbsp;&nbsp;起点：<input type='text' id='key_work_search1' name='key_work_search1' onkeyup='show_poi_list(1);' style='width:150px;'/> <input type='button' value='查询' onclick='javascript:gotoZMap();' style='border:1px solid #ccc'/> ";
    html += "<div style='position: absolute; width: 240px; background: #FFFFFF; height: auto; z-index: 100000; margin-left: -255px; margin-top:21px;border:1px solid #999;display:none;' id='showpoimenu1'>";
    html += "</div>";
    html += "</td>";
    html += "</tr>";
    html += "<tr id='showFrom' style='display:none; height:30px;'>";
    html += "<td>&nbsp;&nbsp;终点：<input type='text' id='key_work_search2' name='key_work_search2' onkeyup='show_poi_list(2);' style='width:150px;'/> <input type='button' value='查询' onclick='javascript:gotoZMap();' style='border:1px solid #ccc'/> ";
    html += "<div style='position: absolute; width: 240px; background: #FFFFFF; height: auto; z-index: 100000; margin-left: -255px; margin-top:21px;border:1px solid #999;display:none;' id='showpoimenu2'>";
    html += "</div>";
    html += "</td>";
    html += "</tr>";
    html += "<tr><td height='10'></td></tr>";
    html += "</table>";
    html += "</form>";

    html += '</div></div></div>';
    return html;
}

function makeZhoubianHtml(pmwidth, pmheight, menuid, k, url, IMGDIR) {
    var html = '';
        html += '<div style="width: ' + (parseInt(pmwidth) + 0 ) + 'px;height: ' + (parseInt(pmheight) + 0 ) + 'px; background: #fff7c8;  text-align: left">' +
            '<div style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 2px solid #ababab; position: relative; left: 0px; top: 0px">' +
            '<div onmouseover="pmwindrag(this, \''+menuid+'\')" style="cursor: move; position: relative; left: 0px; top: 0px; width: ' + pmwidth + 'px; height: 25px; line-height:25px;text-indent:20px; margin-bottom: -30px; border-bottom:2px solid #016E01;">周边查询</div>' +
            '<a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img style="position: absolute; right: 20px; top: 8px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0"/></a>' +
            '<div id="pmwinmask" style="margin-top: 25px; position: absolute; width: 100%; height: 100%;">';


        html += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
        html += "<tr><td height='10'></td></tr>";
        html += "<tr>";
        html += "<td>&nbsp;&nbsp;中心地点：<span id='centerarea'>北京王府井安贞烤鸭店</span></td>";
        html += "</tr>";
        html += "<tr><td height='10'></td></tr>";
        html += "<tr>";
        html += "<td>&nbsp;&nbsp;关&nbsp;键&nbsp;字：<input type='text' id='new_keyword' /></td>";
        html += "</tr>";
        html += "<tr><td height='10'></td></tr>";
        html += "<tr>";
        html += "<td height='25px'>&nbsp;&nbsp;范围半径：<select id='search_area'><option value='500'>500米</option><option value='1000'>1000米</option><option value='2000'>2000米</option><option value='3000'>3000米</option><option value='4000'>4000米</option></select></td>";
        html += "</tr>";
        html += "</tr>";
        html += "<tr><td height='10'></td></tr>";
        html += "<tr>";
        html += "<tr>";
        html += "<td align='center'><input type='button' value='查询' onclick='gotopage();' style='border:1px solid #ccc'/></td>";
        html += "</tr>";
        html += "<tr><td height='10'></td></tr>";
        html += "</table>";

    html += '</div></div></div>';
    return html;
}


function makePhotoHtml(pmwidth, pmheight, menuid, k, url, IMGDIR, imgpath) {
    var html = '';
        html +=
            '<div style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 2px solid #ababab; position: relative; left: 0px; top: 0px">' +
            '<div style="margin-top: 0px;  width: 100%; height: 100%;">';
        html += "<img src='"+imgpath+"' height='"+pmheight+"px' width='"+pmwidth+"px'/>";
        html += '</div>';
        html += '</div>';
        html += '<div onmouseover="pmwindrag(this, \''+menuid+'\')" style="cursor: move;margin-left: 0px; margin-top: 0px; width: ' + pmwidth + 'px; height: 25px; line-height:25px;text-align:right; background-color:#fff;border: 2px solid #ababab;border-top: 0px solid #ababab;padding: 1px;"><a href="###" onclick="showWindow(\''+k+'\', \''+url+'\',\'close\')"><img style="margin-right: 20px; margin-top: 8px" src="' + IMGDIR +'/cha.jpg" title="关闭" border="0"/></a></div>' ;
    return html;
}


function showzijiadiv() {
    if (getObj('fwin_new')) getObj('fwin_new').parentNode.removeChild(getObj('fwin_new'));
    var zijiahtml = makeZijiaHtml('260', '120', 'fwin_new', 'new', '', IMGDIR);
    showWindow('new', '', 'open', 'true', '260', '120', '', '', zijiahtml);
}

function showgongjiaodiv() {
    if (getObj('fwin_new')) getObj('fwin_new').parentNode.removeChild(getObj('fwin_new'));
    var gjhtml = makeGjHtml('260', '120', 'fwin_new', 'new', '', IMGDIR);
    showWindow('new', '', 'open', 'true', '260', '120', '', '', gjhtml);
}

function showzhoubiandiv() {
    if (getObj('fwin_new')) getObj('fwin_new').parentNode.removeChild(getObj('fwin_new'));
    var zhoubianhtml = makeZhoubianHtml('260', '150', 'fwin_new', 'new', '', IMGDIR);
    showWindow('new', '', 'open', 'true', '260', '150', '', '', zhoubianhtml);
}

function selectHangYe() {
    if (getObj('fwin_hot')) getObj('fwin_hot').parentNode.removeChild(getObj('fwin_hot'));
    var hangyehtml = "<iframe src='./selecthangye.html' width='367x' height='237px' FRAMEBORDER=0 SCROLLING=NO id='hangyeiframe' name='hangyeiframe'></iframe>";
    showWindow('hangye', '', 'open', 'true', '360', '230', '', '', hangyehtml);
}

function selectHot() {
    if (getObj('fwin_hangye')) getObj('fwin_hangye').parentNode.removeChild(getObj('fwin_hangye'));
    var hothtml = "<iframe src='selectservice.html' width='707px' height='527px' FRAMEBORDER=0 SCROLLING=NO id='serviceiframe' name='serviceiframe'></iframe>";
    showWindow('hot', '', 'open', 'true', '700', '520', '', '', hothtml);
}

function gotopage() {

}


function showHidden(obj){
    if (obj.id=="queryto") {
        getObj('showTo').style.display="";
        getObj('showFrom').style.display="none";
        end_x = flag_x;
        end_y = flag_y;
        end_name = flag_name;
        start_x = '';
        start_y = '';
        start_end_flag = 1;
    } else if (obj.id=="queryfrom") {
        getObj('showTo').style.display="none";
        getObj('showFrom').style.display="";
        start_x = flag_x;
        start_y = flag_y;
        start_name = flag_name;
        end_x = '';
        end_y = '';
        start_end_flag = 0;
    }
    getObj('key_work_search1').value = '';
    getObj('key_work_search2').value = '';
}

function gotoZMap() {
    getObj('start_end_f').value = start_end_flag;
    getObj('start_x').value = start_x;
    getObj('start_y').value = start_y;
    getObj('end_x').value = end_x;
    getObj('end_y').value = end_y;
    getObj('start_name').value = start_name;
    getObj('end_name').value = end_name;
    document.actform.submit();
}

function show_poi_list(num) {

}

function changeProductList() {
    if (getObj('new_list').style.display == '') {
        getObj('new_list').style.display = 'none';
        getObj('hot_list').style.display = '';
        getObj('newp').style.color = '#ccc';
        getObj('hotp').style.color = '#CF0000';
        getObj('hotp').onclick = '';
        getObj('newp').onclick = function() {
            changeProductList();
        }
    } else {
        getObj('new_list').style.display = '';
        getObj('hot_list').style.display = 'none';
        getObj('hotp').style.color = '#ccc';
        getObj('newp').style.color = '#CF0000';
        getObj('newp').onclick = '';
        getObj('hotp').onclick = function() {
            changeProductList();
        }
    }
}

var autoFunction = {
    follow : function(h) {
        _attachEvent(window, 'scroll', function() {
            var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
            if (parseInt(scrollTop) > h) getObj('floatdiv').style.top = scrollTop + 'px';
            else getObj('floatdiv').style.top = h + 'px';
        })
    },

    auto : function() {
        _attachEvent(window, 'load', function() {autoFunction.follow(260);})
    },

    showselectcity : function() {
        getObj('selectCityName').onmousedown = function(e) {
            if (getObj('fwin_new')) getObj('fwin_new').parentNode.removeChild(getObj('fwin_new'));
            var pmwindragnow = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
           
            var html = makeSelectCityHtml('580', '440', 'fwin_new', 'new', '', IMGDIR, true);
            showWindow('new', '', 'open', 'false', '580', '440', pmwindragnow[0], pmwindragnow[1], html);
            doane(e);
        }
    },

    showselectcityr : function() {
        var html = makeSelectCityHtml('570', '440', 'fwin_new', 'new', '', IMGDIR, '');
        getObj("showmap").innerHTML = html;
    },

    onmousemoving : function() {
        _attachEvent(document.body, 'mousemove', function(e) {
            /*if (getObj('fwin_selectCity')) {
                var obj = is_ie ? event.srcElement : e.target;
                var array = ['myv', 'myvcd', 'mycd', 'pmwinmask', 'fwin_selectCity', 'selectCityName', 'cityclose', 'hotcities', 'mapbgdiv', 'alertdiv', 'fwin_map', 'alertdivtitle', 'alertdivtitlex', 'alertdivbottom', 'alertdivul'];
                if (obj.tagName == 'A') {
                    if (obj.parentNode.id == 'hotcities' || obj.parentNode.id == 'alertdiv' || obj.parentNode.tagName == 'LI') {
                        return;
                    }
                } else if (obj.parentNode.id == 'mapbgdiv' || obj.parentNode.id == 'alertdivul') {
                    return;
                }
                if (!array.inArray(obj.id)) {
                    getObj('fwin_selectCity').parentNode.removeChild(getObj('fwin_selectCity'));
                    if (getObj('fwin_map')) getObj('fwin_map').parentNode.removeChild(getObj('fwin_map'));
                }
                doane(e);
            }*/
            if (getObj("orderselect") && getObj("orderselect").style.display != 'none') {
                var obj = is_ie ? event.srcElement : e.target;
                var array = ['ordera', 'liirq', 'liijg', 'liisj', 'liirx', 'liixp', 'irq', 'ijg', 'isj', 'irx', 'ixp', 'listtopright', 'orderselect', 'searchtopright', 'searchtop'];
                if (!inArray(array, obj.id)) getObj("orderselect").style.display = 'none';
            }
        })
    }
}

//地图视图
function changetabbigmap(num, allnum, prefix) {
    for (var i=1; i <= allnum; i++) {
        if (i == num) {
            getObj(prefix+num).style.fontWeight = "bold";
            getObj(prefix+num).style.backgroundImage = "url('./images/bigmapsearchmenubg.jpg')";
            getObj(prefix+num).style.backgroundRepeat='repeat-x';
            getObj(prefix+num).style.color = "#C00204";
            getObj("content"+num).style.display = "";
        } else {
            getObj("content"+i).style.display = "none";
            getObj(prefix+i).style.fontWeight = "normal";
            getObj(prefix+i).style.color = "#626260";
            getObj(prefix+i).style.backgroundImage = "url('./images/bigmapsearchmenubg1.jpg')";
        }
    }
}

function changeTrBg(obj, type, classname) {
    if (type == 'over') obj.className = 'over';
    else obj.className = classname;
}

function changePersonaltab(num, allnum) {
    for (var i=1; i <= allnum; i++) {
        getObj('tab'+i).style.backgroundImage = i == num ? "url('../images/tabbbg_red.jpg')" : "url('../images/tabbbg.jpg')";
        getObj('tab'+i).className = i == num ? "current_tab" : "nocurrent_tab";
        getObj("content"+i).style.display =  i == num ? "" : "none";
    }
}

function ajax() {
    var ajax = false;
    try {
        ajax = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            ajax = false;
        }
    }
    if (!ajax && typeof XMLHttpRequest!='undefined') {
        ajax = new XMLHttpRequest();
    }
    return ajax;
}

$(document).ready(function(){
   	$('li.mainlevel').mousemove(function(){
		$(this).find('ul').slideDown();//you can give it a speed
	});
	$('li.mainlevel').mouseleave(function(){
		$(this).find('ul').slideUp("fast");
	});		  
});

$(document).bind('click', function(e) {   
	var clickme = $(e.target);   
    if (!clickme.hasClass("top_search_select")) {   
    	$(".SelectBox").hide(); 
    	if (clickme.parent().hasClass("SelectBox")) {
    		clickme.parent().prev().html(clickme.html());   
            clickme.parent().prev().attr("attrid", clickme.attr("attrid"));    
    		//alert((clickme.html()).replace('在','')); 
            var tmpStr = clickme.html();
            ///alert(tmpStr);
            $("#searchArea").val(tmpStr);
        }   
    } else {   
		$(".SelectBox").hide();  //先全体隐藏，再显示点中的下拉列表层   
		clickme.next().show();   
	}   
}); 
		
jQuery(function(jq){
	function changeTab(lis, divs){
		lis.each(function(i){
			var els = jq(this);
			els.mouseenter(function(){
				lis.removeClass();
				divs.stop().hide().animate({'opacity':0},0);
				jq(this).addClass("libg");
				divs.eq(i).show().animate({'opacity':1},300);
			});
		});
		}
	var txzl = jq("#txzl");
	changeTab(txzl.find(".info_menu li"), txzl.find(".turn"));
	var spyd = jq("#spyd");
	changeTab(spyd.find(".info_menu li"), spyd.find(".turn"));
	//var rrF = jq("#hyxx");
	//changeTab(rrF.find(".info_menu li"), rrF.find(".turn"));
});
