// JavaScript Document

var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var Anim = YAHOO.util.Anim;

/*
function showBanner(elIn){
	elIn = Dom.get(elIn);
	elOut = Dom.getElementsBy(
		function(el){ return(Dom.getStyle(el, 'opacity') == 1); },
		'img',
		'content_graphic'
//		function(el){ alert(Dom.getStyle(el, 'opacity')); }
	);
	var fadeOut = new Anim(elOut, { opacity: { to: 0 } }, 0.5);
	var fadeIn =  new Anim(elIn,  { opacity: { to: 1 } }, 0.5);
	fadeOut.onComplete.subscribe(function(){Dom.setStyle(elOut,'opacity', 0);})
	fadeOut.animate();
	fadeIn.animate();
}
*/

function tabnext(obj,event,len,next) {
	var field_length;
	if (event == "down") {
		field_length = obj.value.length;
	}
	else if (event == "up") {
		if (obj.value.length != field_length) {
			field_length = obj.value.length;
			if (field_length == len) {
				if(typeof next != 'undefined'){
					next.focus();
				}
			}
		}
	}
}

function elfocus(el,str){
	if (el.value == str){ el.value = ''; }
}

function elblur(el,str){
	if (el.value == ''){ el.value = str; }
}

Event.onDOMReady( function(){
	var Dom = YAHOO.util.Dom;
	var Event = YAHOO.util.Event;
	var Anim = YAHOO.util.Anim;

	// Dom.setStyle(['banner_1'],'opacity', 1);
	// Dom.setStyle(['banner_2'],'opacity', 0);
	
	// set minheight on inner for IE
	if (document.all){ Dom.get('inner').offsetHeight = 400; }
	
	// set the admin link id and attributes because it doesn't have one coded
	Dom.getElementsBy(
		function(el){ return (el.style.position == 'absolute'); },
		'div',
		'inner',
		function(el){ 
			el.id = 'adminlink'; 
			el.style.padding = '0';
			el.style.position = 'absolute';
			el.style.top = '60px';
			el.style.right = '57px';
			el.style.backgroundColor = 'inherit'; 
			el.style.fontFamily = 'inherit'; 
			el.style.fontSize = 'inherit'; 
			el.style.color = 'inherit'; 
		}
	);
	
	// set nav active
	var am = Dom.get('active_menu').innerHTML;
	var buttons = Dom.getElementsBy(
		function (){ return true; },
		'li',
		'site-nav'
	);
	Dom.addClass(buttons[am].firstChild,'act');
	
	// set subnav active
	/* 
	var asm = Dom.get('active_submenu').innerHTML;
	var sub_buttons = Dom.getElementsBy(
		function (){ return true; },
		'li',
		'site-nav2'
	);
	Dom.addClass(sub_buttons[asm].firstChild,'act');
	*/
	
	// remove quicklogin from all but the homepage
	if (am != 0){ Dom.addClass('quicklogin','hide'); }
	
});