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() {
	jQuery("a.greybox").colorbox({
		width:"598px",
		height:"440px",
		title:true,
		iframe:true
	});
	jQuery("a.greyboxrf").colorbox({
		width:"700px",
		height:"440px",
		title:true,
		iframe:true,
		onClosed:function() { parent.location.reload(true); }
	});
	
/*
	$("a.greybox").click(function(){
	  var t = "onTrack: " + $(this).attr('title');
	  jQuery.GB_show($(this).attr('href'), {
		height: 470,
		width: 600,
		animation: true,
		caption: t,
		close_img: "/includes/template/public/images/greybox/closebox.gif"
	  });
	  return false;
	});


	$("a.greyboxrf").click(function(){
	  var t = "onTrack: " + $(this).attr('title');
	  $.GB_show($(this).attr('href'), {
		height: 470,
		width: 600,
		animation: true,
		caption: t,
		refreshmain: true,
		close_img: "/includes/template/public/images/greybox/closebox.gif"
	  });
	  return false;
	});
*/
	
	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);
	}
	*/
	
	/* ontrack login */
	
	$('.nav-our_programs').mouseenter(function() {
		//$('#SubMenu').show();
	});
	
	$('.nav-our_programs').mouseleave(function() {
		//$('#SubMenu').hide();
	});
	
	$('#SubMenu').mouseenter(function() {
		//$('#SubMenu').show();
	});
	
	$('#SubMenu').mouseleave(function() {
		//$('#SubMenu').hide();
	});
	
	var trackOpen = false;
	
	$('#onTrackLogin').mouseleave(function() {
		//$('#onTrackLogin .mid').slideUp("fast");
		//trackOpen = false;
	});
	
	
	$('#onTrackLogin .top a.loginButton').click(function(event) {
		event.preventDefault();
		
		if(trackOpen){
			trackOpen = false;
			$('#onTrackLogin .mid').slideUp("fast");
		}else{
			trackOpen = true;
			$('#onTrackLogin .mid').slideDown("fast");
		}
	});
	
	$('#onTrackLogin .lspn').focus(function() { 
		if($('#onTrackLogin .lspn').val() == 'LSPN') {
			$('#onTrackLogin .lspn').val("");
		} 
	});
	
	$('#onTrackLogin .lspn').blur(function() {
		if($('#onTrackLogin .lspn').val() == '') {
			$('#onTrackLogin .lspn').val("LSPN");
		} 
	});
	
	$('.searchfield').focus(function() { 
		if($('.searchfield').val() == 'Search') {
			$('.searchfield').val("");
		} 
	});
	
	$('.searchfield').blur(function() {
		if($('.searchfield').val() == '') {
			$('.searchfield').val("Search");
		} 
	});
	
	$('#password-clear').show(); 
	$('#password-password').hide();  
	
	$('#password-clear').focus(function() {  
		$('#password-clear').hide();  
		$('#password-password').show();  
		$('#password-password').focus();  
	});  
	
	$('#password-password').blur(function() {  
		if($('#password-password').val() == '') {  
			$('#password-clear').show();  	
			$('#password-password').hide();  
		}
	}); 

});


Cufon.replace('form legend',{ hover: true });
Cufon.replace('p.adminMenuHead',{ hover: true });
Cufon.replace('h1',{ hover: true });
Cufon.replace('h2',{ hover: true });
Cufon.replace('h3',{ hover: true });
Cufon.replace('h4',{ hover: true });
Cufon.replace('h5',{ hover: true });

