$(document).ready(function(){
	ieHover('#navigation > li');
	resizeFont();
	initAddress();
	//Remove Font Tags
	StripFontTags();
	AddExitMsg();
	Tabs();
	HackIssues();
	$('ul.slides').cycle({
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 0, 
	    next:   '#slNext', 
        prev:   '#slPrev' 
	});
});
/*--- initAddress function ---*/
function initAddress(){
	var _hold = $('.footer-select');
	if(_hold.length > 0){
		var sel_list = _hold.find('.select-office select');
		var _list = _hold.find('.select-content li');
		var _a = sel_list.attr('selectedIndex');
		sel_list.change(function(){
			changeEl(this.selectedIndex);
		});	
		_list.removeClass('active').css('opacity', 0).eq(_a).addClass('active').css('opacity', 1);
		function changeEl(_ind){
			if(_ind != _a){
				_list.parent().stop().animate({height: _list.eq(_ind).outerHeight()}, 300, function(){
					$(this).height('auto');
				});
				_list.eq(_a).removeClass('active').animate({opacity: 0}, { queue:false, duration:300});
				_list.eq(_ind).addClass('active').animate({opacity: 1}, { queue:false, duration:300});
				_a = _ind;
			}
		}
	}
}
/*--- IE6 hover function ---*/
function ieHover(h_list) {
	if ($.browser.msie && $.browser.version < 7) {
		$(h_list).hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
	}
}
/*--- resizeble fonts function ---*/
function resizeFont(){
	var fSize = 1;
	var body = document.body;
	body.style.fontSize = "1em";
	$('#font-normal').click(function(){
		body.style.fontSize = "1em";
		return false;
	});
	$('#font-min').click(function(){
		fSize = body.style.fontSize.replace("em","");
		fSize = parseFloat(fSize) - 0.1;
		if (fSize <= 0.8) fSize = 0.8;  
		body.style.fontSize = fSize+"em";
		return false;
	});
	$('#font-max').click(function(){
		fSize = body.style.fontSize.replace("em","");
		fSize = parseFloat(fSize) + 0.1;
		if (fSize >= 2) fSize = 2;
		body.style.fontSize = fSize+"em";
		return false;
	});
};

/*--- Strip font tags ---*/
function StripFontTags(){
    var mystuff = $('#Table4 p[align!=left][style!=text-align:justify]');
    var myOtherStuff = $('#Table4 p[align!=left][style!=text-align:justify] font[class!=middlecopy]');
    var nothing = 5;
    $('#Table4 p[align!=left][style!=text-align:justify] font[class!=middlecopy]').each(function(){
        $(this).before($(this).html()); //insert contents before element
        $(this).remove();
    });
    $('#Table4 p[align!=left][style!=text-align:justify] span').css('font-size','1em');
    $('.MsoNormal').removeClass('MsoNormal');
}

// JavaScript External Link Exit Message
function exitMsg(){
     var answer = confirm("You are now leaving the Congressman Don Young website. Thank you for visiting. Neither my office nor the U.S. House of Representatives is responsible for the content of the non-House site you are about to access.")

if (!answer)
return false;

return true;
//end of Exit Message
}


// Check whether links are external:
// (Only works with elements that have href):
$.extend($.expr[':'],{
    external: function(a,i,m) {
        if(!a.href) {return false;}
        return a.hostname && a.hostname !== window.location.hostname;
    }
});

/* --- Add Exit Message ---*/
function AddExitMsg()
{
    $('a:external').click(function(){
        return(exitMsg());
    });
}

/* --- Set up Homepage Tabs --- */
function Tabs()
{
    $('ul.tabs a').click(function(event){
        event.preventDefault();
        $('.tabs-holder .tabset:visible').fadeOut();
        $($(this).attr('href')).fadeIn();
    });
}

function HackIssues()
{
    $('.pageTitle[id*=IssueTitle] ~ br').remove();
    $('.pageTitle[id*=IssueTitle]').remove();
}