// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function popup(url,width,height) {
  window.open(url,'popup','width='+width+',height='+height+',scrollbars=yes,resizable=yes,toolbar=no,directories=no,menubar=no,status=no,left=100,top=100');
  return false;
}

function dynamic_character_count(element_to_observe, count_element, maxchars){
	var xlen = 0;
	var text = document.getElementById(element_to_observe).value;
	var txt1 = text;
	txt1 = txt1.replace(/[\\\/\"\']/g, "ZyXw"); // the four characters to be escaped count as two
	x = txt1.match(/ZyXw/g);
	if (x) {
		xlen = x.length;  // how many?
	}
	var remaining = maxchars - text.length - xlen;
	document.getElementById(count_element).innerHTML = remaining;
}