var down_list = getCookie('down_list');
if(down_list == null){
	var down_ar = [];
}else{
	var down_ar = down_list.split(',');
}
Array.prototype.in_array = function(e) 
{ 
    for(i=0;i<this.length;i++)
    {
        if(this[i] == e)
        return true;
    }
    return false;
}
//设置cookie
function SetCookie(name,value,hour)//两个参数，一个是cookie的名子，一个是值
{
	//var Days = 30; //此 cookie 将被保存 30 天
	var exp = new Date();    //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + hour*60*60*1000);
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
}
//取cookie
function getCookie(name)//取cookies函数       
{	 
  var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  if(arr != null) return unescape(arr[2]); return null;
}
//下载
function download(down_url,app_id,appMac,acNum){
	if(down_ar.in_array(app_id) == false){
		down_ar.push(app_id);
		SetCookie('down_list',down_ar.join(','),720);
		if(down_ar.length == 1){
			$('.popStar').hide();
			$('.popStar1').show();
		}else if(down_ar.length == 2){
			$('.popStar').hide();
			$('.popStar2').show();
		}else if(down_ar.length == 3){
			$('.popStar').hide();
			$('.popStar3').show();
		}
	}
	$.post('/index.php/app/net_down',{'app_id':app_id,'os_type':'net_android','appMac':appMac,'acNum':acNum},function(){window.location.href=down_url;});
	$("#down_app_"+app_id).html("已下载");
}

//外源下载统计_android
function download_wya(down_url,app_id,appMac,acNum){
	if(down_ar.in_array(app_id) == false){
		down_ar.push(app_id);
		SetCookie('down_list',down_ar.join(','),720);
		if(down_ar.length == 1){
			$('.popStar').hide();
			$('.popStar1').show();
		}else if(down_ar.length == 2){
			$('.popStar').hide();
			$('.popStar2').show();
		}else if(down_ar.length == 3){
			$('.popStar').hide();
			$('.popStar3').show();
		}
	}
	$.post('/index.php/app/net_down',{'app_id':app_id,'os_type':'net_android','appMac':appMac,'acNum':acNum},function(){window.location.href=down_url;});
	$("#down_app_"+app_id).html("已下载");
}
//外源下载统计_ios
function download_wyo(down_url,app_id,appMac,acNum){
	if(down_ar.in_array(app_id) == false){
		down_ar.push(app_id);
		SetCookie('down_list',down_ar.join(','),720);
		if(down_ar.length == 1){
			$('.popStar').hide();
			$('.popStar1').show();
		}else if(down_ar.length == 2){
			$('.popStar').hide();
			$('.popStar2').show();
		}else if(down_ar.length == 3){
			$('.popStar').hide();
			$('.popStar3').show();
		}
	}
	$.post('/index.php/app/net_down',{'app_id':app_id,'os_type':'net_ios','appMac':appMac,'acNum':acNum},function(){window.location.href=down_url;});
	$("#down_app_"+app_id).html("已下载");
}


$(function(){
	var list_close = getCookie('list_close');
	if(list_close == '1'){
		$('.popDownBtn').addClass('popDownBtnMin');
	}

	$('.popDownBtn .close').click(function () {
		$(this).parents('.popDownBtn').addClass('popDownBtnMin');
		SetCookie('list_close','1',3);
	});

	$('.popStar .close').click(function () {
		$(this).parents('.popStar').fadeOut();
	});
});