$(document).ready(function() {
	// Uniform checkboxes, dropdowns and radios.
    $('select, :checkbox, :radio, :file').uniform();
    
    // Tabs
	$('ul.tabs li:last-child').addClass('last');
	
	$('.tab-panel').css({'position' : 'absolute', 'left' : '-2000px', 'top' : '-20000px'});
	
	// Is there a panel pre-selected?
	var selected_panel = window.location.hash;
	var panel_is_set = false;
	
	if (selected_panel != null) {	
		if ($("ul.tabs li a[href='" + selected_panel + "']").length > 0) {
			// Ok, element found grab the index of this element's parent
			var index = $("ul.tabs li a[href='" + selected_panel + "']").parent().index();
			
			$('.tab-panel:nth-child(' + (index + 1) + ')').css({'position' : '', 'left' : '', 'top' : ''});
			
			// Set active tab
			$('ul.tabs li a').removeClass('active');
			$("ul.tabs li a[href='" + selected_panel + "']").addClass('active');
			
			panel_is_set = true;
		}
	}
	
	if (panel_is_set != true)
	{
		$('ul.tabs li:first-child a').addClass('active');
		$('.tab-panel:first-child').css({'position' : '', 'left' : ''});
	}
	
	$('ul.tabs li a').click(function() {
		var index = $(this).parent().index();
		
		$('.tab-panel').css({'position' : 'absolute', 'left' : '-2000px', 'top' : '-20000px'});
		$('.tab-panel:nth-child(' + (index + 1) + ')').css({'position' : '', 'left' : '', 'top' : ''});
		
		// Set active
		$('ul.tabs li a').removeClass('active');
		$(this).addClass('active');
		
		window.location.hash = $(this).attr('href');
		
		return false;
	});
	
	$('.faq .item:first-child .txt').show();
	
	$('.faq h4 a').click(function() {
		var container = $(this).parent().parent();
		
		$('.faq .txt').slideUp();
		$('.txt', container).slideDown();
		
		return false;
	});
	
	$('a[rel=lightbox]').lightBox();
});
