	//首页登录注册区域
	var login_str = '';	
	var logout_str = '';
	login_str += '<img hspace="2" align="baseline" src="themes/masa/images/pic_user.gif" /> ';
	login_str += "［<a href=\"javascript:;\" onclick=\"login_or_reg('login','index.php');\">用户登录</a>］";
	login_str += "［<a href=\"javascript:;\" onclick=\"login_or_reg('reg','index.php');\">新用户注册</a>］";
//	login_str += '　［<img hspace="3" align="absmiddle" src="themes/masa/images/img/pic_zfb.gif" /><a onclick="document.getElementById(\'form15\').submit()" style="cursor:pointer;">支付宝用户登录</a>］';
	$(document).ready(function(){
    	
	    $("#scrollDiv").Scroll({line:1,speed:500,timer:2000,up:"btn1",down:"btn2"});
	   index_login();
	   
	});
	function index_logout(){
	
		location.href='user.php?act=logout';
//		document.getElementById('index_login').innerHTML = login_str;
	}
	
	function index_login()
	{
    	$.ajax({
			type:"POST",
			url:"ajax.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"act=member",
			success:function (result){
				
				if (result.content == '')
				{
					location.href = result.url;
				}
				else
				{
					$("#index_login").html(result.content);
				}
			},
			error:function (result){
				//alert('服务器错误！');
			}
		});
    	
	}



	//二级商品弹出层
	function showFastFlow(product_id,page)
	{
		$('#question').html('<div class="fast_goods_case"><p style="text-align:center;"><img src="themes/masa/images/loadingAnimation.gif" onclick="$.unblockUI();" alt="loading" /></p><p style="text-align:center;">数据加载中…… <a href="javascript:;" onclick="$.unblockUI();">关闭</a></p></div>');

		var isShowOverlay = true;
		if (page)
		{
			isShowOverlay = false;
		}
		$.blockUI({ 
		    message: $('#question'), css: { 
		        top:  ($(window).height()-400) /2 + 'px', 
		        left: ($(window).width()-420) /2 + 'px',
		        cursor: 'text'
		    },
		    showOverlay:isShowOverlay
		});
//	return false;
	    $.ajax({
	    	type:"GET",
	    	url:"ajax.php?"+"id="+product_id+"&act=fast_show&page="+page,
	    	cache:false,
	    	datatype:'html',
	    	success:function (msg){
	    		 $('#question').html(msg);
	    	},
            error: function()
            {
            	
            }
	    });
	}







/*菜单滑动*/
var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
dropdownindicator: '', //specify full HTML to add to end of each menu item with a drop down menu
enablereveal: [true, 5], //enable swipe effect? [true/false, steps (Number of animation steps. Integer between 1-20. Smaller=faster)]
enableiframeshim: 1, //enable "iframe shim" in IE5.5 to IE7? (1=yes, 0=no)
//No need to edit beyond here////////////////////////
dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, revealtimers: {},
getposOffset:function(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
},
css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add" && !needle.test(el.className))
		el.className+=" "+targetclass
},
showmenu:function(dropmenu, e){
	if (this.enablereveal[0]){
		if (!dropmenu._trueheight || dropmenu._trueheight<10)
			dropmenu._trueheight=dropmenu.offsetHeight
		clearTimeout(this.revealtimers[dropmenu.id])
		dropmenu.style.height=dropmenu._curheight=0
		dropmenu.style.overflow="hidden"
//		dropmenu.style.visibility="visible";
		dropmenu.style.display="block";
		this.revealtimers[dropmenu.id]=setInterval(function(){cssdropdown.revealmenu(dropmenu)}, 10)
	}
	else{
		dropmenu.style.display="block"
	}
	this.css(this.asscmenuitem, "selected", "add")
},
revealmenu:function(dropmenu, dir){
	var curH=dropmenu._curheight, maxH=dropmenu._trueheight, steps=this.enablereveal[1]
	if (curH<maxH){
		var newH=Math.min(curH, maxH)
		dropmenu.style.height=newH+"px"
		dropmenu._curheight= newH + Math.round((maxH-newH)/steps) + 1
	}
	else{ //if done revealing menu
		dropmenu.style.height="auto"
		dropmenu.style.overflow="hidden"
		clearInterval(this.revealtimers[dropmenu.id])
	}
},
clearbrowseredge:function(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
		var dropmenuW=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < dropmenuW)  //move menu to the left?
			edgeoffset=dropmenuW-obj.offsetWidth
	}
	else{
		var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
		var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
		var dropmenuH=this.dropmenuobj._trueheight
		if (windowedge-this.dropmenuobj.y < dropmenuH){ //move up?
			edgeoffset=dropmenuH+obj.offsetHeight
			if ((this.dropmenuobj.y-topedge)<dropmenuH) //up no good either?
				edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
},
dropit:function(obj, e, dropmenuID){
	if (this.dropmenuobj!=null) //hide previous menu
		this.hidemenu() //hide menu
	this.clearhidemenu()
	this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu
	this.asscmenuitem=obj //reference associated menu item
	this.showmenu(this.dropmenuobj, e)
	this.dropmenuobj.x=this.getposOffset(obj, "left")
	this.dropmenuobj.y=this.getposOffset(obj, "top")
	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
	this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
	this.positionshim() //call iframe shim function
},
positionshim:function(){ //display iframe shim function
	if (this.iframeshimadded){
		if (this.dropmenuobj.style.display=="block"){
			this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
			this.shimobject.style.height=this.dropmenuobj._trueheight+"px"
			this.shimobject.style.left=parseInt(this.dropmenuobj.style.left)+"px"
			this.shimobject.style.top=parseInt(this.dropmenuobj.style.top)+"px"
			this.shimobject.style.display="block"
		}
	}
},
hideshim:function(){
	if (this.iframeshimadded)
		this.shimobject.style.display='none'
},
isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},
dynamichide:function(m, e){
	if (!this.isContained(m, e)){
		this.delayhidemenu()
	}
},

delayhidemenu:function(){
	this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
},
hidemenu:function(){
	this.css(this.asscmenuitem, "selected", "remove")
	this.dropmenuobj.style.display='none'
	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px"
	this.hideshim()
},
clearhidemenu:function(){
	if (this.delayhide!="undefined")
		clearTimeout(this.delayhide)
},
addEvent:function(target, functionref, tasktype){
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},
startchrome:function(){
	
	if (!this.domsupport)
		return
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	for (var ids=0; ids<arguments.length; ids++){
		var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
		for (var i=0; i<menuitems.length; i++){
			if (menuitems[i].getAttribute("rel")){
				var relvalue=menuitems[i].getAttribute("rel")
				var asscdropdownmenu=document.getElementById(relvalue)
				this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
				this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
//				this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
				try{
					menuitems[i].innerHTML=menuitems[i].innerHTML+" "+this.dropdownindicator
				}catch(e){}
				this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
					if (!cssdropdown.isContained(this, e)){
						var evtobj=window.event || e
						cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
					}
				}, "mouseover")
				this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
//				this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
			}
		} //end inner for
	} //end outer for
	if (this.enableiframeshim && document.all && !window.XDomainRequest && !this.iframeshimadded){ //enable iframe shim in IE5.5 thru IE7?
		document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="no" style="left:0; top:0; position:absolute; display:none;z-index:90; background: transparent;"></IFRAME>')
		this.shimobject=document.getElementById("iframeshim") //reference iframe object
		this.shimobject.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
		this.iframeshimadded=true
	}
  } //end startchrome
}



function validate_customer()
	{
		var customer = document.getElementById('customer').value;
		var password = document.getElementById('password').value;
		password = password.toString();
		if (!Utils.isEmail(customer))
		{
			alert('请填写您的用户名（邮箱）与密码！');
			document.getElementById('customer').focus();
			return false;
		}
		if (password.length < 6)
		{
			alert('密码不能小1于6位，请重新填写！');
			document.getElementById('password').focus();
			return false;
		}
//		if (password > 20)
//		{
//			alert('密码不能大于20位，请重新填写！');
//			document.getElementById('password').focus();
//			return false;
//		}
		var before_page = $("#loading").html();
		$("#loading").html("登陆中，请稍等……<a href='javascript:;' onclick='validate_customer();'>重试</a>");
		$.ajax({
			type:"GET",
			url:"user_validate.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"customer="+customer+"&password="+password+"&act=login",
			success:function (result){
				if (result.error == 1)
				{
					alert(result.message);
					//before_page += '<div style="color:red;">'+result.message+'</div>';
					$("#loading").html(before_page);
				}
				else
				{
					$("#login_area").html(result.page);
				}
			}
		});
	}
	//退出登陆
	function logout()
	{
		delCookie('mm_customer');
		delCookie('mm_customer_id');
		delCookie('mm_password');
		delCookie('mm_key');
 		var before_page = $("#loading").html();
		$("#loading").html("登出中，请稍等……");
		$.ajax({
			type:"GET",
			url:"user_validate.php?act=logout",
			cache:false,
			dataType:'html',     //接受数据格式
			success:function (result){
				if (result)
				{
					$("#login_area").html(result);
				}
				else
				{
					$("#loading").html(before_page);
				}
			}
		});
	}
	
	//按下回车搜索
	var keyUpdo = function(e)
	{
	    if(e.keyCode==13)
	    {
	        validate_customer();        
	    }    
	}
	//商品历史浏览
	
	function login()
	{
		var customer = document.getElementById('customer').value;
		var password = document.getElementById('password').value;
		password = password.toString();
		if (!Utils.isEmail(customer))
		{
			$("#customer_msg").html('请填写正确的Email！');
			document.getElementById('customer').focus();
			return false;
		}
		if (password.length < 6)
		{
			$("#password_msg").html('密码不能小于6位！');
			document.getElementById('password').focus();
			return false;
		}

		var before_page = $("#loading").html();
		$("#loading").html("登陆中，请稍等……<a href='login();'>重试</a>");
		$.ajax({
			type:"POST",
			url:"user_validate.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"customer="+customer+"&password="+password+"&act=login&return_url=flow.php?step=flow",
			success:function (result){
				if (result.error == 1)
				{
					$("#login_msg").html(result.message);
					$("#loading").html(before_page);
				}
				else
				{
					if (result.return_url == '')
					{
						location.href = 'index.php';
					}
					else
					{
						location.href = result.return_url;
					}
				}
			}
		});
	}

function login_or_reg(type,return_url)
	{
		$('#question').html('<p><img src="themes/masa/images/fast_flow_bgt.gif"></p><div class="fast_goods_case"><p style="text-align:center;"><img src="themes/masa/images/loadingAnimation.gif" onclick="$.unblockUI();" alt="loading" /></p><p style="text-align:center;">数据加载中…… <a href="javascript:;" onclick="$.unblockUI();">关闭</a></p></div><p><img src="themes/masa/images/fast_flow_bgd.gif"></p>');
	
		$.blockUI({ 
		    message: $('#question'), css: { 
		        top:  ($(window).height()-380) /2 + 'px', 
		        left: ($(window).width()-420)/2 + 'px',
		        cursor: 'text'
		    }
		});
		$.ajax({
			type:"POST",
			url:"ajax.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"act="+type,
			success:function (result){
//										alert(result.content);
				if (result.content == '')
				{
					location.href = result.url;
				}
				else
				{
					$("#question").html(result.content);
				}
			},
			error:function (result){
				//alert('服务器错误！');
			}
		});
	}


/**
	*	配送地址用户的验证
	*/
	function valdate_customer(customer,key)
	{
		if (customer != '')
		{
			$.ajax({
				type:"POST",
				url:"user_validate.php",
				cache:false,
				dataType:'json',     //接受数据格式
				data:"customer="+customer+"&act=validate_customer",
				success:function (result){
					if (result.error == 1)
					{
						$("#email_msg_"+key).html(result.message+"，如果您是注册用户，请<a href=\"javascript:;\" onclick=\"login_or_reg('login','flow.php?step=address')\">登陆</a>。");
						document.getElementById('submit_address').disabled = true;
					}
					else
					{
						$("#email_msg_"+key).html("");
						document.getElementById('submit_address').disabled = false;
					}
				}
			});
		}
	}
	/**
	*	地址验证
	*/
	function validate_address(key,is_login)
	{
		var customer = document.getElementById('customer_'+ key).value;
		var province = document.getElementById('province_'+ key).value;
		var city = document.getElementById('city_'+ key).value;
		var districts = document.getElementById('districts_'+ key).value;
		var address = document.getElementById('address_'+ key).value;
		var zipcode = document.getElementById('zipcode_'+ key).value;
		var code = document.getElementById('code_'+ key).value;
		var tel = document.getElementById('tel_'+ key).value;
		var tel_ext = document.getElementById('tel_ext_'+ key).value;
		var mobile = document.getElementById('mobile_'+ key).value;
		var email = document.getElementById('email_'+ key).value;
		var shipping_time = document.getElementById('shipping_time_'+ key);
		if (customer == '')
		{
			alert('请输入收货人姓名！');return false;
		}

		if (province == '')
		{
			alert('请选择省！');return false;
		}
		if (city == '')
		{
			alert('请选择市！');return false;
		}
		//只有北京时才可以选择区
		if (districts == '' && province == 2)
		{
			alert('请选择区！');return false;
		}
		if (address.length < 8)
		{
			alert('详细地址不能少于八个汉字！');return false;
		}
		if(zipcode == '')
		{
			alert('请填写邮政编码！');return false;
		}
		if (shipping_time)
		{
			if (shipping_time.value == '')
			{
				shipping_time.focus();
				alert('请选择配送时间！');return false;
			}
		}
		
		if(mobile.length != 11)
		{
			alert('请填写正确的手机号！');return false;
		}
		if ((code != '' || tel_ext) && tel == '')
		{
			alert('请填写电话号码！');return false;
		}
		
		if (mobile != '')
		{
			if (mobile.length < 11)
			{
				alert('手机号不能少于11位！');return false;
			}
		}		
		if (tel != '')
		{
			if (tel.length != 8 && tel.length != 7)
			{
				alert('电话号码只可以是7位或8位数字！');return false;
			}
		}
		
		if (!Utils.isEmail(email))
		{
			alert('请填写正确的Email地址！');return false;
		}
		else
		{

		}
		if (is_login == 1)
		{
			var password = document.getElementById('password_'+key).value;
			var password1 = document.getElementById('password1_'+key).value;
			password = password.toString();
			password1 = password1.toString();
			if (password.length < 6)
			{
				alert('密码不能小于六位！');return false;
			}
			if (password != password1)
			{
				alert('两次填写的密码不一致！');return false;
			}
		}
//		else
//		{
//			$.ajax({
//				type:"POST",
//				url:"user_validate.php",
//				cache:false,
//				dataType:'json',     //接受数据格式
//				data:"customer="+customer+"&act=validate_customer",
//				success:function (result){
//					if (result.error == 1)
//					{
//						$("#email_msg_"+key).html(result.message+"，如果您是注册用户，请<a href=\"javascript:;\" onclick=\"login_or_reg('login','flow.php?step=address')\">登陆</a>。");
//						document.getElementById('submit_address').disabled = true;
//					}
//					else
//					{
//						$("#email_msg_"+key).html("");
//						document.getElementById('submit_address').disabled = false;
//					}
//				}
//			});
//		}
		return  true;
		
	}
	/**
	*	配送地址城市联动菜单
	*/
	function change_city(parent_id,obj_id,districts_id,type)
	{
		var arr = districts_id.split("_");
		var key = arr[1];
		var sel = document.getElementById(obj_id);
		$('#'+districts_id).hide();
		sel.length = 0;
		create_option(sel,'','请选择');
		$.ajax({
			type:"POST",
			url:"flow.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"parent_id="+parent_id+"&step=change_region&type=" + type,
			success:function (result){
				sel.length = 0;
				if (result.error == 0)
				{
					/* 创建 options */
					var ad = result.content;
					if (ad)
					{
						post_str = '';
						for (i = 0; i < ad.length; i++)
						{
							post_str += '<input type="hidden" value="'+ad[i].post_code+'" id="post_'+ad[i].region_id+'"/><input type="hidden" value="'+ad[i].area_code+'" id="area_'+ad[i].region_id+'"/>';
							create_option(sel,ad[i].region_id,ad[i].region_name);
							if (type == 2)
							{
								$('#'+obj_id).show();
							}
						}
//						var objdiv = document.createElement("DIV");
//						alert(objdiv);
//					    objdiv.id="post_code";
						if (document.getElementById('post_code_'+key))
						{
							$('#post_code_'+key).html(post_str);
//							document.getElementById('post_code_'+key).innerHTML = post_str;
						}
						
					}
				}
				else
				{
					if (type == 2)
					{
						$('#'+obj_id).hide();
					}
				}
			},
			error:function (result){
				//alert('服务器错误！');
			}
		});
	}

	/**
	*	创建新元素
	*/
	function create_option(obj,id,name)
	{
		var opt = document.createElement("OPTION");
		opt.value = id;
		opt.text  = name;
		obj.options.add(opt);
	}


	$(document).ready(function(){
		if (document.getElementById('spanCount'))
		{
			//购物车提示弹窗
		    setShoppingCar();
		    $("#spanCount").DMenu("#content");
		}
	}); 
	
	
	
		(function($){
		$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
                var _btnUp = $("#"+ opt.up);//Shawphy:向上按钮
                var _btnDown = $("#"+ opt.down);//Shawphy:向下按钮
                var timerID;
                var _this=this.eq(0).find("ul:first");
                var     lineH=_this.find("li:first").height(), //获取行高
                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed=opt.speed?parseInt(opt.speed,10):500; //卷动速度，数值越大，速度越慢（毫秒）
                        timer=opt.timer //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                //滚动函数
                var scrollUp=function(){
                        _btnUp.unbind("click",scrollUp); //Shawphy:取消向上按钮的函数绑定
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                                _btnUp.bind("click",scrollUp); //Shawphy:绑定向上按钮的点击事件
                        });

                }
                //Shawphy:向下翻页函数
                var scrollDown=function(){
                        _btnDown.unbind("click",scrollDown);
                        for(i=1;i<=line;i++){
                                _this.find("li:last").show().prependTo(_this);
                        }
                        _this.css({marginTop:upHeight});
                        _this.animate({
                                marginTop:0
                        },speed,function(){
                                _btnDown.bind("click",scrollDown);
                        });
                }
               //Shawphy:自动播放
                var autoPlay = function(){
                        if(timer)timerID = window.setInterval(scrollUp,timer);
                };
                var autoStop = function(){
                        if(timer)window.clearInterval(timerID);
                };
                autoPlay();
                 //鼠标事件绑定
                _this.hover(autoStop,autoPlay).mouseout();
                _btnUp.css("cursor","pointer").click( scrollUp ).hover(autoStop,autoPlay);//Shawphy:向上向下鼠标事件绑定
                _btnDown.css("cursor","pointer").click( scrollDown ).hover(autoStop,autoPlay);

        }       
})
})(jQuery);
	
	//获取购物车内的物品数
	function setShoppingCar()
	{
	    $.ajax({
	    	type:"POST",
	    	url:"ajax.php",
	    	cache:false,
	    	dataType:'html',     //接受数据格式
	    	data:"act=num",
	    	success:function (msg){
	    	
	    		if (msg != 0)
	    		{
//	    			var inner_msg = "<div id='scrollDiv1'><ul><li><a href='flow.php?step=flow'>您已經選中有<span style='color:red;font-weight:bold;'>"+msg+" </span>件商品</a></li><li><span style='color:red;font-weight:bold;'>幸运100%中奖</span></li><li><span style='color:red;font-weight:bold;'>买二送一</span></li></ul></div>"
//	    			$("#spanCount").html(inner_msg);
//			        $("#scrollDiv1").Scroll({line:1,speed:500,timer:2000});
	    			$("#spanCount").html("<a href='flow.php' style='color:white;'>您已經選中有<font class='num'>"+msg+" </font>款商品</a>");
	    		}
	    		else
	    		{
//	    			var inner_msg = "<div id='scrollDiv1'><ul><li>购物车中有<span style='color:red;font-weight:bold;'>"+msg+" </span>件商品</li><li><span style='color:red;font-weight:bold;'>幸运100%中奖</span></li><li><span style='color:red;font-weight:bold;'>买二送一</span></li></ul></div>"
//	    			$("#spanCount").html(inner_msg);
//			        $("#scrollDiv1").Scroll({line:1,speed:500,timer:2000});
	    			$("#spanCount").html("<a href='flow.php' style='color:white;'>您已經選中有<span style='color:red;font-weight:bold;'>"+msg+" </span>款商品</a>");
	    		}
	    		
	    	}
	    });
	}

	function GetLast2Prod()
	{
	    $("#content").html("loading......");
	    $.ajax({
	    	type:"POST",
	    	url:"ajax.php",
	    	cache:false,
	    	dataType:'html',     //接受数据格式
	    	data:"act=header_cart",
	    	success:function (msg){
	    		 $("#content").html("loding......");
	    		//alert(msg);
	    		 $('#content').html(msg);
	    	}
	    });
	}


function checkAll(e, itemName)
{
  var aa = document.getElementsByName(itemName);
  for (var i=0; i<aa.length; i++)
   aa[i].checked = e.checked;
}
function checkItem(e, allName)
{
  var all = document.getElementsByName(allName)[0];
  if(!e.checked) all.checked = false;
  else
  {
    var aa = document.getElementsByName(e.name);
    for (var i=0; i<aa.length; i++)
     if(!aa[i].checked) return;
    all.checked = true;
  }
}
	
	/**
	*	验证时间格式 2009-02-11 00:00:00
	*/
	function strDateTime(str) 
	{
		var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
		var r = str.match(reg); 
		if(r==null)return false; 
		var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
		return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
	}
	
	// 短时间，形如 (13:04:06) 
	function isTime(str) 
	{ 
		var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/); 
		if (a == null) {alert('输入的参数不是时间格式'); return false;} 
		if (a[1]>24 || a[3]>60 || a[4]>60) 
		{
			alert("时间格式不对"); 
			return false 
		} 
		return true; 
	}
	
	//短日期，形如 (2003-12-05) 
	function strDate(str) 
	{
		var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
		if(r==null)return false;
		var d= new Date(r[1], r[3]-1, r[4]);
		return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
	}
	/**
	*
	*/
	function check_date(id)
	{
		var time = document.getElementById(id).value;
		if (time)
		{
			if (!strDateTime(time))
			{
				alert("您填寫的時間格式不正確，時間格式應為：2009-02-11 00:00:00");
				document.getElementById(id).focus();
				document.getElementById(id).select();
				return false;
			}
		}
		return true;
	}
	
function onlyNum() 
{ 
if(!(event.keyCode==46)&&!(event.keyCode==8)&&!(event.keyCode==37)&&!(event.keyCode==39)) 
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105))) 
event.returnValue=false; 
		if (event.ctrlKey)
		{
			event.returnValue=true; 
		}
} 

function onlyPirce() 
{ 
if(!((event.keyCode>=48&&event.keyCode<=57))) 
event.returnValue=false; 
} 

	/* $Id : utils.js 5052 2007-02-03 10:30:13Z weberliu $ */

var Browser = new Object();

Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != - 1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != - 1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != - 1);

var Utils = new Object();

Utils.htmlEncode = function(text)
{
  return text.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

Utils.trim = function( text )
{
  if (typeof(text) == "string")
  {
    return text.replace(/^\s*|\s*$/g, "");
  }
  else
  {
    return text;
  }
}

Utils.isEmpty = function( val )
{
  switch (typeof(val))
  {
    case 'string':
      return Utils.trim(val).length == 0 ? true : false;
      break;
    case 'number':
      return val == 0;
      break;
    case 'object':
      return val == null;
      break;
    case 'array':
      return val.length == 0;
      break;
    default:
      return true;
  }
}

Utils.isNumber = function(val)
{
  var reg = /^[\d|\.|,]+$/;
  return reg.test(val);
}

Utils.isInt = function(val)
{
  if (val == "")
  {
    return false;
  }
  var reg = /\D+/;
  return !reg.test(val);
}

Utils.isEmail = function( email )
{
  var reg1 = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/;

  return reg1.test( email );
}

Utils.isTel = function ( tel )
{
  var reg = /^[\d|\-|\s|\_]+$/; //只允许使用数字-空格等

  return reg.test( tel );
}

Utils.fixEvent = function(e)
{
  var evt = (typeof e == "undefined") ? window.event : e;
  return evt;
}

Utils.srcElement = function(e)
{
  if (typeof e == "undefined") e = window.event;
  var src = document.all ? e.srcElement : e.target;

  return src;
}

Utils.isTime = function(val)
{
  var reg = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/;

  return reg.test(val);
}

function rowindex(tr)
{
  if (Browser.isIE)
  {
    return tr.rowIndex;
  }
  else
  {
    table = tr.parentNode.parentNode;
    for (i = 0; i < table.rows.length; i ++ )
    {
      if (table.rows[i] == tr)
      {
        return i;
      }
    }
  }
}

document.getCookie = function(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
      return decodeURIComponent(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

document.setCookie = function(sName, sValue, sExpires)
{
  var sCookie = sName + "=" + encodeURIComponent(sValue);
  if (sExpires != null)
  {
    sCookie += "; expires=" + sExpires;
  }

  document.cookie = sCookie;
}

document.removeCookie = function(sName,sValue)
{
  document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

function getPosition(o)
{
    var t = o.offsetTop;
    var l = o.offsetLeft;
    while(o = o.offsetParent)
    {
        t += o.offsetTop;
        l += o.offsetLeft;
    }
    var pos = {top:t,left:l};
    return pos;
}

function cleanWhitespace(element)
{
  var element = element;
  for (var i = 0; i < element.childNodes.length; i++) {
   var node = element.childNodes[i];
   if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
     element.removeChild(node);
   }
}