	//读取cookies
	function getCookies(){
		var CookiesVal=readCookie("SP_ShopView");
		var CookiesVal=CookiesVal.replace(',',"");
		//alert("你浏览过:"+unescape(CookiesVal));
		GetShowCookies(CookiesVal,1);
	}
	//读取cookies用户信息
	function getUserCookies(iType){
		var iTypeVal;
		if(iType==0){
			iTypeVal=readLoginCookie("id");
		}else if(iType==1){
			iTypeVal=readLoginCookie("SPUserName");
		}else if(iType==2){
			iTypeVal=readLoginCookie("SPUserName");
		}else if(iType==3){
			var iTypeValA;
			iTypeValA=readLoginCookie("SPUserType");
			if(iTypeValA==0){
				iTypeVal="普通会员"
			}else if(iTypeValA==1){
				iTypeVal="批发会员"
			}else if(iTypeValA==2){
				iTypeVal="VIP会员"
			}else if(iTypeValA==3){
				iTypeVal="代销会员"
			}else if(iTypeValA==4){
				iTypeVal="自主会员"
			}
		}
		return iTypeVal;
	}
	//读取LoginCookies	1022
	function readLoginCookie(name)
	{
	  var cookieValue = "";
	  var search = name + "=";
	  if(document.cookie.length > 0)
	  { 
	    offset = document.cookie.indexOf(search);
	    if (offset != -1)
	    { 
	      offset += search.length;
	      end = document.cookie.indexOf("&", offset);
	      if (end == -1) end = document.cookie.length;
	      cookieValue = document.cookie.substring(offset, end)
	    }
	  }
	  return cookieValue;
	}
	//检测用户是否处于登录状态临时	1022
	function isLoginType() {
		var IsLoginType;
		var IsLoginVal;
		IsLoginType=readLoginCookie("SPUserName");
		if(IsLoginType!=""){
			IsLoginVal="true";
		}else{
			IsLoginVal="false";
		}
		return IsLoginVal;
	}
	//LOAD状态
	function getLoad(NumVal){
		//LOAD状态
		if(NumVal==1){
			$('#load').remove();
			$('#loading').append('<span id="load"><span style="position: relative; bottom: 2px;"> 读取中...</span></span>');
			$('#load').show('');
		}else if(NumVal==0){
			$('#load').hide('fast');
		}else {
			$('#load').remove();
			$('#loading').append('<span id="load"><span style="position: relative; bottom: 2px;"> 读取中...</span></span>');
			$('#load').show('');
			$('#load').hide('fast');
		}
	}
	//消息状态
	function getMessage(tVal,iVal){
		//LOAD状态
		$('#'+iVal+'msg').remove();
		$('#'+iVal).append('<span id="'+iVal+'msg"><img src="/images/Fwdw.png" border="0" height="18" width="18" class="png24" style="position: relative; top: 0px"><span style="position: relative; bottom: 6px"> '+tVal+' </span></span>');
		$('#'+iVal+'msg').show();
		setTimeout(function(){$("#"+iVal+"msg").hide()},2000);
	}
	//浏览过的商品cookies保存
	function SP_ShopView(id,pimg){
		var Days = 15;   //cookie 将被保存两个月
		var exp  = new Date();  //获得当前时间
		exp.setTime(exp.getTime() + Days*24*60*60*1000);  //换成毫秒

		var name="SP_ShopView";
		var ID=id;
		var productimg=pimg;
		var test=false;
		var values="," + escape(ID) + "#" + escape(productimg);
		var cookieValue = readCookie(name);
		sss=cookieValue.split(",")
			for (i=0;i<sss.length;i++){
				s=sss[i].split("#");
				for(j=0;j<s.length;j++){
					if(s[0]==escape(ID))
					{
						test=true;
						break;
					}
				}
			}
		if (test){
			test=false;
		}
		else{
			document.cookie = name + "=" + values + cookieValue + ";path=/;expires=" + exp.toGMTString();
			//getCookies();
		}
		//window.location.href='/text.txt';
	}
	//购物袋Cookies保存
	function SP_ShopBag(id){
		var Days = 15;   					//cookie 将被保存两个月
		var exp  = new Date();  				//获得当前时间
		exp.setTime(exp.getTime() + Days*24*60*60*1000);	//换成毫秒

		var name="SP_ShopBag";
		var ID=id;
		var test=false;
		var values=escape(ID);
		var cookieValue = readCookie(name);
		sss=cookieValue.split(",")
			for (i=0;i<sss.length;i++){
				s=sss[i].split("#");
				for(j=0;j<s.length;j++){
					if(s[0]==escape(ID))
					{
						test=true;
						break;
					}
				}
			}
		if (test){
			test=false;
		}
		else{
			document.cookie = name + "=" + values + ";path=/;expires=" + exp.toGMTString();
			getCookies();
		}
		//window.location.href='/text.txt';
	}
	//读取cookies
	function readCookie(name)
	{
	  var cookieValue = "";
	  var search = name + "=";
	  if(document.cookie.length > 0)
	  { 
	    offset = document.cookie.indexOf(search);
	    if (offset != -1)
	    { 
	      offset += search.length;
	      end = document.cookie.indexOf(";", offset);
	      if (end == -1) end = document.cookie.length;
	      cookieValue = document.cookie.substring(offset, end)
	    }
	  }
	  return cookieValue;
	}
	//清除COOKIE
	function clears()
	{
		document.cookie="SP_ShopView"+"=";
		//document.cookie="SP_ShopBag"+"=";
		getCookies();
	}
	//显示浏览过商品Cookies记录
	function GetShowCookies(CookiesVal,pageno){
		getLoad(1);
		$.ajax({
			type:"POST",
			url:"/function/sp_fun.asp",
			data:"action=getshowcokiess&CVal="+CookiesVal+"&pageno="+pageno+"&num="+Math.round(Math.random()*10000),
			success:function(GetShowCookies_data){
				$("#showCookies").html(GetShowCookies_data);
				getLoad(0);
			}
		});
	}
	//记录访问20100429新增
	function GetUserView(){
		$.ajax({
			type:"POST",
			url:"/function/sp_fun.asp",
			data:"action=getuserview&num="+Math.round(Math.random()*10000),
			success:function(){
			}
		});
	}
	//用户主登录(弹窗)
	function login_checkH() {
		//getMessage("请稍后,正在核对并请求登录.","loadmsgh");
		var usernameh=$("#usernameh").val();
		var passwordsh=$("#passwordsh").val();
		var pathurl=$("#pathurl").val();
		if(usernameh==""){
			getMessage("登录帐号不允许为空!","loadmsgh");
			$("#usernameh").focus();
			return false;
		}
		if(passwordsh==""){
			getMessage("登录密码不允许为空!","loadmsgh");
			$("#passwordsh").focus();
			return false;
		}
		if(usernameh!=""&&passwordsh!=""){
			$.blockUI();
			$.ajax ({
				url:"/function/sp_fun.asp",
				type:"POST",
				data:"action=ulogin&u="+escape(usernameh)+"&p="+escape(passwordsh)+"&numr="+new Date(),
				success:function(login_data){
		            if( login_data == "0" ){
						$.unblockUI();
						$("#usernameh").focus();
						getMessage("错误:请核对您的注册信息!","loadmsgh");
						$("#usernameh").val("");
						$("#passwordsh").val("");
		               			return false;
					}else{
						$.unblockUI();
						//getCookies();
						$("#member").html(login_data);
						$("#login_win").fadeOut("normal");
						$("#usernameh").val(""); 
						$("#passwordsh").val("");
						$('#loadmsghmsg').remove();
						$("#huiyuandenglu").html("");
						$("#userlogin").html("尊敬的<a href='/usermodified.html'>"+getUserCookies('2')+"</a>，["+getUserCookies('3')+"] <span onclick='loginout()' style='cursor:hand;'>[退出]</span><br>");
						if(pathurl!=""){
							window.location="/"+pathurl;
						}
		                		return true;
					}
				}
			}); 
		}
	}
	//提取用户购物袋信息
	function GetShowUserShopping(){
		getLoad(1);
		$.ajax({
			type:"POST",
			url:"/function/sp_fun.asp",
			data:"action=showusershopping&num="+Math.round(Math.random()*10000),
			success:function(GetShowUserShopping_data){
				$("#showusershopping").html(GetShowUserShopping_data);
				getLoad(0);
			}
		});
	}
	//用户退出
	function loginout() {
		$.ajax ({
			url:"/function/sp_fun.asp",
			type:"Get",
			data:"action=loginout&numr="+new Date(),
			success:function(loginout_data){
				$("#member").html(loginout_data);
 				$("#userlogin").html("<img src='/images/zhuce.png' class=\"png24\" onclick=\"window.location='/userregister.html';\" style='cursor:hand;'>&nbsp;&nbsp;<img src=\"/images/huiyuandenglu.png\" class=\"png24\" onclick=\"LoginFun($(this),isLoginType());\" style='cursor:hand;'><br>");
				$("#huiyuandenglu").html("<div class=\"serviceTitleText\">欢迎来到945in时尚！马上登录，选购您喜欢的商品？</div>");
				getCookies();
              return true;
			}
		}); 
	}
	//刷新用户(信息\身份等)
	function RefreshStatus() {
		$.ajax ({
			url:"/function/sp_fun.asp",
			type:"GET",
			data:"action=getuserstatus&numr="+new Date(),
			success:function(){
				$("#userlogin").html("尊敬的"+getUserCookies('2')+"，<span style='cursor:hand;' onclick='RefreshStatus();'>["+getUserCookies('3')+"]</span> <span onclick='loginout()' style='cursor:hand;'>[退出]</span><br>");
			}
		}); 
	}
	//显示指定信息
	function GetShowMsg(iType,sType) {
		$.ajax ({
			url:"/function/sp_fun.asp",
			type:"POST",
			data:"action=getshowmessges&itype="+iType+"&stype="+sType+"&numr="+new Date(),
			success:function(iType_data){
				$("#"+iType).html(iType_data);
                		return true;
			}
		}); 
	}
	//登录窗口显示
	function LoginFun(obj,itype,path){
		if(itype=="false"){
			var offsetTop = (window.screen.availHeight/2)-272;
			var offsetLeft = (document.body.clientWidth/2)-272;
			$("#login_win").css("left",offsetLeft+"px");
			$("#login_win").animate({top : (offsetTop)+"px"},{ duration:600 , queue:false });
			$("#login_win").fadeIn("normal");
			if(path!=undefined){
				$("#pathurl").val(path);
			}else{
				$("#pathurl").val("");
			}
			$("#usernameh").focus();
		}else{
			if(path!=undefined){
				window.location="/"+path;
			}else{
				window.location.reload();
			}
		}
	}
	//自定义消息状态
	function getMessageX(tVal,iVal){
		//LOAD状态
		$('#'+iVal+'msg').remove();
		$('#'+iVal).append('<span id="'+iVal+'msg">'+tVal+'</span>');
		$('#'+iVal+'msg').show();
		setTimeout(function(){$("#"+iVal+"msg").hide()},2000);
	}
	//搜索商品
	function GetSearchProduct(){
		var ctype=escape($("#ctype").val());
		var keywords=escape($("#keywords").val());
		if(keywords=="%u8BF7%u8F93%u5165%u5173%u952E%u5B57"||keywords==""){
			return false;
		}
		if(ctype!=""&&keywords!="%u8BF7%u8F93%u5165%u5173%u952E%u5B57"){
			getMessageX("<b>正在搜索您输入的 "+keywords+"#</b>","searchmsg");
			$.ajax({
				type:"POST",
				url:"/function/sp_fun.asp",
				data:"action=getsearchproduct&ct="+ctype+"&ky="+keywords+"&num="+Math.round(Math.random()*10000),
				success:function(GetSearchProduct_data){
					var GetSearchProductVal=GetSearchProduct_data;
					var GetSearchProductArray=GetSearchProductVal.split("$");
					if(GetSearchProductArray[0]==1){
						getMessageX("<b>已找到"+keywords+"#，正在跳转.</b>","searchmsg");
						window.location=GetSearchProductArray[1];
						//window.open(GetSearchProductArray[1],'','');
						return false;
					}else if(GetSearchProductArray[0]>1){
						window.location=GetSearchProductArray[1];
						return false;
					}else{
						getMessageX("<b>没有找到您所需要的信息!</b>","searchmsg");
						return false;
					}
				}
			});
		}
	}
	//快速购买
	function Fast_Shop(Pid){
		var Productid=Pid;
		if(Productid!=""){
			$.ajax ({
				url:"/function/sp_fun.asp",
				type:"POST",
				data:"action=AddFastShopSave&productid="+Productid+"&numr="+new Date(),
				success:function(isOkadd_datea){
					if(isOkadd_datea==1){
						GetShowUserShopping();
						$("#showaddshopping").html("");
						$("#showaddshopping").append('←已添加到您的购物车!');
						$("#showaddshopping").show();
						setTimeout(function(){$("#showaddshopping").hide()},2000);
					}else{
						$("#showaddshopping").html("");
						$("#showaddshopping").append('<font color=red>←添加失败,请确认是否有货!</font>!');
						$("#showaddshopping").show();
						setTimeout(function(){$("#showaddshopping").hide()},2000);
					}
					return true;
				}
			});
		}
	}
	//检测Flash控件
	function MakeFlashString(source,id,width,height,wmode, otherParam)
	{	
		return "<embed src="+source+" quality=high wmode="+wmode+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+width+" height="+height+"></embed>";
	}
	//加载Flash控件
	function MakeObjectString(classid, codebase, name, id, width,height, param)
	{
		return "<object classid="+classid+" codebase="+codebase+" name="+name+" style=\"z-index:-10;\" width="+width+" height="+height+" id="+id+"><param name=wmode value="+wmode+">"+param+"</object>";
	}
	
	// innerHTML模式
	function SetInnerHTML(target, code)
	{ 
		target.innerHTML = code; 
	}
	
	// DocumentWrite模式
	function DocumentWrite(src)
	{
		document.write(src);
	}
	/**********  PNG24 图处理透明  **********************/
	function setPng24(obj) { 
		obj.width=obj.height=1; 
		obj.className=obj.className.replace(/\bpng24\b/i,''); 
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
		obj.src='';  
		return ''; 
	}
/* flash */
function FlashObject(swf, width, height, bgcolor, id, flashvars) {
	var strFlashTag = new String();
	if (navigator.appName.indexOf("Microsoft") != -1) {
		strFlashTag += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
		strFlashTag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0\" ";
		strFlashTag += "id=\"" + id + "\" width=\"" + width + "\" height=\"" + height + "\">";
		strFlashTag += "<param name=\"movie\" value=\"" + swf + "\"/>";
		if (flashvars != null) {
			strFlashTag += "<param name=\"flashvars\" value=\"" + flashvars + "\"/>";
		}
		strFlashTag += "<param name=\"quality\" value=\"best\"/>";
		strFlashTag += "<param name=\"bgcolor\" value=\"" + bgcolor + "\"/>";
		strFlashTag += "<param name=\"menu\" value=\"false\"/>";
		strFlashTag += "<param name=\"salign\" value=\"LT\"/>";
		strFlashTag += "<param name=\"scale\" value=\"noscale\"/>";
		strFlashTag += "<param name=\"wmode\" value=\"transparent\"/>";
		strFlashTag += "<param name=\"allowScriptAccess\" value=\"always\"/>";
		strFlashTag += "</object>";
	} else {
		strFlashTag += "<embed src=\"" + swf + "\" ";
		strFlashTag += "quality=\"best\" ";
		strFlashTag += "bgcolor=\"" + bgcolor + "\" ";
		strFlashTag += "width=\"" + width + "\" ";
		strFlashTag += "height=\"" + height + "\" ";
		strFlashTag += "menu=\"false\" ";
		strFlashTag += "scale=\"noscale\" ";
		strFlashTag += "id=\"" + id + "\" ";
		strFlashTag += "salign=\"LT\" ";
		strFlashTag += "wmode=\"transparent\" ";
		strFlashTag += "allowScriptAccess=\"always\" ";
		if (flashvars != null) {
			strFlashTag += "flashvars=\"" + flashvars + "\" ";
		}
		strFlashTag += "type=\"application/x-shockwave-flash\" ";
		strFlashTag += "pluginspage=\"http://www.macromedia.com/go/getflashplayer\">";
		strFlashTag += "</embed>";
	}
	document.write(strFlashTag);
}

function flashWrite(url,w,h,id,bg,vars,win){
 var flashStr=
 "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
 "<param name='allowScriptAccess' value='always' />"+
 "<param name='movie' value='"+url+"' />"+
 "<param name='FlashVars' value='"+vars+"' />"+
 "<param name='wmode' value='"+win+"' />"+
 "<param name='menu' value='false' />"+
 "<param name='quality' value='high' />"+
 "<param name='bgcolor' value='"+bg+"' />"+
 "<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
 "</object>";
 document.write(flashStr);

}