$( document ).ready( function() { 

         $( "#subnav" ).find( "a[href=http://www.imacs.org/IMACSWeb/IMACSWeb/parser.aspx?pageid=60]" ).css( { backgroundColor: "RGB( 255,255,153)" } ); 
} );


function tempNavBarInit091214( data )
{
    $("#subnav a").each( function() { $( this ).attr( "style" , "" ); } );
    if ( data.theParent ) data.theParent.addClass( "current" ).next().show();
    data.theOne.css( "background", "#fff" );
}

tempNavBarInit091214B = function( pageNumber )
        {
                $("#subnav a").each(
                        function()
                        {
                                if ( $( this ).attr( "href" ) == undefined || $( this ).attr( "href" ).indexOf( "pageid=" + pageNumber ) == -1 )
                                    return;
                                $( this ).css( "background", "#fff" );
                                if ( $(this).parent().parent().prev().is( "a" ) )
                                    {
                                        $(this).parent().parent().prev().addClass( "current" );
                                        $( this ).parent().parent().show();
                                    }
                        } );
        }


function NavbarHighlight( linkname )
{
	$(document).ready( 
		function()
		{
			$("#subnav a:contains(" + linkname + ")").filter( ":first" ).each(
				function()
				{
					// look for a parent that is preceded by an expander link
					$(this).parents( "ul" ).each(
						function()
						{
							var prev = $(this).prev();
							
							if ( prev.hasClass( "expander" ) )
							{
								$(this).show(); // show the UL
								prev.addClass( "current" );
							}							
						}
					);
					
					$(this).parent().addClass( "selected" );
				}
			);
		}
	);
}

// scrolling
function getScrollY()
{
    var y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        y = window.pageYOffset;
    } else if( document.body && document.body.scrollTop ) {
        // DOM
        y = document.body.scrollTop;
    } else if( document.documentElement && document.documentElement.scrollTop ) {
        // IE6 standards compliant mode
        y = document.documentElement.scrollTop;
    }
    return y;
}
            
function setScrollY( y )
{
    window.scrollTo( 0, y );
}

// readmore

function readMore( id )
{
	var div = $("#" + id + " .extra");
	if ( div.css('display') == 'none' ) 
	{
		div.css('display','block').fadeIn();
	}
	else 
	{
		div.css('display','none').fadeOut();
	}
}

$(document).ready( 
	function() 
	{
		if ( !document.getElementById || !document.createTextNode ) {return;} // test to see if user agent supports modern dom

		// fix display of PNG images and background images on IE5.5 and IE6	
		if ( $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent) )
		{
			$.ifixpng('/FileData/IMACSWeb/images/transparentpixel.gif');
			$('#bottom').append('<div id="fakebottom">&nbsp;</div>'); // fix for IE6 unclickable links
				$('img[src$=.png], #top, #fakebottom, #dl-top, #dl-bottom, #spotlight-top' ).ifixpng( 'crop' );
		}

		// slideshow
		$('#slideshow').innerfade({
				speed: 1750, // speed of transition
				timeout: 7000, // time to view each slide
				type: 'sequence',
				containerheight: '100px'
		});

		$( "ul a.curriculum,ul a.hscurriculum,ul a.expander,ul a.current" ).click( 
			function () 
			{ 
				$(this).next().toggle();
				return false;
			}
		);

		$( '#tabpane table' ).addClass( 'hide' );

		// Hide all divs within #tabpane (except #openingdiv) whose id ends in 'div'
		$( '#tabpane div[id$=div]' ).not( '#openingdiv' ).attr( 'class', 'hide' );

		$( 'div.selector > ul > li:first-child' ).attr( 'class', 'open' );
		$( 'div.selector > ul > li:first-child' ).siblings().attr( 'class', 'closed' );

		// Simplify wording if only one top-level menu item
		$( 'div.selector' ).each(
			function()
			{
				if ( $(this).find( '> ul > li' ).length == 1 )
				{
					$(this).siblings( 'p.coursesinstructions' ).text( 'To view class availability, click a class description.' );
					$(this).siblings( 'p.summerinstructions' ).text( 'To view class availability, click a week.' );
				}
				else
				{
					$(this).siblings( 'p.coursesinstructions' ).text( 'To view class availability, click a subject and then a class description.' );
					$(this).siblings( 'p.summerinstructions' ).text( 'To view class availability, click a location and then a week.' );
				}
			});

		$( 'div.tab' ).click(
			function()
			{
				$(this).attr( 'class', 'seltab' );
				$(this).siblings().attr( 'class', 'tab' );
				var selID = $(this).attr( 'id' );
				var divID = selID.substring( 0, selID.length - 3 ) + 'div';
				$( '#' + divID ).siblings().not( '.tailtab' ).addClass( 'hide' );
				$( '#' + divID ).removeClass( 'hide' );
						
				return false;
			});
		$( 'div.selector > ul > li' ).hover(
			function()
			{ // mouseover
				if ( $(this).attr( 'class' ) == 'closed' )
				{
					$(this).attr( 'class', 'over' );
					return false;
				}
			},
			function()
			{ //mouseout
				if ( $(this).attr( 'class' ) == 'over' )
				{
					$(this).attr( 'class', 'closed' );
					return false;
				}
			});
		$( 'div.selector > ul > li' ).click(
			function()
			{
				$(this).siblings().find( 'ul:visible' ).slideUp( 'slow' );
				$(this).find( 'ul' ).slideDown( 'slow' );
				$(this).attr( 'class', 'open' );
				$(this).siblings().attr( 'class', 'closed' );
				return false;
			});
		$( 'div.selector > ul > li > ul > li > a' ).click(
			function()
			{
				if ( $(this).attr( 'id' ) )
				{
					var anchor = $(this).attr( 'id' );
					$( anchor ).siblings( 'table' ).addClass( 'hide' );
					$( anchor ).removeClass( 'hide' );
						
					// remember which link has been clicked
					var gpul = $(this).parents( '.selector' );
					gpul.find( 'ul > li > ul > li > a'  ).removeClass( 'clicked' );
					$(this).addClass( 'clicked' );
				}
				return false;
			});

		var qString = window.location.search.substring( 1 ); // query string after question mark
		if ( qString != null && qString != '' )
		{
			// open / close submenu according to setup recorded in query string
			var params = qString.split( '&' );
			var cLink = $( '#' + params[ 0 ] + '-curriculum' );
			if ( params[ 2 ] == 'o' )
			{
				cLink.removeClass( 'curriculum' );
				cLink.addClass( 'current' );
				cLink.next().toggle();
			}
			else
			{
				cLink.removeClass( 'current' );
				cLink.addClass( 'curriculum' );
			}
			setScrollY( parseInt( params[ 1 ] ) );
		}
	}
);
