$( document ).ready( function(){
	// z-index layering fix for IE7

	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});	
	

							  
	$('.blink')
		.focus(function(){
			if( $(this).attr('value') == $(this).attr('title') ) {
				$(this).attr({ 'value': '' });
			}
		})
		.blur(function(){
			if( $(this).attr('value') == '' ) {
				$(this).attr({ 'value': $(this).attr('title') })
			}
		});
		
		
	$('#slider .slider-thumbnails a').click(function(){
		var index = $(this).parent().find('a').index(this);
		
		$('#slider .slider-thumbnails a').removeClass('active');
		$('#slider .slider-thumbnails a').eq(index).addClass('active');
		
		$('.slides li').hide()
		$('.slides li').eq(index).fadeIn();
		
		$('#ajax-carousel-content').load($(this).attr('href'));
		
		return false;
		
	});
	
	
	$('.slideshow .slider-thumbnails a').click(function(){
		var index = $(this).parent().find('a').index(this);
		
		$('.slideshow .slider-thumbnails a').removeClass('active');
		$('.slideshow .slider-thumbnails a').eq(index).addClass('active');
		
		$('.slideshow .big img').hide()
		$('.slideshow .big img').eq(index).fadeIn();
		
		return false;
		
	});
	
	
	$('.tabs a').click(function(){
		var ul = $(this).parent().parent();
		var container = ul.parent().parent().parent();
		var index = ul.find('a').index(this);
		
		ul.find('a').removeClass('active');
		ul.find('a').eq(index).addClass('active');
		
		container.find('.tab-content').hide();
		container.find('.tab-content').eq(index).show();
		
		$('#homepage-tab-headline').html($(this).attr('title'));
		$('#tab-headline').html($(this).attr('title'));		
		return false;
	});
	
	
	
	$('.follow-nav a').click(function(){
		var index = $(this).parent().parent().find('a').index(this);
		
		$('.follow-tab').hide();
		$('.follow-tab').eq(index).show();
		
		$('.follow-nav li').removeClass('active');
		$('.follow-nav li').eq(index).addClass('active');
		
		return false;
	})
	
	$(".acc").accordion();
	
	$(".videos a[rel^='prettyPhoto']").prettyPhoto({ theme: 'dark_rounded' });
	$(".sidebar-video a[rel^='prettyPhoto']").prettyPhoto({ theme: 'dark_rounded' });
	
	$('.col').hover(
		function(){ $(this).addClass('col-hover'); },
		function(){ $(this).removeClass('col-hover'); }
	);
	
	$('.Prosperity').click(function() {
		$('.col').removeClass('col-active');
		$('.col-p').addClass('col-active');
	});
	$('.Liberty').click(function() {
		$('.col').removeClass('col-active');
		$('.col-l').addClass('col-active');
	});
	$('.Security').click(function() {
		$('.col').removeClass('col-active');
		$('.col-s').addClass('col-active');
	});	

	$('.ajax-issues a').click(function(){
		$('#ajax-issue-content').load($(this).attr('href'));		
		return false;
	});
	

	$('#navigation li').hover(
    	function(){ $(this).find('.dd').show(); $(this).addClass('active'); },
        function(){ $(this).find('.dd').hide(); $(this).removeClass('active'); }
	);

});
