//By ilovecolors.com.ar
//www.ilovecolors.com.ar/rotating-jquery-tabs/

//array to store IDs of our tabs
var tabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change tab and highlight current tab title
function change(stringref){
	//hide the other tabs
	jQuery('.tab:not(#' + stringref + ')').hide();
	//show proper tab, catch IE6 bug
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0")
		jQuery('.tab#' + stringref).show();
	else 
		jQuery('.tab#' + stringref).show('');
	//clear highlight from previous tab title
	jQuery('.htabs a:not(#' + stringref + 't)').removeClass('select');
	//highlight currenttab title
	jQuery('.htabs a[href=#' + stringref + ']').addClass('select');
}
function next(){
	//call change to display next tab
	change(tabs[ind++]);
	//if it's the last tab, clear the index
	if(ind >= tabs.length)
		ind = 0;
}
jQuery(document).ready(function(){
	//donate form
	$('#biloxi_table,#nashville_ticket,#biloxi_ticket').blur(function() {
		var biloxi_table_price = 220;
		var biloxi_table_amt = $('#biloxi_table').val();
		var bixoli_table_cost = biloxi_table_amt * biloxi_table_price;
		
		//alert(bixoli_table_cost);
		
		var biloxi_ticket_price = 15;
		var biloxi_ticket_amt = $('#biloxi_ticket').val();
		var bixoli_ticket_cost = biloxi_ticket_amt * biloxi_ticket_price;
		
		//alert(bixoli_ticket_cost);
		
		var nashville_ticket_price = 50;
		var nashville_ticket_amt = $('#nashville_ticket').val();
		var nashville_ticket_cost = nashville_ticket_amt * nashville_ticket_price;
		
		//alert(nashville_ticket_cost);
		
		var total_amount = bixoli_table_cost + bixoli_ticket_cost + nashville_ticket_cost;
		//alert(total_amount);
		$('#total').val(total_amount);
	});	
	//store all tabs in array
	jQuery(".tab").map(function(){
		tabs[ind++] = jQuery(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize tabs, display the current tab
	jQuery(".tab:not(:first)").hide();
	jQuery(".tab:first").show();
	//highlight the current tab title
	jQuery('#' + tabs[0] + 't').addClass('select');
	//handler for clicking on tabs
	jQuery(".htabs a").click(function(){
		jQuery("#info div").hide();
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		jQuery('#' + stringref + 'info').show();
		//display referenced tab
		change(stringref);
		return false;
		
	});
	$('#container').fadeIn();
	//start rotating tabs
	inter = setInterval("next()", 6000);
	//clears inputs & textarea
	$('input:text,textarea').focus(function(){
            if($(this).val() == $(this).attr('defaultValue')){
                $(this).val('');
            }
        });

        $('input:text,textarea').blur(function(){
            if($(this).val() == ''){
                $(this).val($(this).attr('defaultValue'));
            }
     });
});
$(function(){
	$("#nashville").click(function(){
		clearInterval(inter);
		$("#biloxiinfo,#lainfo").hide();	
		$("#info,#nashvilleinfo").fadeIn("slow");	
	});

	$("#biloxi").click(function(){
		clearInterval(inter);
		$("#lainfo,#nashvilleinfo").hide();
		$("#info,#biloxiinfo").fadeIn("slow");
	});	

	$("#la").click(function(){
		clearInterval(inter);
		$("#biloxiinfo,#nashvilleinfo").hide();	
		$("#info,#lainfo").fadeIn("slow");
	});
});