﻿var AmwEvent = function()
{
    this.name = 'event';
    this.done=true;         //默认为执行外部带参数链接
    this.searched = true;   //默认为执行外部带参数查询
}
AmwEvent.prototype.init=function()
{
    //alert('init');
    //this.done= false;
}
AmwEvent.prototype.amwOnEnd=function()
{
    //alert('001');
    //this.done= true;
}
//AmwEvent.prototype.initS=funciton()
//{
//    this.searched = false;
//}
//AmwEvent.prototype.amwSearch=function()
//{
//    
//}
var xEvent = new AmwEvent();

var rightShow=true;
var allShow=true;
var miniMapShow=true;
var divMapHeight=0;
var type=[];
var panel=2;
type[0]=1;
type[1]=11;
var map=o_mapid;
var mapAction={action:'',argu:[]};
var isComplete=false;
var doc = document.compatMode=="CSS1Compat"?document.documentElement:document.body; 

window.onresize=doc_resize;
function doc_resize(){
	bodyWidth=doc.clientWidth;//document.body.clientWidth;
	bodyHeight=doc.clientHeight;//document.body.clientHeight;
	//$('div__debug').innerHTML = $('div__debug').innerHTML + bodyHeight + ',' + bodyWidth + '<br />';
	//if(bodyHeight!=doc.scrollHeight){
	//	bodyHeight=doc.scrollHeight-75;
	//}
	$('divMap').style.width=bodyWidth+'px';
	$('divMap').style.height=bodyHeight+'px';
	//$('divFullScreen').style.left=bodyWidth-360;
//	if(bodyWidth<998){
//		$('mainTable').style.width=998;
//		//$('divFullScreen').style.left=650;
//		$('mainTable').style.height=bodyHeight-100;
//	}
//	else{
//		$('mainTable').style.width='100%';
//		$('mainTable').style.height=bodyHeight-100;
//	}
	//$('divFullScreen').style.left=$('divMap').offsetWidth-700;
	setPos1();

}
function body_onload(){
    xEvent.init();
	doc_resize();
	doMapAction();
	
	setTimeout('loadend()',2000);
}
function loadend(){
	isComplete=true;
	switchObjView('loading',false);
	//xEvent.amwOnEnd();
}
function enterByNav(id,type){
	if(!isBodyLoaded()) return false;
	showResult(id,type);
}
function doMapAction(){
	if(popomap.getMapStatus()){
		switch(mapAction.action){
			case 'showResult':
				showResult(mapAction.argu[0],mapAction.argu[1]);
				break;
			case 'showNote':
				showNote(mapAction.argu[0]);
				break;
			case 'doRight':
				alert("doright");
				popomap.init(0,0,true);
				doRight(mapAction.argu);
				break;
			default:
				loadXY();
				break;
		}
		if(mapAction.action!='doRight')
		{
		    if(xEvent.done==false)
		    {
		        xEvent.amwOnEnd();
		    }
		    else
		    {
		        var tempArg= new Array();
		        tempArg.push('1');
		        doRight(tempArg);
		        }
		}
	}
	else{
		setTimeout('doMapAction()',500);
	}
}
/**
*   @remark     :柳寒风
*   @function   :显示或是隐藏右侧
*   @param      :null
*/
function showRight(){
    //若右侧已显示,那么,隐藏
	if(rightShow){
	    //当前显示的是首页则完全隐藏
		if(panel==2){
			$('rightP').style.display='none';			
		}
		//当前显示的不是首页则保留分类隐藏内容
		else{
			$('ifr').style.display='none';			
			//$('ifr_top2').style.display='none';
			$('rightP').width='39px';
		}
		rightShow=false;		
	}
	//右侧已隐藏,那么,显示
	else{
	    //右原来隐藏的是首页,那么显示并设置宽度
		if(panel==2){
			$('rightP').style.display='';
			$('rightP').width='397px';
		}
		else{
		    //若原来隐藏的不是首页,那么显示Iframe并设置右边的宽度
			$('ifr').style.display='';
			//$('ifr_top2').style.display='';
			$('rightP').width='397px';
		}
		rightShow=true;
	}
	setPos1();
}

function fullScreen_old(){
    //当前的状态不是全屏,那么全屏显示
	if(allShow){
		$('headNav').style.display='none';
		$('rightP').style.display='none';
		$('rightButton').style.display='none';
		//$('searchTbl').style.display='';
		$('divMap').style.height=bodyHeight-1;
		//$('divFullScreen').style.top='0px';
		allShow=false;
	}//当前状态是全屏状态,那么返回到原来的大小
	else{
	    //若原来的右边的显示状态为显示,那么显示右边
		if(rightShow){
			$('rightP').style.display='';
			$('rightButton').style.display='';
		}
		else{
			if(panel!=2)$('rightP').style.display='';
			$('rightButton').style.display='';
		}
		//显示头部导航条
		$('headNav').style.display='';
		//$('searchTbl').style.display='none';
		//设置地图高度
		$('divMap').style.height=bodyHeight-90;
		//$('divFullScreen').style.top='96px';
		allShow=true;
	}
	//$('divFullScreen').style.left=$('divMap').offsetWidth-700;
	setPos1();
}
function setPos1(){
    if ($('divFullScreen')) {
        $('divFullScreen').style.top = '0px';
        $('divFullScreen').style.left = 0; //cmd:$('divMap').offsetWidth-660;
    }
    if ($('divMapNav')) {
        $('divMapNav').style.top = '0px';
        //$('divSpring').style.top='0px';
        //$('divSpring02').style.left=$('divMap').offsetWidth-130;
        if ($('divMapNav')) $('divMapNav').style.width = $('divMap').offsetWidth;
        if ($('divMapNav').style.display == '') {
            $('divMapNav').style.height = $('divMap').offsetHeight;
            if ($('divMapNav_img')) {
                $('divMapNav_img').style.left = Math.floor(($('divMap').offsetWidth - 671) / 2);
                $('divMapNav_img').style.top = Math.floor(($('divMap').offsetHeight - 549) / 2);
            }
            if ($('divMapNav_close')) $('divMapNav_close').style.left = 20; //cmd:$('divMap').offsetWidth-567;
        }
    }
	divMapHeight=$('divMap').offsetHeight;
	
	//navWidth();
}
/**
*   清除右边首页导航的状态 by 柳寒风 on 2008-06-10
*/
function clearPanel()
{
//    if(!rightShow)showRight();
//    //mapClear();
//    $('panel_btn'+panel).className='f1_normal';
//    $('panel'+1).style.display='none';
//    if(panel!=2&&null!=panel)$('tbl'+panel).style.display='none';
//    panel = 2;
    changePanel(100);
}
/**
*   清除右边有分类导航的状态 by 柳寒风 on 2008-06-11
*/
function clearPanel2()
{
    changePanel(101);
}
/**
*   @author     :柳寒风
*   @function   :显示右侧有分类的页面
*   @param {int} p  :原来面板编号
*   @param {int} i  :当前面板编号
*/
function showPanel1(p,i)
{
    //若原来的是首页,那么,更换用来显示的panel
    if(p==2){
		$('panel'+2).style.display='none';
		$('panel'+1).style.display='';
	}
	else{
		$('tbl'+p).style.display='none';
	}
	$('tbl'+i).style.display='';
}
/**
*   @author     :柳寒风
*   @function   :显示右侧页首页面
*   @param {int} p  :原来面板编号
*   @param {int} i  :当前面板编号
*/
function showPanel2(p,i)
{
    $('panel'+1).style.display='none';
    if(p!=2)$('tbl'+p).style.display='none';
    $('panel'+2).style.display='';
    if(i!=100)
    {
        ifrRight.location='/info/Info_Index.aspx';
        ifr.location="about:blank";
    }
}
/**
*   选择面板
*   @param  :编号           (不可为空)
*   @param  :标记           (可为空)
*   @param  :指定面板编号   (可为空)
*   @param  :指定地址       (可为空)
*/
function changePanel(i,flag,typeid,xurl){
    var _xtypeid='';
    var _xurl='';
    if(typeid)
        _xtypeid =typeid;
    if(xurl)
        _xurl = xurl;
	if(!flag&&!isBodyLoaded())
	{
	    setTimeout('xEvent.amwOnEnd()',1000);
	    return false;
	}
	if(!rightShow)showRight();
	if($('panel_btn'+i))
	    if(i==panel&&$('panel_btn'+i).className=='f1')
	    {
	        if(!flag&&'1214'!=flag)
	         return;
	     }
	mapClear();
	if($('panel_btn'+panel))
	    $('panel_btn'+panel).className='f1_normal';
	if($('panel_btn'+i))
	    $('panel_btn'+i).className='f1';
	//alert(panel+"=panel::i="+i);
	switch (i)
	{
	    case 2:
	        //显示首页
		    showPanel2(panel,i);
		    panel=i;
	        break;
	    //显示首页的发布(清除panel1,显示panel2)
	    case 100:
	        break;
	    //显示首页的发布(清除panel2,显示panel1)
	    case 101:
	        break;
	    case 102:	        
	        showPanel2(panel,100);
		    panel=2;
	        if(_xurl!='')
	        {
	            ifrRight.location=_xurl;
                ifr.location="about:blank";
            }
	        break;
	    default:
	        //显示有分类的页面
		    showPanel1(panel,i);
		    panel=i;
		    if(_xtypeid!='')
		    {
		        if(_xurl!='')
		            changeIfr(_xtypeid,_xurl);
		        else
		            changeIfr(_xtypeid);
		    }else
		    {
		        if(_xurl!='')
		            changeIfr(type[i],_xurl);
		        else
		        //更改有分类的页面地址
	            changeIfr(type[i]);
	        }
	        break;
	}
}

var className=[];
className[0]='quan_';
className[1]='yp_';
var dir=[];
dir[0]='';
dir[1]='yp/yp/';
var urls={};
urls['0,1']='/info/InfoIndex.aspx';     //首页
//urls['0,1']='info/InfoIndex_old.aspx';
urls['0,2']='/info/housescript.aspx';   //房产
//urls['0,2']='info/house.aspx';
urls['0,3']='/info/job.aspx';           //工作
urls['0,4']='/info/Friends.aspx';       //交友
urls['0,5']='/info/live.aspx';          //生活
urls['0,6']='/info/food.aspx';          //美食
urls['0,7']='/info/tour.aspx';          //旅游
urls['0,8']='/info/Typelist.aspx';      //分类列表
urls['0,9']='/info/news.aspx';          //新闻

urls['1']='/YP/TypeClass.aspx?_flowId=sub&TypeID={@id}&map={@map}';
urls['1,11']='/YP/yp_index.aspx';           //首页
urls['1,0']='/YP/TypeClass.aspx?TypeID=1';  //餐欢
urls['1,1']='/YP/TypeClass.aspx?TypeID=2';  //娱乐
urls['1,2']='/YP/TypeClass.aspx?TypeID=3';  //住宿
urls['1,3']='/YP/TypeClass.aspx?TypeID=4';  //购物
urls['1,4']='';
urls['1,5']='/YP/TypeClass.aspx?TypeID=5';  //房产
urls['1,6']='/YP/TypeClass.aspx?TypeID=6';  //汽车
urls['1,7']='/YP/TypeClass.aspx?TypeID=143';  //家居
urls['1,8']='/YP/TypeClass.aspx?TypeID=8';  //教育
urls['1,9']='/YP/TypeClass.aspx?TypeID=9';  //医疗
urls['1,10']='/YP/TypeClass.aspx?TypeID=141';//美容


urls['1,12']='/YP/TypeClass.aspx?TypeID=61';//党政
urls['1,13']='/YP/TypeClass.aspx?TypeID=62';//商务
urls['1,14']='/YP/TypeClass.aspx?TypeID=63';//金融
urls['1,15']='/YP/TypeClass.aspx?TypeID=64';//广告
urls['1,16']='/YP/TypeClass.aspx?TypeID=65';//建材
urls['1,17']='/YP/TypeClass.aspx?TypeID=66';//IT业
urls['1,18']='/YP/TypeClass.aspx?TypeID=67';//物流
urls['1,19']='/YP/TypeClass.aspx?TypeID=142';//通迅

function changeIfr(id,url){
	if(!rightShow)showRight();
	var obj=$('b_'+panel+'_'+id);
	if(id<10)var classN=className[panel]+'0'+id+'_hit';
	else{var classN=className[panel]+id+'_hit';}
	obj.className=classN;
	if(id!=type[panel]){
		if(type[panel]<10) var classN=className[panel]+'0'+type[panel];
		else{var classN=className[panel]+type[panel];}
		$('b_'+panel+'_'+type[panel]).className=classN;
		type[panel]=id;
	}
	if(!url){
		if(urls[panel+','+id]){
			url=urls[panel+','+id];
		}
		else if(urls[panel]){
			url=urls[panel];
		}
	}
	if(url.indexOf('@')!=-1){
		url=url.replace('{@id}',id).replace('{@map}',map);
	}
	ifrRight.location="about:blank";
	//ifrRight.style.display='none';
	ifr.location=url;
}
/*
*   选择城市
*/
function switchCity(){
	var obj=$('divCity');
	if(obj.style.display==''){
		obj.style.display='none';
	}
	else{
		obj.style.display='';
		obj.style.left=bodyWidth-300;
	}
}
/*
*   导航栏状态
*/
function getNavStatus(){
	if($('divMapNav').style.display=='')
		return true;
	else 
		return false;
}
/**
*  是否加载完成
*/
function isBodyLoaded(){
	return isComplete;
}
var navTimer=null;
function switchNavView(flag){
	if(typeof(flag)=='undefined'){
		if($('divMapNav').style.display=='none'){
			$('divMapNav').style.display='';
			if(!navTimer)navTimer=setInterval('openNav()',10);
		}
		else{
			if(!navTimer)navTimer=setInterval('closeNav()',10);
		}
	}
	else{
		if(flag){
			$('divMapNav').style.display='';
			if(!navTimer)navTimer=setInterval('openNav()',10);
		}
		else{
			if(!navTimer)navTimer=setInterval('closeNav()',10);
		}
	}
	//navWidth();
}
//管理层
var adminTimer=null;
function switchAdmin(flag){
	if(typeof(flag)=='undefined') return false;
		if(flag){
			if(!adminTimer)adminTimer=setInterval('closeAdmin()',10);
		}
		else{
			$('divMapAdmin').style.display='';
			if(!adminTimer)adminTimer=setInterval('openAdmin()',10);
		}
}
//
function openAdmin(){
	var h=$('divMapAdmin').offsetHeight;
	var step=45;
	if(h<divMapHeight){
		if(h+step<=divMapHeight)$('divMapAdmin').style.height=h+step;
		else $('divMapAdmin').style.height=divMapHeight;
	}
	else{
		clearInterval(adminTimer);
		adminTimer=null;
	}
}
function closeAdmin(){
	var h=$('divMapAdmin').offsetHeight;
	var step=45;
	if(h>step){
		$('divMapAdmin').style.height=h-step;
	}
	else{
		$('divMapAdmin').style.display='none';
		clearInterval(adminTimer);
		adminTimer=null;
	}
}

//end管理层
function switchNavView2(){
	if(!isBodyLoaded()) return false;
	switchNavView();
}
function switchMapView(flag){
	if(flag=='undefined'){
		with($('divMap').style){
			display=display==''?'none':'';
		}
	}
	else{
		if(flag){
			$('divMap').style.display='';
		}
		else{
			$('divMap').style.display='none';
		}
	}
}
function switchObjView(id,flag){
	if(!$(id))return false;
	if(flag=='undefined'){
		with($(id).style){
			display=display==''?'none':'';
		}
	}
	else{
		if(flag){
			$(id).style.display='';
		}
		else{
			$(id).style.display='none';
		}
	}
}
function openNav(){
	var h=$('divMapNav').offsetHeight;
	var step=45;
	if(h<divMapHeight){
		if(h+step<=divMapHeight)$('divMapNav').style.height=h+step;
		else $('divMapNav').style.height=divMapHeight;
	}
	else{
		clearInterval(navTimer);
		navTimer=null;
	}
}
function closeNav(){
	var h=$('divMapNav').offsetHeight;
	var step=45;
	if(h>step){
		$('divMapNav').style.height=h-step;
	}
	else{switchObjView('loading',false);
		$('divMapNav').style.display='none';
		clearInterval(navTimer);
		navTimer=null;
	}
}

function isEmpty(fieldValue)
{
	var regEx = /\S+/i;
	if(regEx.test(fieldValue))
		return false;
	else
		return true;
}
function setMapValue(form){
	if(form&&form.map){
		if(typeof(map)=='number'){
			form.map.value=map;
			return true;
		}
		else{
			national.showMsg('%{NoMap:没有找到地图}');
			return false;
		}
	}
	return true;
}
function postInfo () {
    changePanel(2);
    ifrRight.location= '/info/typelist.aspx';
}
/**
*   右边操作
*   @param  argu    :编号
*/
function doRight(argu){
return;
	var right=argu[0];
	var unit=argu[1];
	switch(right){
		case '1':
			rightOpen('info/Info_Index.aspx');
			break;
		case '2':
			rightOpen('info/FenleiIndex.aspx',0);
			break;
		case '3':
			rightOpen('http://info.baidu.com/typelist.aspx');
			break;
		case '4':
			var url='newmap/unitjoin.aspx?_flowId=join3&unit='+unit+'&city='+city;
			rightOpen(url);
			break;
		case 'tour':
			var url='gztour.htm';
			rightOpen(url,0,7);
			break;
		default:
			rightOpen('info/Info_Index.aspx');
			break;
	}
}
/**
*   显示右边
*   @param url      :地址
*   @param panel    :板面编号
*   @param tyep     :类型编号
*/
function rightOpen(url,panel,type){
	if(!allShow){
		$('rightP').style.display='';
		$('rightButton').style.display='';
		rightShow=true;
		setPos1();
	}
	if(typeof(panel)=='number'){
		changePanel(panel,true);
		$('panel_btn0').className='f1';
		if(typeof(type)=='number')changeIfr(type);
		$('ifr').src=url;
	}
	else{
		changePanel(2);
		if(url!='info/Info_Index.aspx')$('panel_btn2').className='f1';
		$('ifrRight').src=url;
	}
}
function setPanel2Style(){
	$('panel_btn2').className='f1';
}
function dosearch(form,keyword,initKey)
{
    xEvent.done = true;
	if(!setMapValue(form)) return false;
	if(!keyword&&(isEmpty(form.keyword.value)||form.keyword.value==initKey)){
	  national.showMsg('%{EnterKeyword:请输入关键字}');
	  form.keyword.focus();
	  return false;
	}
	changePanel(2);
	setPanel2Style();
	if(keyword){
		form.keyword.value=keyword;
		form.submit();
	}
	return true;
}
/**
*   地图搜索
*/
function dosearch1(keyword){
	if(!isComplete) {
	    if(xEvent.done==true)
	    {
		    national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		}else
		{
		    setTimeout('xEvent.amwOnEnd()',1000);
		}
		return false;
	}
	var form=document.mapForm;
	form.action = '/mapsearch.aspx';
	form.target = 'ifrRight';
	if(form.screen){
		var d=getMapRang();
		form.lx.value=Math.floor(d.startX/2);
		form.ly.value=Math.floor(d.startY/2);
		form.ux.value=Math.floor(d.endX/2);
		form.uy.value=Math.floor(d.endY/2);
	}
	var initKey=national.getStr('Common','MapSearchValue','楼房实体 / 道路 / 河流');
	alert("k="+keyword);
	return dosearch(form,keyword,initKey);
}
/**
*   黄页搜索
*/
function dosearch2(keyword){
	if(!isComplete) {
	    if(xEvent.done==true)
	    {
		    national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		}else
		{
		    setTimeout('xEvent.amwOnEnd()',1000);
		}
		return false;
	}
	var form=document.ypForm;
	form.action = '/ypsearch.aspx';
	form.target = 'ifrRight';
	if(form.screen){
		var d=getMapRang();
		form.lx.value=Math.floor(d.startX/2);
		form.ly.value=Math.floor(d.startY/2);
		form.ux.value=Math.floor(d.endX/2);
		form.uy.value=Math.floor(d.endY/2);
	}
	var initKey=national.getStr('Common','YPSearchValue','医疗保健 / 维修中心 / 企业服务 / 美容健身 / 运动休闲...');
	alert("k="+keyword);
	return dosearch(form,keyword,initKey);
}
/**
*   E城信息搜索
*/
function dosearch3(keyword){
	if(!isComplete) {
	    if(xEvent.done==true)
	    {
		    national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		}else
		{
		    setTimeout('xEvent.amwOnEnd()',1000);
		}
		return false;
	}
	var form=document.infoForm;
	form.city.value=city;
	form.province.value=province;
	form.action = '/infosearch.aspx';
	form.target = 'ifrRight';
	var initKey=national.getStr('Common','InfoSearchValue','房产 / 工作 / 美食 / 购物 / 旅游 / 交友 / 本地新闻...');
	return dosearch(form,keyword,initKey);
}
function doquerySmart(){
	rightOpen('/busline.aspx?op=smartSearch&map='+map);
}
function doquery1(form)
{
	if(!isComplete) {
		national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		return false;
	}
    if (isEmpty(form.from.value)||form.from.value=='所在地')
	{
   	   national.showMsg('%{EmptyFrom:起始不能为空}');
	   form.from.focus();
      return false;
     }
	 else if (isEmpty(form.to.value )||form.to.value=='目的地')
	 {
   	   national.showMsg('%{EmptyTo:终点不能为空}');
	   form.to.focus();
       return false;
     }else
	 {
	    form.action = 'busline.aspx';
		form.target = 'ifrRight';
		changePanel(2);
		setPanel2Style();
		//menuSwitch('search');
	 }
	 return setMapValue(form);
 } 
function doquery2(form)
{  
	if(!isComplete) {
		national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		return false;
	}
     if (isEmpty(form.stationName.value )||form.stationName.value==national.getStr('Common','StationSearchValue','例如:体育中心'))
	{
   	   national.showMsg('%{EmptyStation:站点不能为空}');
	   form.stationName.focus();
       return false;
     }else
	 {
	    form.action = 'busline.aspx';
		form.target = 'ifrRight';
		changePanel(2);
		setPanel2Style();
		//menuSwitch('search');
	 }
	 return setMapValue(form);
 }
function doquery3(form)
{
	if(!isComplete) {
		national.showMsg('%{WaitMap:请在加载完以后再搜索,谢谢}!');
		return false;
	}
     if (isEmpty(form.name.value )||form.name.value==national.getStr('Common','LineSearchValue','例如:178'))
	 {
   	   national.showMsg('%{EmptyLine:路线不能为空}');
	   form.name.focus();
      return false;
     }else
	 {
	    form.action = 'busline.aspx';
		form.target = 'ifrRight';
		changePanel(2);
		setPanel2Style();
		//menuSwitch('search');
	 }
	 return setMapValue(form);
 }
var maptype=3;
//改变地图类型
function changeMapType(id){
    maptype = id;
    popomap.changeMapType(id);
}
var isloadSign={};
isloadSign['1']=false;  //
isloadSign['2']=false;   //公交站点
isloadSign['21']=false; //楼房
isloadSign['22']=true; //道路
isloadSign['23']=false; //停车场
isloadSign['24']=false; //全景图(VR)
isloadSign['25'] = false; //路网
isloadSign['27'] = true; //店铺
isloadSign['28'] = true; //店铺s
function loadSign(id){
	if(isloadSign[id]) isloadSign[id]=false;
	else isloadSign[id]=true;
	var value=isloadSign[id];
	if($('loadSign'+id))
	    $('loadSign'+id).checked=isloadSign[id];
	switch(id){
		case 1:
			break;
		case 2:
			if(value) popomap.loadSign('BusStation');
			else popomap.removeSign('BusStation');
			break;
		case 3:
			break;
		case 21:
		    if(value) popomap.loadSign('building');
			else popomap.removeSign('building');
		break;
		case 22:
		    if(value) popomap.loadSign('maploadx');
			else
			{
			    popomap.clearMapLoad();
			    popomap.removeSign('maploadx');
			 }
		break;
		case 23:
		    if(value) popomap.loadSign('mapparkx');
			else popomap.removeSign('mapparkx');
		break;
		case 24:
		    if(value) popomap.loadSign('mapvrx');
			else popomap.removeSign('mapvrx');
		break;
		case 25:
		    if(value) popomap.showRoadWeb();
			else popomap.hiddenRoadWeb();
		break;
		case 26:
		    if(value) popomap.loadSign('adv');
		    else popomap.removeSign('adv');
		case 27:
		    if (value) popomap.loadSign('shopflag');
		    else popomap.removeSign('shopflag');
		    break;
		case 28:
		    if (value) popomap.loadSign('shopflags');
		    else popomap.removeSign('shopflags');
		    break;
		default:
			break;
	}
}
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

function closeWindow(){
	postData('chat/chat.aspx?_flowId=exit','',getMsg);
	$('divChat').style.display='none';
	$('ifrChat').src='';
}
function miniWindow(){
  $('divChat').style.display='none';
  ismini = true;

}

function getMsg(data){
	var d = data.replace(/^\s*|\s*$/,'');
	if (d.length>0){
	  var sp1=document.createElement('div');
	  sp1.innerHTML=data;
      alert(sp1.innerText);
	}
}
function showChat(){
	if($('divChat').style.display==''){
		$('divChat').style.display='none';
		ismini = true;
		//$('chatImage').src = 'images/skin/chart.gif';
	}
	else{
		$('divChat').style.display='';
		if($('ifrChat').src=='') $('ifrChat').src='/chat/chat.aspx?_flowId=port';
		ismini = false;
		//$('chatImage').src = 'images/skin/chart.gif';
		
	}
}
var ismini = false;//如果聊天窗口最小化；
var moveSx=0,moveSy=0,moveElm=null;
function elmdown(evt,obj){
	evt=evt?evt:event;
	moveElm=obj?$(obj):evt.srcElement?evt.srcElement:evt.target;
	moveSx=evt.clientX-moveElm.offsetLeft;
	moveSy=evt.clientY-moveElm.offsetTop;
	moveElm.style.position='absolute';
	moveElm.setCapture();
}
function elmmove(evt){
	evt=evt?evt:event;
	if(moveElm==null) return;

	if (evt.clientX-moveSx<0){
		moveElm.style.left = 0;
	}else{
		moveElm.style.left=evt.clientX-moveSx;
	}


	if (evt.clientY-moveSy<0){
		moveElm.style.top = 0;
	}else{
      moveElm.style.top=evt.clientY-moveSy;
	}

}

function elmup(evt){
	moveElm=null;
	document.releaseCapture();
}
Object.extend = function(dest, source, replace) {
	for(prop in source) {
		if(replace == false && dest[prop] != null) continue;
		dest[prop] = source[prop];
	}
	return dest;
};

Object.extend(Function.prototype, {
	apply: function(o, a) {
		var r, x = "__fapply";
		if(typeof o != "object") o = {};
		o[x] = this;
		var s = "r = o." + x + "(";
		for(var i=0; i<a.length; i++) {
			if(i>0) s += ",";
			s += "a[" + i + "]";
		}
		s += ");";
		eval(s);
		delete o[x];
		return r;
	},
	bind: function(o) {
		if(!window.__objs) {
			window.__objs = [];
			window.__funcs = [];
		}

		var objId = o.__oid;
		if(!objId)
			__objs[objId = o.__oid = __objs.length] = o;

		var me = this;
		var funcId = me.__fid;
		if(!funcId)
			__funcs[funcId = me.__fid = __funcs.length] = me;

		if(!o.__closures)
			o.__closures = [];

		var closure = o.__closures[funcId];
		if(closure)
			return closure;

		o = null;
		me = null;

		return __objs[objId].__closures[funcId] = function() {
			return __funcs[funcId].apply(__objs[objId], arguments);
		};
	},
	bindAsEventListener:function(object) {
		var __method = this;
		return function(event) {
			return __method.call(object, event || window.event);
		}
	}
}, false);
