// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function switch_it(id)
{
  var content = document.getElementById("content" + id);
  var publication = document.getElementById("publication" + id);
  var a = document.getElementById("a" + id);

  if (publication.className == "selected")
  {
    Effect.BlindUp(content);
    publication.className = "";
    a.className = "";
  }
  else
  {
    Effect.BlindDown(content);
    publication.className = "selected";
    a.className = "selected";
  }
  return false;
}

function switch_news(id)
{
  var news = document.getElementById("news" + id);

  if (news.className == "news_selected")
  {
    news.className = "news";
  }
  else
  {
    news.className = "news_selected";
  }
  return false;
}

/**
* Generate a new password, which may then be copied to the form
* with suggestPasswordCopy().
*
* @param string the form name
*
* @return boolean always true
*/
function suggestPassword() {
	// restrict the password to just letters and numbers to avoid problems:
	// "editors and viewers regard the password as multiple words and
	// things like double click no longer work"
	var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ";
	var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
	var passwd = document.getElementById('generated_pw');
	passwd.value = '';

	for ( i = 0; i < passwordlength; i++ ) {
		passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
	}
	return passwd.value;
}
