<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="js/jquery/jquery.min.js"></script>
<script src="js/jquery/jquery.cookie.js"></script>
<link href="js/jquery/tipTip/tipTip.css" rel="stylesheet"/>
<!-- [if IE 6]>
<link href="js/jquery/tipTip/ie6.css" rel="stylesheet"/>
<![endif]-->
<script src="js/jquery/tipTip/jquery.tipTip.js" charset="utf-8"></script>
<style>
<!--
.page input { width:50px;}
-->
</style>
</head>
<body>
					<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;">
						<tr class="thead">
							<td width="5%"><input type="checkbox" class="checkall"/></td>
							<td width="7%">广告ID</td>
							<td width="15%">广告名称</td>
							
							<td width="8%">状态
								</td>
						</tr>
						<!--{foreach from=$datalist item=data}-->
						<tr class="tiptip" title="地址：<!--{$data.ad_url}--><br>广告语：<!--{$data.ad_language}-->" onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
							<td><input type="checkbox" class="adid" name="recordId" value="<!--{$data.id}-->"/></td>
							<td><!--{$data.id}--></td>
							<td><!--{$data.ad_name}--></td>
							<td><!--{if $data.status == 1}-->已发布<!--{elseif $data.status == 9}-->未发布<!--{/if}--></td>
							
						</tr>
						<!--{foreachelse}-->
						<tr><td colspan="4">没有对应数据</td></tr>
						<!--{/foreach}-->
						<tr class="page"><td colspan="4"><!--{$pager}--></td></tr>
					</table>
<script>
$(document).ready(function(){
	$(".tiptip").tipTip({defaultPosition: "bottom"});
	
	var ad_cookies = $.cookie("ADCOOKIES");
	var ADARRAY;
	if(ad_cookies != "" &&　ad_cookies != undefined)
	{
		ADARRAY = ad_cookies.split("|");
		if($.isArray(ADARRAY)){
			for(var i=0;i<ADARRAY.length;i++)
			{	
				$(".adid").each(function(){
					if($(this).val() == ADARRAY[i]){
						$(this).attr("checked",true);
					}
				});
				
			}
		}
	}
	
	/*列表页面checkbox全选和反选*/
	$(".checkall").click(function(){
		if ($(this).attr("checked") == true) {
			$("[type=checkbox][name=recordId]").each(function(){
				if ($(this).attr("checked") != true) {
					$(this).attr("checked", "true");
					$(this).parent().parent().attr("bgColor", "#edf6ff");
				}
				addtocookie($(this).val());
			});
		} else {
			$("[type=checkbox][name=recordId]").each(function(){
				if ($(this).attr("checked") == true) {
					$(this).attr("checked", "");
					$(this).parent().parent().attr("bgColor", "#ffffff");
					deletofromcookie($(this).val());
				}
			});
		}
	});
	
	$(".adid").click(function(){
		if($(this).attr("checked"))
		{
			addtocookie($(this).val());
		}else{
			deletofromcookie($(this).val());
		}
	});
	
	function addtocookie(adid)
	{

		var ad_cookies2 = $.cookie("ADCOOKIES");
		var ADARRAY2;
		if(ad_cookies2 != "" &&　ad_cookies2 != undefined)
		{
			ADARRAY2 = ad_cookies2.split("|");
			if($.isArray(ADARRAY2)){
				$(ADARRAY2).each(function(k,v){
					if(adid == v )
					{
						return false;
					}
				});
			}
			
			$.cookie("ADCOOKIES",ad_cookies2+"|"+adid);
		}else{
			$.cookie("ADCOOKIES",adid);
		}
	}
	
	function deletofromcookie(adid)
	{
		var ad_cookies2 = $.cookie("ADCOOKIES");
		var ADARRAY2;
		var newcookie='';
		if(ad_cookies2 != "" &&　ad_cookies2 != undefined)
		{
			ADARRAY2 = ad_cookies2.split("|");
			if($.isArray(ADARRAY2)){
				$(ADARRAY2).each(function(k,v){
					if(adid != v )
					{
						if(newcookie == ""){
							newcookie = v;
						}else{
							newcookie+= "|"+v;
						}
					}
				});
			}
			
			$.cookie("ADCOOKIES",newcookie);
		}
	}
});

/**
 * 表格变色效果
 * @param tr
 * @return
 */
function chgTrColor(tr){
	if ($(tr).find("[type=checkbox][name=recordId]").attr("checked") == true) {
		$(tr).attr("bgColor", "#edf6ff");
	} else {
		$(tr).attr("bgColor", ($(tr).attr("bgColor") == "#edf6ff")?"#ffffff":"#edf6ff");
	}
}

</script>
</body>
</html>