var change_topleft_img_id = 1;
var ad_num;
var paused = false;
$(function(){
	ad_num = $('#i_focus_btn  ul  li');
	change_topleft_img_timer = setInterval("auto_change_topleft_img()",5000);
	setInterval('AutoScroll("#newest_scroll")', 2000)
});

function AutoScroll(obj)
{
   $(obj).find("ul:first").animate({marginTop:"-49px"}, 1000, function() {$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);});
}

function auto_change_topleft_img(){
    var id = change_topleft_img_id>=ad_num.length?1:change_topleft_img_id+1;
    change_topleft_img(id);
}

function change_topleft_img(id){
	if(paused)
	{
		return;
	}
	paused = true;
    clearInterval(change_topleft_img_timer);
    change_topleft_img_id = id;
   // ad_num.each(function(i,v){
for(i=1;i<ad_num.length+1;i++){
        if(i == id)
        {
            $('#index_brand_left_img_'+i).hide().fadeIn(500,function(){});
            $('#index_brand_left_txt_'+i).addClass('i_cur');
        }
        else
        {
	        $('#index_brand_left_img_'+i).hide();
	        //$('#index_brand_left_img_'+i).css('display','none');
	        $('#index_brand_left_txt_'+i).removeClass();
        }
}
   // });
    paused = false;
    change_topleft_img_timer=setInterval("auto_change_topleft_img()",5000);
}

/**
* �
*/
function move_hot_goods(select,keyid){
		var i=1;
		while(document.getElementById('hot_goods_desk_'+select+'_'+i)){
		if(i==keyid){
		$('#hot_goods_desk_'+select+'_'+i).css('display','none');
		$('#hot_goods_content_'+select+'_'+i).css('display','block');
		}else{
		$('#hot_goods_desk_'+select+'_'+i).css('display','block');
		$('#hot_goods_content_'+select+'_'+i).css('display','none');
		}
		i++;
		}

}

function fastbuy(){
    var rec_id = $('input[type=hidden][name=fastbuy_rec_id]').val();
    if(rec_id == undefined){
        var rec_ids = new Array();
        $('input:checked[type=checkbox][name=fastbuy_rec_id]').each(function(i){
            rec_ids.push($(this).val());
        });
        rec_id = rec_ids.join('|');
    }
    if(rec_id ==''){
        alert('请选择购买的商品。');
        return false;
    }
    $.ajax({
       url:'/fastbuy.php',
       data:{step:'add_to_cart',campaign:'fastbuy',rec_id:rec_id,rnd:new Date().getTime()},
       dataType:'json',
       type:'GET',
       success:function(result){
           if(result.error!=0){
               alert(result.message);
               return false;
           }
           location.href="/fastbuy.php";
           return true;
       }
    });
}
