addEvent(window, "load", attach_make_title_shortcut);
addEvent(window, "load", attach_password_rules);


sfHover = function() {  
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



function attach_make_title_shortcut() {
  if (document.getElementById && document.getElementById('title') && document.getElementById('title_shortcut')) {
    document.getElementById('title').onchange = make_title_shortcut;
    document.getElementById('title').onblur = make_title_shortcut;
  }
}

function make_title_shortcut() {
  var thetitle = document.getElementById('title').value.toLowerCase();
  var thetitle_shortcut = thetitle.replace(/ /g, '_');
	var validchars="abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var thischar = '';
	var thefinal_shortcut = '';
	for (i=0;i<thetitle_shortcut.length;i++) {
		thischar = thetitle_shortcut.charAt(i);
		if (validchars.indexOf(thischar) != -1) {
			thefinal_shortcut += thischar;
		}
	}
  document.getElementById('title_shortcut').value = thefinal_shortcut;
}



function attach_password_rules() {
  if (document.getElementById && document.getElementsByTagName) {
		var a=document.getElementsByTagName('a');
		for (x=0;x<a.length;x++) {
			if (a[x].className=='form_rules') {
				a[x].onclick=function() {
					window.open (this.getAttribute('href'), "rules_new_window", "status=1,toolbar=1,resizable=1, height=300, width=400");
					return false;					
				}
			}
		}
	}
}