	var httpRequest;
	var _memberName=null;
	
	//设置登录/退出登录按钮
	function setLoginButton(loginButton){
		var loginObj=document.getElementById("login");
		if(loginObj!=null){
			loginObj.innerHTML=loginButton;
		}
	}
	
	//设置会员名称
	function setMemberName(memberName){
		var memberNameObj=document.getElementById("memberName");
		if(memberNameObj!=null){
			memberNameObj.innerHTML=memberName;
		}
	}
	//去掉“我要开店”
	function clearCmp(){
		var cmpObj=document.getElementById("cmp");
		if(cmpObj!=null){
			cmpObj.style.display="none";
		}
	}
	
	//从后台取出用户名，刷新前台显示
	function refreshMemeberName(){
		var url="/onlineMember.do?method=getMemberName&" + new Date();
		httpRequest=getHttpRequest();
		if(!httpRequest){
			alert("您的浏览器不支持AJAX！");
			return;
		}
		httpRequest.onreadystatechange = processRefreshMemberName;
		httpRequest.open("GET",url,true);
		httpRequest.send(null);
	}
	
	//处理返回的会员名
	function processRefreshMemberName(){
		if( httpRequest.readyState == 4 ){
			if( httpRequest.status == 200 ){
				_memberName=httpRequest.responseText;
				if(_memberName==null || _memberName==""){
					setMemberName("您好，欢迎光临炫体网！");
					setLoginButton("<a href=\"/view/user_login.jsp\">登录</a>");
				}
				else{
				//	clearCmp();
					setMemberName(_memberName+" 您好,欢迎登陆炫体网！");
					setLoginButton("<a href=\"/marketlogin.do?method=destroySession\">退出登录</a>");
				}
			}
			else{
				window.status="取得用户名时出错，服务器可能正在重启....."
			}
		}
	}

	
	function insertCatalog(name,value){
		var catalogs=document.getElementById("_parentCatalogId");
		catalogs.options.add(new Option(name,value,true,true),0);
	}
	
	function clearCatalogFlag(){
		var catalogs=document.getElementById("_parentCatalogId");
		catalogs.options[0].text=catalogs.options[0].text.replace("└","");
	}
	
//搜索商品、店铺、店长
function searchCheck(){
	var form = document.searchForm;
  	if(form.searchType.value=="0"){ 
  		if(form.pcd.value=="MN1000" && form.kw.value==""){
  			window.location="/list";
  		}else{ 	
	  		form.method.value="productSearchList";
	  		form.spd.value=form.pcd.value;
	  		form.submit();
  		}
  	}else {
  		form.action="/storeList.do";
  		form.method.value="storeSearchList";
  		form.searchContent.value=form.kw.value;
  		form.title.value=form.searchType.value;
  		form.submit();
  	}
}
function setSearchType(value){
	document.getElementById("_searchTypeId").value=value;
}
//在搜索商品、店铺、店长文本框内敲回车调用的方法
function callsearchCheck(event){
	if (!event) {
    	event = window.event;
    }
    if (event && event.keyCode && event.keyCode == 13) {
		searchCheck();
		return false;
    } 
}
//在搜索真品通文本框内敲回车，调用的方法
function searchCallCheck(event){
	if (!event) {
    	event = window.event;
    }
    if (event && event.keyCode && event.keyCode == 13) {
		searchReal();
	}
}
//真品通商品搜索
function searchReal(){
	var form = document.productionConfigureForm;
	form.method.value="view";
	form.submit();
}
//焦点到搜索真品通验证框时，文字消失
function onProdFocus(){
	var barCode = document.getElementById("realinput");
	if(barCode.value == '输入商品条形码'){
		barCode.value="";
	}
}
function insertSearchContent(searchContent){
	var content = document.getElementById("_searchContent");
	for(var i=0;i<searchContent.length;i++){
		searchContent = searchContent.replace("&lt;","<");
		searchContent = searchContent.replace("&gt;",">");
		searchContent = searchContent.replace("&#39;","'");
		searchContent = searchContent.replace("&amp;","&");
		searchContent = searchContent.replace("&quot;","\"");
	}
	content.value = searchContent;
}
/*
function discountSearch(discountStart,discountEnd){
	var form = document.searchForm;
	form.method.value="productAllList";
	form.discountStart.value=discountStart;
	form.discountEnd.value=discountEnd;
	form.submit();

}*/

function insertIntoBarCode(barCode,brandId){
	var realBarCode = document.getElementById("realinput");
	var realBrandId = document.getElementById("realselect");
	for(var i=0;i<barCode.length;i++){
		barCode = barCode.replace("&lt;","<");
		barCode = barCode.replace("&gt;",">");
		barCode = barCode.replace("&#39;","'");
		barCode = barCode.replace("&amp;","&");
		barCode = barCode.replace("&quot;","\"");
	}
	realBarCode.value = barCode;
	realBrandId.value = brandId;
}

var _TopADID;			//顶层广告ID
/*
关闭最顶端的广告层
//四个参数：d为关闭一次后，几天不显示此广告
*/
function closeTopAD(d){
	var obj=document.getElementById("topAd");
	if(obj){
		document.body.removeChild(obj);
		//在COOKIE中加入标记，下次打开新的网页时，不再弹出
		setCookieDays( _TopADID , "1" , "/" ,d);
	}
}

function showTopAD(){
	if(_TopADID=="")return ;					//如果ID为空，那么
	var cookieValue=getCookie(_TopADID);		//如果客户机器已关闭过该广告链接，则下次查看不显示［直接删除]
	if(cookieValue!="1")
	{
		var obj=document.getElementById("topAd");
		if(obj)
		{
			obj.style.display="block";
		}
	}
}

 if (window.addEventListener) {
  window.addEventListener('load', showTopAD, false); 
 } else if (window.attachEvent) { 
  window.attachEvent('onload', showTopAD);
 }
//window.onload=showTopAD;
//window.attachEvent("onload", showTopAD);

