function swf(_src,fw,fh,vars){
	var html = ''
		+ '<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="'+fw+'" height="'+fh+'" align="middle">\n'
		+ '<param name="allowScriptAccess" value="always" />'
		+ '<param name="movie" value="'+_src+'" />\n'
		+ '<param name="quality" value="high" />\n'
		+ '<param name="scale" value="exactfit" />\n'
		+ '<param name="wmode" value="transparent" />\n'
		+ '<param name="flashvars" value="'+vars+'" />\n'
		+ '<embed src="'+_src+'" wmode="transparent" flashvars="'+vars+'" scale="exactfit" quality="high" width="'+fw+'" height="'+fh+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'
		+ '</object>\n';
	document.write(html);
	//document.title='111';
}

function setHome () {
 document.all('bbbbb').style.behavior='url(#default#homepage)';
 document.all('bbbbb').setHomePage('http://www.huishua.com/');
}

 function FloatingDIV()
 {
   var introDiv = document.getElementById("INTRO_DIV");
   introDiv.style.top = 104;
   FloatingDIV_refresh();
 } 
 
 function FloatingDIV_refresh()
 {
        var StartPoint, EndPoint;
        var introDiv = document.getElementById("INTRO_DIV");
 
        StartPoint = parseInt(introDiv.style.top);
        EndPoint = document.body.scrollTop;
       
        if (EndPoint < 0) EndPoint = 0;
 
        if (StartPoint != EndPoint ) {
         ScrollAmount = Math.ceil( Math.abs( EndPoint - StartPoint ) / 15 );
		//alert(ScrollAmount);
         introDiv.style.top = parseInt(introDiv.style.top) + ( ( EndPoint < StartPoint ) ? -ScrollAmount : ScrollAmount );
        }
		
        setTimeout ("FloatingDIV_refresh();",0);
 }
 
 function applycard (cardid) {
  alert ("准备中...");
 }
 
 function buy (pid) {
  alert ("准备中...");
 }
 
 function send (page) {
  location='mailto:?subject=好友推荐&body=我在惠刷网上看到这个内容还不错，看看吧！ http://www.huishua.com'+escape(page);
 }
 
 function cardcompare (page) {
  var banks = document.getElementsByName("bank[]");
  var cbank = new Array();;
  count = 0;
  for (i=0; i< banks.length; i++) {
   if (banks[i].checked) {
    cbank[count] = banks[i].value;
    count++;
   }
  }
  if (!count) {
   alert ("请选择银行卡！");
  } else {
   loc = "";
   for (k = 1; k<= cbank.length; k++) {
    loc += "card"+k+"="+cbank[k-1]+"&";
   }
   location = "./card_compare.php?" + loc;
  }
 }

 $(document).ready(function(){
	$(".select_bank").click(showchild=function(){
		$(this).children("ul").toggle();
	}).children("ul").bind('mouseover',function(){
		$(this).show();				
	}).children("li").bind('mouseover',function(){
		//$(this).parent().show();		
		$(this).parent().children("li").css("background-color","#fff");//所有变白
		$(this).css("background-color","#597DBB");//选中高亮
		$(this).parent().mouseout(function(){$(this).hide();});
	}).click(function(){		
		//alert($(".select_bank ul").html());
		
	});
	

	$(".xiala").click(function(){
		var ul = $(this).prev().children("ul");
		ul.toggle();
	});
 });


 function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
//document.onfocusin=bluring;
function shouchang(uid){
		if(uid==0){
			if(confirm("您还没有登录\n请马上登录… ")){
				window.location.href="login.php";
			}else{
				return false;
			}
		}else{
			alert("收藏成功");
		}
		
	}
$(document).ready(function() {
	
	$("#more").click(function(){
		if($(".shopbox").css("display")=='block'){
			$(this).html('<img src="images/btn_expand_green.gif" border="0" style="height=:22px; vertical-align:middle;" alt="查看更多商户" >');
			//$(".shopbox").fadeIn();
		}else{
			$(this).html('<img src="images/btn_collapse_green.gif" border="0" style="height=:22px; vertical-align:middle;" alt="只显示当前商户" >');
			//(".shopbox").fadeOut();
		}
		$(".shopbox").slideToggle("normal");
	});

	/*改变图片颜色*/
	var _src1,_src2;
	$(".changImgColor").hover(function(){
		_src1 = $(this).children('img').attr("src");
		_src2 = $(this).attr("_src");
		$(this).children('img').attr("src",_src2);
	},function(){ $(this).children('img').attr("src",_src1); });
	//显示 删除 修改按钮  添加两个css   出发事件的容器 class='show_button'  显示的容器 class="option_button"
	$(".show_button").hover(function(){ $(this).find(".option_button").css("display","block");},function(){$(this).find(".option_button").css("display","none")});
	//卡片展开，关闭
	$(".open_up").click(function(){
		if($(this).children("img").attr('src')=='images/z01.gif'){
			$(".card_box").hide();
			$(this).children("img").attr('src','images/z02.gif');
			$('.open_down > img').attr('src','images/z06.gif')
		}else{
			$(".card_box").show();
			$(this).children("img").attr('src','images/z01.gif');
			$('.open_down > img').attr('src','images/z05.gif')
		}
		//
	});
	$(".open_down").click(function(){
		if($(this).children("img").attr('src')=='images/z05.gif'){
			$(".card_box").hide();
			$(this).children("img").attr('src','images/z06.gif');
			$('.open_up > img').attr('src','images/z02.gif')
		}else{
			$(".card_box").show();
			$(this).children("img").attr('src','images/z05.gif');
			$('.open_up > img').attr('src','images/z01.gif')
		}
		//
	});
	
	//全选 全否
	var _sel = $(".ids");
	$("#selAll").click(function(){		
		_sel.attr("checked",'true');
	});
	$("#calAll").click(function(){
		_sel.attr("checked",false);
	});
	$("#delAll").click(function(){
		var ids=0,is_selone=0;
		_sel.each(function(){
			if($(this).attr('checked')==true){
				is_selone++;
				ids = ids+','+$(this).val();
			}
		});
		if(is_selone){
			if(confirm("确认要删除吗？")){
				_href = $(this).attr("href");
				$(this).attr("href",_href+'&ids='+ids);
				return true;
			}else{
				return false;
			}
		}else{
			if($(this).attr("msg")){
				alert($(this).attr("msg"));
			}
			return false;
		}
		
	});
	$("a").focus(function(){
		$(this).blur();
	});
});

function shoucangajax(aid,stype,uid) {
	//alert(uid);return false;
	if(uid==0){
			var referer='';
			switch(stype){
				case 'active':referer='active_info.php?id='+aid;break;
				case 'discount':referer='discountinfo.php?discount='+aid;break;
				case 'bystageshop':referer='bystageshopinfo.php?bystageshop='+aid;break;
				case 'shop':referer='bystageshopshopinfo.php?shop='+aid;break;3
			}
			
			if(confirm("此功能只向会员开放，请先登录！　　　")){
				window.location.href="login.php?referer="+referer;
			}else{
				return false;
			}
	} else {
		var d = new Date(); 
		$.ajax({
		   type: "GET",
		   url: "favorite.php",
		   data: "id=" + aid + "&type=" + stype + "&uid=" + uid+"&t="+d.getTime(),
		   success: function(msg){
		     alert(msg);
		   }
		}); 
	}
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

var show_info = function(){
	//$(".info").show();$(".simple").hide();
	//$("#xiang").css("background-image","url(_imgs/btn_xiang_1.gif)");
	//$("#jian").css("background-image","url(_imgs/btn_jian_11.gif)");
	$("#xiang").addClass("xiang_sel");
	$("#jian").removeClass("jian_sel");
}
var show_simple=function(){
	//$(".info").hide();$(".simple").show();
	//$("#xiang").css("background-image","url(_imgs/btn_xiang_11.gif)");
	//$("#jian").css("background-image","url(_imgs/btn_jian_1.gif)");

	$("#xiang").removeClass("xiang_sel");
	$("#jian").addClass("jian_sel");
}	
//设置帮助也title
function cutUrl(){
	var _aa = document.title.indexOf("#");
	if(_aa > 0){
		_bb = document.title.substring(0,_aa);
		document.title = _bb;
	}
}
//过滤关键字
function filt_from(name){
	var frm = document.forms['active_list'];
	_a = $(frm).attr('action');
	name = name.split("|");  
	for(i=0;i<name.length;i++){
		_a = cut_parm(_a,name[i]);
	}
	//alert(_a);return false;
	
	
	$(frm).attr('action',_a);
	$("form[name=active_list]").submit();
	//frm.submit();
	//return false;
}
function cut_parm(str,name){
	var   strArray=new   Array();   
	var   strArray2=new   Array();   
    strArray=str.split("?");  
    strArray=strArray[1].split("&");  
	var i=0;
	var len = strArray.length;
	
	while(strArray[i]){
		_tmp = strArray[i];
		strArray2 = strArray[i].split("=");
		if(strArray2[0]==name){
			if(i==(len-1)){
				str = str.replace("&"+_tmp, "");
			}else{
				str = str.replace(_tmp+"&", "");
			}
			
			break;
		}
		//alert(strArray2[0]);
		i++;
	}
	return str;
}

//验证邮箱
function isEmail( 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 );
}

//验证手机号
function isMobel(value)  
{  
	if(/^13\d{9}$/g.test(value)||(/^15[0-35-9]\d{8}$/g.test(value))||  
	(/^18[0-9]\d{8}$/g.test(value))){    
				return true;  
	}else{  
				return false;  
	}  
}  
//===============自定义函数===================//
/*
* 2008年11月15日1:31:44
* ajax 处理函数
* @url 地址
* @prama 参数  { name: "John", time: "2pm" },
* @innerid 选择id 
***/
function updater(url,prama,innerid)
{
	$.get(url, prama,
	  function(data){
	    $("#"+innerid).html(data);
	  }); 
}

//投票
function poll(id){
	t = new Date();
	$.get("online_apply_loveice.php?act=poll&t="+t.getTime(),{loveice_id:id},function(date){
		if(date==-9){
			alert("参数传递错误");
		}else if(date==-1){
			if(confirm("您还没登录，登录后才能进行投票！马上登录？　　")){
				location.href="login.php";
			}
		}else if(date==-2){
			alert("您已经对这款产品投过票了，呵呵~~　");
		}else if(date>0){
			$("#pollnum"+id).html(date);
			alert("投票成功，感谢您的支持！　");
		}
		
	});
}

//投票数量初始化
function iniPollnums(){
	t = new Date();
	var n=16;
	$.getJSON("online_apply_loveice.php?act=getpoll&t="+t.getTime(),function(date){
		for(var i=0;i<date.length;i++){
			if(i>n){
				break;
			}
			$("#pollnum"+date[i].loveice_id).html(date[i].nums);
			//alert(date[i].loveice_id);break;
		}
	});
}
