// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

$(document).ajaxSend(function(event, request, settings) {
  if (typeof(AUTH_TOKEN) == "undefined") return;
  // settings.data is a serialized string like "foo=bar&baz=boink" (or null)
  settings.data = settings.data || "";
  settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});

jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} 
})

function showAjax() {
	$("#ajax_loader").show()
}         

$(document).ready(function() {	
  
	

  $(".progress_bar").each(function(e) {
    
    pc = $(this).html().replace("%","")
    try {
			$(this).progressbar({ value: pc})
    } catch(e) {}
  })

	$("#period_copy input").click(function(e) {
		if( $(this).attr("id") == "period_copy_subjects" ) {
			if( !$(this).attr("checked") ) $("#period_copy_comments").attr("checked","");
		}
		
		if( $(this).attr("id") == "period_copy_groups" ) {
			if( !$(this).attr("checked") ) {
				$("#period_copy_comments").attr("checked","");
				$("#period_copy_students").attr("checked","");
			}
		}
		
		if( $(this).attr("id") == "period_copy_comments" ) {
			if( $(this).attr("checked") ) { 
				$("#period_copy_groups").attr("checked","checked");
				$("#period_copy_subjects").attr("checked","checked");
			}
		}
		
		if( $(this).attr("id") == "period_copy_students" ) {
			if( $(this).attr("checked") ) { 
				$("#period_copy_groups").attr("checked","checked");
			}
		}
		
		
	})

   
});


function inappropriate(comment) { 
	$("#comment_search_" + comment).remove();
	$.get("/comments/inappropriate/" + comment);
}

