﻿// JScript 文件公用的JS

/*******************************************************************************************
                                    类别工具

*******************************************************************************************/

//地图搜索类别工具栏中指定按扭图片设为选中图片
function Topmenu(name,i)
{
     TopmenuClear();
	
	   document.getElementById(name).src="../images/z_1_"+i+".gif";
	   document.getElementById("MapSelectMapLabel"+i).style.display="";
	   
}
//地图搜索类别工具栏中所有按扭图片设为默认图片
function TopmenuClear()
{
    for(i=1;i<=4;i++)
    { 
        document.getElementById("img"+i).src="../images/z_"+i+".gif";
        document.getElementById("MapSelectMapLabel"+i).style.display="none";
       
    }
}

//===============根据选择切换搜索视图
function Topmeun1(name,i)
{
    TopmeunClear1();
	var src=document.getElementById(name).src.substring(0,document.getElementById(name).src.length-4);
	   document.getElementById(name).src=src+"_2.gif";
	   document.getElementById("MapSelectMapLabel"+i).style.display="";
	   

}
function TopmeunClear1()
{
    for(i=1;i<=4;i++)
    {        
        document.getElementById("MapSelectMapLabel"+i).style.display="none";	   
    }
    document.getElementById("img1").src="images/BusLine.gif";
    document.getElementById("img2").src="images/MapSearch.gif";
    document.getElementById("img3").src="images/SearchNearBy.gif";
    document.getElementById("img4").src="images/TypeSearch.gif";
}




/*******************************************************************************************
                                    出行服务

*******************************************************************************************/

function selectRightmenu(i)
{
       selectRightmenuClear();		  
	   document.getElementById("BusDIV"+i).style.display="";
	   
}
//地图搜索类别工具栏中所有按扭图片设为默认图片
function selectRightmenuClear()
{
    for(i=0;i<=2;i++)
    { 
       
        document.getElementById("BusDIV"+i).style.display="none";
       
    }
}

/*******************************************************************************************
                                    分类查询

*******************************************************************************************/

function ShowComType()
{     
    document.getElementById('comTypeDiv').style.display="";
    if(document.getElementById("lblTree").innerHTML=="")
    {        
        getTypeTree();
    }
    if(document.getElementById("Search1$dlstCity"))
    {
        $("Search1$dlstCity").style.display="none";
    }
}

/*******************************************************************************************
                                    黄页分类查询

*******************************************************************************************/
// 黄页中行业分类在地图服务中查询
function OpenType(typename,city)
{
   //window.document.form1.firstChild.lastChild.firstChild.nodeName
   // window.open("../map.aspx?city="+escape(document.getElementById('hdcity').value)+"&SearchByTypeName="+escape(typename)+"&SearchByTypeNumber="+escape(typeid));
   window.location.href="Default.aspx?city="+escape(city)+"&comtype="+escape(typename);

}
//黄页中的企业在地图服务中的定位
 function OpenBigMap(city,comid)
 {
  window.open("../map.aspx?city="+escape(city)+"&id="+escape(comid));  
 }

/*******************************************************************************************
                                    公用方法

*******************************************************************************************/
//搜索框获得焦点的事件
function ClearText(ControlName,text)
{
    if(document.getElementById(ControlName).value==text)
    {
        document.getElementById(ControlName).value="";
    }
}
//搜索框失去焦点的事件
function FillText(ControlName,text)
{
    if(document.getElementById(ControlName).value=="")
    {
        document.getElementById(ControlName).value=text;
    }
}


//解析URL
function request(requestName)
{
    var Url=window.location.search;
    var requestValue="";
    if(Url.indexOf("?")!=-1)   
    {   
        var str=Url;
        var ParamCount="";
        var name=new Array();
        var value=new Array();
        var ToTalParam=str.substring(str.indexOf("?")+1);//鍙栧嚭锛熷彿鍚庣殑鎵€鏈夊弬鏁?
 	       ParamCount=ToTalParam.split("&").length;//寰楀埌鍙傛暟涓暟
 	       for(i=0;i<ParamCount;i++)
 	       {
 	       name[name.length]=ToTalParam.split("&")[i].split("=")[0];
 	       value[value.length]=ToTalParam.split("&")[i].split("=")[1];
 	       }
 	       for (i=0;i<name.length;i++)
 	       {
 	            if(name[i]==requestName)
 	            {
 	                requestValue=value[i];
 	                break;
 	            }
 	       }
 	      
     }
     return requestValue;
}

//创建一个层
//
//参数：id 层唯一的标识； left 与父容器左边距 ；top 与父容器上边距；width 层的宽度；height 层的高度；content 内容
//      bgcolor 背景颜色；fontcolor； 字体的颜色 bordercolor； 边框颜色；opacity 透明度；zIndex Z轴
//
function createDiv(id,left,top,width,height,content,bgcolor,fontcolor,bordercolor,borderWidth,opacity,zIndex)
{
    if(!left){ left=0; }
	if(!top){ top=0; }
    if(!width){	width = 200;}
	if(!height){height = 200;}
	if(!zIndex){ zIndex=1; }
	if(!opacity){ opacity = 0.8;}
	if(!fontcolor){	fontcolor = "fontcolor";}
	if(!bordercolor){bordercolor = "fontcolor";}
	if(!bgcolor){bgcolor="White";}
	if(!content){content="";}
	var div = document.createElement("Div");
	div.id=id;
	div.style.left = left+"px";
	div.style.top = top+"px";
	div.style.width = width+"px";
	div.style.height = height+2+"px";
	div.style.position = "absolute";
	div.style.zIndex = zIndex;
	div.style.filter="alpha(opacity="+opacity*100+")";
	div.style.opacity=opacity;
	div.innerHTML=content; 
	div.style.backgroundColor = bgcolor;
	div.style.color=fontcolor;
	div.style.fontSize="12px";
	div.style.border=borderWidth+"px solid "+bordercolor;
	window.document.form1.appendChild(div);
}
 //加载Flash 
function loadFlash(name,height,width,url)
{
    var str="";
    str="<object height=\""+height+"\" width=\""+width+"\" id="+name+" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 \" style=\" z-index:0\">";
    str +="<param name=\"movie\" value=\""+url+"\"/><param name=\"quality\" value=\"high\" />";
    str +="<embed src=\""+url+"\" name="+name+" swLiveConnect=\"true\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"  wmode=\"transparent\" width=\""+width+"\" height=\""+height+"\"></embed></object> ";       
    document.write(str);
}
//去空&nbspHTML;
function clearNbsp(name)
{
    name=name.replace("&nbsp;","");
    name=name.replace(/\<[^>]*>/g,""); 
    return name;
}

function loading()
{
    return "<img src=\"images/loading.gif\">";
}