	//首页登录注册区域
	var login_str = '';	
	var logout_str = '';
	login_str += "<li><a href=\"javascript:;\" onclick=\"login_or_reg('login','index.shtml');\">用户登录</a></li>";
	login_str += "<li><a href=\"javascript:;\" onclick=\"login_or_reg('reg','index.shtml');\">新用户注册</a></li>";
        // login_str += '<li><a href=\"/passport.php\"
        // target=\"_blank\">支付宝用户登录</a></li>';
        login_str += '<li><a href="http://www.masamaso.com/help.html" target="_blank">新手帮助</a></li>';
	$(document).ready(function(){
	    if (getCookie('mm_customer'))
	    {
			index_login();
	    }
	    else
	    {
	    	if (document.getElementById('index_login'))
	    	{
	    		document.getElementById('index_login').innerHTML = login_str;
	    	}
	    }
	    
		bodyclick = document.getElementsByTagName('body').item(0);
		rSelects();
		bodyclick.onclick = function(){
			for (i=0;i<selects.length;i++){
				if ((i>0) || (location.href.indexOf('flow') >= 0)) continue;
				$m('select_info_' + selects[i].name).className = 'tag_select';
				$m('options_' + selects[i].name).style.display = 'none';
			}
		}
		/**购物车**/
		if (document.getElementById('flowPrice'))
		{
           $.getJSON("http://www.masamaso.com/flowjson.php?callback=?",  
                function(msg){ 
		    		 if (msg.num != 0) {
						$("#flowPrice").html("总金额：<font class='yuan'>￥</font>"+parseInt(msg.price));
						$("#flowNum").html(msg.num);
					 }
           });		}
		if (document.getElementById('act_li_num')) {
		    if (document.getElementById('act_li_num').value > 0) $("#scrollDiv").Scroll({line:1,speed:500,timer:2000,up:"btn1",down:"btn2"});
		}
	});
	function index_logout(){
		var mm_id = getCookie('mm_customer_id');
		setCookie('mm_id',mm_id);
		delCookie('mm_customer');
		delCookie('mm_customer_id');
		delCookie('mm_password');
		delCookie('mm_key');
		location.href='index.shtml';
//		document.getElementById('index_login').innerHTML = login_str;
	}
	
	function index_login()
	{
    	var arr = getCookie('mm_customer').split("@");
		var arr = arr[0].split("%40");
    	logout_str += arr[0];
    	logout_str += '　<a href="user.php">我的帐户</a>　<a href="user_order.php">我的订单</a>';
    	logout_str += "　<a href=\"javascript:index_logout();\" onclick=\";\">退出</a>";
    	
    	if (document.getElementById('index_login'))
    	{
    		document.getElementById('index_login').innerHTML = logout_str;
    	}
	}



	//二级商品弹出层
	function showFastFlow(product_id,page)
	{
		$('#question').html('<div style="padding:50px;border:1px solid #E7E7E7;background:#FDFDFD;text-align:center;line-height:20px;"><p><img src="http://image.masamaso.com/loading.gif" onclick="$.unblockUI();" alt="loading" /></p><p>数据加载中…… <a href="javascript:;" onclick="$.unblockUI();">关闭</a></p></div>');
		var isShowOverlay = true;
		if (page)
		{
			isShowOverlay = false;
		}
		$.blockUI({ 
		    message: $('#question'), css: { 
		        top:  ($(window).height()-450) /2 + 'px', 
		        left: ($(window).width()-580) /2 + 'px',
		        cursor: 'text'
		    },
		    showOverlay:isShowOverlay
		});
//	return false;
	    $.ajax({
	    	type:"GET",
	    	url:"fast_show_goods.php?"+"id="+product_id+"&act=fastview&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<12)
			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"
	}
	var d_num = parseInt(dropmenu.id.substring(8,10));
	if (d_num != undefined) {
		d_num += 1;
	}
	else d_num = 0;
	if (document.getElementById('menu_m'+d_num)) document.getElementById('menu_m'+d_num).className = 'm'+d_num;
//	if (d_num < 9) document.getElementById('img'+dropmenu.id).src = 'http://image.masamaso.com/menu_h_0'+(d_num+1)+'.gif';
//	else document.getElementById('img'+dropmenu.id).src = 'http://image.masamaso.com/menu_h_'+(d_num+1)+'.gif';
	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(){
	for (var n=0;n<14;n++) {
//		if (n < 9) document.getElementById('imgdropmenu'+n).src = 'http://image.masamaso.com/menu_on_0'+(n+1)+'.gif';
//		else document.getElementById('imgdropmenu'+n).src = 'http://image.masamaso.com/menu_on_'+(n+1)+'.gif';
		if (document.getElementById('menu_m'+n)) document.getElementById('menu_m'+n).className = '';
	}
	this.css(this.asscmenuitem, "selected", "remove")
	this.dropmenuobj.style.display='none'
	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px"
	this.hideshim()
	gl_set();
},
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 jump_url(url) {
	var previous = 'index.php';
	var previous_param = '';
	var current_arr = url.split('?');
	var current_param = current_arr[1];
	var current = current_arr[0].split('.com/');
	current = current[1];
	document.getElementById('delIframe').src = 'http://www.masamaso.com/union/operate/visitor_path.php?previous='+escape(previous)+'&previous_param='+escape(previous_param)+'¤t='+escape(current)+'¤t_param='+escape(current_param)+'&domain='+domain;
	window.open(url);
}

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()
	{
		var mm_id = getCookie('mm_customer_id');
		setCookie('mm_id',mm_id);
		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 insert_history()
	{
		var pn_dispaly = getCookie('PN').split('||');
		var bc_dispaly = getCookie('BC').split('||');
		var sn_dispaly = getCookie('SN').split('||');
		var sp_dispaly = getCookie('SP').split('||');
		
		$("#history_area").html('');
//		var hisgory = getCookie('history');
//		hisgory = eval('(' + hisgory + ')');
		var history_str = '';
//		for (key in hisgory)
//		{
//			if (hisgory[key])
//			{
//				arr = hisgory[key].split('|');
//				history_str += '<li>';
//				history_str += '<div class="goods_skim_tp"><a href="goods.php?id='+arr[0]+'" title="'+arr[2]+'" target="_blank"><img src="http://www.masamaso.com/upload/'+arr[3]+'_s_1.jpg" alt="'+arr[2]+'" /></a></div>';
//				history_str += '<div class="goods_skim_txt gray9">';
//				history_str += '<p><a href="goods.php?id='+arr[0]+'">'+arr[2]+'</a></p>';
//				history_str += '<p class="goods_skim_price">￥'+arr[1]+'</p>';
//				history_str += '</div>';
//				history_str += '</li>';
//				$("#history_area").html(history_str);
//			}
//		}
		//最近浏览的商品
		for (var i=0;i<pn_dispaly.length;i++) {
			if (pn_dispaly[i] != '') {
				var sntext = sn_dispaly[i].slice(0,16)+"...";
				if (i == pn_dispaly.length-1)
				{
					history_str += '<li class="border_none">';
				}
				else
				{
					history_str += '<li>';
				}
				history_str += '<div class="goods_skim_tp"><a href="goods_'+pn_dispaly[i]+'.html" title="'+sn_dispaly[i]+'" target="_blank"><img src="http://image03.masamaso.com/s/'+bc_dispaly[i]+'_s_0.jpg" alt="'+sn_dispaly[i]+'" /></a></div>';
				history_str += '<div class="goods_skim_txt gray">';
				history_str += '<p><a href="goods_'+pn_dispaly[i]+'.html">'+sntext+'</a></p>';
				history_str += '<p class="goods_skim_price">￥'+sp_dispaly[i]+'</p>';
				history_str += '</div>';
				history_str += '</li>';
			}
		}
		$("#history_area").html(history_str);
	}

	
	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 insert_history()
//{
//	$("#history_area").html('');
//	var hisgory = getCookie('history');
//	if (hisgory)
//	{
//		hisgory = eval('(' + hisgory + ')');
//		var history_str = '';
//		for (key in hisgory)
//		{
//			if (hisgory[key])
//			{
//				arr = hisgory[key].split('|');
//				history_str += '<li>';
//				history_str += '<div class="goods_skim_tp"><a href="goods.php?id='+arr[0]+'" title="'+arr[2]+'" target="_blank"><img src="http://www.masamaso.com/upload/'+arr[3]+'_s_1.jpg" alt="'+arr[2]+'" /></a></div>';
//				history_str += '<div class="goods_skim_txt gray9">';
//				history_str += '<p><a href="goods.php?id='+arr[0]+'">'+arr[2]+'</a></p>';
//				history_str += '<p class="goods_skim_price">￥'+arr[1]+'</p>';
//				history_str += '</div>';
//				history_str += '</li>';
//				$("#history_area").html(history_str);
//			}
//		}
//	}
//}


function login_or_reg(type,return_url)
	{
		$('#question').html('<div style="padding:50px;border:1px solid #E7E7E7;background:#FDFDFD;text-align:center;line-height:20px;"><p><img src="http://image.masamaso.com/loading.gif" onclick="$.unblockUI();" alt="loading" /></p><p>数据加载中…… <a href="javascript:;" onclick="$.unblockUI();">关闭</a></p></div>');
	
		$.blockUI({ 
		    message: $('#question'), css: { 
		        top:  ($(window).height()-350) /2 + 'px', 
		        left: ($(window).width()-420)/2 + 'px',
		        cursor: 'text'
		    }
		});
		$.ajax({
			type:"POST",
			url:"user_validate.php",
			cache:false,
			dataType:'json',     //接受数据格式
			data:"type="+type+"&act=flow_login_reg&return_url="+return_url,
			success:function (result){
				if (result.content == '' || result.content == undefined)
				{
					$.unblockUI();
					if (result.url != '' && result.url != undefined) 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 (!mobile.isMobile())
		{
			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;
//					}
//				}
//			});
//		}

        //检测用户的详细信息里是否有省市信息
        if (document.getElementById('address_'+ key).value.indexOf(document.getElementById('city_'+ key).options[document.getElementById('city_'+ key).selectedIndex].text) >= 0){
        	
        } else document.getElementById('address_'+ key).value = document.getElementById('city_'+ key).options[document.getElementById('city_'+ key).selectedIndex].text+"市"+document.getElementById('address_'+ key).value;
        if (document.getElementById('address_'+ key).value.indexOf(document.getElementById('province_'+ key).options[document.getElementById('province_'+ key).selectedIndex].text) >= 0){
        	
        } else document.getElementById('address_'+ key).value = document.getElementById('province_'+ key).options[document.getElementById('province_'+ key).selectedIndex].text+"省"+document.getElementById('address_'+ key).value;

		return  true;
		
	}
	
	String.prototype.Trim = function() {   
	var m = this.match(/^\s*(\S+(\s+\S+)*)\s*/);   
	return (m == null) ? "" : m[1];   
	}   
	  
	String.prototype.isMobile = function() {   
	return (/^(?:1[3|5|8]\d)-?\d{5}(\d{3}|\*{3})/.test(this.Trim()));   
	} 
	/**
	*	配送地址城市联动菜单
	*/
	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");
//		}
//		if (document.getElementById('flowPrice'))
//		{
//		    $.ajax({
//		    	type:"POST",
//		    	url:"flow.php",
//		    	cache:false,
//		    	dataType:'json',     //接受数据格式
//		    	data:"step=header_cart_price",
//		    	success:function (msg){
//		    		 if (msg.num != 0) {
//						$("#flowPrice").html("总金额：￥"+msg.price);
//						$("#flowNum").html(msg.num);
//		    		 }
//		    	}
//		    });
//		}
//	}); 
	
	
	
		(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()
	{
		var cart_num = 0;
		var product_cookie = getCookie("product");
		var event_offers_cart_cookie = getCookie("event_offers_cart");
			if (product_cookie)
			{
				var product_cookie_obj = eval('(' + product_cookie + ')');  
				for (var i in product_cookie_obj)
				{
					if (!isNaN(product_cookie_obj[i]['num']))
					{
						cart_num += parseInt(product_cookie_obj[i]['num']);
					}
				}
			}
			if (event_offers_cart_cookie)
			{
				var event_offers_cart_cookie_obj = eval('(' + event_offers_cart_cookie + ')');  
				for (var i in event_offers_cart_cookie_obj)
				{
					if (event_offers_cart_cookie_obj[i]['event_product'])
					{
						for (var n; n <= event_offers_cart_cookie_obj[i]['event_product'].length;n++)
						{
							if (!isNaN(event_offers_cart_cookie_obj[i]['event_product'][n]['num']))
							{
								cart_num += parseInt(event_offers_cart_cookie_obj[i]['event_product'][n]['num']);
							}
						}
						
					}
				}
			}
		$("#spanCount").html("<a href='flow.php?step=flow' style='color:#fcf3cf;'>购物车中有<span style='color:red;font-weight:bold;'>"+(cart_num)+" </span>款商品</a>");
	}

	function GetLast2Prod()
	{
	    $("#content").html("loading......");
	    $.ajax({
	    	type:"POST",
	    	url:"flow.php",
	    	cache:false,
	    	dataType:'html',     //接受数据格式
	    	data:"step=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, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
}

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);
   }
}

/**************************************************   
 2010-3-6   
   图片轮播 
***************************************************/   
var PImgPlayer = {   
        _timer : null,   
        _items : [],   
        _container : null,   
        _index : 0,   
        _imgs : [],   
        intervalTime : 3500,         
        init : function( objID, w, h, time ){   
                this.intervalTime = time || this.intervalTime;   
                this._container = document.getElementById( objID );   
                this._container.style.display = "block";   
                this._container.style.width = w + "px";   
                this._container.style.height = h + "px";   
                this._container.style.position = "relative";   
                this._container.style.overflow = "hidden";   
                //this._container.style.border = "1px solid #fff";   
                var linkStyle = "display: block; TEXT-DECORATION: none;";   
                if( document.all ){   
                        linkStyle += "FILTER:";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') ";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') ";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)";   
                        linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Inset ()";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )";   
                        linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%";   
                }   
                //   
                var ulStyle = "margin:0;width:"+w+"px;position:absolute;z-index:999;FILTER:Alpha(Opacity=50,FinishOpacity=50, Style=1);overflow: hidden;bottom:1px;height:16px; border-right:1px solid #fff;";   
                //   
                var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";   
                //   
                var baseSpacStyle = "clear:both; display:block; width:15px;line-height:16px; font-size:12px; FONT-FAMILY:'????';opacity: 0.6;";   
                baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";   
                baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";   
                //   
                var ulHTML = "";   
                if (this._items.length > 1) {
	                for(var i = this._items.length -1; i >= 0; i--){   
	                        var spanStyle = "";   
	                        if( i==this._index ){   
	                                spanStyle = baseSpacStyle + "background:#1C6EA7;";   
	                        } else {                                   
	                                spanStyle = baseSpacStyle + "background:#000;";   
	                        }   
	                        ulHTML += "<li style=\""+liStyle+"\">";   
	                        ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";   
	                        ulHTML += "</li>";   
	                }   
                }
                //   
                var html = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\" style=\""+linkStyle+"\"></a><ul style=\""+ulStyle+"\">"+ulHTML+"</ul>";   
                this._container.innerHTML = html;   
                var link = this._container.getElementsByTagName("A")[0];           
                link.style.width = w + "px";   
                link.style.height = h + "px";   
                link.style.background = 'url(' + this._items[0].img + ') no-repeat center center';   
                //   
                this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );   
        },   
        addItem : function( _title, _link, _imgURL ){   
                this._items.push ( {title:_title, link:_link, img:_imgURL } );   
                var img = new Image();   
                img.src = _imgURL;   
                this._imgs.push( img );   
        },   
        play : function( index ){   
        		if (document.getElementById("na_num").value == 1) return false;
                if( index!=null ){   
                        this._index = index;   
                        clearInterval( this._timer );   
                        this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );   
                } else {   
                        this._index = this._index<this._items.length-1 ? this._index+1 : 0;   
                }   
                var link = this._container.getElementsByTagName("A")[0];           
                if(link.filters){   
                        var ren = Math.floor(Math.random()*(link.filters.length));   
                        link.filters[ren].Apply();   
                        link.filters[ren].play();   
                }   
                link.href = this._items[this._index].link;   
                link.title = this._items[this._index].title;   
                link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center';   
                //   
                var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";   
                var baseSpacStyle = "clear:both; display:block; width:15px;line-height:16px; font-size:12px; opacity: 0.6;";   
                baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";   
                baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";   
                var ulHTML = "";   
                for(var i = this._items.length -1; i >= 0; i--){   
                        var spanStyle = "";   
                        if( i==this._index ){   
                                spanStyle = baseSpacStyle + "background:#1C6EA7;";   
                        } else {                                   
                                spanStyle = baseSpacStyle + "background:#000;";   
                        }   
                        ulHTML += "<li style=\""+liStyle+"\">";   
                        ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";   
                        ulHTML += "</li>";   
                }   
                this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML;           
        },   
        mouseOver : function(obj){   
                var i = parseInt( obj.innerHTML );   
                if( this._index!=i-1){   
                        obj.style.color = "#1C6EA7";   
                }   
        },   
        mouseOut : function(obj){   
                obj.style.color = "#fff";   
        }   
}   


/**************************************************   
 2010-3-6   
   下拉菜单 
***************************************************/   
var selects = document.getElementsByTagName('select');
var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;

function $m(id) {
	return document.getElementById(id);
}

function stopBubbling (ev) {	
	ev.stopPropagation();
}
function rSelects() {
	for (i=0;i<selects.length;i++){
		if ((i>0) || (location.href.indexOf('flow') >= 0)) continue;
		selects[i].style.display = 'none';
		select_tag = document.createElement('div');
			select_tag.id = 'select_' + selects[i].name;
			select_tag.className = 'select_box';
		selects[i].parentNode.insertBefore(select_tag,selects[i]);

		select_info = document.createElement('div');	
			select_info.id = 'select_info_' + selects[i].name;
			select_info.className='tag_select';
			select_info.style.cursor='pointer';
		select_tag.appendChild(select_info);

		select_ul = document.createElement('ul');	
			select_ul.id = 'options_' + selects[i].name;
			select_ul.className = 'tag_options';
			select_ul.style.position='absolute';
			select_ul.style.display='none';
			select_ul.style.zIndex='999';
		select_tag.appendChild(select_ul);

		rOptions(i,selects[i].name);
		
		mouseSelects(selects[i].name);

		if (isIE){
			selects[i].onclick = new Function("clickLabels3('"+selects[i].name+"');window.event.cancelBubble = true;");
		}
		else if(!isIE){
			selects[i].onclick = new Function("clickLabels3('"+selects[i].name+"')");
			selects[i].addEventListener("click", stopBubbling, false);
		}		
	}
}
function rOptions(i, name) {
	var options = selects[i].getElementsByTagName('option');
	var options_ul = 'options_' + name;
	for (n=0;n<selects[i].options.length;n++){	
		option_li = document.createElement('li');
			option_li.style.cursor='pointer';
			option_li.className='open';
		$m(options_ul).appendChild(option_li);

		option_text = document.createTextNode(selects[i].options[n].text);
		option_li.appendChild(option_text);

		option_selected = selects[i].options[n].selected;

		if(option_selected){
			option_li.className='open_selected';
			option_li.id='selected_' + name;
			$m('select_info_' + name).appendChild(document.createTextNode(option_li.innerHTML));
		}
		
		option_li.onmouseover = function(){	this.className='open_hover';}
		option_li.onmouseout = function(){
			if(this.id=='selected_' + name){
				this.className='open_selected';
			}
			else {
				this.className='open';
			}
		} 
	
		option_li.onclick = new Function("clickOptions("+i+","+n+",'"+selects[i].name+"')");
	}
}
function mouseSelects(name){
	var sincn = 'select_info_' + name;

	$m(sincn).onmouseover = function(){ if(this.className=='tag_select') this.className='tag_select_hover'; }
	$m(sincn).onmouseout = function(){ if(this.className=='tag_select_hover') this.className='tag_select'; }

	if (isIE){
		$m(sincn).onclick = new Function("clickSelects('"+name+"');window.event.cancelBubble = true;");
	}
	else if(!isIE){
		$m(sincn).onclick = new Function("clickSelects('"+name+"');");
		$m('select_info_' +name).addEventListener("click", stopBubbling, false);
	}

}
function clickSelects(name){
	var sincn = 'select_info_' + name;
	var sinul = 'options_' + name;	
    for (i=0;i<selects.length;i++){	
		if ((i>0) || (location.href.indexOf('flow') >= 0)) continue;
		if(selects[i].name == name){				
			if( $m(sincn).className =='tag_select_hover'){
				$m(sincn).className ='tag_select_open';
				$m(sinul).style.display = '';
			}
			else if( $m(sincn).className =='tag_select_open'){
				$m(sincn).className = 'tag_select_hover';
				$m(sinul).style.display = 'none';
			}
		}
		else{
			$m('select_info_' + selects[i].name).className = 'tag_select';
			$m('options_' + selects[i].name).style.display = 'none';
		}
	}

}
function clickOptions(i, n, name){		
	var li = $m('options_' + name).getElementsByTagName('li');

	$m('selected_' + name).className='open';
	$m('selected_' + name).id='';
	li[n].id='selected_' + name;
	li[n].className='open_hover';
	$m('select_' + name).removeChild($m('select_info_' + name));

	select_info = document.createElement('div');
		select_info.id = 'select_info_' + name;
		select_info.className='tag_select';
		select_info.style.cursor='pointer';
	$m('options_' + name).parentNode.insertBefore(select_info,$m('options_' + name));

	mouseSelects(name);

	$m('select_info_' + name).appendChild(document.createTextNode(li[n].innerHTML));
	$m( 'options_' + name ).style.display = 'none' ;
	$m( 'select_info_' + name ).className = 'tag_select';
	selects[i].options[n].selected = 'selected';

}
function gl_set() {
	//var mh_url = location.href;
//	if (mh_url.indexOf('index') >= 0) {
//		document.getElementById('menu_m0').className = 'm0';
//	}
//	else if (mh_url.indexOf('category') >= 0) {
//		if (document.getElementById('parent_id')) {
//			var par_id = document.getElementById('parent_id').value;
//			if (par_id == 330) document.getElementById('menu_m1').className = 'm1';
//			if (par_id == 333) document.getElementById('menu_m2').className = 'm2';
//			if (par_id == 334) document.getElementById('menu_m3').className = 'm3';
//			if (par_id == 368) document.getElementById('menu_m4').className = 'm4';
//			if (par_id == 336) document.getElementById('menu_m5').className = 'm5';
//			if (par_id == 337) document.getElementById('menu_m6').className = 'm6';
//			if (par_id == 339) document.getElementById('menu_m7').className = 'm7';
//			if (par_id == 340) document.getElementById('menu_m8').className = 'm8';
//			if (par_id == 362) document.getElementById('menu_m9').className = 'm9';
//			if (par_id == 411) document.getElementById('menu_m10').className = 'm10';
//			if (par_id == 345) document.getElementById('menu_m11').className = 'm11';
//		}
//	}
}
//window.onload = function(e) {
//	bodyclick = document.getElementsByTagName('body').item(0);
//	rSelects();
//	bodyclick.onclick = function(){
//		for (i=0;i<selects.length;i++){	
//			$m('select_info_' + selects[i].name).className = 'tag_select';
//			$m('options_' + selects[i].name).style.display = 'none';
//		}
//	}
//}

/**************************************************   
 2010-3-6   
   下拉菜单 end
***************************************************/   
