﻿$(document).ready(function() {
	// Disables buttons
	//$('div.nav a.nav-calendar').click(function() {
	//	return false;
	//});
	
	//$('div.nav a.nav-register').click(function() {
	//	return false;
	//});
	//$('div.nav a.nav-speakers').click(function() {
	//	return false;
    //});
    /*$('div.nav a.nav-newsletter').click(function() {
		return false;
	});*/
			
						
	// Search focus/blur
	$('.search').focus(function() {
		if ($(this).val() == 'Search') {
			$(this).val('');
		}
	});
	$('.search').blur(function() {
		if ($(this).val() == '') {
			$(this).val('Search');
		}
	});


	$('a#submit').click(function() {
		var searchURL = "/searchResults.aspx?s=" + $('.search').val();
		window.location = searchURL;
	});

	// Days Left countdown
	countdown();

	function countdown() {
		var today;
		var theYear, theMonth, theDate;
		var timeToGo, daysToGo;

		today = new Date();
		eventDate = new Date(2011, 8, 13, 0, 0, 0);

		theYear = today.getFullYear();
		theMonth = today.getMonth();
		theDate = today.getDate();

		today = Date.parse(today);
		eventDate = Date.parse(eventDate);

		timeToGo = eventDate - today;
		daysToGo = Math.floor(timeToGo / 86400000);

		if (today < eventDate)
			document.getElementById('countdown').innerHTML = daysToGo;
		else
			document.getElementById('countdown').innerHTML = "Now";
	}

	// Sponsors Rotator
	size = $("ul.rotator li").size();
	index = Math.floor(Math.random() * size);
	$("ul.rotator li:eq(" + index + ")").find("img").addClass("show");
	rotator();

	
});
var size;
var index;
var temp;
function rotator() {
	if (index == 0)
		temp = size - 1;
	else if (index == size) {
		index = 0;
		temp = size - 1;
	}
	else
		temp = index - 1;

	$("ul.rotator li:eq(" + temp + ")").find("img").removeClass("show");
	$("ul.rotator li:eq(" + index + ")").find("img").addClass("show");

	index++;
	
	setTimeout('rotator()', 3000);
}
