

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function show_or_hide_rules() {

	body_tags = document.getElementsByTagName("body");
	body_class = body_tags[0].getAttribute("class");

	if (body_class == "lined") {
		body_tags[0].setAttribute("class", "");				
	} else {
		body_tags[0].setAttribute("class", "lined");		
	}	

}


function show_open_id_fields() {

	standard_fields_div = document.getElementById("standard_fields");
	standard_fields_div.setAttribute("class", "");
	
	
	open_id_div = document.getElementById("open_id_fields");
	open_id_div.setAttribute("class", "active");
}

function show_standard_fields() {

	open_id_div = document.getElementById("open_id_fields");
	open_id_div.setAttribute("class", "");


	standard_fields_div = document.getElementById("standard_fields");
	standard_fields_div.setAttribute("class", "active");
}

function add_keyboard_shortcut(key, func) {
	document.onkeydown = function(e) {
		var element;
		if(e.target) element=e.target;
		else if(e.srcElement) element=e.srcElement;
		if(element.nodeType===3) element=element.parentNode;

		if(element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') return;
		else {
			var code;
			if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
			
			if (String.fromCharCode(code) === key && e.ctrlKey) {
				func();
			}
			
		}
	}
}

addLoadEvent(add_keyboard_shortcut("L", show_or_hide_rules));