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

function clear_on_click(field, label) 
{
	if (field.value == label)
	{
		field.value = "";
	}
}

function popup(mylink, windowname)
{
	if (! window.focus) return true;
	var href;
	if (typeof(mylink) == 'string')
	{
		href=mylink;
	} 
	else
	{
  	href=mylink.href;
	}
	window.open(href, windowname, 'width=400,height=500,scrollbars=yes');
	return false;
}

// When set to the onKeyDown event handler for a text field this will prevent anything
// other than numbers from being entered.
function numbers_only(evt)
{
  var cc = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
  if (cc>32 && (cc < 48 || cc > 57))
  {
    return false;
  }
  return true
}

function numbers_and_stuff(evt)
{
  var cc = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
  if (cc>32 && (cc < 48 || cc > 57)  && (cc < 96 || cc > 105) && 
       (cc < 32 || cc > 46) && 
       (cc!=32) && (cc!=109) && (cc!=189)  )
  {
    alert("Not allowing code "+cc);
    return false;
  }
  return true
}