// JavaScript Document

//functions of java script
/*

$(document).ready(function() {
	
	$('#notifications').addClass('visible');
    
});

*/

/* check all function, select all  */

$(document).ready(function() {
     $('#selecctall').click(function(event) {  //on click 
         if(this.checked) { // check select status
             $('.checkbox1').each(function() { //loop through each checkbox
                 this.checked = true;  //select all checkboxes with class "checkbox1"               
             });
         }else{
             $('.checkbox1').each(function() { //loop through each checkbox
                 this.checked = false; //deselect all checkboxes with class "checkbox1"                       
             });         
         }
     });
     
});

/*dialog box delete*/
jQuery(function($) {
	
	
	
	
	////////////////////////////////// check all ////////////////////////////////////////////
	$("form input[id='check_all']").click(function() { // triggred check
		
		var inputs = $("form input[type='checkbox']"); // get the checkbox
		
		for(var i = 0; i < inputs.length; i++) { // count input tag in the form 
			var type = inputs[i].getAttribute("type"); //  get the type attribute
				if(type == " functioncheckbox") {
					if(this.checked) {
						inputs[i].checked = true; // checked
					} else {
						inputs[i].checked = false; // unchecked
				 	 }
				} 
		}
	});
	
	
	// delete user
	$("form input[id='delete_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a user(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these users?");	
		} else {
			return confirm("Are you sure you want to delete these users?");	
		  }		
	});
	
	
		
	/* //////////////////////////////////////////// Update user function //////////////////////////*/

	$("form input[id='edit_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a user to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// Block user function //////////////////////////*/

	$("form input[id='block_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To block a user, Please select a user.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to block.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// UNBlock user function //////////////////////////*/

	$("form input[id='unblock_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To unblock a user, Please select a user.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to unblock.");
			return false;
		}
	
		
		
	});
	
	

	
	//publish users
	$("form input[id='publish_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish users
	$("form input[id='unpublish_u']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	

	
	// restore selected users
	$("form input[id='restore_t']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a user(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these users?");	
		} else {
			return confirm("Are you sure you want to restore these users?");	
		  }		
	});
	
	
	
	
	/// restore deleted users
	$(".restore").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 var trash_refresh = $('.trash_refresh');// collect the class of refresh
		 
	    if(confirm("Do you  really want to restore?"))
	    {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_users.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
		
	
	
	
	
	/*///////////////////////////////////////edit roles *///////////////////////////////////////*/
	$("form input[id='edit_rol']").click(function() {  // triggred submit
		
		var count_checked = $("[name='role[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete roles*//////////////
	$("form input[id='delete_rol']").click(function() {  // triggred submit
		
		var count_checked = $("[name='role[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	
	//publish roles
	$("form input[id='publish_rol']").click(function() {  // triggred submit
		
		var count_checked = $("[name='role[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish roles
	$("form input[id='unpublish_rol']").click(function() {  // triggred submit
		
		var count_checked = $("[name='role[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	// restore selected roles
	$("form input[id='restore_rol']").click(function() {  // triggred submit
		
		var count_checked = $("[name='role[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a role(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	
	
	/// restore deleted roles
	$(".restore_role").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_roles.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_role").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
	
	
	
	/*///////////////////////////////////////edit user groups *///////////////////////////////////////*/
	$("form input[id='edit_ug']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user_group[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete user groups*//////////////
	$("form input[id='delete_ug']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user_group[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	
		
	//publish user groups
	$("form input[id='publish_ug']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user_group[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish user_groups
	$("form input[id='unpublish_ug']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user_group[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	// restore selected groups
	$("form input[id='restore_ug']").click(function() {  // triggred submit
		
		var count_checked = $("[name='user_group[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a user group(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	
	
	/// restore deleted user group
	$(".restore_user_group").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_user_groups.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_user_group").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
	///////////////////////////////// end of user groups //////////////////////////////////////////////	
	



///////////staff module starts here
	// delete staff
	$('#delete_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a staff to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these staff?");	
		} else {
			return confirm("Are you sure you want to delete these staff?");	
		  }		
	});
	
	
		
	/* //////////////////////////////////////////// Update staff function //////////////////////////*/

	$('#edit_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a staff to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// Block staff function //////////////////////////*/

	$('#block_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To block a staff, Please select a staff.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to block.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// UNBlock staff function //////////////////////////*/

	$('#unblock_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To unblock a staff, Please select a staff.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to unblock.");
			return false;
		}
	
		
		
	});
	
	

	
	//publish staffs
	$('#publish_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish staff
	$('#unpublish_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	

	
	// restore selected staffs
	$('#restore_s').click(function() {  // triggred submit
		
		var count_checked = $("[name='staff[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a staff to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these staff?");	
		} else {
			return confirm("Are you sure you want to restore these staff?");	
		  }		
	});
	
	
	
	
	/// restore deleted staff
	$(".restore").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 var trash_refresh = $('.trash_refresh');// collect the class of refresh
		 
	    if(confirm("Do you  really want to restore?"))
	    {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_staffs.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});



	/////////////////////////////////////////  begin news ///////////////////////////////////////
	/*///////////////////////////////////////edit news*///////////////////////////////////////*/
	$("form input[id='edit_n']").click(function() {  // triggred submit
		
		var count_checked = $("[name='news[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select an item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete news*//////////////
	$("form input[id='delete_n']").click(function() {  // triggred submit
		
		var count_checked = $("[name='news[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	// restore selected news
	$("form input[id='restore_n']").click(function() {  // triggred submit
		
		var count_checked = $("[name='news[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish news
	$("form input[id='publish_n']").click(function() {  // triggred submit
		
		var count_checked = $("[name='news[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish news
	$("form input[id='unpublish_n']").click(function() {  // triggred submit
		
		var count_checked = $("[name='news[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted news
	$(".restore_news").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_news.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_news").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		/////////////////////////////////////////////////// end news ///////////////////////////////////////
	
	////////////////////////////////////////////// begin events ///////////////////////////////////////////
	/*///////////////////////////////////////edit events *///////////////////////////////////////*/
	$("form input[id='edit_ev']").click(function() {  // triggred submit
		
		var count_checked = $("[name='event[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select an item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete events*//////////////
	$("form input[id='delete_ev']").click(function() {  // triggred submit
		
		var count_checked = $("[name='event[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	// restore selected events
	$("form input[id='restore_ev']").click(function() {  // triggred submit
		
		var count_checked = $("[name='event[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish events
	$("form input[id='publish_ev']").click(function() {  // triggred submit
		
		var count_checked = $("[name='event[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish events
	$("form input[id='unpublish_ev']").click(function() {  // triggred submit
		
		var count_checked = $("[name='event[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted events
	$(".restore_event").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_events.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_event").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
	////////////////////////////////////////////// end events ////////////////////////////////////////////////
	
	
	////////////////////////////// begin pictures ///////////////////////////////////////////////
	/*///////////////////////////////////////edit pictures *///////////////////////////////////////*/
	$("form input[id='edit_pic']").click(function() {  // triggred submit
		
		var count_checked = $("[name='picture[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select an item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete pictures*//////////////
	$("form input[id='delete_pic']").click(function() {  // triggred submit
		
		var count_checked = $("[name='picture[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	// restore selected pictures
	$("form input[id='restore_pic']").click(function() {  // triggred submit
		
		var count_checked = $("[name='picture[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish pictures
	$("form input[id='publish_pic']").click(function() {  // triggred submit
		
		var count_checked = $("[name='picture[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish pictures
	$("form input[id='unpublish_pic']").click(function() {  // triggred submit
		
		var count_checked = $("[name='picture[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted pictures
	$(".restore_picture").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_pictures.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_picture").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
		////////////////////////////////////// end of pic /////////////////////////////////////////////
	

	
	/*///////////////////////////////////////edit videos *///////////////////////////////////////*/
	$("form input[id='edit_vid']").click(function() {  // triggred submit
		
		var count_checked = $("[name='video[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select an item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete videos*//////////////
	$("form input[id='delete_vid']").click(function() {  // triggred submit
		
		var count_checked = $("[name='video[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	// restore selected videos
	$("form input[id='restore_vid']").click(function() {  // triggred submit
		
		var count_checked = $("[name='video[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish video
	$("form input[id='publish_vid']").click(function() {  // triggred submit
		
		var count_checked = $("[name='video[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish vid
	$("form input[id='unpublish_vid']").click(function() {  // triggred submit
		
		var count_checked = $("[name='video[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted videos
	$(".restore_video").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_videos.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_video").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
		////////////////////////////////////////////// end of videos ///////////////////////////////////////////////////////
	

	/*///////////////////////////////////////edit faculties *///////////////////////////////////////*/
	$("form input[id='edit_fac']").click(function() {  // triggred submit
		
		var count_checked = $("[name='faculty[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete faculties*//////////////
	$("form input[id='delete_fac']").click(function() {  // triggred submit
		
		var count_checked = $("[name='faculty[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	// restore selected faculties
	$("form input[id='restore_fac']").click(function() {  // triggred submit
		
		var count_checked = $("[name='faculty[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish fac
	$("form input[id='publish_fac']").click(function() {  // triggred submit
		
		var count_checked = $("[name='faculty[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish
	$("form input[id='unpublish_fac']").click(function() {  // triggred submit
		
		var count_checked = $("[name='faculty[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted faculties
	$(".restore_faculty").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_faculties.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_faculty").fadeOut(1000);
				location.reload();
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
		
 ///////////////////////////// end of faculty functions ///////////////////////////////////////////////////
	
	////////////////////////////// begin departments functions /////////////////////////////////////////////
	/*///////////////////////////////////////edit departments *///////////////////////////////////////*/
	$("form input[id='edit_dp']").click(function() {  // triggred submit
		
		var count_checked = $("[name='department[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select an item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete departments*//////////////
	$("form input[id='delete_dp']").click(function() {  // triggred submit
		
		var count_checked = $("[name='department[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	
	
	// restore selected departments
	$("form input[id='restore_dp']").click(function() {  // triggred submit
		
		var count_checked = $("[name='department[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish dep
	$("form input[id='publish_dp']").click(function() {  // triggred submit
		
		var count_checked = $("[name='department[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish department
	$("form input[id='unpublish_dp']").click(function() {  // triggred submit
		
		var count_checked = $("[name='department[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted departments
	$(".restore_department").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_departments.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_department").text('Please Wait..').fadeTo(1000,1, function(){
				location.reload();
					});
				
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		//////////////////////////////////// end of departments functions /////////////////////////////////////////////////////

	
	/*///////////////////////////////////////edit states *///////////////////////////////////////*/
	$("form input[id='edit_st']").click(function() {  // triggred submit
		
		var count_checked = $("[name='state[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one item to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete stat *//////////////
	$("form input[id='delete_st']").click(function() {  // triggred submit
		
		var count_checked = $("[name='state[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	/*///////////////////////////////////////edit lgs *///////////////////////////////////////*/
	$("form input[id='edit_lga']").click(function() {  // triggred submit
		
		var count_checked = $("[name='lga[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	
	
	
	
	/* ///////////////////////////////////////// delete lgas *//////////////
	$("form input[id='delete_lga']").click(function() {  // triggred submit
		
		var count_checked = $("[name='lga[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	/////////////////////////////////// begin courses ////////////////////////////////
	/*///////////////////////////////////////edit courses *///////////////////////////////////////*/
	$("form input[id='edit_cs']").click(function() {  // triggred submit
		
		var count_checked = $("[name='course[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	
	
	
	
	/* ///////////////////////////////////////// delete course *//////////////
	$("form input[id='delete_cs']").click(function() {  // triggred submit
		
		var count_checked = $("[name='course[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
	
	
	
	
	// restore selected courses
	$("form input[id='restore_cs']").click(function() {  // triggred submit
		
		var count_checked = $("[name='course[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish course
	$("form input[id='publish_cs']").click(function() {  // triggred submit
		
		var count_checked = $("[name='course[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish course
	$("form input[id='unpublish_cs']").click(function() {  // triggred submit
		
		var count_checked = $("[name='course[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted courses
	$(".restore_course").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_courses.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_course").text('Please Wait..').fadeTo(1000,1, function(){
				location.reload();
					});
				
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
		////////////////////////////// end of courses////////////////////////////////////
	
	
	
	
	
	//////////////////////////// begin subject ///////////////////////////////////////////////////
	
	//////////////////////////////////////edit subject *///////////////////////////////////////*/
	$("form input[id='edit_sj']").click(function() {  // triggred submit
		
		var count_checked = $("[name='subject[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	/* ///////////////////////////////////////// delete subject *//////////////
	$("form input[id='delete_sj']").click(function() {  // triggred submit
		
		var count_checked = $("[name='subject[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
		// restore selected subjects
	$("form input[id='restore_sj']").click(function() {  // triggred submit
		
		var count_checked = $("[name='subject[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these items?");	
		} else {
			return confirm("Are you sure you want to restore these items?");	
		  }		
	});
	
	
	//publish subjects
	$("form input[id='publish_sj']").click(function() {  // triggred submit
		
		var count_checked = $("[name='subject[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to publish.");
			return false;
		} 
		
	});
	
	//unpublish subjects
	$("form input[id='unpublish_sj']").click(function() {  // triggred submit
		
		var count_checked = $("[name='subject[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select a item(s) to unpublish.");
			return false;
		} 
		
	});
	
	
	
	
	
	/// restore deleted subjects
	$(".restore_subject").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_subjects.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_subject").text('Please Wait..').fadeTo(1000,1, function(){
				location.reload();
					});
				
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		///////////////////////////////////// end of subjects //////////////////////////////////////////////////
		
		
		
		///////////////////////////////////////////////  begin ip filter //////////////////////////////////////////
		
		// delete ip filter
	$("form input[id='delete_ip']").click(function() {  // triggred submit
		
		var count_checked = $("[name='ip[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
		
	/* //////////////////////////////////////////// Update ip function //////////////////////////*/

	$("form input[id='edit_ip']").click(function() {  // triggred submit
		
		var count_checked = $("[name='ip[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item(s) to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// Block items function //////////////////////////*/

	$("form input[id='block_ip']").click(function() {  // triggred submit
		
		var count_checked = $("[name='ip[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To block, Please select an item.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to block.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// UNBlock ip function //////////////////////////*/

	$("form input[id='unblock_ip']").click(function() {  // triggred submit
		
		var count_checked = $("[name='ip[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To unblock, Please select Item.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to unblock.");
			return false;
		}
	
		
		
	});
	
	
	
	// restore selected items
	$("form input[id='restore_ip']").click(function() {  // triggred submit
		
		var count_checked = $("[name='ip[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these item(s)?");	
		} else {
			return confirm("Are you sure you want to restore these item(s)?");	
		  }		
	});
	
	
	
	
	/// restore deleted ips
	$(".restore_ip").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_ips.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_ip").text('Please Wait..').fadeTo(1000,1, function(){
				location.reload();
					});
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
	//////////////////////////////////////////////////////// ip ends //////////////////////////////////////////////////////
	
	//////////////////////////////////////////////////////// begin control box /////////////////////////////////////////////
	
		// delete control box filter
	$("form input[id='delete_control_box']").click(function() {  // triggred submit
		
		var count_checked = $("[name='control_box[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item(s) to delete.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to delete these item(s)?");	
		} else {
			return confirm("Are you sure you want to delete these item(s)?");	
		  }		
	});
	
	
		
	/* //////////////////////////////////////////// Update control_box function //////////////////////////*/

	$("form input[id='edit_control_box']").click(function() {  // triggred submit
		
		var count_checked = $("[name='control_box[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select item(s) to edit.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to edit.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// Block items function //////////////////////////*/

	$("form input[id='block_control_box']").click(function() {  // triggred submit
		
		var count_checked = $("[name='control_box[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To deactivate, Please select an item.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to block.");
			return false;
		}
	
		
		
	});
	
	
	
	/* //////////////////////////////////////////// UNBlock ip function //////////////////////////*/

	$("form input[id='unblock_control_box']").click(function() {  // triggred submit
		
		var count_checked = $("[name='control_box[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("To unblock, Please select Item.");
			return false;
		} 
		
		if(count_checked > 1)
		{
			alert("Please choose only one to unblock.");
			return false;
		}
	
		
		
	});
	
	
	
	// restore selected items
	$("form input[id='restore_control_box']").click(function() {  // triggred submit
		
		var count_checked = $("[name='control_box[]']:checked").length; // count the checked
		if(count_checked == 0) {
			alert("Please select  item(s) to restore.");
			return false;
		} 
		if(count_checked == 1) {
			return confirm("Are you sure you want to restore these item(s)?");	
		} else {
			return confirm("Are you sure you want to restore these item(s)?");	
		  }		
	});
	
	
	
	
	/// restore deleted control_boxs
	$(".restore_control_box").click(function(){
		
		
		 var element = $(this); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		
		 
	    if(confirm("Do you  really want to restore?"))
	   {	 
	   	 $.ajax({
		 type: "POST",
		 url: "tab_restore_deleted_control_boxs.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				$('#message').html(html);
				$(".restore_control_box").text('Please Wait..').fadeTo(1000,1, function(){
				location.reload();
					});
				
				
		 
		 
		 	}// end success
		 })
	   }
		   
  	return false; 
		
		
		});
		
     //////////////////////////////////////////// end control box /////////////////////////////////////////////////////////
	 
	 
	 
	 ////////////////////////////////////////// validation for password //////////////////////////////////////////////////
	 
	 ///////////// for password
	 $('.error_msg_old_pw').hide(); // hide old password error first
	 $('.error_msg_new_pw').hide(); // hid new password error first
	 $('.error_msg_cm_pw').hide(); // hide confirm error password first
	 $('.change_password').click(function(event){ // then if update is clicked
		 
	
		 
		 var old_password = $('#old_password').val();
		 var old_password_len = old_password.length; // collect the lenght of the pw
		 
		 var new_password = $('#new_password').val();
		 var new_password_len = new_password.length; //collect tghe legnth of the npw
		 
		 var confirm_new_password = $('#confirm_new_password').val();
		 
		 var data = 'old_password='+old_password+'&new_password='+new_password;  // collect all the dat and pass to php file
			 
		 
		 
		
		 
		 if(old_password_len < 1)
		 {
			 $('.error_msg_old_pw').show();
			
		 }
		 else if(new_password_len < 1)
		 {
			 $('.error_msg_new_pw').show();
			 
		 }
		 else if(new_password != confirm_new_password)
		 {
			 $('.error_msg_cm_pw').show();

			 
		 }
		 else
		 {
		 
		 
			 
			 if(confirm("Do you  really want to update the password ?"))
			 {
			   $("#flash").show();
			   $("#flash").fadeIn(400).html('Loading..');
			   
			   
			   $.ajax({
			   type: "POST",
			   url: "tab_update_users_password.php", 
			   data: data,
			   cache: true,
			   success:function(html)
				  {
					  
						
					  $("#flash").hide();
					  $('#feedback_message').html(html);
					  
					  /*$(".restore").fadeOut(1000);
					  location.reload();
					  */
					  
			   
			   
				  }// end success
			   })
		   }
			   
		   return false;
		   
		 }//end of else
		 
		 event.preventDefault();
		 
		 
		 
		 
		 
	 });
	 
	 
	 
	 
	 /////////////////////////////////////// end of password validation //////////////////////////////////////////////////
	
	
	 /************** this is for data table ****************** 
	 ** it activates the table to be allowe to use  ************
     *********************** activate datatables ----*/
     $('#example').DataTable({
		 
		responsive: true, // for table responsiveness
		
		
		 "pageLength": 50, //default page lenght
		
		
		
		"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], //for showing all the rows
		
		stateSave: true, // for saving a aprticular state in tables position
		
		
		
		 
	});
	
	

	 
	 /**********************  this he function that initiates the tooltip **************
	 ** it allows tooltip to show *****************************************************/
	 	
  	$('[data-toggle="tooltip"]').tooltip();
	
	
	
	
	/********************************* this is the finction for pop over ***********************/
	$('[data-toggle="popover"]').popover();
	
	
	
	/****************************** live table edit for nce ***********************************/
	 $.fn.editable.defaults.mode = 'popup';
        $('.xedit').editable();		
		$(document).on('click','.editable-submit',function(){
			var key = $(this).closest('.editable-container').prev().attr('key');
	  var x = $(this).closest('.editable-container').prev().attr('id');
	  var y = $('.input-sm-m').val();
	  var z = $(this).closest('.editable-container').prev().text(y);
	  
				  $.ajax({
					  url: "live_table_edit/process.php?ssid="+x+"&ssdata="+y+'&key='+key,
					  type: 'GET',
					  success: function(s){
						  if(s == 'status'){
						  $(z).html(y);}
						  if(s == 'error') {
						  alert('Error Processing your Request!');}
					  },
					  error: function(e){
						  alert('Error Processing your Request!!');
					  }
				  });
			  });





/****************************** live table edit for prence  ***********************************/
	 // $.fn.editable.defaults.mode = 'popup';
  //       $('.xedit_prence').editable();		
		// $(document).on('click','.editable-submit',function(){
		// 	var key = $(this).closest('.editable-container').prev().attr('key');
	 //  var x = $(this).closest('.editable-container').prev().attr('id');
	 //  var y = $('.input-sm-m').val();
	 //  var z = $(this).closest('.editable-container').prev().text(y);
	  
		// 		  $.ajax({
		// 			  url: "live_table_edit/process_prence.php?ssid="+x+"&ssdata="+y+'&key='+key,
		// 			  type: 'GET',
		// 			  success: function(s){
		// 				  if(s == 'status'){
		// 				  $(z).html(y);}
		// 				  if(s == 'error') {
		// 				  alert('Error Processing your Request!');}
		// 			  },
		// 			  error: function(e){
		// 				  alert('Error Processing your Request!!');
		// 			  }
		// 		  });
		// 	  });
	
		
		
		// //reload column or table
		 //var refreshId = setInterval(function() 
//		 {
//		   $('#timeval').load('show_grade.php');
//		 }, 1000);
		
		
		
		
		
		function get_score()
		{
		 var element = $('.get-score'); 
		 var id = element.attr("id"); 
    	 var info = 'id=' + id; 
		 $.ajax({
		 type: "POST",
		 url: "show_grade.php", 
	 	 data:info,
		 success:function(html)
		 	{
				
				
				  $('#timeval').html(html);
				 // $('#timeval').load('show_grade.php');
				//$(".restore_control_box").text('Please Wait..').fadeTo(1000,1, function(){
				//location.reload();
					//});
				
				
		 
		 
		 	}// end success
		 })
		 
		 return false;
	    }
		
		
		//then start refereshing 
		get_score();
		
		
		 
		
		/// store a reference to the datatable
		 // var $dataTable = $("#example").dataTable({ /* Your settings */ });
//		  
//		  // in the AJAX success:
//		  success: function(data) {
//			  $dataTable.fnDraw();
//		  }
			 
}); // jquery end









//print function
	//function for printing a page
function doit(){
if (!window.print){
alert("You need NS4.x to use this print button!")
return
}
window.print()
}	
        
    
