var isShowIM=false;
function func_glossary(word)
{
	var fs='height=320px,width=440px,left=0,top=0,resizable=no';
	window.open('../edu/glossary.htm?word='+word,'_blank',fs);
}

function func_getQueryString( sProp ) {
	var re = new RegExp( sProp + "=([^\\&]*)", "i" );
	var a = re.exec( document.location.search );
	if ( a == null )
		return "";
	return a[1];
}

function func_sendHttp(sUrl,sXml){

    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", sUrl, false);
	try
	{
	    xmlhttp.Send("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root>"+sXml+"</root>");
		return xmlhttp.responseText;
	}
	catch (e)
	{
		return e.toString();
	}
}

function func_XmlHttp(sUrl,sXml)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Open("POST", sUrl, false);
	try
	{
	    xmlhttp.Send(sXml);
		return xmlhttp.responseText;
	}
	catch (e)
	{
		return e.toString();
	}
}

function func_sleep(ms)
{
	var xmlServerHttp = new ActiveXObject("Msxml2.ServerXMLHTTP");
	var lResolve = 5 * 1000;
	var lConnect = 5 * 1000;
	var lSend = 15 * 1000;
	var lReceive = 15 * 1000;
	xmlServerHttp.setTimeouts(lResolve, lConnect, lSend, lReceive);
	xmlServerHttp.open("GET", "http://localhost/sample.xml", false);
	xmlServerHttp.send();

}


function func_setCookie(name,value)
{
    var Days = 37;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/;";
}

function func_getCookie(name)
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}



function func_delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 365*24*60*1000);
    var cval=func_getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function func_set_recently_items(newitem)
{
	
	var item1=func_getCookie('func_recently_item1');
	var item2=func_getCookie('func_recently_item2');
	var item3=func_getCookie('func_recently_item3');

	if(!item1) 
	{
		func_setCookie('func_recently_item1',newitem);
	}
	else if(!item2)
	{
		if(newitem!=item1)
		{
			func_setCookie('func_recently_item2',item1);
			func_setCookie('func_recently_item1',newitem);
		}
	}
	else
	{
		if(newitem!=item1)
		{
			func_setCookie('func_recently_item1',newitem);
			func_setCookie('func_recently_item2',item1);
			if(newitem!=item2)
			{
			func_setCookie('func_recently_item3',item2);
			}
		}
	}
}

function func_set_recently_diamonds(newitem)
{
	
	var item1=func_getCookie('func_recently_diamond1');
	var item2=func_getCookie('func_recently_diamond2');
	var item3=func_getCookie('func_recently_diamond3');

	if(!item1) 
	{
		func_setCookie('func_recently_diamond1',newitem);
	}
	else if(!item2)
	{
		if(newitem!=item1)
		{
			func_setCookie('func_recently_diamond2',item1);
			func_setCookie('func_recently_diamond1',newitem);
		}
	}
	else
	{
		if(newitem!=item1)
		{
			func_setCookie('func_recently_diamond1',newitem);
			func_setCookie('func_recently_diamond2',item1);
			if(newitem!=item2)
			{
			func_setCookie('func_recently_diamond3',item2);
			}
		}
	}
}


function getAbsPosition(obj, offsetObj)
{
	if(obj==null){return([0,0])};
	var _offsetObj=(offsetObj)?offsetObj:document.body;
	var x=obj.offsetLeft-1;
	var y=obj.offsetTop;
	var tmpObj=obj.offsetParent;
	
	x+=parseInt((obj.currentStyle.borderLeftWidth=="medium")?0:obj.currentStyle.borderLeftWidth.replace("px",""));
	y+=parseInt((obj.currentStyle.borderTopWidth=="medium")?0:obj.currentStyle.borderTopWidth.replace("px",""));

	while ((tmpObj!=_offsetObj) && tmpObj)
	{
		x+=tmpObj.offsetLeft+tmpObj.clientLeft-tmpObj.scrollLeft ;
		y+=tmpObj.offsetTop+tmpObj.clientTop-tmpObj.scrollTop;
		if (tmpObj.tagName=="TABLE") x-=(tmpObj.currentStyle.borderLeftWidth=="medium")?0:tmpObj.currentStyle.borderLeftWidth.replace("px","");
		if (tmpObj.tagName=="TABLE") y-=(tmpObj.currentStyle.borderTopWidth=="medium")?0:tmpObj.currentStyle.borderTopWidth.replace("px","");
		tmpObj=tmpObj.offsetParent;
	}
	return ([x, y]);
}

function fi_is_interger(sval)
{
	var sPattern="^\\d+$";
	var re=new RegExp(sPattern);
	return re.test(sval);
}

function fi_is_numeric2(sval)
{
	var sPattern="^\\d{0,"+2+"}(\\.{1}\\d{0,"+2+"})?$";
	var re=new RegExp(sPattern);
	return re.test(sval);
}

function func_closemenu()
{
	document.all.finger_catalog.src="../img/finger.jpg";
	document.all.catalog.style.display="none";
	document.all.finger_catalog.vspace="0";
	document.all.finger_metal.src="../img/finger.jpg";
	document.all.metal.style.display="none";
	document.all.finger_metal.vspace="0";
}

function this_open_menu(menus)
{
	switch(menus)
	{
		case "catalog":
		{
			if(document.all.catalog.style.display=="none")
			{
				document.all.finger_catalog.src="../img/finger_abc.jpg";
				document.all.finger_catalog.vspace="2";
				document.all.catalog.style.display="";
			}
			else
			{
				document.all.finger_catalog.src="../img/finger.jpg";
				document.all.finger_catalog.vspace="0";
				document.all.catalog.style.display="none";
			}
			break;
		}
		case "metal":
		{
			if(document.all.metal.style.display=="none")
			{
				document.all.finger_metal.src="../img/finger_abc.jpg";
				document.all.finger_metal.vspace="2";
				document.all.metal.style.display="";
			}
			else
			{
				document.all.finger_metal.src="../img/finger.jpg";
				document.all.finger_metal.vspace="0";
				document.all.metal.style.display="none";
			}
			break;
		}
	}
}


function func_querybyprice(pagename,minmax,class_p,metal,other,desc)
{
	var url="../product/pc_searchresult.aspx?pagename="+pagename+"&minmax="+minmax+"&class_p="+class_p
		+"&metal="+metal+"&other="+escape(other)+"&desc="+desc;
	window.location=url;
	
}

function func_show_product_detail(id,pagename,menu,style)
{
	window.open('../product/pd_display.aspx?ProductID='+id+'&pagename='+pagename+'&menu='+menu+'&style='+style,'_blank');
	//window.open('../product/pd_'+id+'.aspx?pagename='+pagename+'&menu='+menu+'&style='+style,'_blank');
}

function this_feedback(id,pagename,menu,style)
{
	window.open('../product/pd_display.aspx?pageindex=f&ProductID='+id+'&pagename='+pagename+'&menu='+menu+'&style='+style,'_blank');
}

function func_pagenav_over()
{
	ip=event.srcElement;
		ip.style.color="#874B87";
	ip.style.textDecoration="underline";
}

function func_pagenav_out()
{
	ip=event.srcElement;
	ip.style.color="#818181";
	ip.style.textDecoration="none";
}

function print_pd_page(id)
{
	window.print();
}

function func_compare_diamond(is_iframe)
{
	var s='';
	var trs=document.getElementsByTagName('tr');
	for(var i=0;i<trs.length;++i)
	{
		if(trs[i].fi_checked==true)  s+=','+trs[i].diamond_id;
		
	}
	
	if(s!='') s=s.substring(1);
 	if(s!='') func_sendHttp('../diamond/Register_compare.aspx',s);
 	if(is_iframe)
 	{
 		window.parent.location='../diamond/diamond_comparison.aspx';
 	}
 	else
 	{
 		window.location='../diamond/diamond_comparison.aspx';
 	}

}

function func_addto_compare(did,is_iframe)
{
	if(!did) return;
	//alert(did);
	func_sendHttp('../diamond/Register_compare.aspx',did);
 	if(is_iframe)
 	{
 		window.parent.location='../order/diamond_comparison.aspx';
 	}
 	else
 	{
 		window.location='../order/diamond_comparison.aspx';
 	}
}

function func_get_shapecode(shape)
{
	var rtn="";
	switch(shape)
	{
		case "圆形":
			rtn="rd";
			break;
		case "公主方形":
			rtn="pr";
			break;
		case "祖母绿形":
			rtn="ec";
			break;
		case "椭圆形":
			rtn="ov";
			break;
		case "橄榄形":
			rtn="mq";
			break;
		case "水滴形":
			rtn="ps";
			break;
		case "心形":
			rtn="hs";
			break;
	}
	return rtn;
}

//钻石搜索结果
function this_DiamondImg()
{
	var shape=func_getQueryString("shape");
	switch(shape)
	{
		case "圆形":
			document.all.diamondImg.src='../diamond/img/rd_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "公主方形":
			document.all.diamondImg.src='../diamond/img/pr_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "祖母绿形":
			document.all.diamondImg.src='../diamond/img/ec_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "椭圆形":
			document.all.diamondImg.src='../diamond/img/ov_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "橄榄形":
			document.all.diamondImg.src='../diamond/img/mq_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "水滴形":
			document.all.diamondImg.src='../diamond/img/ps_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
		case "心形":
			document.all.diamondImg.src='../diamond/img/hs_img.gif';
			document.all.diamondShape.innerText=shape+'钻石';
			break;
	}
}

function this_selectShape()
{
	var shape;
	var shapes=document.getElementsByName("shape");
	for(var i=0;i<shapes.length;++i)
	{
		if(shapes[i].checked)
		{
			shape=shapes[i].value;
			break;
		}
	}
	window.location="../diamond/search_result.aspx?low_price=0&high_price=9999999&shape="+shape;	
}


function skeyword_click()
{
	skw=document.all.skeyword;
	if(skw.value=='输入产品编号') 
	{
		skw.value='';
		skw.className='';
	}
}

function func_fulltext_search(key)
{
	if(key!='输入产品编号' && key)
	{
		var url=func_sendHttp('../gift/fulltext_search.aspx?key='+key,null);
		if(url && url!='error')
		{
			window.navigate(url);
		}
		else
		{
			alert('没有找到与['+key+']相关的内容。');
		}	
	}
	else
	{
		alert('请输入您要搜索的关键字！');
		document.all.skeyword.value='';
		document.all.skeyword.className='';
		document.all.skeyword.focus();
	}
}

//变通产品加入购物车
function func_toBasket(ringsize,pid,class_p,icbc)
{
	var url="../order/XmlServer.aspx?action=toBasket";
	var xml="<prms ctype=\"A\" pid=\""+pid+"\""
	switch(class_p)
	{
		case "戒指":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择手指大小！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" ringsize=\""+ringsize.value+"\""
			}
			break;
		}
		case "吊坠":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择吊坠链长度！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" pendantsize=\""+ringsize.value+"\""
			}
			break;
		}
	}
	xml+="/>";
	func_sendHttp(url,xml);
	if(icbc)
	{
		window.location="../order/icbc_shopping.aspx";
	}
	else
	{
		window.location="../order/shopping.aspx";
	}
}



//套件产品加入购物车
function func_pdsuit_toBasket(keyname,pid)
{
	var url="../order/XmlServer.aspx?action=pdsuit_toBasket";
	var select_ringsize_w=document.all.select_ringsize_women.value;
	var select_ringsize_m=document.all.select_ringsize_man.value;
	
	if(!parseInt(select_ringsize_w))
	{
		alert('请选择女戒指圈。');
		document.all.select_ringsize_women.focus();
		return;
	}
	var select_ringsize_m=document.all.select_ringsize_man.value;
	if(!parseInt(select_ringsize_m))
	{
		alert('请选择男戒指圈。');
		document.all.select_ringsize_man.focus();
		return;
	}
	
	var xml="<prms keyname=\""+keyname+"\" pid=\""+pid+"\" ringsize_w=\""+select_ringsize_w+"\" ringsize_m=\""+select_ringsize_m+"\"/>";
	func_sendHttp(url,xml);
	window.location="../order/shopping.aspx";
}

//套件产品加入收藏夹
function func_pdsuit_toWishList(keyname,pid)
{
	var url="../order/XmlServer.aspx?action=pdsuit_toWishlist";
	var select_ringsize_w=document.all.select_ringsize_women.value;
	
	if(!parseInt(select_ringsize_w))
	{
		alert('请选择女戒指圈。');
		document.all.select_ringsize_women.focus();
		return;
	}
	var select_ringsize_m=document.all.select_ringsize_man.value;
	if(!parseInt(select_ringsize_m))
	{
		alert('请选择男戒指圈。');
		document.all.select_ringsize_man.focus();
		return;
	}
	
	
	var xml="<prms keyname=\""+keyname+"\" pid=\""+pid+"\" ringsize_w=\""+select_ringsize_w+"\" ringsize_m=\""+select_ringsize_m+"\"/>";
	func_sendHttp(url,xml);
	window.location="../order/wish_list.aspx";
}

//团购产品加入购物车
function func_gs_toBasket(ringsize,pid,class_p)
{
	var url="../order/XmlServer.aspx?action=toBasket";
	var xml="<prms ctype=\"G\" pid=\""+pid+"\""
	switch(class_p)
	{
		case "戒指":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择手指大小！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" ringsize=\""+ringsize.value+"\""
			}
			break;
		}
		case "吊坠":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择吊坠链长度！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" pendantsize=\""+ringsize.value+"\""
			}
			break;
		}
	}
	xml+="/>";
	func_sendHttp(url,xml);
	window.location="../order/shopping.aspx";
}

//普通产品加入收藏夹
function func_toWishList(ringsize,pid,class_p)
{
	var url="../order/XmlServer.aspx?action=toWishList";
	var xml="<prms ctype=\"A\" pid=\""+pid+"\""
	switch(class_p)
	{
		case "戒指":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择手指大小！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" ringsize=\""+ringsize.value+"\""
			}
			break;
		}
		case "吊坠":
		{
			if(ringsize)
			{
				if(ringsize.value=='')
				{
					alert('请选择吊坠链长度！');
					document.all.select_ringsize.focus();
					return;
				}
				xml+=" pendantsize=\""+ringsize.value+"\""
			}
			break;
		}
	}
	xml+="/>";
	func_sendHttp(url,xml);
	window.location="../order/wish_list.aspx";
}


function function_check_feedback()
{
	if(document.all.title.value=='')
	{
		alert('请您输入评论主题!');
		document.all.title.focus();
		return false;
	}	
	
	if(document.all.msg.value=='')
	{
		alert('请您输入评论内容!');
		document.all.msg.focus();
		return false;
	}
	
	
	var ss=document.getElementsByName('stars');
	var st=-1;
	for(var i=0;i<ss.length;++i)
	{
		if(ss[i].checked) 
		{
			st=ss[i].value;
			break;
		}
	}
	if(st==-1)
	{
		alert('请您评分，谢谢!');
		document.all.stars5.focus();
		return false;
	}
	
	
	return true;
}

function check_gsdate()
{
	
	if(document.all.text.value=='')
	{
		alert('请您输入评论内容!');
		document.all.text.focus();
		return false;
	}
	if(document.all.text.value.length>250)
	{
		alert('评论内容少于250个字符!');
		document.all.text.focus();
		return false;
	}
	return true;

}

//登录帐号
function this_login()
{
	var account=document.all.Left1_Login1_account;
	var password=document.all.Left1_Login1_password;
	if(account.value=="")
	{
		alert('请输入您的email地址！');
		account.focus();
		return false;
	}
	if(password.value=="")
	{
		alert('请输入您的密码！');
		password.focus();
		return false;
	}
	var url="../order/XmlServer.aspx?action=login";
	var xml="<prms account=\""+account.value+"\" password=\""+password.value+"\" />";
	
	var rtn=func_sendHttp(url,xml);
	
	if(rtn=="2")
	{
		window.location=window.location;
	}
	else if(rtn=="1")
	{
		alert("对不起，您的密码有误！");
		return false;
	}
	else
	{
		alert("对不起，帐号不存在！");
		return false;
	}
	
	return true;
}

//退出登录
function this_loginout(icbc)
{
	if(confirm('真的要退出吗？'))
	{
		var xml='<prms LoginOut="yes" />';
		var response=func_sendHttp('../order/loginout.aspx',xml);
		if(!icbc)
		{
			window.top.location="../index/index.aspx";
		}
		else
		{
			window.location="../icbc/icbc_main.aspx";
		}
	}
}

function func_ExcuteB1(s)
{
	var url="../order/XmlServer.aspx?action=tobasket1_fixed";
	var xml="<prms s=\""+s+"\"/>";
	func_sendHttp(url,xml);
}

//购物流程更改样式
function this_shopping(n)
{
	eval('document.all.shopping_'+n+'.style.color="#FF0000"');
}

function ordersGuide_display(i)
{
	document.all.ifrm.src="ordersGuideDisplay.aspx?id="+i;
}

function IsFlashInstalled()
{
	var swf=null;
	try
	{
		swf=new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
	}catch(ex)
	{
	}
	return (swf!=null);
}

// JavaScript Document
function writeflashhtml( arg )
{
	if(!IsFlashInstalled())
	{
		document.write('<span style="color:red">您还没有安装Flash或禁用了Flash，请点击<a href="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0">这里下载并安装启用Flash</a></span>');
		return;
	}
	
	var parm = [];
	var _default_version = "6,0,29,0";
	var _default_quality = "high";
	var _default_align = "middle";
	var _default_menu = "false";

	for(i = 0; i < arguments.length; i ++)
	{
		parm[i] = arguments[i].split(' ').join('').split('=');
		for (var j = parm[i].length-1; j > 1; j --)
		{
			parm[i][j-1]+="="+parm[i].pop();
		}
		switch (parm[i][0])
		{
			case '_version': var _version = parm[i][1];break;
			case '_swf' : var _swf = parm[i][1];break;
			case '_base' : var _base = parm[i][1];break; 
			case '_quality' : var _quality = parm[i][1];break; 
			case '_loop' : var _loop = parm[i][1];break; 
			case '_bgcolor' : var _bgcolor = parm[i][1];break; 
			case '_wmode' : var _wmode = parm[i][1];break; 
			case '_play': var _play = parm[i][1];break; 
			case '_menu' : var _menu = parm[i][1];break;
			case '_scale' : var _scale = parm[i][1];break;
			case '_salign' : var _salign = parm[i][1];break; 
			case '_height' : var _height = parm[i][1];break; 
			case '_width' : var _width = parm[i][1];break; 
			case '_hspace' : var _hspace = parm[i][1];break; 
			case '_vspace' : var _vspace = parm[i][1];break; 
			case '_align' : var _align = parm[i][1] ; break ; 
			case '_class' : var _class = parm[i][1] ; break ; 
			case '_id' : var _id = parm[i][1] ; break ; 
			case '_name' : var _name = parm[i][1] ; break ; 
			case '_style' : var _style = parm[i][1] ; break ; 
			case '_declare' : var _declare = parm[i][1] ; break ; 
			case '_flashvars' : var _flashvars = parm[i][1] ; break ; 
			default :;
		}
	}

	var thtml = ""
	thtml += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + ((_version)?_version:_default_version) + "'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	if(_declare) thtml += " " + _declare
	thtml += ">"
	if(_swf) thtml += "<param name='movie' value='" + _swf + "'>"
	if(_quality) thtml += "<param name='quality' value='" + _quality + "'>" 
	else thtml += "<param name='quality' value ='" + _default_quality + "'>"
	if(_loop) thtml += "<param name='loop' value='" + _loop + "'>"
	if(_bgcolor) thtml += "<param name='bgcolor' value='" + _bgcolor + "'>"
	if(_play) thtml += "<param name='play' value='" + _play + "'>"
	if(_menu) thtml += "<param name='menu' value='" + _menu + "'>"
	else thtml += "<param name='menu' value='" + _default_menu + "'>"
	if(_scale) thtml += "<param name='scale' value='" + _scale + "'>"
	if(_salign) thtml += "<param name='salign' value='" + _salign + "'>"
	if(_wmode) thtml += "<param name='wmode' value='" + _wmode + "'>"
	if(_base) thtml += "<param name='base' value='" + _base + "'>"
	if(_flashvars) thtml += "<param name='flashvars' value='" + _flashvars + "'>"
	thtml += "<embed pluginspage='http://www.macromedia.com/go/getflashplayer'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	thtml += " type='application/x-shockwave-flash'"
	if(_declare) thtml += " " + _declare 
	if(_swf) thtml += " src='" + _swf + "'"
	if(_quality) thtml += " quality='" + _quality + "'"
	else thtml += " quality='" + _default_quality + "'"
	if(_loop) thtml += " loop='" + _loop + "'"
	if(_bgcolor) thtml += " bgcolor='" + _bgcolor + "'"
	if(_play) thtml += " play='" + _play + "'"
	if(_menu) thtml += " menu='" + _menu + "'"
	else thtml += " menu='" + _default_menu + "'"
	if(_scale) thtml += " scale='" + _scale + "'"
	if(_salign) thtml += " salign='" + _salign + "'"
	if(_wmode) thtml += " wmode='" + _wmode + "'"
	if(_base) thtml += " base='" + _base + "'"
	if(_flashvars) thtml += " flashvars='" + _flashvars + "'"
	thtml += "></embed>"
	thtml += "</object>"
	//alert(thtml);
	document.write(thtml);
	
}

function formatNumber(number,pattern){
    var str            = number.toString();
    var strInt;
    var strFloat;
    var formatInt;
    var formatFloat;
    if(/\./g.test(pattern)){
        formatInt        = pattern.split('.')[0];
        formatFloat        = pattern.split('.')[1];
    }else{
        formatInt        = pattern;
        formatFloat        = null;
    }

    if(/\./g.test(str)){
        if(formatFloat!=null){
            var tempFloat    = Math.round(parseFloat('0.'+str.split('.')[1])*Math.pow(10,formatFloat.length))/Math.pow(10,formatFloat.length);
            strInt        = (Math.floor(number)+Math.floor(tempFloat)).toString();                
            strFloat    = /\./g.test(tempFloat.toString())?tempFloat.toString().split('.')[1]:'0';            
        }else{
            strInt        = Math.round(number).toString();
            strFloat    = '0';
        }
    }else{
        strInt        = str;
        strFloat    = '0';
    }
    if(formatInt!=null){
        var outputInt    = '';
        var zero        = formatInt.match(/0*$/)[0].length;
        var comma        = null;
        if(/,/g.test(formatInt)){
            comma        = formatInt.match(/,[^,]*/)[0].length-1;
        }
        var newReg        = new RegExp('(\\d{'+comma+'})','g');

        if(strInt.length<zero){
            outputInt        = new Array(zero+1).join('0')+strInt;
            outputInt        = outputInt.substr(outputInt.length-zero,zero)
        }else{
            outputInt        = strInt;
        }

        var 
        outputInt            = outputInt.substr(0,outputInt.length%comma)+outputInt.substring(outputInt.length%comma).replace(newReg,(comma!=null?',':'')+'$1')
        outputInt            = outputInt.replace(/^,/,'');

        strInt    = outputInt;
    }

    if(formatFloat!=null){
        var outputFloat    = '';
        var zero        = formatFloat.match(/^0*/)[0].length;

        if(strFloat.length<zero){
            outputFloat        = strFloat+new Array(zero+1).join('0');
            //outputFloat        = outputFloat.substring(0,formatFloat.length);
            var outputFloat1    = outputFloat.substring(0,zero);
            var outputFloat2    = outputFloat.substring(zero,formatFloat.length);
            outputFloat        = outputFloat1+outputFloat2.replace(/0*$/,'');
        }else{
            outputFloat        = strFloat.substring(0,formatFloat.length);
        }

        strFloat    = outputFloat;
    }else{
        if(pattern!='' || (pattern=='' && strFloat=='0')){
            strFloat    = '';
        }
    }

    return strInt+(strFloat==''?'':'.'+strFloat);
}
  /**
      *@param srcStr表示要格式化的数
       *@param nAfterDot 要保留的位数
      */ 
function strFormatNumber(srcStr,nAfterDot){
    var srcStr,nAfterDot;
    var resultStr,nTen;
    srcStr = ""+srcStr+"";
    strLen = srcStr.length;
    dotPos = srcStr.indexOf(".",0);
    if (dotPos == -1){
        resultStr = srcStr+".";
        for (i=0;i<nAfterDot;i++){
            resultStr = resultStr+"0";
        }
        return resultStr;
    } else{
        if ((strLen - dotPos - 1) >= nAfterDot){
            nAfter = dotPos + nAfterDot + 1;
            nTen =1;
            for(j=0;j<nAfterDot;j++){
            nTen = nTen*10;
        }
        resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
        return resultStr;
        } else{
            resultStr = srcStr;
            for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
                resultStr = resultStr+"0";
            }
            return resultStr;
        }
    }
}


function func_pagecounter()
{
	var pc=document.all.fi_page_counter
	if(pc)
	{
		var url="../servers/counter.aspx?action=pagecounter";
		var hrf=trim(window.location.href);
		var pos=hrf.indexOf('?');
		
		if(pos!=-1)	hrf=hrf.substring(0,pos);
		if(hrf.charAt(hrf.length-1)=='#') hrf=hrf.substring(0,hrf.length-1);
		
		var xml="<prms rawurl=\""+escape(hrf)+"\"/>";
		var rtn=func_sendHttp(url,xml);
		document.all.fi_page_counter.innerHTML="visited count:"+rtn;
		
	}
}

//去左空格; 
function ltrim(s){ 
return s.replace( /^\s*/, ""); 
} 
//去右空格; 
function rtrim(s){ 
return s.replace( /\s*$/, ""); 
} 
//去左右空格; 
function trim(s){ 
return rtrim(ltrim(s)); 
} 
