$j(document).ready(function() {
	
	$j(".accordion").accordion({
		autoHeight: false
	});
	
	$j(".tabbox").tabs();
	$j(".tabbed").tabs();
	
	if ($j('.slideshow').length > 0) {
		$j('.slideshow').cycle({
			'cleartype':true,
			'cleartypeNoBg':true
		});
	}
	
	if ($j('.slider-horizontal').length > 0) {
		$j('.slider-horizontal').cycle({
			'timeout':0,
			'speed':1000,
			'fx':'scrollHorz',
			'next':'.next-videos',
			'prev':'.prev-videos',
			'cleartype':true,
			'cleartypeNoBg':true
		});
	}
	
	if ($j('.video-slides').length > 0) {
	startSlide = $j('.video-slides').children().length - 1;
	$j('.video-slides').cycle({
			'timeout':0,
			'speed':1000,
			'fx':'scrollHorz',
			//'next':'.next-videos',
			//'prev':'.prev-videos',
			 'pager': '.video-pager',
			 'startingSlide': startSlide,
			'cleartype':true,
			'cleartypeNoBg':true
		});
		
		$j('.slider-bottom .video-thumb a').unbind();
		
		$j('.slider-bottom .video-thumb a').click(function(e){
			e.preventDefault();
			//var index = $j(this).index();
			
			
		});
		
		$j('.slider-bottom .video-thumb').click(function(e){
			e.preventDefault();
			//var index = $j(this).index();
			
			var index = $j(this).attr('rel');
			index = parseInt(index) + 1;
			console.log(index);
			$j('.video-pager a:nth-child('+index+')').click();
		});
	}
	
	// # IE Helpers
	$j('#nav>li:last-child').addClass('_last-child');
	$j('._featurebox:last-child').addClass('_last-child'); 
	$j('fieldset:last-child').addClass('_last-child'); 
	$j('p:last-child').addClass('_last-child'); 
	$j('.video-thumb:last-child').addClass('_last-child'); 
	$j('.box:last-child').addClass('_last-child'); 
	
	$j('a.submit').unbind();
	$j('a.submit').click(function(e){
		e.preventDefault();
		var href = $j(this).attr('href');
		var form = $j(this).parents('form');
		if (href != '' && href != '#') {
			form.attr('action',href);
		}
		form.submit();		
	});	
	
	if (window.height < 1000)
		
		//$j('#footer').css('top',)
	
	if ($j.browser.msie == true && $j.browser.version.substr(0,1) == 7) {
	}
	
	Cufon.replace('#navbar li a');
	Cufon.replace('#topnav .social a');
	Cufon.replace('.futura');
	Cufon.replace('h2');
});
