var PClocation = unescape(getCookie('PClocation'));/*存储ip判断的地区字段*/
var area_lmt_tag = 'sh';/*初始化当前城市显示的窗口，没有车市的一律显示北京的；*/
function setCookie(name, value, expires, path, domain, secure){
	var expires = new Date();
	expires.setTime(expires.getTime() + 24*60*60*1000);
	var domain=".wanyuwang.com"
	var s = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString(): "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie=s;
}

function getCookie(name){
	return unescape(document.cookie.replace(new RegExp(".*(?:^|; )"+name+"=([^;]*).*|.*"),"$1"));
}

function IPCallBack(location){
	PClocation = location;
	setCookie('PClocation',escape(location));
}

function needJS(fn,src,callback) { callback=callback||function(){}; if(fn) return callback(false);//功能早已载入
    var scripts=window.__needJS__||(window.__needJS__=[]); var script=scripts[src]||(scripts[src]={loaded:false,callbacks:[]}); //取得全局加载队列中的目标项
    if(script.loaded) return callback(false); var cbs=script.callbacks; cbs.push(callback); //cbs: 回调函数列表
    if(cbs.length==1) { var js=document.createElement("script");
        js.onload=js.onreadystatechange=function(){ var st=js.readyState; if(st&&st!="loaded"&&st!="complete") return;
            script.loaded = true; for(var i=0; i<cbs.length; i++) cbs[i](true);
        }; js.src=src; document.getElementsByTagName("head")[0].appendChild(js);
}   } //needJS()

//关闭,最小化,最大化
function showDiv(innerCall){
    if(document.getElementById('PcPoPmarket')==null)return;
	if(Number(getCookie("divStatus"))==1 && !!innerCall){
		closeDiv();
	}else if (Number(getCookie("divStatus"))==2 && !!innerCall)
	{
		hideDiv();
	}else{
		document.getElementById('PcPoPmarket').style.height = 237+'px';
		document.getElementById('showvod').style.display = 'none';
		document.getElementById('hidevod').style.display = 'block';
	}
}

function hideDiv(innerCall){
    if(document.getElementById('PcPoPmarket')==null)return;
	document.getElementById('PcPoPmarket').style.height = 29 + 'px';
	document.getElementById('hidevod').style.display = 'none';
	document.getElementById('showvod').style.display = 'block';
	if(!innerCall)setCookie("divStatus",2);
}

function closeDiv(innerCall){
    if(document.getElementById('PcPoPmarket')==null)return;
	document.getElementById('PcPoPmarket').style.display = 'none';
	if(!innerCall)setCookie("divStatus",1);
}

document.write("<span id=tmpAreaLmtDiv></span>");
//writeAreaLmtDiv(area_lmt_tag);

function writeAreaLmtDiv() {
	if (area_lmt_tag!=null && area_lmt_tag.length > 0){
	    var s="";
	    try{
			//以下是为了兼容 xhtml1.0 和 html4两种情况 / ie6 ie7 ff 的兼容用hack
			if(document.compatMode && document.compatMode != 'BackCompat'){
				s+=('<DIV  style="z-index:1000;right:0;bottom:0; height:237px;width:350px;overflow:hidden;POSITION:fixed;'+(/MSIE 7/.test(navigator.appVersion)?'':'_position:absolute; _margin-top:expression(document.documentElement.clientHeight-this.style.pixelHeight+document.documentElement.scrollTop);')+'" id="PcPoPmarket" >');
			}else {
				s+=('<DIV  style="z-index:1000;right:0;bottom:0; height:237px;width:350px;overflow:hidden;POSITION:fixed;*position:absolute; *top:expression(eval(document.body.scrollTop)+eval(document.body.clientHeight)-this.style.pixelHeight);" id="PcPoPmarket" >');
			}
			s+=(' <div style="z-index:1000; POSITION: absolute; width:350px; height:30px; overflow:hidden;"><span style="CURSOR: pointer;float:left;clear:none; width:123px; height:14px; overflow:hidden; margin:10px 5px;"></span><span style="CURSOR: pointer;float:right;clear:none; width:15px; height:14px; margin:6px 5px;" onclick=closeDiv()></span><span style="background-image:url(http://www1.pconline.com.cn/images/lmt/oncity_big.gif);CURSOR: pointer;float:right; width:15px; height:14px; overflow:hidden;clear:none;display:none; margin:9px 1px 0 0; " onclick=showDiv() id="showvod"></span><span style="background-image:url(http://www1.pconline.com.cn/images/lmt/oncity_small.gif);CURSOR: pointer;float:right;overflow:hidden; width:15px; height:14px; clear:none; display:bolck; margin:9px 1px 0 0;" onclick=hideDiv() id="hidevod"></span></div> ');
			s+=("<iframe scrolling=no frameborder=0 width=350 height=237 src=http://www.wanyuwang.com/files/floatdiv/sh.htm />-</iframe>");
			s+=('</DIV>');
			document.getElementById('tmpAreaLmtDiv').innerHTML = s;
			setTimeout('hideDiv(true);', 16000);
		}catch(err){}
	}
	showDiv(true);
}

function playLmtAreaWindow(){
    if(PClocation.indexOf('广东')>=0 && PClocation.indexOf('深圳')<0 && PClocation.indexOf('惠州')<0 && PClocation.indexOf('东莞')<0){
        area_lmt_tag='gz';
	}else if(PClocation.indexOf('深圳')>=0 || PClocation.indexOf('惠州')>=0 || PClocation.indexOf('东莞')>=0){
        area_lmt_tag='sz';
    }else if(PClocation.indexOf('北京')>=0){
        area_lmt_tag='bj';
    }else if(PClocation.indexOf('上海')>=0){
        area_lmt_tag='sh';
    }else if(PClocation.indexOf('香港')>=0){
        area_lmt_tag='hk';
    }else if(PClocation.indexOf('广西')>=0){
        area_lmt_tag='gx';
    }else if(PClocation.indexOf('重庆')>=0){
        area_lmt_tag='cq';
    }else if(PClocation.indexOf('湖北')>=0){
        area_lmt_tag='wh';
    }else if(PClocation.indexOf('山东')>=0){
        area_lmt_tag='sd';
    }else if(PClocation.indexOf('江苏')>=0){
        area_lmt_tag='js';
    }else if(PClocation.indexOf('吉林')>=0 || PClocation.indexOf('辽宁')>=0){
        area_lmt_tag='ln';
    }else if(PClocation.indexOf('福建')>=0){
        area_lmt_tag='fj';
    }else if(PClocation.indexOf('成都')>=0){
        area_lmt_tag='cd';
    }else if(PClocation.indexOf('西安')>=0){
        area_lmt_tag='xa';
    }else if(PClocation.indexOf('湖南')>=0){
        area_lmt_tag='hn';
    }else if(PClocation.indexOf('江西')>=0){
        area_lmt_tag='jx';
    }else if(PClocation.indexOf('黑龙江')>=0){
        area_lmt_tag='hl'
    }else if(PClocation.indexOf('内蒙古')>=0){
        area_lmt_tag='nm'
    }else if(PClocation.indexOf('台湾')>=0){
        area_lmt_tag='tw';
    }else if(PClocation.indexOf('浙江')>=0){
        area_lmt_tag='zj';
	}else if(PClocation.indexOf('河北')>=0){
        area_lmt_tag='hb';
    }else if(PClocation.indexOf('河南')>=0){
        area_lmt_tag='henan';
    }else {area_lmt_tag='bj'}

    writeAreaLmtDiv();
}

//执行
if(PClocation==null || PClocation.length==0){
	needJS(null,'http://whois.pconline.com.cn/jsFunction.jsp',playLmtAreaWindow);
}else{
	playLmtAreaWindow();
}