/**
 * @author mraichelson
 */
// this creates a boolean variable we can test against to see if the browser is safari mobile on iphone
	var is_iphone=false;
	var agent=navigator.userAgent.toLowerCase();
	if(agent.indexOf('iphone')!=-1){
		is_iphone=true;
	}

// code applied to the page via jQuery when the DOM is ready.
$(document).ready(function(){
	// add a class to the first and last LI in any OL or UL
	$('ul,ol').each(function(){
		$('li:first',this).addClass('first');
		$('li:last',this).addClass('last');
	});

	// split "twocol" lists into two columns
	$('ul.twocol,ol.twocol').each(function(){
		$('li:nth-child(odd)',this).css({width:'45%',float:'left',clear:'both'});
		$('li:nth-child(even)',this).css({width:'45%',float:'right'});
	});

	// create tabbed content areas.
	$('div.tabbed>ul').tabs();
	$('div.tabbed ul.tabs li a').focus(function(){
		this.blur();
	});

	// add a class to event calendar list items on mouseover
	if(!is_iphone){ // disable this behavior on iphone
		$('ul#eventlist li').hover(
			function(){ // mouseover
				$(this).addClass('over');
			},
			function(){ // mouseout
				$(this).removeClass('over');
			}
		);

	}

	// add a class to the last div.module inside a .modules container
	$('div.modules div.module:last').addClass('last');

	// top navigation and dropdown menus
	if(!is_iphone){ // disable this behavior on iphone
		$('#navigation li[id^="nav"]').hover(
			function(){ //mouseover actions
				$(this).addClass('open');
				if(!$('a.active',this)[0]){ // only apply this if the .active item is NOT within the currently hovered menu
					$('#navigation a.active').css('border-bottom','1px solid #B4B1A0').css('height','37px');
				}
			},
			function(){ // mouseout actions
				$(this).removeClass('open');
				$('#navigation a.active').css('border-bottom','none').css('height','38px');
			}
		);
	}
	// allow top menus to function when tabbing through links
	$('#navigation li[id^="nav"] a').focus(function(){
		$(this).parents('li[id^="nav"]').addClass('open');
	});
	$('#navigation li[id^="nav"] a').blur(function(){
		$(this).parents('li[id^="nav"]').removeClass('open');
	});

	// highlight parent items of left nav
	$('ul#left-nav a.active').parents('ul').parents('li').addClass('with-sub').find('a:first').addClass('active-sub');
	$('ul#left-nav li>a.active').parents('li').addClass('with-sub');
	$('a.expander').click(function() {
			$(this).attr({'href':'javascript:void(0);'});
			if ($(this).children('img').attr('src')=='http://atsdev01.cua.edu/redesigns/upgrades/www_fye/res/img/nav-exp-open.gif')  {
				$(this).children('img').attr({'src' : 'http://atsdev01.cua.edu/redesigns/upgrades/www_fye/res/img/nav-exp-close.gif'});
				$(this).parents('li').children('ul').css({'display':'block'});
			} else {
				$(this).children('img').attr({'src' : 'http://atsdev01.cua.edu/redesigns/upgrades/www_fye/res/img/nav-exp-open.gif'});
				$(this).parents('li').children('ul').css({'display':'none'});
			}
			return(false);
								   });

	// attach extra class to BODY of pages on iphone for some CSS adjustments
	if(is_iphone){ $('body').addClass('iphone'); }

	// prevent blank search form submission
	$('#global-search form').submit(function(){
		if($('#q',this).val()===''){
			return false;
		}
	});
});
        var ftr = '<img src="//www.cua.edu/res/images/celebrating125years.gif" style="float: right;" alt="Celebrating 125 Years">';
        ftr = ftr + '<a href="http://www.cua.edu/contact-us.cfm">Contact Us/Directory</a>';
        ftr = ftr + '<span class="divider">|</span>';
        ftr = ftr + '<a href="http://computing.cua.edu/policies/dmca.cfm" rel="license">Copyright Information</a>';
        ftr = ftr + '<span class="divider">|</span>';
        ftr = ftr + '<a href="http://www.cua.edu/speech-enabled.cfm">Speech Enabled</a>';
        ftr = ftr + '<span class="divider">|</span>';
        ftr = ftr + '<a href="http://www.cua.edu/safety/disability-accommodations.cfm">Disability Accommodations</a>';
        ftr = ftr + '<br>';
        ftr = ftr + '<span class="vcard">';
        ftr = ftr + '<span class="fn n"><span class="org">The Catholic University of America</span></span>';
        ftr = ftr + '<span class="divider">*</span>';
        ftr = ftr + '<span class="adr">';
        ftr = ftr + '<span class="street-address">620 Michigan Ave., N.E.</span>';
        ftr = ftr + '<span class="divider">*</span>';
        ftr = ftr + '<span class="locality">Washington</span>, <span class="region">DC</span> <span class="postal-code">20064</span>';
        ftr = ftr + '</span>';
        ftr = ftr + '</span>';

        $(document).ready(function(e) {
        $('#footer-content').html(ftr);
    });
