/** Modified script originall by Marco van Hylckama Vlieg web: http://www.i-marco.nl/weblog/ **/

function initMenus() {
	$('ul#nav_827929 ul').hide();
	//$.each($('ul#nav_720411'), function(){
		//$('#' + this.id + '.expandfirst ul:first').show();
	//$('ul#nav_720411 ul:first').show();
	
	//$('ul#nav_720411 li.practice ul').show();
	//$('ul#nav_720411 li.selected ul').show();

	
	if($('ul#nav_827929 li.about').hasClass('selected')) {
		$('li.about.selected ul').show();
	} else if($('ul#nav_827929 li.advocacy').hasClass('selected')) {
		$('li.advocacy.selected ul').show();
	} /*else {
		$('ul#nav_827929 li.advocacy ul').show();
	}*/
	
	//});
	$('ul#nav_827929 li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			//if($('#' + parent).hasClass('noaccordion')) {
			//	$(this).next().slideToggle('normal');
			//	return false;
			//}
			
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				//if($('#' + parent).hasClass('collapsible')) {
					// The following allows the menus to collapse
					$('#' + parent + ' ul:visible').slideUp('normal');
				//}
				//return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus();});



/** SCROLL TO NAMED ANCHOR **/

$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});


/************************************************************************************************
HIDES IMAGES IN WEB APP IF DONT EXIST
***************************************************************************************************/	

function ImageLoadFailed() {
	window.event.srcElement.style.display = "none";
}



/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});






//include other Javascript File
function IncludeJavaScript(jsFile)
  {
	document.write('<script type="text/javascript" src="' + jsFile + '"></script>');
  }
//Call the other JS here:
IncludeJavaScript('/_js/date.js');






