String.prototype.trim=function()
{
	return this.replace(/\u3000/g," ").replace(/(^\s*)|(\s*$)/g,"");
}

function ajax()
{
	var ajax=null;
	try
	{
		ajax=new ActiveXObject("Msxml2.XMLHttp");
	}catch(e)
	{
		try
		{
			ajax=new ActiveXObject("Microsoft.XMLHttp");
		}catch(E)
		{
			ajax=null;
		}
	}
	if (!ajax&&typeof XMLHttpRequest!='undefined')
	{
		ajax=new XMLHttpRequest();
	}
	return ajax;
}

function copy(txt,res)
{
	var r;
	if(res==null)
	{
		r="复制成功";
	}
	else
	{
		r=res;
	}
	copyToClipboard(txt,r);
}

copyToClipboard=function(txt,res)
{
	if(window.clipboardData)
	{
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
		alert(res);
	}
	else if(navigator.userAgent.toLowerCase().indexOf("Opera")!=-1)
	{
		window.location=txt;
	}
	else if(window.netscape)
	{
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}catch(e)
		{
			alert("您的浏览器安全策略限制您进行剪贴板操作，请在浏览器地址栏中输入'about:config'并将'signed.applets.codebase_principal_support'设置为true之后重试或直接手工复制");
			return false;
		}
		var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if(!clip)
		{
			return;
		}
		var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if(!trans)
		{
			return;
		}
		trans.addDataFlavor('text/unicode');
		var str=new Object();
		var len=new Object();
		var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=txt;
		str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if(!clip)
		{
			return false;
		}
		clip.setData(trans,null,clipid.kGlobalClipboard);
		alert(res);
	}
}

function bookmark()
{
	var title=document.getElementsByTagName("title")[0];
	if(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)
	{
		title=title.textContent;
	}
	else
	{
		title=title.innerText;
	}
	addBookmark(title);
}

var url=document.URL;
function addBookmark(title)
{
	if(window.sidebar&&"object"==typeof(window.sidebar)&&"function"==typeof(window.sidebar.addPanel))
	{
		window.sidebar.addPanel(title,url,"");
	}
	else if(document.all&&"object"==typeof(window.external))
	{
		window.external.addFavorite(url,title);
	}
}

function cookieEnabled()
{
	if(navigator.cookiesEnabled)
	{
		return true;
	}
	document.cookie="testcookie";
	var cookieSet=document.cookie;
	if(cookieSet.indexOf("testcookie")!=-1)
	{
		document.cookie="";
		return true;
	}
	return false;
}

function checkMsg(obj)
{
	var msgLink;
	if(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)
	{
		msgLink=obj.textContent;
	}
	else
	{
		msgLink=obj.innerText
	}
	if(msgLink.indexOf("(")!=-1)
	{
		var count=msgLink.substring(4,msgLink.length-1);
		return count;
	}
	else
	{
		return 0;
	}
}

function checkPopups(popup)
{
	if(getCookie("popups")!=null)
	{
		var temp=getCookie("popups");
		if(temp.indexOf(popup)!=-1)
		{
			return false;
		}
		else
		{
			setCookie("popups",temp+"_"+popup,"expired",1);
			return true;
		}
	}
	else
	{
		setCookie("popups","_"+popup,"expired",1);
		return true;
	}
}

function rightClick(evt,sid,ty,txt)
{
	evt=evt?evt:(window.event?window.event:null);
	var rightnum=window.event?event.button:evt.button;
	if(rightnum==2)
	{
		if(ty==0)
		{
			txt=prompt("是否确认修改标题?",txt);	
		}
		else if(ty==1)
		{
			txt=prompt("是否确认修改单位?",txt);
		}
		else if(ty==2)
		{
			txt=prompt("是否确认修改标题?",txt);	
		}
		else if(ty==3)
		{
			txt=prompt("是否确认修改单位?",txt);
		}
		if(txt!=null)
		{
			document.getElementById("ref").value=location.href;
			if(ty==0)
			{
				document.f.action="/updateService.aspx?sid="+sid+"&s=&subject="+escape(txt);
			}
			else if(ty==1)
			{
				document.f.action="/updateService.aspx?sid="+sid+"&s=&unit="+escape(txt);
			}
			else if(ty==2)
			{
				document.f.action="/updateService.aspx?sid="+sid+"&ts=&subject="+escape(txt);
			}
			else if(ty==3)
			{
				document.f.action="/updateService.aspx?sid="+sid+"&ts=&unit="+escape(txt);
			}
			document.f.submit();
		}
	}
}

function insertAdjacentHTML_firefox(obj,where,html)
{ 
	var e=obj.ownerDocument.createRange();
	e.setStartBefore(obj);
	e=e.createContextualFragment(html);
	switch(where)
	{
		case 'beforeBegin':obj.parentNode.insertBefore(e,obj);break;
		case 'afterBegin':obj.insertBefore(e,obj.firstChild);break;
		case 'beforeEnd':obj.appendChild(e);break;
		case 'afterEnd':
		if(!obj.nextSibling)obj.parentNode.appendChild(e);
		else obj.parentNode.insertBefore(e,obj.nextSibling);break;
	}
}

function contains_ff(obj,obj2)
{
	if(obj2==obj)return true;
	while(obj2=obj2.parentNode)if(obj2==obj)return true;
	return false;	
}

function checkContained(obj,ev)
{
	if(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)
	{
		return !contains_ff(obj,ev.relatedTarget);
	}
	else
	{
		return !obj.contains(ev.toElement);
	}
}

function getCities()
{
	var cities=new Array(
	"全国","北京","上海","广州","深圳","杭州"
	);
	var cLinks=new Array(
	"www","bj","sh","gz","shenzhen","hangzhou"
	);
	var count=0;
	var html="<div id='cd' class='cities-list'>";
	for(var i=0;i<cities.length;i++)
	{
		if(i==0)
		{
			html+="<a href='http://"+cLinks[i]+".fwbao.com/'>"+cities[i]+"</a>";
		}
		else
		{
			html+="<a href='http://www.fwbao.com/branches.html'>"+cities[i]+"</a>";
		}
		if(count!=2)
		{
			html+="&nbsp; ";
			count++;
		}
		else
		{
			if(i<cities.length-1)
			{
				html+="<br/>";	
			}
			count=0;
		}
	}
	html+="</div>";
	return html;
}

function showup(obj)
{
	document.getElementById("handle").className="choose-handle-mover";
	if(document.getElementById("cd")==null)
	{
		if(navigator.userAgent.toLowerCase().indexOf("ie")!=-1)
		{
			obj.insertAdjacentHTML("beforeEnd",getCities());
		}
		else
		{
			insertAdjacentHTML_firefox(obj,"beforeEnd",getCities());
		}
	}
}

function shrink(obj,ev)
{
	document.getElementById("handle").className="choose-handle";
	if(checkContained(obj,ev))
	{
		obj.removeChild(document.getElementById("cd"));
	}
}

var bodyfrm;
var adst

function promptPopup()
{
	bodyfrm=(document.compatMode.toLowerCase()=="css1compat")?document.documentElement:document.body;
	adst=document.getElementById("popMsgBox").style;
	adst.top=(bodyfrm.clientHeight-146)+"px";
	adst.left=(bodyfrm.clientWidth-260)+"px";
	setInterval("moveR();",80);
}

function moveR()
{
	adst.top=(bodyfrm.scrollTop+bodyfrm.clientHeight-146)+"px";
	adst.left=(bodyfrm.scrollLeft+bodyfrm.clientWidth-260)+"px";
}

function closeX(){adst.display='none'}

function $id(id)
{
	return document.getElementById(id);
}