// Function for fancybox overlay

$(function() {

	/* This is basic - uses default settings */
	
	$("a#freeTrial").fancybox();
	$("a#freeTrialFeature").fancybox();
	$("a#footerFreeTrial").fancybox();
	$("a.scheduleFreeTrial").fancybox();
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
});

// function for rotating banners

$(function(){
  var images = ['signUp_header1.png', 'signUp_header2.png', 'signUp_header3.png', 'signUp_header4.png', 'signUp_header5.png', 'signUp_header6.png', 'signUp_header7.png', 'signUp_header8.png', 'signUp_header9.png',];
  $('#signup').css({'background-image': 'url(/images/freeTrialHeaders/' + images[Math.floor(Math.random() * images.length)] + ')'});
});

// function for other field in source seleect

$(function(){
  $('#other').hide();
  $('#source').change(function(){
    if(this.value == 'other: ')
    {
      $('#other').show();
    } else {
      $('#other').hide();
    }
  });
  $('#source').change();
});

// function for selecting time/date for free trial

$(function(){
  
  $("#dropperWrap").hide();
  
  $("#datepicker").change(function(){
    var dateVal = $("#datepicker").val();
    $("#p2").remove();
    $("#results").append(
      "<p id=\"p2\">" + dateVal + "</p>"
      );
    if (dateVal.match(/^Sun/)){
      $("#dropperWrap").hide();
      $("#p2").append("<br/>from 1:00pm to 2:00pm").fadeIn(slow);
    } else if (dateVal.match(/^Sat/)){
      $("#dropperWrap").show();
      $("#dropper").html("<option></option>" + "<option>1:00pm - 2:00pm</option>" + "<option>2:30pm - 3:30pm</option>");
    } else {
      $("#dropperWrap").show();
      $("#dropper").html("<option></option>" + "<option>5:30pm - 6:30pm</option>" + "<option>7:00pm - 8:00pm</option>")
    } 
  });
  
  $("#dropper").change(function(){
    var dateVal = $("#datepicker").val();
    var timeValue = $("#dropper").val();
    $("#p2").remove();
    $("#results").append(
      "<p id=\"p2\">" + dateVal + "<br/>from " + timeValue + "</p>"
      );
  });
  
});

