// JavaScript Document
function checkAll11(){
	var pcount = document.video.video_count.value;
	for (i = 0; i < pcount; i++) {
		eval('document.video.delete'+i+'.checked = true') ;
	}
}
function unCheckAll11(){
	var pcount = document.video.video_count.value;
	for (i = 0; i < pcount; i++) {
		eval('document.video.delete'+i+'.checked = false') ;
	}
}
function dropdown_select_search(siteUrl){
	var action=document.getElementById('video_order').value;
	
	document.forms.video1.action = siteUrl+"videos/display_video_search";
	document.forms.video1.submit();
}

function actionvidcatBulk(siteUrl,category){
		
		var action=document.getElementById('bulk').value;
		var cate = document.cat_list.elements["cat[]"];
		var chkd=0;
		for(i=0;i<cate.length;i++)
			if(cate[i].checked)
			 			chkd=1;
			
	
		if(action !=0){
				if(chkd==1){
					if (confirm(MSG_DELETE_CONFIRMATION)) {
						document.forms.cat_list.action = siteUrl+"videos/bulk_delete_cat/"+action;
						document.forms.cat_list.submit();
					}
				} else {
					show_system_message("Please select atleast one category");
					return false;
				}
				
		}else{
			show_system_message(MSG_ACTION_SELECT);
			return false;
			}
	   	
}
function comment_video(siteUrl){
	//alert("afsaf");
	var post_id=$('input#post_id').val();
	var comment=$('textarea#comment').val();
	var info = 'video_id='+post_id+'&comment='+comment;
	//alert(info);
	$.ajax({
	type: "POST",
	url: siteUrl+"videos/insert_comment",
	data: info,
	success: function(data) {
  	//alert(data);
	 $('#com_list').html(data)  ; 
	    $('#message_div').html("<div id='msg_div'>"+MSG_ADD.replace('\%S\%', 'this item')+"</div>");
		$('#msg_div').css('background-color','#9C6').animate({ opacity: "show" }, "slow");
		document.post_comment.comment.value="";
		
		$('#one').hide() ;
          }
	});
	return false;
}
function delete_video(siteUrl){	
	//alert(siteUrl);
	
	var pcount = document.video.video_count.value;
	var check=0;
	var allids = "";
	
	for (i = 0; i < pcount; i++) {
		
		if(eval('document.video.delete'+i+'.checked == true')) {
			
			if(allids == ""){ check++;
				allids += eval('document.video.delete'+i+'.value');
			}
			else{
				check++;
				allids += ","+eval('document.video.delete'+i+'.value');
				}
				//alert(allids);
		}
	}//end for
		//alert(allids);
		if(check>0){
  if (confirm(MSG_DELETE_CONFIRMATION.replace('\%S\%', 'video'))) {	 
					document.forms.video.ids.value = allids;
					document.forms.video.action = siteUrl+"videos/delete_video/";
					document.forms.video.submit();
				
			}
		} else {
			show_system_message(MSG_DELETE_SELECT.replace('record', 'video'));
		}
}

function publishClick(siteUrl){
	
	var to=document.getElementById('list2');
	var to2=document.getElementById('list4');
	var read_array=new Array();
	var write_array=new Array();
	for(var y=0;y<to.options.length;y++){
		var p=to.options[y];
		read_array[y]=p.value;
		}
			if(!Array.indexOf){
			  Array.prototype.indexOf = function(obj){
			   for(var i=0; i<this.length; i++){
				if(this[i]==obj){
				 return i;
				}
			   }
			   return -1;
			  }
			}
		if(read_array.indexOf('Y')==-1){
					if(read_array==""){
						read_array[0]="NO";
						//alert(read_array);
					} else{
						read_array[to.options.length]='N'
					}
		}
		$('#read_list').val(read_array);
		for(var y=0;y<to2.options.length;y++){
		var p=to2.options[y];
		write_array[y]=p.value;
		}
			if(write_array.indexOf('Y')==-1){
					if(write_array==""){
					write_array[0]="NO";
					} else{
						write_array[to2.options.length]='N'
					}
		}
		$('#write_list').val(write_array);
	var update=document.getElementById('update');
	var myField = document.getElementById('1');
}

function confirmationBox(){
	return confirm(MSG_DELETE_CONFIRMATION.replace('\%S\%', 'video'));
}

function openBox(d){
	var ob=document.getElementById(d);
	ob.style.display=(ob.style.display=='none')?'block':'none';
}
	
