﻿//makes any element hoverable and clickable
function elHover(el) {
	el.hover(
		function() {$(this).addClass('hover-state');},
		function() {$(this).removeClass('hover-state');}
	);
	el.click(function(){
    	window.location=$(this).find('.sessionURL a').attr('href');
		return false;
	});
}

function tabs() {
    var tabContainers = $('div.tabs > div.tab-content');
    tabContainers.hide().filter(':first').show();
    $('div.tabs ul.tab-nav a').click(function(){
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.tab-nav a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
}

//basic countdown timer
function timer(eventDate, counterEl) {
    var today = new Date(),
	targetDay = new Date(eventDate),
    msPerDay = 24 * 60 * 60 * 1000,
    timeLeft = (targetDay.getTime() - today.getTime()),
    e_daysLeft = timeLeft / msPerDay;
    if (e_daysLeft > 0){
	    daysLeft = Math.floor(e_daysLeft);
	}
	else {
		daysLeft = 0;
	}
	counterEl.html(daysLeft + ' ');
}

function formTip(el, txt){
		el.val(txt).focus(function(){
				$(this).val('');
		});
}

$(function() {
    elHover($('#speakers li'));
    tabs();
	timer('04/19/2010', $('#counter'));
	formTip($('#SignUpBox'), '[Your Email]')
	$('#ctl00_PlaceHolderMain_NewsletterSignupDemographics1_btnSubmit').val('Submit');
});