var togglers = new Object();

var hdanz = {
	/*
	 * contains reference to the admin menu ul element that the script uses
	 * to show or hide on mouse over for IE because of not supporting the 
	 * :hover pesudoclass properly.
	 */
	adminMenu : null,

	startList : function() {
		if (document.getElementById("nav-second")) {
			navRoot = document.getElementById("nav-second");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					for (x=0; x<node.childNodes.length; x++) {
						y = node.childNodes[x];
						if (y.nodeName=="SPAN") {
							y.onmousedown=function() {
								hdanz.collapseAll();
								this.parentNode.className+=" over active";
							}
						}
					}
				}
			}
		}
	},

	collapseAll : function() {
		if (document.getElementById("nav-second")) {
			navRoot = document.getElementById("nav-second");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.className=node.className.replace(" over", "");
					node.className=node.className.replace(" active", "");
				}
			}
		}
	},

	/*
	 * Add the event handlers that show and hide the admin menu when the user
	 * moves the mouse over the "client login" button.
	 */
	adminMenu : function() {
		if (document.getElementById('nav-first')) {
			var menuItems = document.getElementById('nav-first').getElementsByTagName('li');
			for (var i = 0; i < menuItems.length; i++) {
				if (menuItems[i].className == 'login') {
					var adminMenu = menuItems[i].getElementsByTagName('ul');
					if (adminMenu.length == 1) {
						hdanz.adminMenu = adminMenu[0];
						menuItems[i].onmouseover = function() {
							hdanz.adminMenu.style.display = 'block';
						}
						menuItems[i].onmouseout = function() {
							hdanz.adminMenu.style.display = 'none';
						}
					}
				}
			}
		}
	}

}


window.onload = function() {
	hdanz.startList();
	hdanz.adminMenu();
}

$(document).ready(function() {
	if($('input#cb_postaladdress').length && $('input#cb_postaladdress').attr('checked') == true) {
		$('div#postaladdress').find('input|select').attr('disabled', true).end().hide();
	}

	$('input#cb_postaladdress').change(function() {
		if(this.checked == true) {
			$('div#postaladdress').find('input|select').attr('disabled', true).end().slideUp();
		} else {
			$('div#postaladdress').slideDown().find('input|select').attr('disabled', false);
		}
	}
	);
	
	if($('input[@name=standard_type]:checked').length && $('input[@name=standard_type]:checked').val() == 'el') {
		$('legend#standardscovered').parent().find('input[@class=fullsuite]').parents('label').hide();
	}
	
	var standardsChange = function() {
		if($(this).val() == 'el') {
			$('legend#standardscovered').parent().find('input[@class=fullsuite]').parents('label').hide();
		} else {
			$('legend#standardscovered').parent().find('input[@class=fullsuite]').parents('label').show();
		}
	}
	if($.browser.msie) {
		$('input[@name=standard_type]').click(standardsChange);
	} else {
		$('input[@name=standard_type]').change(standardsChange);
	}
});