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

function show_div_on_checkbox_setting(div_id, checkbox_id, value_for_shown){
	var checkbox = $(checkbox_id);
	var div_element = $(div_id);
	if (checkbox.checked != value_for_shown) {
		div_element.hide();
	}
	checkbox.observe('change', function(event) {
		if (checkbox.checked != value_for_shown)
			div_element.fade();
		else
			div_element.appear();
	})
}

function grades_compute_total(target_id, field_ids) {
	var total = 0;
	for (var i = 0; i < field_ids.length; i++) {
		var fval = $(field_ids[i]).value;
		if (fval != "") {
			total += parseFloat(fval);
		}
	}
	$(target_id).update(total + '')
}	

function submission_validation_update_visiblity(id_suffix) {
	var vtype = $('deliverable_validation_type_' + id_suffix).value;
	var v_rpkg = $('deliverable_validation_rpkg_' + id_suffix);
	var v_upkg = $('deliverable_validation_upkg_' + id_suffix);
	var v_rupkg = $('deliverable_validation_rupkg_' + id_suffix);
	var v_bin = $('deliverable_validation_bin_' + id_suffix);
	
	v_rpkg.hide();
	v_upkg.hide();
	v_rupkg.hide();
	v_bin.hide();
	if (vtype == 'RemoteScriptValidation') {
		v_rpkg.show();
		v_rupkg.show();
	}
	else if (vtype == 'UploadedScriptValidation') {
		v_upkg.show();
		v_rupkg.show();
	}
	else if (vtype == 'ProcValidation') {
		v_bin.show();
	}
}

function submission_packager_update_fe(target_elem, base, prefix_elem, suffix_elem) {
	var fprefix = $(prefix_elem).value;
	var fsuffix = $(suffix_elem).value;
	$(target_elem).update(fprefix + base + fsuffix);
}

@@ -1624,8 +1624,803 @@
 fix);%0A%7D%0A
+%0A// Windows renders custom fonts very badly, so we disable them.%0Aif (/win/i.test(navigator.platform)) %7B%0A  Event.observe(window, 'load', function() %7B%0A    if (!document.styleSheets) %7B return; %7D%0A    %0A    for (var i = 0; i %3C document.styleSheets.length; i++) %7B%0A      var sheet = document.styleSheets%5Bi%5D;%0A      var rules = sheet.cssRules %7C%7C sheet.rules;%0A      var fontRules = %5B%5D;%0A      for (var j = 0; j %3C rules.length; j++) %7B%0A        var rule = rules%5Bj%5D;%0A        if (rule.type == 5) %7B  // @font-face rule%0A          fontRules.push(j);%0A        %7D%0A      %7D%0A      for (var j = fontRules.length - 1; j %3E= 0; j--) %7B%0A        if (sheet.deleteRule) %7B%0A          sheet.deleteRule(fontRules%5Bj%5D);%0A        %7D else if (sheet.removeRule) %7B%0A          sheet.removeRule(fontRules%5Bj%5D);%0A        %7D%0A      %7D%0A    %7D  %0A  %7D);  %0A%7D%0A

Remove @font-face directives on Windows so that the display sucks less.