function navHover() {
	var mainNav = $('main-nav');
	if (!mainNav) return false;
	mainNav.select('li').each(function(node) {
		node.observe('mouseover', function(e){ this.addClassName('over'); });
		node.observe('mouseout', function(e){ this.removeClassName('over'); });
	});
}
Event.observe(window,'load',navHover);


function loginBehavior(){
	if(!document.getElementById('username')) return false;
	if(!document.getElementById('password')) return false;

	var username = document.getElementById('username');
	var password = document.getElementById('password');

		username.onblur = function(){
			if(this.value == ''){
				this.value='Username';
				if(password.value == ''){
					password.value = 'Password';
				}
			} 
		}

		username.onfocus = function(){
			if(this.value == 'Username'){ 
				this.value=''; 
				password.value = '';
				}
		}

		password.onblur = function(){
			if(this.value == ''){
				this.value='Password';
			} 
		}

		password.onfocus = function(){
			if(this.value == 'Password'){ 
				this.value='';
				}
		}	
		
}

Event.observe(window,"load",loginBehavior);



function setNewWindow() {
	// make sure the browser has what we need
	if (!document.getElementsByTagName) return false;
	// get the elements
	var links = document.getElementsByTagName("a");
	// make sure there are any
	if (links.length < 1) return false;
	for (a=0; a < links.length; a++) {
		var link = links[a];
		if ((link.getAttribute("href")) && (link.getAttribute("rel") == "external")) {
			link.onclick = function() {
				var location = this.getAttribute("href");
				window.open(location, "newWindow");
				return false;
			}
		}
	}
}
Event.observe(window,"load",setNewWindow);

function bigPapa() {
	$$('a[rel="bigpopup"]').each(function(node){
		node.observe('click', function(evt){
			Event.stop(evt);
			var papa = window.open(this.readAttribute("href"), "bigPopupWindow", "toolbar=no,scrollbars=yes");
			papa.moveTo(50,50);
			papa.resizeTo(screen.availWidth - 50,screen.availHeight - 50);
			papa.focus();
			return false;
		});
	});
}
Event.observe(window,"load",bigPapa);


function toggleFormHeader() {                 
	if (!($('collapse-trigger'))) return false;
	$('collapse-trigger').observe('click',function(e){
		Event.stop(e);
		$('form-container').toggle();
		this.toggleClassName('collapseOpen');
		this.toggleClassName('collapseClosed');
	})
}   
Event.observe(window,"load",toggleFormHeader);

function closePopUp() {
	if (!($('close-trigger'))) return false;
	$('close-trigger').observe('click',function(e){
		window.close();   // Why isn't this working???
	})
}  
Event.observe(window,"load",closePopUp);
