var ie = (document.all) ? true : false;
var winalert=window.alert;
window.alert =function(v){
	winalert(v);
	loadings(false);
}
function $(obj){
	if(typeof(obj)=="string")return document.getElementById(obj);
	return obj;
}
function getElementPosition(target){
	if(target.offsetParent){
		for(var posX=0,posY=0;target.offsetParent;target=target.offsetParent){
			posX+=target.offsetLeft;
			posY+=target.offsetTop;
		}
		return {left:posX,top:posY};
	}else return {left:target.x,top:target.y};
}
var drawAd=function(adID,vSub,vTree){
	var sp=getAdHTML(adID,vSub,vTree);
	sp=sp.replace(/<iframe(.*) height=([\",\b]?)0(.*)<\/iframe>/gi,"");
	if(sp==""){
		sp='<span id="adsp'+adID+'"/>';
		document.write(sp);
		eval('$("adsp'+adID+'").parentNode.style.display="none";');
	}else document.write(sp);
}
function getAdHTML(adID,vSub,vTree){
	var vTreeP="";
	if(vTree.length==9){
		vTree=vTree.substring(6,9);
		vTreeP="0";
	}else if(vTree.length==6){
		vTree=vTree.substring(3,6);
		vTreeP="1";
	}else vTree="";
	
	var district=new Array();
	try{
		district=adDistrTool[vTree];
	}catch(e){}
	var adA,adCA,a;
	var sp="";
	var sc='adA=adA'+adID+';adCA=adCA'+adID.substring(0,2)+';'
	var adIndex=-1;
	try{
		eval(sc);
	}catch(e){
		adA=new Array();
		adCA=new Array();
	}
	
	for(var i=adA.length -1;i>=0;i--){
		a=adA[i];		
		if(a[0]==vSub || a[0]==''){
			if((vTree=="" && a[1]=="") || (vTreeP="0" && (vTree==a[1] || a[1]==""))){
				adIndex=i;
				break;
			}
			if(vTreeP=="1"){
				if(a[1]==""){
					adIndex=i;
					break;
				}else{
					for(var j=0;j<district.length;j++){
						if(a[1]==district[j]){
							adIndex=i;
							break;
						}
					}	
				}				
			}
			
			
		}
	}
	if(adIndex>=0)sp=adCA[adA[adIndex][2]];
	return sp;
}
Array.prototype.map=function(f) { 
	var arr=[];
	for(var i=0;i<this.length;i++)arr.push(f(this[i]));
	return arr;
}
ScriptFragment='(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
Object.extend = function(destination, source) {
	for(property in source)destination[property] = source[property];
	return destination;
}
Object.extend(String.prototype, {
	stripTags: function(){return this.replace(/<\/?[^>]+>/gi, '');},
	stripScripts: function(){return this.replace(new RegExp(ScriptFragment, 'img'), '');},
	extractScripts: function(){
		var matchAll = new RegExp(ScriptFragment, 'img');
		var matchOne = new RegExp(ScriptFragment, 'im');
		return (this.match(matchAll) || []).map(function(scriptTag) {
		  return (scriptTag.match(matchOne) || ['', ''])[1];
		});},
	evalScripts: function(){return this.extractScripts().map(eval);}
});
window.refresh=function(){
alert(2222)
}
function drawDiv(id,ans){
	$(id).innerHTML=ans;
	ans.evalScripts();
	footer();
}
///////
var tagSplit=",";
function messBox(isOk,mess){
	var str='<ul class="'+(isOk ? 'messOk' : 'messErr')+'">';	
	str+='<li class="left"></li><li id="messID" class="middle"></li><li class="right"></li>';	
	str+="</ul>";
	var o=document.getElementById("messDiv");
	var hasMess="none";
	if(o){
		if(mess=="")o.innerHTML="";
		else{
			o.innerHTML=str;
			$("messID").innerHTML=mess;
			hasMess="block";
		}
		o.style.display=hasMess;
	}else alert((isOk ? "系统信息" : "错误")+"\n\n"+mess);
}
String.prototype.replaceAll = stringReplaceAll; 
function stringReplaceAll(AFindText,ARepText){raRegExp = new RegExp(AFindText,"g");  return this.replace(raRegExp,ARepText)} 
String.prototype.trim = function(){
	return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
function transTag(str){
	var tagSplit=",";
	var maxLen=10;
	var maxNum=10;
	str=str.replaceAll("，",tagSplit);
	str=str.replaceAll("、",tagSplit);
	str=str.replaceAll("　"," ");
	if(str.indexOf(tagSplit)>0)str=str.replaceAll(" ","");
	else str=str.replaceAll(" ",tagSplit);
	var a=str.split(tagSplit);
	str="";
	var num=0;
	if(a.length==1){
		str+=a[0];
		return str;
	}
	for(i=0;i<a.length;i++){
		if(a[i]=="")continue;
		if(num>maxNum)break;
		num++;
		if(i!=a.length-1){
			if(a[i].length>maxLen)a[i]=a[i].substring(0,maxLen);
			str+=a[i]+tagSplit;
		}else{
			if(a[i].length>maxLen)a[i]=a[i].substring(0,maxLen);
			str+=a[i];
		}
	}
	return str;
}
function windowSize() {
	if(typeof(window.innerWidth)=='number'){//Non-IE
		return {width : window.innerWidth, height : window.innerHeight};
	} else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){//IE 6
		return {width : document.documentElement.clientWidth ,height : document.documentElement.clientHeight};
	} else if(document.body && ( document.body.clientWidth || document.body.clientHeight)){//IE 4
		return {width : document.body.clientWidth ,height : document.body.clientHeight};
	}
	return {width : 0,height : 0 };	
}
function footer(){
	var h=windowSize().height, fObj=$('footer');dh=getElementPosition($('footerF')).top+$('footerF').clientHeight;
	var fh=fObj.clientHeight+dh+10;
	if (0<h -fh) fObj.style.marginTop=(h -fh -3)+'px';
	else fObj.style.marginTop = 0;
	fObj.style.visibility = 'visible';
}
function footerTool(){
	return;
}
function viewCount(optType,uid,id){
	return false;
}
function checkRefuseKey(){
alert("内容含有敏感字符!");
return false;
}
function createElement(parent,tagname){
	var elem=document.createElement(tagname);
	if(parent)parent.appendChild(elem);
	return elem;
}
var loadingO;
var loadingD;
function loadings(boo,type,oA){
try{
	if(boo){
		loadingO=oA;
		if(!loadingD){
			loadingD=createElement(document.body,"img");
			loadingD.src="http://css.8j.com/comm/images/loading1.gif";
			loadingD.style.position="absolute";
			loadingD.style.zIndex="100";
		}
		loadingD.style.left=(document.documentElement.clientWidth/2)+"px";
		loadingD.style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight/2)+"px";
	}else{
		if(!loadingD)return;
	}
	for(i=0;i<loadingO.length;i++)try{loadingO[i].disabled=boo;}catch(e){}
	if(loadingD)loadingD.style.display=boo ? "block" : "none";
}catch(e){}
}
function postTag(tag){
	$("postTag").value=tag;
	$("tagForm").submit();
}
function setMenuF(ind){
	if($(ind)){
		if(ind=="enterpriseMoreID" || ind=="reviewID" || ind=="eventsID" || ind=="guideID" || ind=="questionID" || ind=="userGID"){
			$(ind).className="on";
		}else{
			$(ind).className="ont";
			if(ind!='indexID')$("enterpriseMoreID").className="on";
		}
	}
}