var authShown = 0;
var authBlur = 0;
var authTimeout;

$j(document).ready(function() {
	
	//$j(".auth_drawer").topZIndex();
	
	var thisbrowser = $j.client.browser;
	var thisos 		= $j.client.os;
	if (thisos == 'Mac' && (thisbrowser == 'Firefox' || thisbrowser == 'Safari')) {
		$j("#search_links").css("font-size","11px").css("margin-top","0px");			
		$j("#home_middle_content li").css("font-size","10px");
	}
	
	//alert("thisos: " + thisos + " - thisbrowser: " + thisbrowser);
	
	if (thisos == 'Windows' && thisbrowser == 'Explorer') {
		$j("#header_nav").css('width','940px');
		$j(".auth_drawer_container").css('width','265px').css('margin-right','5px');
		$j(".auth_drawer input").css('width','237px');
		$j(".auth_actions").css('margin-top','2px');
		$j("p.auth_footer_links").css('margin-top','2px');
	}
	
	// ---------------------------------------------------------------------
	// auth container show/hide handling	
	$j(".auth_drawer_container").mouseleave(
		function() {
			if ($j("#username").val() == '' || $j("#password").val() == '') {
				if ($j("#username").is(":focus") || $j("#password").is(":focus")) { 
					authBlur = 0;
				} else {
					authBlur = 1;
					clearTimeout(authTimeout);
					authTimeout = setTimeout("closeAuth()",5000);
				}
			}
		}
	);
	
	$j(".auth_drawer_container").mouseenter(
		function() {
			authBlur = 0;
			clearTimeout(authTimeout);
		}
	);
	
	$j("#client_portaldiv").mouseleave(
		function() {
			if ($j("#username").val() == '' || $j("#password").val() == '') {
				authBlur = 1;
				clearTimeout(authTimeout);
				authTimeout = setTimeout("closeAuth()",5000);
			}
		}
	);
	
	$j("#username").blur(
		function() {
			if ($j(this).val() == '') {
				authBlur = 1;
				clearTimeout(authTimeout);
				authTimeout = setTimeout("closeAuth()",5000);
			}
		}
	);
	
	$j("#username").focus(
		function() {
			authBlur = 0;
		}
	);
	
	$j("#password").blur(
		function() {
			if ($j("#username").val() == '') {
				authBlur = 1;
				clearTimeout(authTimeout);
				authTimeout = setTimeout("closeAuth()",5000);
			}
		}
	);
	
	$j("#password").focus(
		function() {
			authBlur = 0;
		}
	);
	
	$j("#client_portaldiv a").click(
		function() {
			if (authShown == 0) {
				$j(".auth_drawer_container").show('slide',{direction:'up',queue:false},'800');
				$j(".auth_drawer").show();
				authShown = 1;
			}
			else {
				authBlur = 1;
				closeAuth();
			}
		}
	);
	
	$j(".closeBtn").click(
		function() {
			authBlur = 1;
			closeAuth();
		}
	);
	
	// end auth slider show/hide handler code
	// ----------------------------------------------------------------
	
	
	var sb_num_slides = 30;
	var active_sbslide_num = Math.floor(Math.random()*sb_num_slides);
	$j("#sb_slide_"+active_sbslide_num).removeClass("hidden");
	if ($j("#sidebar_slideshow")) {
		$j('#sidebar_slideshow ul').cycle({
			fx:      			'fade',
			speed:				'500',
			timeout: 			'3000',
			pause:         		0,
			startingSlide: 		active_sbslide_num
		});
	}


	// HOMEPAGE THUMB MOUSEOVER HANDLERS	
	if(typeof(isHomePage) !== 'undefined') {
		var overColor = '#98f703';
		// --------------------------
		$j("#civgov_tn")
		.mouseover(function() {
			$j("#arrows1").removeClass("yellow").css("color",overColor);
		})
		.mouseleave(function() {
			$j("#arrows1").css("color","").addClass("yellow");
		});	
		
		// --------------------------
		$j("#defense_tn")
		.mouseover(function() {
			$j("#arrows2").removeClass("yellow").css("color",overColor);
		})
		.mouseleave(function() {
			$j("#arrows2").css("color","").addClass("yellow");
		});
		
		// --------------------------
		$j("#law_tn")
		.mouseover(function() {
			$j("#arrows3").removeClass("yellow").css("color",overColor);
		})
		.mouseleave(function() {
			$j("#arrows3").css("color","").addClass("yellow");
		});
		
		// --------------------------
		$j("#health_tn")
		.mouseover(function() {
			$j("#arrows4").removeClass("yellow").css("color",overColor);
		})
		.mouseleave(function() { 
			$j("#arrows4").css("color","").addClass("yellow");
		});
	}
	// -- END HOMEPAGE MOUSEOVER HANDLERS
	
});


$j.extend($j.expr[':'], {
    focus: function(element) { 
        return element == document.activeElement; 
    }
});



function closeAuth() {
	if (authBlur == 1) {
		$j(".auth_drawer_container").slideUp();
		authShown = 0;
	}
}


// simplePreload( '01.gif', '02.gif' ); 
function simplePreload() { 
	var args = simplePreload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++) {
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
}

//function doZoom(size) {
//		
//	var o = $j(".rightSidebarSubSection").children("p,a");
//	//$j(document).find("p,a,li").css('line-height',parseFloat($(this).css('line-height') + size) + 'px');
//	
//	for(i=0;i<o.length;i++) {      
//		o[i].style.fontSize = size + 'em';
//		o[i].style.lineHeight = size + "px";
//	} 
//		
//	var p = $j("#subcontent_main").children("p,li,a");
//	for(i=0;i<p.length;i++) {      
//		p[i].style.fontSize = size + 'em';
//		p[i].style.lineHeight = size + "px";
//	}  
//
//	var p = $j("#subcontent_main td").children("p,li,a");
//	for(i=0;i<p.length;i++) {      
//		p[i].style.fontSize = size + 'em';
//		p[i].style.lineHeight = size + "px";
//	}
//}



// =============================================================
		function handleChange(obj) {
			hideAllDescriptions(obj.value);
		}
		
		function hideAllDescriptions(val) {
			//$j('div.jobDescriptionClass').setStyle('display','none'); // hide all the descriptions
			//$j(val).setStyle('display','block');
			
			$j('div.jobDescriptionClass').hide();
			$j("#"+val).show();
		}

