$(document).ready(function(){
	load_group_info();	
});
function add_contact_grp(){
	//alert('inside function');
	var operation = 'insert_add_contact_grp';
	var grp_name = $('#grp_name').val();
	var grp_comments = $('#grp_comments').val();
	//var grp_status = $('#grp_status').val();
    
	var dataStr="grp_name="+grp_name+"&grp_comments="+grp_comments+"&operation="+operation;

	//alert(dataStr);
	if (grp_name == "") {
        alert("Enter group name");
        $('#grp_name').focus();
        return false;
    }
	else{
			
	$.ajax({
					url: 'module/general_notice/add_group_ajax.php',
					dataType: 'text',
					data: dataStr,                         
					type: 'POST',
					success: function(php_script_response){

						alert(php_script_response);
						load_group_info();
						
					}

		});

			clearInput();
	}
}
function show_edit_contact_grp(id){
	var datastr="_id="+id;
	//alert(datastr);
	$("#edit_contact_grp").load("module/general_notice/edit_conatct_grp.php",datastr);
	
}
function perform_update_conatact(){
	var operation='edit_contact_grp';
	var selected_id_to_edit = $("#selected_id_to_edit").val();
	var edit_grp_name = $("#edit_phn_grp_name").val();
	var edit_comments = $("#edit_grp_comments").val();
	var contact_status = $('#edit_grp_status').val();
	//alert(file_path);
	var dataStr="contact_status="+contact_status+"&selected_id_to_edit="+selected_id_to_edit+"&operation="+operation
	+"&edit_grp_name="+edit_grp_name+"&edit_comments="+edit_comments;

	//alert(dataStr);

	$.ajax({
		type:"post",
		url:"module/general_notice/add_group_ajax.php",
		data:dataStr ,
		success:function(st){
				alert(st);
				load_group_info();
				//edit_web_banner_to_show();
		}
	});
}
function delete_conatact_grp(id){
	var operation = 'delete_conatact_grp';
	var datastr="_id="+id+"&operation="+operation;
	//alert(datastr);
	//$('#form_data').css('display','none');
	  if (confirm("Are you sure want to delete The selected Row?"))
	  {
		 $.ajax({
				type:"post",
				url:"module/general_notice/add_group_ajax.php",
				data:datastr ,
				success:function(st){
					 alert(st);
					 load_group_info();
				
				}
				
			}); 		
	  }
	
}
$('#grp_name').keypress(function(e){
	//alert('inside keypress function');
	if(e.which == 13){
		
		//var contact_no = $("#contact_no").val();
		//var name = $("#name").val();
		//var contact_email =  $("#contact_email").val();
		
		$("#grp_comments").focus();
	}
	
});
$('#grp_comments').keypress(function(e){
	//alert('inside keypress function');
	if(e.which == 13){
		
		$("#grp_name").focus();
		add_contact_grp();
	}
	
});
function load_group_info(){
	$("#group_info").load("module/general_notice/add_contact_group_datatable.php");	

}