$def with(vlist, isconnect, refreshstatus, datesort)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>video</title>
<link href="/static/style/video.css" type="text/css" rel="stylesheet" />
<script src="/static/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="/static/js/jquery.tools.min.js" type="text/javascript"></script>
<script src="/static/js/tinyTips.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/js/jquery.artDialog.source.js?skin=aero"></script>
<script src="/static/js/video.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/js/toolsForPB.js"></script>
<script type="text/javascript" src="/static/js/plantform.js"></script>
<script type="text/javascript">

var VideoView_Movies_video = '$trans("VideoView_Movies_video")'
var inSelect='<div class="select"><span class=""></span><input type="checkbox" /></div>';
var delExpoFlag = false;
var refrshdDia;
var isconnectFlag = $isconnect;
var refreshStatus = '$refreshstatus';
var Video_data_downloading = '$trans('Video_data_downloading')';
var Video_data_refreshing = '$trans('Video_data_refreshing')';
var DownloadFailed = '$trans('DownloadFailed')';
$$(function(){
	if (refreshStatus == "start"){
		$$('.operaterefresh li[rel=addFlag]').removeClass().addClass('refreshing');	
	}else{
		$$('.operaterefresh li[rel=addFlag]').removeClass('refreshing');	
	}
	
	if(isconnectFlag == 1){
		$$('.operateUl li[rel=addFlag]').removeClass('disabled');
		$$('.operaterefresh li[rel=addFlag]').removeClass('disabled');
	}else{
		$$('.operateUl li[rel=addFlag]').removeClass().addClass('disabled');
		$$('.operaterefresh li[rel=addFlag]').removeClass().addClass('disabled');
	}

	$$('.operateUl li').hover(function() {
		if(($$(this).attr('rel') == "needFlag" && !delExpoFlag) || ($$(this).attr('rel') == "addFlag" && isconnectFlag == 0)) return false;
		$$(this).addClass('hover').siblings().removeClass('hover');					  
	}, function(){
		$$(this).removeClass('hover');
	}).mousedown(function(){
		if(($$(this).attr('rel') == "needFlag" && !delExpoFlag) || ($$(this).attr('rel') == "addFlag" && isconnectFlag == 0)) return false;
		$$(this).removeClass('hover').addClass('down');
	}).mouseup(function(){
		if(($$(this).attr('rel') == "needFlag" && !delExpoFlag) || ($$(this).attr('rel') == "addFlag" && isconnectFlag == 0)) return false;
		$$(this).removeClass('down');
	})
	
	$$('.operaterefresh li').hover(function(){
		if (isconnectFlag == 0) return false;
		$$(this).addClass('hover').siblings().removeClass('hover');	
	}, function(){
		$$(this).removeClass('hover');
	}).mousedown(function(){
		if (isconnectFlag == 0) return false;
		$$(this).removeClass('hover').addClass('down');
	}).mouseup(function(){
		if (isconnectFlag == 0) return false;
		$$(this).removeClass('down');
	})
	
	$$('.albumPic').hover(function(){
	    if($$(this).find('input').length == 0){ //判断是否已经存在div.select
			$$(this).find('a').after(inSelect);
		}
		$$(this).addClass('hover')
		//$$(this).find('.playBto').addClass('hover');
		$$('.select span').hover(function(){
			$$(this).addClass('hover');							
		}, function(){
			$$(this).removeClass('hover');
		})
	},function(){
		//$$(this).find('.playBto').removeClass('hover');
		$$(this).removeClass('hover');
		var len = $$(this).parent('td').find("input:checked").length;
		if(len == 0){
			//$$(this).removeClass('hover');	
			$$(this).find('.select').remove();
		}
		//$$('div.tooltip').hide();
	})
	
	$$('.select span').live('click',function(){
			if($$(this).hasClass('selected')){
				$$(this).siblings(':checkbox')[0].checked = false;
				$$(this).removeClass('selected');
				$$(this).parents('tr').siblings('tr').find('a').removeClass('selected').siblings('input')[0].checked = false;
				var len = $$(this).parents('td').find("input:checked").length;
				var selectall = $$(".select input:checked").length;
				if(selectall == 0){
					$$(this).parents('td').find('.select').remove();
					delExpoFlag = false;
				}else{
					delExpoFlag = true;
				}				
			}else{
				$$(this).addClass('selected');
				$$(this).siblings(':checkbox')[0].checked = true;
				$$(this).parents('td').find('.albumPic').each(function(){
					 if($$(this).find('input').length == 0){//判断是否已经存在div.select
						$$(this).find('a').after(inSelect);						
					}
				})
				delExpoFlag = true;
				var len = $$(this).parents('td').find("input:checked").length;
				var lenTotal = $$(this).parents('td').find("input").length;
				if(len == lenTotal) $$(this).parents('tr').siblings('tr').find('a').addClass('selected').siblings('input')[0].checked = true;
			}
			if(delExpoFlag){
				$$('.operateUl li[rel=needFlag]').removeClass('disabled');
				if($$('#refresh').hasClass("refreshing"))
				{
				   $$('#delete').removeClass().addClass("disabled");
				}
			}else{
				$$('.operateUl li[rel=needFlag]').removeClass().addClass('disabled');
			}
			var subLen = $$('.subClasses input:checked').length;
			var lenAll = $$('.subClasses input').length;
			$$('#selectAll a')[subLen == lenAll ? 'addClass' : 'removeClass']('selected').siblings('input')[0].checked = subLen == lenAll ? true : false;		
	})
	$$('.selectAll a').hover(function(){
		$$(this).addClass('hover')
	},function(){
		$$(this).removeClass('hover')
	})
	/*单个文件夹的全选*/
	$$('.subClasses a').click(function(){
		$$(this).parents('tr').siblings().find('.select').remove();
		if(!$$(this).hasClass('selected')){
			$$(this).parents('tr:eq(1)').siblings('tr').find('.albumPic a').after(inSelect);
			$$(this).parents('tr:eq(1)').siblings('tr').find('.select span').addClass('selected');
			$$(this).parents('tr:eq(1)').siblings('tr').find('.select input').each(function(){
				$$(this)[0].checked = true;								 
			})
			$$(this).siblings(':checkbox')[0].checked = true;
			$$(this).addClass('selected');
		}else{
			$$(this).siblings(':checkbox')[0].checked = false;
			$$(this).removeClass('selected');
		}
		var len = $$('div.albumPic').find("input:checked").length;
		delExpoFlag = len == 0 ? false : true;
		if(delExpoFlag){
				$$('.operateUl li[rel=needFlag]').removeClass('disabled');
				if($$('#refresh').hasClass("refreshing"))
				{
				   $$('#delete').removeClass().addClass("disabled");
				}
			}else{
				$$('.operateUl li[rel=needFlag]').removeClass().addClass('disabled');
		}
		var subLen = $$('.subClasses input:checked').length;
		var lenAll = $$('.subClasses input').length;
		$$('#selectAll a')[subLen == lenAll ? 'addClass' : 'removeClass']('selected').siblings('input')[0].checked = subLen == lenAll ? true : false;
	})
	/*全选*/
	$$('#selectAll a').click(function(){
		$$('.select').remove();
		if($$(this).hasClass('selected')){
			$$('.subClasses a').removeClass('selected');
			$$('.subClasses input').each(function(){
				$$(this)[0].checked = false;
			})
			$$(this).siblings(':checkbox')[0].checked = false;
			$$(this).removeClass('selected');
		}else{
			$$('.albumPic a').after(inSelect);	
			$$('.select span').addClass('selected');
			$$('.select input').each(function(){
				$$(this)[0].checked = true;								 
			})
			$$('.subClasses a').addClass('selected');
			$$('.subClasses input').each(function(){
				$$(this)[0].checked = true;
			})
			$$(this).siblings(':checkbox')[0].checked = true;
			$$(this).addClass('selected');
		}
		var selectall = $$(".select input:checked").length;
		delExpoFlag = selectall != 0 ? true:false;
	    if(delExpoFlag){
				$$('.operateUl li[rel=needFlag]').removeClass('disabled');
				if($$('#refresh').hasClass("refreshing"))
				{
				   $$('#delete').removeClass().addClass("disabled");
				}
			}else{
				$$('.operateUl li[rel=needFlag]').removeClass().addClass('disabled');
		}		
	})

	 

	 //$$("div.albumPic[title]").tooltip({effect: 'bouncy'});
	//$$("div.albumPic").each(function(index){
	 //   $$(this).tinyTips("rel",null);
	// });
	 $$("div.albumPic").each(function(){
	    $$(this).tinyTips();
	    //var overlay = $$("<div/>")
	    //overlay.attr("class","overlay");
	    //$$(this).children("a").append(overlay);
	    //overlay.hide();
	    //var hover = $$("<div/>")
	    //hover.attr("class","hover");
	    //hover.html($$(this).attr("rel"));
	    //$$(this).children("a").append(hover);
	    //hover.hide();
	    //overlay.stop().fadeTo(500, .7);
	    //hover.stop().show().css({ "left" : "-20px" }).animate({left : 0}, 300);
	    //$("#hover").stop().show().css({ "left" : "0px" }).animate({left : 0}, 300);
		//$("#overlay").stop().fadeTo(500, .7)
	 });
	 $$('div.serDiv img').click(function(){
		$$('#videoSer').val('');
		$$("#videoSer").trigger('keyup');
	})
	 
})

function KeyDownFunction()
	{
	if (typeof window.event != 'undefined') {  
	           document.onkeydown = function() {  
	             var type = event.srcElement.type;  
	             var code = event.keyCode;  
	             return ((code != 8 && code != 13) ||  
	                     (type == 'text' && code != 13 ) ||  
	                     (type == 'textarea') ||  
	                     (type == 'submit' && code == 13))  
	           }  
	         } else { // FireFox/Others  
	           document.onkeypress = function(e) {  
	   
	             var type = e.target.localName.toLowerCase();  
	             var code = e.keyCode;  
	             if ((code != 8 && code != 13) ||  
	                 (type == 'input' && code != 13 ) ||  
	                 (type == 'textarea') ||  
	                 (type == 'submit' && code == 13)) {  
	                 return true;  
	             } else {  
	                 return false ;  
	             }  
	           }  
	         } 
	}
</script>
</head>
<body style="overflow:hidden" oncontextmenu="return false" onselectstart="return false" onkeydown="KeyDownFunction()">
	<div id="musicListWrap">
    	<div class="operateBar">
			<div id="selectAll" class="selectAll"><a class=""></a><input type="checkbox" /></div>
        	<ul class="operateUl">
            	<li class="disabled" id="addVideo" rel="addFlag"><span><em class="addIcon"></em>$trans('VideoView_WEB_ADD')</span></li>
                <li class="disabled" id="expo" rel="needFlag"><span>$trans('VideoView_WEB_EXPORT')</span></li>
                <li class="disabled" id="delete" rel="needFlag"><span>$trans('VideoView_WEB_DEL')</span></li>
            </ul>
			<ul class="operaterefresh">
                <li class="refresh" id="refresh" rel="addFlag"></li>
            </ul>
            
			<div class="serDiv"><input type="text" id="videoSer" class="videoSer" name="videoSer"/><img src="/static/imgs/clear__.png"/></div>
        </div>
		<div class="wrapAuto">
        <!-- Classification 1 start  -->
		<div class="imageblock">
		$for date in datesort:
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td>
							<table class="classification" width="100%" border="0" cellpadding="0" cellspacing="0">
								<tbody>
									<tr>
										<td>
											<div class="selectAll subClasses"><a class=""></a><input type="checkbox" /></div> &nbsp;$date
										</td>
									</tr>
								</tbody>
							</table>
						</td>
					</tr>
					<tr>
						<td id="source">
							$for l in vlist[date]:
								<div class="albumPic" rel=" $l["Size_Str"]<br/>  $l["Duration_str"]<br/>  $l["Date"]<br/>  $l["Type"].split('/')[-1]<br/>" vid="$l["Vid"]" name="$l["Name"]" type="$l["Type"].split('/')[-1]">
									<a>
										<img id="$l["Vid"]"  src="$l["NailPath"]" width="160" height="130" /img>
										
										<div class="playBto"></div>
									</a>
								</div>
						</td>
					</tr> 
				</tbody>
			</table>
        <!-- Classification 1 end  -->
		</div>
		</div>
	</div>	
<div id='vedioLoad' style="display:none">$trans('Video_data_downloading')...(<span>0</span>%)</div>
<script language="javascript">
$$(document).ready(function(){

	$$('.wrapAuto').height($$(window).height() - 45);
	$$('.imageblock').height($$('.imageblock').height() + 90);
	
	$$(window).resize(function() {	
		$$('.wrapAuto').height($$(window).height() -45);
		$$('.imageblock').height('auto')
		$$('.imageblock').height($$('.imageblock').height() + 90);
	})

//搜索
	 $$("#videoSer").bind('keyup',function(){
		var keyVal = $$(this).val();
		if(keyVal == ''){
			$$("div.albumPic").each(function(){
				$$(this).show();
			})
		}else{
			if((/\.\*/).test(keyVal)) keyVal = keyVal.substring(0,keyVal.indexOf('.'));
			if((/\*\./).test(keyVal)){
				keyVal = keyVal.substring(keyVal.indexOf('.') + 1);
				//var reg = eval('/.*('+keyVal+')$$/');
				$$("div.albumPic").each(function(){
					var str = $$(this).attr('type');
					$$(this)[str.indexOf(keyVal) == -1 ? 'hide' : 'show']();
				})
			}else{
				$$("div.albumPic").each(function(){
					var str = $$(this).attr('name') + $$(this).attr('type');
					$$(this)[str.indexOf(keyVal) == -1 ? 'hide' : 'show']();
				})
			}
		}
	})
//添加
	 $$("#addVideo").click(function(){
		var data = {};
		data.file= [];
		$$.post("/Video/Add",data,function(){
		})
		setTimeout("AddVideos()",1000);
	 })	
//导出
	$$("#expo").click(function(){
		if(!delExpoFlag) return false;
		var data = {};
		data.indexes = [];
		$$(".select input:checked").each(function(){
			var index = $$(this).parents("div.albumPic").attr("vid");
			data.indexes.push(index);
		})
		$$.post("/Video/Export",data,function(){
		})
	 })
//删除
	$$("#delete").click(function(){
		if($$(this).hasClass("disabled")) return false;
		art.dialog({
			title: "$trans('PhotoView_Web_DELDLG_Title')",
			content:"$trans('VideoView_Web_DELDLG_Content')",
			okVal: "$trans('PB_BUTTON_OK')",
			cancelVal: "$trans('PBMainView_WEB_CANCEL')",
			icon: "question",
			lock: true,
			background:'#fff',
			opacity: 0.7,
			ok:function(){
				
				var data = {};
				data.indexes = [];
				$$(".select input:checked").each(function(){
					var index = $$(this).parents("div.albumPic").attr("vid");
					//$$("p").append(index)
					data.indexes.push(index);
				})
				
				$$.post("/Video/Del",data,function(){
					
				})
			},
			cancel: true
		})
		
	 })
//刷新
	$$("#refresh").click(function(){
		if(isconnectFlag == 0) return false; 
        if($$(this).hasClass("refreshing")) return false;
		$$(this).removeClass().addClass('refreshing');
		$$.post("/Video/Refresh",function(){
		})
		
		/*refrshdDia = art.dialog({
		title:	Video_data_refreshing,
		content: Video_data_downloading,
		icon: "loading",
		lock: true,
		background:'#fff',
		opacity: 0.7
		})*/
		
		
		setTimeout("LoadRefreshStatus()",1000);
		
		
	})
	
	$$(".playBto").click(function(){
	var index = $$(this).siblings("img").attr('id')
	var data = {};
	data.id = index;
	$$.post("/Video/Play",data,function(){
	})
	refrshdDia = art.dialog({
		title:	Video_data_downloading,
		content: $$("#vedioLoad")[0],
		icon: "loading",
		lock: true,
		background:'#fff',
		opacity: 0.7,
		close: function(){
			$$.post("/Video/Cancel",function(){
	});
		}
	})
	
	setTimeout("LoadPlayPercent()",1000);
	//LoadPlayPercent();
	
	})
	
})

function LoadPlayPercent(){
	//alert("into");
	$$.getJSON('/Video/Video/VideoPercent?now='+ new Date().getTime(), function(result){
		//alert(result.length);
		//$$("img#"  + result.Vid).attr("src",result.NailPath);
		//result = $$.ParseJSON
		//$$("p").append(result.length)
		/*
		$$.each(result, function(index,item){
			$$("img#"  + item.Vid).attr("src",item.NailPath);
		}
		)
		*/
		//$$("p").append(result.percent)
		if((result.percent < 1.00) && result.succ){
			//set percent
			//alert(result.percent);
			$$("#vedioLoad span").html(parseInt(result.percent * 100) );
			setTimeout("LoadPlayPercent()",1000);
			//refrshdDia({content:result.percent});
		}
		else if ( !result.succ){
			//set incorrect 
			refrshdDia.close();
			art.dialog({
				title:	Video_data_downloading,
				content: DownloadFailed,
				icon: "error",
				lock: true,
				background:'#fff',
				opacity: 0.7,
				cancel: true
			})
		}
		else{
			//set 100%
			$$("#vedioLoad span").html(100);
			$$("#vedioLoad span").html(0);
			refrshdDia.close();
		}

	})
}
function LoadRefreshStatus(){
	$$.getJSON('/Video/Video/RefreshStatus?now='+ new Date().getTime(), function(result){
		if(result.Refresh == 'finished') {
			//vlist = result.data;
			$$(this).removeClass().addClass('refresh');
			//refrshdDia.close();
			//window.location.reload();
			
		}
		else{
			setTimeout("LoadRefreshStatus()",1000);
		}
	})
}

function AddVideos(){
	$$.getJSON('/Video/Video/AddVideos?now='+ new Date().getTime(), function(result){
		if(result.AddVmItems == 'finished') {
			//vlist = result.data;
			refrshdDia.close();
			//window.location.reload();
			
		}
		else{
			setTimeout("AddVideos()",1000);
		}
	})
}

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