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

Event.observe(window, 'load', function() {
	// don't grab focus if the page is a content page from the CMS
	var cms = $A(document.getElementsByTagName('meta')).find(function(e) {
		return e.name == 'Generator' && e.content == 'CMS';
	});
  var e = $A(document.getElementsByTagName('*')).find(function(e) {
    return (e.tagName.toUpperCase() == 'INPUT' && (e.type == 'text' || e.type == 'password'))
        || e.tagName.toUpperCase() == 'TEXTAREA' || e.tagName.toUpperCase() == 'SELECT';
  });
  if (!cms && e) { 
	  e.focus();
	  e.select();
	}
});

function noenter(event) {
	if(event.keyCode == 13) {
		event.stop();
	}
};

function toggleComment(comment) {
	var container = $(comment + '-comment_form_container');
	container.toggle(); 
	if(container.visible()) {
		$(comment + '-comment_link').update('Cancel');
	}
	else {
		$(comment + '-comment_link').update('Comment');		
	}
};