$(document).ready(
	function(){

	//tag IE6 browser for CSS fixes
	
	if ( jQuery.support.tbody  != true ) {
		//alert('bingo!');
		$('body').prepend('<!--[if IE 6]><div style="background-color:yellow">You are using Internet Explorer 6! Please consider upgrading your browser!</div><![endif]-->  ');
	};

		if ($.browser.msie && $.browser.version == 6) {
			$('body').addClass('ie6');
			};
		if ($.browser.msie) {
			$('body').addClass('ie');

		//IE fixes 
			//horizontal rule fix (convert hr tag to div and class .hr)
			$('hr').replaceWith('<div class="hr"></div>');		
			
			//rounded borders (transparent gifs inserted with css)
			var ieWrap		=	'<div class="ieWrap" />';				
			var ieTop 		=	'<div class="ieTop"><!--IE rounded border--></div>';
			var ieBottom 	=	'<div class="ieBottom"><!--IE rounded border--></div>';
			$('#navigation').wrap(ieWrap);
			$('#main').wrapInner(ieWrap);
			$('.ieWrap').prepend(ieTop).append(ieBottom);

			//li hovers
			$('ul#menu ul li a')
				.hover(
					function () {
						$(this).css('background-color','#9CB03E');
					},
					function () {
						$(this).css('background-color','#D5E2ED');
					}
				);
			
			//sitemap backgrounds
			$('#sitemap-wrap').css('background-image','../images/sitemap_bg.jpg')
			$('#sitemap-wrap #sitemap').css('background-image','../images/sitemap-content_bg.jpg')
			
			};		

	//remove typographical widows in p tags 
	// - shared by Karl Swedberg at http://www.learningjquery.com/2008/07/three-quick-ways-to-avoid-widows
	// - modified by brandon whitesell
		var pText = ' ';
		$('#content p').each(function() {
			var pArray = $(this).text().split(' '),
			pLast = pArray.pop();
			pText = pArray.join(' ') + '&nbsp;' + pLast;
			$(this).html(pText);
			}); 
	
	//turn on jQuery Tools
	//**tabs**
		$("ul.css-tabs").tabs("div.css-panes > div", {effect: 'ajax'}).history().scroll(screenTop);
	//**slides**
		$("div.tabs").tabs(".images > li", { 
			// enable "cross-fading" effect 
			effect: 'fade', 
			fadeOutSpeed: "slow", 
	 
			// start from the beginning after the last tab 
			rotate: true 
		 
			// use the slideshow plugin. It accepts its own configuration 
			}).slideshow();


	//sidebar and menu (sidebar and navigation)
		$('#sidebar div.potentialApplicants h4') //main categories on sidebar
			.click(
				function () {
					$(this).parent('div').toggleClass('opened');
				}
			);
		$('li.subMenu a') // submenus
			.click(
				function () {
					$(this)
						.next('ul').toggleClass('opened')
						.parent('li.subMenu').toggleClass('opened');
				}
			);		


	//slides
//		if	( $('#slides') ) {
//			$('#slides')
//				.before('<div id="slideNav">') 
//				.cycle( { 
//					fx:     'fade', 
//					speed:  'fast', 
//					timeout: 8000, 
//					pause: 	'1',
//					pager:	'#slideNav' 
//					});
//			};
			
	//sitemap

		$('#footer #sitemap-link a')
			.click(
				function () {
					$('#footer #sitemap-link a').removeAttr('href');
					$('#footer #sitemap #sitemap-container').load('./sitemap.html');
					$(window).scrollTop(0);
					$('#sitemap-wrap').show();
				}
			);
			
		$('#sitemap span.closeMap')
			.click(
				function () {
					$('#sitemap-wrap').hide();
				}
			);
	
		$("#sitemap-ds").css("opacity", "0.9");
		
		$("#sitemap-ds").doFade({ fadeColor: "#005293" });
		$("#sitemap ul").doFade({ fadeColor: "#9CB03E" });
		$("#sitemap ul ul").doFade({ fadeColor: "#470736" });
		$("#sitemap ul ul ul").doFade({ fadeColor: "#CF8442" });
				
	
///////////////////////
// end main function
	}
// end document.ready
);

