$(function(){

//Homepage AW Gets Results Details
	$('#results li a').click(function(){
		awGetsResults($(this));
		return false;
	});
	
	$('#results .toggle').click(function(){
		th = $(this);
		if(th.hasClass('open')){
			awGetsResults($('#results li a').eq(0));
		}else if(th.hasClass('close')){
			th.removeClass('close').addClass('open');
			$('#results li a').removeClass('active');
			$('div.'+result+', #dancing-girl2').fadeOut(300, function(){
				$('#results').animate({width: '457px'}, 900, "jswing");
			});
			$('.rcol, .lcol').removeClass('expanded');				
		}
		return false;
	});
		
//Subpage Photo Slider
	$('#photo-slider').cycle({ 
		fx:     'fade', 
		speed:  '1000', 
		timeout: 6000, 
		pager:  '#nav-slider',
		pagerEvent: 'mouseover', 
		pauseOnPagerHover: true 					
	});

//SideNav switcher
	var hash = window.location.hash;
	tab = hash.substring(1);
	if (tab){
	showSubContent($('a.'+tab));
	}

	$('#sidenav a').live('click', function(){
		showSubContent($(this));
	});	

	
//Latest News Accordian
	$('.news-title').click(function(){
		$(this).siblings('.news-body').toggle(300);
		return false;
	});
	
});

//Remove Labels on Autofill Inputs (Chrome)
$(window).load(function(){
	if($('input:-webkit-autofill')){
		th = $('input:-webkit-autofill');
		removeLabel(th)
	}		
});



////////////////////////////// GET RESULTS ////////////////////////////////
function showSubContent(th){
		if(th.hasClass('active')){
			return false;
		}
		tab = th.attr('class');
		parentUL = th.closest('ul');
		parentUL.find('.active').removeClass('active');
		$('.point').remove();
		th.addClass('active').append('<span class="point"><img src="assets/images/nav_point.png" alt="" /></span>');
		$('#content .sub-content').hide();
		$('.'+tab).show();	
}
	
function awGetsResults($this) {
		result = $this.attr('class');
		$('#results .active').removeClass('active');
		$this.addClass('active').siblings('.pointer').addClass('active');
;
		if (!$('.lcol').hasClass('expanded')){
			$('#results .toggle').removeClass('open').addClass('close');	
			$('#results').animate({width: '915px'}, 900, "jswing", function(){
				$('div.'+result+', #dancing-girl2').fadeIn(300);
			});
			$('.rcol, .lcol').addClass('expanded');		
		}else{
			$('div.'+visibleResult).fadeOut(300, function(){
				$('div.'+result).fadeIn(300);
			});
		}
		visibleResult = result;
}



