/// <reference path="jquery-1.3.2.min.js"/>


// Navigation Controller
var navController = {
    init : function(){
        this.run();    
    },
    run : function(){
		var a = false;
		$('div#nav ul li:not(div#nav ul li ul li)').hover(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				a = true;
			}
			$(this).addClass('on')								  
		},function(){
			if(a){
				$(this).addClass('active')
				a = false;
			}
			$(this).removeClass('on')
		});
    }
}


// Sponsors Controller
var sponsorController = {
    init : function(){
        this.run();    
    },
    run : function(){
		$('#goldSponsors').innerfade({
			timeout: 3500															   
		});
		$('#silverSponsors').innerfade({
			timeout: 3750															   
		});
		$('#bronzeSponsors').innerfade({
			timeout: 4000															   
		});
    }
}


// Nicey McList
var listController = {
	init : function(){
		this.run();	
	},
	run : function(){
		$('ol li:first').addClass('first');
		$('ol li:odd').addClass('zebra');
	}
}


function LoadCalendarStub() {
    $.get("/CalendarStub.aspx", null,
    function(result) {
        $('#calendarStub').replaceWith(result);
    });
}

function LoadCurrentEvents() {
    $.get("/CurrentEvents.aspx", null,
    function(result) {
        $('#currentEventsStub').replaceWith(result);
    });
}

function LoadPastEvents() {
    $.get("/PastEvents.aspx", null,
    function(result) {
        $('#pastEventsStub').replaceWith(result);
    });
}

function AddTotal() {
    var total = 0.0;
    $('input.fees').each(function(i) {
        var qty = isNaN(this.value) ? 0 : this.value;
        total += (qty * $(this).attr("rel"))
    });
    $('#spanTotal').text("$" + total.toFixed(2));
}



// Page Initialization
function initialize(){
    navController.init();
	sponsorController.init();
	listController.init();

	LoadCalendarStub();
}


// Start
$(document).ready(function(){
    initialize();
});